Repository navigation
Open
Description
Describe the bug
I am unable to read in my lf files when using SpikeGLXRawIO. The file structure is currently as below. When I had all the lf files be t0 instead of tcat it worked flawlessly.
ya008_20240525_g0
├── ya008_20240525_g0_ct_offsets.txt
├── ya008_20240525_g0_fyi.txt
├── ya008_20240525_g0_imec0
│ ├── ya008_20240525_g0_t0.imec0.ap.bin
│ ├── ya008_20240525_g0_t0.imec0.ap.meta
│ ├── ya008_20240525_g0_tcat.imec0.lf.bin
│ └── ya008_20240525_g0_tcat.imec0.lf.meta
├── ya008_20240525_g0_imec1
│ ├── ya008_20240525_g0_t0.imec1.ap.bin
│ ├── ya008_20240525_g0_t0.imec1.ap.meta
│ ├── ya008_20240525_g0_tcat.imec1.lf.bin
│ └── ya008_20240525_g0_tcat.imec1.lf.meta
├── ya008_20240525_g0_t0.nidq.bin
└── ya008_20240525_g0_t0.nidq.meta
To Reproduce
(neuroconv_312) ➜ test2 ipython
Python 3.12.3 | packaged by conda-forge | (main, Apr 15 2024, 18:38:13) [GCC 12.3.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.26.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import neo.rawio
In [2]: reader = neo.rawio.SpikeGLXRawIO(dirname='./ya008_20240525_g0')
In [3]: reader.parse_header()
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Cell In[3], line 1
----> 1 reader.parse_header()
File /scratch/ct5868/.conda/envs/neuroconv_312/lib/python3.12/site-packages/neo/rawio/baserawio.py:189, in BaseRawIO.parse_header(self)
176 """
177 Parses the header of the file(s) to allow for faster computations
178 for all other functions
179
180 """
181 # this must create
182 # self.header['nb_block']
183 # self.header['nb_segment']
(...)
186 # self.header['spike_channels']
187 # self.header['event_channels']
--> 189 self._parse_header()
190 self._check_stream_signal_channel_characteristics()
191 self.is_header_parsed = True
File /scratch/ct5868/.conda/envs/neuroconv_312/lib/python3.12/site-packages/neo/rawio/spikeglxrawio.py:147, in SpikeGLXRawIO._parse_header(self)
144 signal_channels = []
145 for stream_name in stream_names:
146 # take first segment
--> 147 info = self.signals_info_dict[0, stream_name]
149 stream_id = stream_name
150 stream_index = stream_names.index(info["stream_name"])
KeyError: (0, 'imec1.ap')
Environment:
- OS: Linux
- Python version: 3.12
- Neo version: 0.13.1
I am happy to provide access to the meta files. The SpikeGLX data is rather large so if having access to that would be necessary, I'd have to ask IT how to best distribute that data.
Activity
samuelgarcia commentedon Jul 26, 2024
@alejoe91 can you handle this ?
h-mayorquin commentedon Dec 10, 2024
I think this should be fixed by this:
#1608
It has been a while but any chance you could try this @tabedzki ?
alejoe91 commentedon Jan 8, 2025
@tabedzki just following up on this. The solution implemented in #1608 by @h-mayorquin should work here because files are parsed based on the original file name in the meta file. Can you test it on your end?
tabedzki commentedon Jan 23, 2025
Thanks for your patience. Unfortunately, this does not address the underlying issue.
I got the same error across other folders so it is not confined to this specific directory.
h-mayorquin commentedon Jan 23, 2025
Can you print what is inside signals_info_dict?
We definitely need a more informative error there.
tabedzki commentedon Jan 23, 2025
Thanks guys for looking into this more. Please find attached the dict requested
signals_info_dict.txt
h-mayorquin commentedon Jan 23, 2025
OK, I understand the bug. Can you share the data with us so I can create a stub for this and add it to the tests?
The problem is that you combine a tcat signal with one that is not. The tcat is always the segment 0 but the other signal (ap) is assigned segment one. The the line that is trigger the error is assuming that there is always a segment 0 for every stream.
The
scan_filesfunction should be modified somehow to take this into account (order segments per stream).@samuelgarcia @alejoe91 how common is to have tcat lf but not ap? It is not clear to me how we should handle this.
tabedzki commentedon Jan 23, 2025
I'd have to check with the researcher if I can share his data, though the data itself is large (95GB). What would be the recommended way to do that if I am granted permission?
h-mayorquin commentedon Jan 27, 2025
Well, if you don't have acesss to an s3 bucket, dropbox, google drive, mega, etc with that capability then I have a script for stubing spikeglx data here:
https://gist.github.com/h-mayorquin/b5abe6ae8e8484976c2d27e0bb04e2a2
We will have to fine-tune for your case, we can do it in a 15 minutes short meeting.
It is important for us to know why is tcat only applied to the lp band and not to ap. Moreover, why is the gating mechanism (g0) preserved on the naming even after tcat. In short, a summary description of the dataset for provenance on our test data.
mik-schutte commentedon Jan 31, 2025
I seem to be facing a similar issue
Folder structure:
SNA-137704_mstim_20112024_S1_1_g0
├── catgt_SNA-137704_mstim_20112024_S1_1_g0
│ ├── SNA-137704_mstim_20112024_S1_1_g0_ct_offsets.txt
│ ├── SNA-137704_mstim_20112024_S1_1_g0_fyi.txt
│ ├── SNA-137704_mstim_20112024_S1_1_g0_tcat.imec0.ap.bin
│ ├── SNA-137704_mstim_20112024_S1_1_g0_tcat.imec0.ap.meta
│ ├── SNA-137704_mstim_20112024_S1_1_g0_tcat.imec0.ap.xd_384_6_500.txt
│ ├── SNA-137704_mstim_20112024_S1_1_g0_tcat.nidq.meta
│ ├── SNA-137704_mstim_20112024_S1_1_g0_tcat.nidq.xd_1_0_500.txt
│ └── SNA-137704_mstim_20112024_S1_1_g0_tcat.nidq.xd_1_1_200.txt
├── SNA-137704_mstim_20112024_S1_1_g0_imec0
│ ├── SNA-137704_mstim_20112024_S1_1_g0_t0.imec0.ap.bin
│ └── SNA-137704_mstim_20112024_S1_1_g0_t0.imec0.ap.meta
├── SNA-137704_mstim_20112024_S1_1_g0_t0.nidq.bin
└── SNA-137704_mstim_20112024_S1_1_g0_t0.nidq.meta
Code to reproduce
No matter which stream_id I define, the error remains the same:
Interestingly, I am able to load the catGT filtered data when I run:
Hopefully this is the right location for this issue. As I see g0 mentioned in the comment above I also removed the catgt folder's affix of '_g0' but this did not alter anything.
I am also willing to share any necessary additional information or data.
tabedzki commentedon Jan 31, 2025
Hi h-mayorquin,
Thanks for being willing to help and for providing a stubbing mechanism. Here is the stubbed data
h-mayorquin commentedon Feb 5, 2025
Hi @tabedzki
The data that you shared with me does not have the binaries for the tcat processed lfp or nidq.
The script that I shared with you is a draft. I was expecting that we could take a look together andc finish it but now that I look at it again I think that you only need to modify the
file_pattern: str = "*.ap.bin"argument in thecreate_data_stubfunction.Note also, that you might need to modify the number of channels manually accordingo to your data.
Reach to me in slack if you need help with it.
h-mayorquin commentedon Feb 5, 2025
@tabedzki, @samuelgarcia and I are wondering:
How come you only have the LF concatenated? We believe that typically, tcat is used for concatenation, so it’s confusing for us to see both concatenated and non-concatenated data in the same folder. Could tcat be used for something else? Do you happen to know?
@mik-schutte
Hi, your case is different since tcat is only present in one folder. Your case should work if you point the dirname of spikeglx rawio to the folder that either has tcat or does not. You can set dirname to either
catgt_SNA-137704_mstim_20112024_S1_1_g0or137704_mstim_20112024_S1_1_g0_imec0, and that should work.That said, we’d still like to understand why you have both tcat and non-tcat data at the same time. Is tcat used for something other than concatenation?
We need this context to make a good solution for this. We already have some ideas but we need your input.
mik-schutte commentedon Feb 11, 2025
Thanks for your solution, it has worked for me!
My tcat files were created through running catGT, which I use to extract noisy channels, filter the recording, extracting behavioural timestamps but most importantly perform global demuxing. This program was recommended by a lab member and I have not been able to obtain as good as a filtering with spikeinterface.
billkarsh commentedon Dec 24, 2025
CatGT output is always labeled tcat regardless of what operations were performed {concatenation, filtering, LFP extraction, ...}. The user has the option of directing output from CatGT to a new folder that does not overlap the input. That's done by invoking the -dest option. If -dest is omitted, the CatGT output is placed into the input folder, which was a popular request in order to minimize the number of folders. This use case can cause files with original name tags like _g0_t0 to appear within the same folders as CatGT output having name tags like _g0_tcat.
A user on the #spikesorting channel of Neuropixels Discord has just reported an error reading CatGT output mixed with input files. So this issue apparently persists. https://discord.com/channels/1446542289114763284/1449521360278782028/1453227737740214454
It really doesn't make sense to me that a user would mix CatGT outputs (named tcat) back in with original files (named otherwise) and intend to treat these together as a set, since they are in fact not a set, unless the user further imposes a new homogeneous naming on them to forge an association. So I think the best thing for SpikeInterface to do on meeting this situation is to say "Error: These files have mixed naming conventions (tcat and non-tcat) so do not belong together as a logical set."
jenniferColonell commentedon Dec 24, 2025
One more note: when CatGT processes ni and obx files, there will be output files of the form:
run_name_g0_tcat.obx0.obx.meta (and the binary)
run_name_g0_tcat.nidq.meta (and the binary)
These cases need to be added to parse_spikeglx_fname in (neo/rawio/spikeglxrawio.py) so that correct gate and trigger indices are returned.