-
Notifications
You must be signed in to change notification settings - Fork 271
MaxwellIO: Fix issue due to disparity between routed and mapped channels #1703
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,6 +65,19 @@ def __init__(self, filename="", rec_name=None): | |
|
|
||
| def _source_name(self): | ||
| return self.filename | ||
|
|
||
| def _get_ids_and_electrodes(self, version, stream_id, h5file, mapping): | ||
| if int(version) == 20160704: | ||
| ids = np.array(mapping["channel"]) | ||
| els = np.array(mapping["electrode"]) | ||
| else: | ||
| ids = np.array(h5file["wells"][stream_id][self.rec_name]["groups"]["routed"]["channels"]) | ||
| els = np.array(mapping["electrode"]) | ||
| ids = ids[ids >= 0] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what does an id < 0 mean in this case ?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was also taken from the existing code and I can only guess what it means. I know that the spike files can contain negative timestamps relative to the starting time so I wouldn't put it beyond them to also have negative channel numbers in some scenarios, but I personally haven't encountered them yet. Maybe that is also something occuring in the older data format. |
||
| mask = np.unique(mapping["channel"][np.isin(np.array(mapping["channel"]), ids)], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer to break this up into a couple lines because it is really hard to follow the logic when everything is chained together.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not highlighting the line I wanted it to. I meant for line 77 it is really chained logic.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Totally understandable, I tried to split it into two. Maybe you have a more expressive variable name for the masks created. |
||
| return_index=True)[1] | ||
| return ids, els[mask] | ||
|
|
||
|
|
||
| def _parse_header(self): | ||
| import h5py | ||
|
|
@@ -175,11 +188,7 @@ def _parse_header(self): | |
| } | ||
| self._stream_buffer_slice[stream_id] = slice(None) | ||
|
|
||
| channel_ids = np.array(mapping["channel"]) | ||
| electrode_ids = np.array(mapping["electrode"]) | ||
| mask = channel_ids >= 0 | ||
| channel_ids = channel_ids[mask] | ||
| electrode_ids = electrode_ids[mask] | ||
| channel_ids, electrode_ids = self._get_ids_and_electrodes(version, stream_id, h5file, mapping) | ||
|
|
||
| for i, chan_id in enumerate(channel_ids): | ||
| elec_id = electrode_ids[i] | ||
|
|
||
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.
Could you document where this version number comes from in a comment? Was this dev docs etc. I think knowing magic numbers at all times.
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.
I took the version number from the existing code. My best guess is that it is actually the release date of the first file version, where the structure was a little different. Our lab works with the MaxTwo device which was released later on so I assume that it never used this version because it needs additional fields to correctly represent the multiple wells of the MaxTwo device. There is also an option for legacy data formats in the software supplied by maxwell, so I assume it must be that.