Skip to content

Commit b5b49df

Browse files
authored
Merge branch 'master' into neuronexus
2 parents 28b0191 + 5a6786a commit b5b49df

File tree

7 files changed

+35
-10
lines changed

7 files changed

+35
-10
lines changed

doc/source/authors.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ and may not be the current affiliation of a contributor.
9595
* Rémi Proville [44]
9696
* Paul Adkisson [24]
9797
* Luiz Tauffer [24]
98+
* Akshaj Verma [46]
99+
* Letizia Signorelli [47]
98100

99101
1. Centre de Recherche en Neuroscience de Lyon, CNRS UMR5292 - INSERM U1028 - Université Claude Bernard Lyon 1
100102
2. Unité de Neuroscience, Information et Complexité, CNRS UPR 3293, Gif-sur-Yvette, France
@@ -141,6 +143,8 @@ and may not be the current affiliation of a contributor.
141143
43. University of Genoa, Italy
142144
44. AquiNeuro, SAS
143145
45. Maxwell Biosystems AG
146+
46. Brain Center, University Medical Center Utrecht, Utrecht University, The Netherlands
147+
47. Centre for Molecular Medicine Norway (NCMM), University of Oslo, Norway
144148

145149

146150

neo/core/spiketrainlist.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,11 @@ def __init__(self, items=None, parent=None):
113113
self._channel_id_array = None
114114
self._all_channel_ids = None
115115
self._spiketrain_metadata = {}
116-
if parent is not None and parent.__class__.__name__ != "Segment":
117-
raise AttributeError("The parent class must be a Segment")
116+
117+
from .segment import Segment # import here rather than at the top to avoid circular import
118+
119+
if parent is not None and not isinstance(parent, Segment):
120+
raise AttributeError("If provided, the parent class must be a Segment")
118121
self.segment = parent
119122

120123
@property

neo/rawio/axonarawio.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,7 @@ def _get_analogsignal_chunk(self, block_index, seg_index, i_start, i_stop, strea
377377
if channel_indexes is None:
378378
channel_indexes = [i for i in range(bin_dict["num_channels"])]
379379
elif isinstance(channel_indexes, slice):
380-
channel_indexes_all = [i for i in range(bin_dict["num_channels"])]
381-
channel_indexes = channel_indexes_all[channel_indexes]
380+
channel_indexes = self._get_active_channels()
382381

383382
num_samples = i_stop - i_start
384383

@@ -562,6 +561,20 @@ def get_active_tetrode(self):
562561
active_tetrodes.append(tetrode_id)
563562
return active_tetrodes
564563

564+
def _get_active_channels(self):
565+
"""
566+
Returns the ID numbers of the active channels as a list.
567+
E.g.: [20,21,22,23] for tetrode 6 active.
568+
"""
569+
active_tetrodes = self.get_active_tetrode()
570+
active_channels = []
571+
572+
for tetrode in active_tetrodes:
573+
chans = self._get_channel_from_tetrode(tetrode)
574+
active_channels.append(chans)
575+
576+
return np.concatenate(active_channels)
577+
565578
def _get_channel_from_tetrode(self, tetrode):
566579
"""
567580
This function will take the tetrode number and return the Axona
@@ -632,12 +645,13 @@ def _get_signal_chan_header(self):
632645
gain_list = self._get_channel_gain()
633646
offset = 0 # What is the offset?
634647

648+
first_channel = (active_tetrode_set[0] - 1) * elec_per_tetrode
635649
sig_channels = []
636650
for itetr in range(num_active_tetrode):
637651

638652
for ielec in range(elec_per_tetrode):
639-
cntr = (itetr * elec_per_tetrode) + ielec
640-
ch_name = f"{itetr + 1}{letters[ielec]}"
653+
cntr = (itetr * elec_per_tetrode) + ielec + first_channel
654+
ch_name = f"{itetr + active_tetrode_set[0]}{letters[ielec]}"
641655
chan_id = str(cntr)
642656
gain = gain_list[cntr]
643657
stream_id = "0"

neo/rawio/micromedrawio.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ def __init__(self, filename=""):
5151
self.filename = filename
5252

5353
def _parse_header(self):
54-
5554
with open(self.filename, "rb") as fid:
5655
f = StructFile(fid)
5756

@@ -133,7 +132,11 @@ def _parse_header(self):
133132
sig_grounds = []
134133
for c in range(Num_Chan):
135134
zname2, pos, length = zones["LABCOD"]
136-
f.seek(pos + code[c] * 128 + 2, 0)
135+
# Force code[c] which is currently a uint16 (or u2) into a int to prevent integer overflow
136+
# for the following operation -- code[c] * 128 + 2.
137+
# An integer overflow below may have side - effects including but not limited
138+
# to having repeated channel names.
139+
f.seek(pos + int(code[c]) * 128 + 2, 0)
137140

138141
chan_name = f.read(6).strip(b"\x00").decode("ascii")
139142
ground = f.read(6).strip(b"\x00").decode("ascii")
@@ -269,7 +272,6 @@ def _event_count(self, block_index, seg_index, event_channel_index):
269272
return n
270273

271274
def _get_event_timestamps(self, block_index, seg_index, event_channel_index, t_start, t_stop):
272-
273275
raw_event = self._raw_events[event_channel_index][seg_index]
274276

275277
# important : all events timing are related to the first segment t_start

neo/rawio/spikeglxrawio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ def extract_stream_info(meta_file, meta):
576576
if (
577577
"imDatPrb_type" not in meta
578578
or meta["imDatPrb_type"] == "0"
579-
or meta["imDatPrb_type"] in ("1015", "1016", "1022", "1030", "1031", "1032", "1100", "1121", "1123","1300")
579+
or meta["imDatPrb_type"] in ("1015", "1016", "1022", "1030", "1031", "1032", "1100", "1121", "1123", "1300")
580580
):
581581
# This work with NP 1.0 case with different metadata versions
582582
# https://github.com/billkarsh/SpikeGLX/blob/15ec8898e17829f9f08c226bf04f46281f106e5f/Markdown/Metadata_30.md

neo/test/iotest/test_plexon2io.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
TEST_PLEXON2 = bool(os.getenv("PLEXON2_TEST"))
2222

23+
2324
@unittest.skipUnless(HAVE_PYPL2 and TEST_PLEXON2, "requires pypl package and all its dependencies")
2425
class TestPlexon2IO(BaseTestIO, unittest.TestCase):
2526
entities_to_download = TestPlexon2RawIO.entities_to_download

neo/test/rawiotest/test_plexon2rawio.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
TEST_PLEXON2 = bool(os.getenv("PLEXON2_TEST"))
2121

22+
2223
@unittest.skipUnless(HAVE_PYPL2 and TEST_PLEXON2, "requires pypl package and all its dependencies")
2324
class TestPlexon2RawIO(
2425
BaseTestRawIO,

0 commit comments

Comments
 (0)