Skip to content
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

Fix electrode selection in Axona raw recording #1520

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/source/authors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ and may not be the current affiliation of a contributor.
* Téo Lohrer
* Anthony Pinto [41]
* Xin Niu
* Letizia Signorelli [42]

1. Centre de Recherche en Neuroscience de Lyon, CNRS UMR5292 - INSERM U1028 - Universite Claude Bernard Lyon 1
2. Unité de Neuroscience, Information et Complexité, CNRS UPR 3293, Gif-sur-Yvette, France
Expand Down Expand Up @@ -130,6 +131,7 @@ and may not be the current affiliation of a contributor.
39. Massachusetts General Hospital, Department of Molecular Biology
40. Plexon Inc.
41. Paris Brain Institute
42. Centre for Molecular Medicine Norway (NCMM), University of Oslo, Norway



Expand Down
22 changes: 18 additions & 4 deletions neo/rawio/axonarawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,7 @@ def _get_analogsignal_chunk(self, block_index, seg_index, i_start, i_stop, strea
if channel_indexes is None:
channel_indexes = [i for i in range(bin_dict["num_channels"])]
elif isinstance(channel_indexes, slice):
channel_indexes_all = [i for i in range(bin_dict["num_channels"])]
channel_indexes = channel_indexes_all[channel_indexes]
channel_indexes = self.get_active_channels()
zm711 marked this conversation as resolved.
Show resolved Hide resolved

num_samples = i_stop - i_start

Expand Down Expand Up @@ -558,6 +557,20 @@ def get_active_tetrode(self):
tetrode_id = int(key.strip("collectMask_"))
active_tetrodes.append(tetrode_id)
return active_tetrodes

def get_active_channels(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public or private? what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I advice to make things private by default and move away from it when you have a good reason to.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's how I was leaning too. I don't see why the user would run this function.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree with making them private

"""
Returns the ID numbers of the active channels as a list.
E.g.: [20,21,22,23] for tetrode 6 active.
"""
active_tetrodes = self.get_active_tetrode()
active_channels = []

for tetrode in active_tetrodes:
chan = self._get_channel_from_tetrode(tetrode)
active_channels.append(chan)

return np.concatenate(active_channels)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the benefit of concat? I need to doublecheck what is chan is it a list of all channels from a tetrode. If that is the case I would call it channels or chans instead so we know it's plural.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, chan is a list of all channels from a tetrode, so I agree to call it channels or chans.

Since I was using this function only for the _get_analogsignal_chunk function and it needed the list of active channels as an array I returned directly active_channels as an array. But we can also do it in _get_analogsignal_chunk and keep this function consistent with get_active_tetrodes and return directly active_channels


def _get_channel_from_tetrode(self, tetrode):
"""
Expand Down Expand Up @@ -629,12 +642,13 @@ def _get_signal_chan_header(self):
gain_list = self._get_channel_gain()
offset = 0 # What is the offset?

first_channel = (active_tetrode_set[0] - 1)*elec_per_tetrode
sig_channels = []
for itetr in range(num_active_tetrode):

for ielec in range(elec_per_tetrode):
cntr = (itetr * elec_per_tetrode) + ielec
ch_name = f"{itetr + 1}{letters[ielec]}"
cntr = (itetr * elec_per_tetrode) + ielec + first_channel
ch_name = "{}{}".format(itetr + active_tetrode_set[0], letters[ielec])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ch_name = "{}{}".format(itetr + active_tetrode_set[0], letters[ielec])
ch_name = f"{itetr + active_tetrode_set[0]}{letters[ielec]}"

we try to keep the codebase on f-strings since they are faster and easier to read :)

chan_id = str(cntr)
gain = gain_list[cntr]
stream_id = "0"
Expand Down
Loading