SpikeInterface / spikeinterface

A Python-based module for creating flexible and robust spike sorting pipelines.
https://spikeinterface.readthedocs.io
MIT License
533 stars 187 forks source link

Open ePhys extractor #2462

Closed mohebial closed 9 months ago

mohebial commented 10 months ago

Hi @alejoe91, I am trying to load an open ephys neuropixel recording and I am getting the following error.

 File ~\anaconda3\envs\spkint\lib\site-packages\spikeinterface\extractors\neoextractors\openephys.py:332 in read_openephys
    recording = OpenEphysLegacyRecordingExtractor(folder_path, **kwargs)

  File ~\anaconda3\envs\spkint\lib\site-packages\spikeinterface\extractors\neoextractors\openephys.py:77 in __init__
    NeoBaseRecordingExtractor.__init__(

  File ~\anaconda3\envs\spkint\lib\site-packages\spikeinterface\extractors\neoextractors\neobaseextractor.py:200 in __init__
    stream_names = list(stream_channels["name"])

IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

I think the logic of the if condition in the spikeinterface/src/spikeinterface/extractors/neoextractors/openephys.py line 334 is reverse and should be: if ~np.any([f.endswith("continuous") for f in files]): Changing that in the code fixed my issue. I appreciate it if you take a look and let me know if I have made a mistake.

Cheers, Ali

line 332:340

# auto guess format
    files = [str(f) for f in Path(folder_path).iterdir()]
    if np.any([f.endswith("continuous") for f in files]):
        #  format = 'legacy'
        recording = OpenEphysLegacyRecordingExtractor(folder_path, **kwargs)
    else:
        # format = 'binary'
        recording = OpenEphysBinaryRecordingExtractor(folder_path, **kwargs)
    return recording
alejoe91 commented 9 months ago

Hi @mohebial

The logic looks correct to me. The "legacy" files have {channel}.continuous. I think that the problem is that you are not pointing to the root open ephys folder, but to a recording folder. You should use the folder_name that contains the Record Node *** folder.