Skip to content
Open
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
19 changes: 14 additions & 5 deletions neo/rawio/maxwellrawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Contributor

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.

Copy link
Author

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.

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]
Copy link
Contributor

Choose a reason for hiding this comment

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

what does an id < 0 mean in this case ?
I see we do the same thing in the old code, but since I don't work on this reader much I would love to know what this means.

Copy link
Author

Choose a reason for hiding this comment

The 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)],
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Author

Choose a reason for hiding this comment

The 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
Expand Down Expand Up @@ -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]
Expand Down
Loading