-
Notifications
You must be signed in to change notification settings - Fork 230
BlackrockSortingExtractor - load only .nev files, ignore nsX #3843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@alejoe91 @h-mayorquin could you take a look at this whenever you get a chance? thanks! |
|
Can you describe more about the files? I am not familiar with this format. |
|
@h-mayorquin
important: this change depends on the current |
|
Thanks @luiztauffer I wonder if the sorting extractor should automatically just load the nev file only. The other files shouldn't be required for loading spike trains only. What do you think? |
|
@alejoe91 in the current implementation, the Extractor seems to depend on the streams recordings to extract the sampling rate, otherwise the user need to provide the sampling rate at instantiation. spikeinterface/src/spikeinterface/extractors/neoextractors/neobaseextractor.py Lines 417 to 418 in d7cf286
This shouldn't be the case, though. I can look into it, and see if we could make them independent. Probably this mixing comes originally from the fact that:
|
|
@alejoe91 check it out now, let me know what you think |
…nterface into blackrock-nev
for more information, see https://pre-commit.ci
which feature that we merge recently? There will be release soon.
Agree with this. @alejoe91 the tests are failing because of pinnin numcodes. Oh, I see you merged already. |
|
@h-mayorquin I believe it's this one: NeuralEnsemble/python-neo@b87b8f2 |
src/spikeinterface/extractors/neoextractors/neobaseextractor.py
Outdated
Show resolved
Hide resolved
Ah, the overflow of Thinh. Yes, there will be a release soon according to the neo team. |
|
@luiztauffer Ok, this is hardcoded here on the python neo side anyway. So no need to override the function at all. If we are going to use the wf we might as well just hardcoded in the init of blackrock and avoid all the coding complications. |
|
@h-mayorquin right, nice catch! Yeah, from the SI wrapper side, I believe it would be better to wait for your PR to get merged and then we can retrieve the sampling rate from the neo reader, instead of hard coding it here again. This way we keep true to whatever neo says, including if there's any future changes to that parameter |
|
If we consider
This approach has a few advantages:
|
|
maybe instead of |
You mean that if the sampling_frequency is None then the main sampling frequency is used?
I suggest that for your conversion you should just set the sampling frequency to this value there and ask them if that the is the sampling frequency of the signal that they sorted. |
|
It looks like Blackrock won’t need If we want to keep having But I don’t think it’s reasonable for a Neuroconv DataInterface to have a required argument for something which is a fixed attribute down the line, in the |
[bold mine] Yes, I think that’s the core of the issue. The Neo sampling frequency is undocumented, and the last time I discussed the extractor with Sam, he mentioned he hasn’t touched it in a while. I also asked him about using the frequency from the spike header, and he said it might not be accurate. In other words, I don’t fully trust that value, and I’d prefer to leave an escape valve in case we're wrong so we don’t have to tell users to wait for another PR to correct the mistake.
If there’s only one signal channel, the heuristic gets the sampling frequency from that channel, which should be the signal that was sorted. Otherwise, if there’s more than one signal, the user gets an error telling them to set the sampling frequency manually. Regardless of all that, it's important to point out that this is a problem for us (people who work with other people's data) because we often don’t know the correct sampling frequency. Hopefully, most users will be the ones who generated the data (fingers crossed), in which case it's better if they always set the frequency themselves. Maybe in this case we should have an especial error for when the segments in the sorting are not the same as the signal which was the initial problem, right? I’ve come around to agree with Sam that users should be responsible for setting the sampling frequency as neo is not the right tool to fetch this from and he, reasonably, does not want to maintain that. All that said, I’m okay with adding the heuristic you’re suggesting here for the sake of expediency and give the user more options. Let’s see what others think. |
|
just adding now the option to to pass two relevant kwargs to the neo reader: |
h-mayorquin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 on this.
Will allow users to specify the sampling frequency and to load data when there are more than one segment on the recording but not in the sorting.
| stream_id: Optional[str] = None, | ||
| stream_name: Optional[str] = None, | ||
| sampling_frequency: Optional[float] = None, | ||
| nsx_to_load: Optional[int | list | str] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the typing of this seems strange, can you double check @luiztauffer?
Sam is going to vacations so if he does not have time to check it before that I will merge this next Monday but just double check this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, makes sense.
There are cases when we'd like to load only the
.nevfile containing the events data, and ignore the local.nsXfiles. One example for this is when an experimenter pauses and then resumes the recording. This creates a different number of segments between nev and nsX, which breaks neo reader.Thankfully, neo already allows for it, all we need to do is to explicitly pass the
nsx_to_loadargument. So, in this PR I'm proposing adding it as an optional argument toBlackrockSortingExtractor.Ps.: It's probably be a good idea tho eventually allow passing forward all kwargs available at the neo extractors directly from the SI wrappers
__init__methods, aneo_kwargs: dictor something