Allow get_samples to retrieve channels based on ID, not order in data array#41
Allow get_samples to retrieve channels based on ID, not order in data array#41jsiegle merged 3 commits intoopen-ephys:mainfrom
get_samples to retrieve channels based on ID, not order in data array#41Conversation
|
This looks very useful, thanks for adding this! |
|
Thanks again for this PR! I took a closer look at the implementation and decided to change the logic a bit, both for the sake of backwards compatibility and for generality. It's important to keep the function of the It is definitely useful to be able to specify channels by the original index in cases where they have been remapped. However, the way you implemented it won't work for all use cases. For example, if there are multiple headstages connected to an acquisition board, each with a CH1, what should index "1" refer to? So as an alternative I added the ability to select channels by name, using a list of strings as a |
Problem
The default behavior for
get_samplesis to return all channels in the order in which they are stored, typically in increasing numerical order. However, if thechannel mapplugin is placed in the signal chain before arecord node, the order of channels will follow the order of the specified channel mapping, but no indication is given to the user that the channel ordering is not 1--n as without thechannel mapplugin.Solution
The array index is looked-up from a dictionary that translates the channel ID (an integer of version of channel name, where
'CH22' = 22) to the index of the storage array.Order is kept consistent with the
channel mapplugin as recorded in theoebinfile. By default, all channels are returned. If you board hasadditional
ADCnchannels, they are sequentially numbered after reachingthe last
CHnnlabeled channel.This PR allows for the user to specify channel by it's ID, not it's index. This will allow for a direct selection of channels via the
channel_by_numberargument, where index 1 == 'CH1' .Changes
The
get_samplesmethod now includes the arguments:selected_channelsis a positional or keyword argument that allows channels to be selected via array index in the order stored in the sample array.Superficially similar to the existing approach, the selected channels area always selected using the channel map dictionary, such that the user gets the channel they intend, but indices are consistent with python 0-based arrays.
channel_by_numberis a keyword-only argument allows channels to be selected by ID to extract specific channels by channel ID number (integers followingCHin theoebinfile). If your board has additionalADCnchannels, they are sequentially numbered after reaching the lastCHnnlabeled channel.The changes only apply to binary and oebin formats. I am not familiar with NWB format and I do not know if it needs such a change.