probeinterface icon indicating copy to clipboard operation
probeinterface copied to clipboard

probe not ordered by 'device_channel_indices'

Open RobertoDF opened this issue 8 months ago • 11 comments

Hi,

I am loading a json file exported from ONIX using read_probeinterface. I see that the probe loaded is not ordered by 'device_channel_indices'. I suspect this is the reason for some downstream problems (waveform extraction fails).

probes = read_probeinterface(json_file)

raw_rec = raw_rec.set_probegroup(probes)

how can I order the probes object by 'device_channel_indices' before assigning it?

Thanks!

RobertoDF avatar Apr 16 '25 11:04 RobertoDF

the json exported from onix is ordered by "contac_ids" and not 'device_channel_indices' .

Image

RobertoDF avatar Apr 16 '25 11:04 RobertoDF

Hi @RobertoDF

You don't need to reorder the probe. When setting a probe/probegroup, SpikeInterface reorders by device_channel_indices automatically ;)

alejoe91 avatar Apr 16 '25 11:04 alejoe91

You can check with:

pg = raw_rec.get_probegroup()
pg.to_dataframe()

alejoe91 avatar Apr 16 '25 11:04 alejoe91

oh! ok than maybe the problem is that I should keep the original order!?

RobertoDF avatar Apr 16 '25 11:04 RobertoDF

is that possible to do easily?

RobertoDF avatar Apr 16 '25 11:04 RobertoDF

Are you getting any errors? If not then don't worry about it :)

alejoe91 avatar Apr 16 '25 11:04 alejoe91

The main problem is that when I extract the waveforms, thay are all flat.

The code does work with other rec types though.

Image

RobertoDF avatar Apr 16 '25 13:04 RobertoDF

Are you filtering the data before creating the analyzer? From the plots, that seems to be the issue...

alejoe91 avatar Apr 16 '25 15:04 alejoe91

no, I just do

 raw_rec = read_binary(path_recording,
                              sampling_frequency=fs_hz,
                              dtype=np.uint16,
                              num_channels=num_channels,
                              gain_to_uV=gain_to_uV,
                              offset_to_uV=offset_to_uV)


        probes = read_probeinterface(probe_json)

        raw_rec = raw_rec.set_probegroup(probes)
        raw_rec = spre.scale_to_uV(recording=raw_rec)

I see that the scaling happens automatically in the sorting_analyzer. is it bad to provide the already scaled trace?

RobertoDF avatar Apr 16 '25 15:04 RobertoDF

I just noticed that they are not totally flat, this is the biggest cluster by amplitude

Image

they are just unusually small.

RobertoDF avatar Apr 16 '25 15:04 RobertoDF

Ah yes, you don't need to scale twice. The create_sorting_analyzer will automatically scale to uV since by the default it has a parameter called return_scaled=True.

If you don't pre-filter the recording, at least with a high pass, there might be low-freq fluctuations that might affect waveform extraction and templates. Can you try to highpass filter the recording before creating the analyzer?

alejoe91 avatar Apr 16 '25 15:04 alejoe91

am I correct in thinking that it is enough to high pass at the line of the sorting analyzer? create_sorting_analyzer(sorting, spre.highpass_filter(recording=sub_rec)) kilosort is already doing it by itself when sorting.

RobertoDF avatar Apr 17 '25 08:04 RobertoDF

yes that's correct :)

alejoe91 avatar Apr 17 '25 08:04 alejoe91

Ok this looks better now thanks!

RobertoDF avatar Apr 17 '25 10:04 RobertoDF