-
Notifications
You must be signed in to change notification settings - Fork 190
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
Clarification for get_traces
's channel_ids
#3049
Comments
Salut Baptiste! So we have a few different things coming from Neo: channel_names, channel_ids, and channel_indices. Names can be anything so that's why we don't typically use them (some ephys readers let people apply custom names which means we can't guarantee uniqueness). The channel_ids are the hardcoded names (that the hardware supplies). Sometimes these are the same as the indices if the hardware doesn't give us a unique identifier (and so we just use the indices as the ids). At the spikeinterface level they can be strings or ints, but since neo returns the ids as strings (I think always... @samuelgarcia , @alejoe91 , @h-mayorquin ) for a neo extractor you would give them as strings.
Sorry there was context to that you are missing. What this really means was that the type of channel_ids = 'channel 1' # this is bad for the argument
channel_ids = ['channel 1'] # this is good for the argument The root issue is that some functions allow the user to provide an individual item rather than a list of items (even if that list contains one thing). So we were emphasizing that the argument needed a container rather than the item itself. Now back to your question.
A dtype of As far as adding the type info I think that is fair. But the issue is they can currently be either string or int. (Here is the debate #1432 in case you're interested). I've written an essay so let me know if something isn't clear. |
To avoid this type of confusiong you can just call recording.get_channel_ids() and you will see the type, shape and form of the ids. I think the first error can be improved though to tell what are the ids so you would not have had to go through all the trace. Let me work on that. I think that is good that @zm711 points out #1432 as it will avoid this type of errors if we always had stings (altought @b-grimaud mentioned that his natura instinct was ints so that's an argument to the other side). |
I opened a PR #3052 which hopefully will make someone else avoid the hops that you had to go through to find this out. Now if you repeat your workflow above a more helpful message will be displayed: |
@zm711 Thanks a lot for the clarification !
I see, I think I misunderstood
I went back into the numpy Thanks for the PR, it does make things a lot clearer in my opinion !
To be fair, I think this is mostly because the data I work with uses ints for indexing so I've always assimilated |
Yes, extractors contain arrays under the hood and we need to make a distinction between indices that are used to access content ( Glad you think the PR will help other people in the future. We aim to save users time! |
This is another example of why we should create a glossary of the library (as @JoeZiminski has suggested). We have this in the development docs, but the end-user likely doesn't read those. |
When calling
get_traces
, I instinctively (and perhaps wrongly) listedchannel_ids
as a list ofint
.Which results in :
Going through the trace I saw that
ids_to_indices
looks for the selected channels in_main_ids
, but when checking that array I noticed that the declareddtype
:doesn't match that of the individual values :
I checked for the file types I had on hand (BioCAM's
.brw
and MaxWell's.h5
) and both had similar file types in their channel arrays.I know that, at least for Biocam files, the
neo
header parsing function returns an array ofint
, and I couldn't find exactly where the type changes.Either way, that explains the error and passing
channel_ids
as a list ofstr
works fine.However, while looking through the issues to see if this was brought up previously, I came across #2320 where it is stated :
Which leads me to the following questions :
Is it possible to clarify, in the docstrings and maybe the type hints, which type should the iterable contain ? And would it be useful to assert that type or convert it if one is passed instead of the other ?
Apologies if this is somehow specific to the file types I've tried, in which case I'll go through
neo
again.Running SI 0.101.0rc0 from source, Python 3.12.2, Ubuntu 24.04.
The text was updated successfully, but these errors were encountered: