python-neo icon indicating copy to clipboard operation
python-neo copied to clipboard

Trigger on several segments for LFP

Open Samcrl0 opened this issue 1 year ago • 1 comments

Describe the bug Hello, I would like to concatenate several segments to realize the LFP analysis on the different sgments. I got the recording of the trigger during the acquisition.

But when I use neo, I have difficultiees to get a simple list of the values;and when I use the rawio or spikeinterface, I do not succeed to get the ANALOG-IN-1 signal, which correspond to the trigger.

Firstly this is what I tried:

test=[]

for file in seg:   #seg is a list containing the different segment's files

if file[-3:] == "rhs":

neo_data = IntanIO(filename=file).read()

trig = neo_data[0].segments[0].analogsignals[2]

trig= trig.T

test.append(trig[0])

and this is the output:

[array([-0.00093769, -0.00031208, -0.00062489, ...,  0.00031258,
         0.00031258,  0.00093723], dtype=float32) * V,
 array([ 0.00031258,  0.00031258, -0.00062489, ..., -0.00031208,
        -0.00093769, -0.00093769], dtype=float32) * V,
 array([-0.00031208, -0.00031208,  0.00062538, ..., -0.00031208,
         0.00093723,  0.00062538], dtype=float32) * V]

I also tried a .expend instead of a .append, but it increase significatively the computing time It gives me a long lilst like this:

[...
array(-0.00093769, dtype=float32) * V,
 array(-0.00093769, dtype=float32) * V,
 array(0.00062538, dtype=float32) * V,
 array(-2.2888183e-07, dtype=float32) * V,
 array(-0.00062489, dtype=float32) * V,
 array(-0.00031208, dtype=float32) * V,
 ...]

Expected behaviour Do you have a solution to have:

trig = [-0.00093769, -0.00031208, -0.00062489, ..., -0.00031208,
         0.00093723,  0.00062538]

or eventually

trig = array([-0.00093769, -0.00031208, -0.00062489, ..., -0.00031208,
         0.00093723,  0.00062538], dtype=float32) * V

?

Thank you for your help.

Samcrl0 avatar May 30 '24 09:05 Samcrl0

Howdy @Samcrl0,

If you just want analog-in-01, I would recommend rawio.

reader = IntanRawIO("filename.rhd")
reader.parse_header()
raw_chunk = reader.get_analogsignal_chunk(block_index=0,
                                                  seg_index=0,
                                                  stream_index=3, # this is for analog
                                                   )
                                        
float_chunk = reader.rescale_signal_raw_to_float(raw_chunk, stream_index=3) # this goes from raw values to the actual voltages

analog_one_data = [:, 0] # first column would be analog-in-1

or if you want to have a punch of data I would recommend doing spikeinterface you could do something similar. But I would need to know what the final goal was.

zm711 avatar May 30 '24 12:05 zm711

I'll close this, but let us know if you have more questions.

zm711 avatar Jul 19 '24 19:07 zm711