Skip to content

Commit 153673a

Browse files
authored
black formatting
1 parent f401627 commit 153673a

File tree

3 files changed

+21
-22
lines changed

3 files changed

+21
-22
lines changed

neo/rawio/intanrawio.py

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def _parse_header(self):
129129
# if header-attached there is one giant memory-map
130130
if self.file_format == "header-attached":
131131
self._raw_data = np.memmap(self.filename, dtype=data_dtype, mode="r", offset=header_size)
132-
132+
133133
# for 'one-file-per-signal' we have one memory map / neo stream
134134
elif self.file_format == "one-file-per-signal":
135135
self._raw_data = {}
@@ -139,7 +139,9 @@ def _parse_header(self):
139139
size_in_bytes = file_path.stat().st_size
140140
dtype_size = np.dtype(stream_datatype).itemsize
141141
n_samples = size_in_bytes // (dtype_size * num_channels)
142-
signal_stream_memmap = np.memmap(file_path, dtype=stream_datatype, mode="r", shape=(num_channels, n_samples)).T
142+
signal_stream_memmap = np.memmap(
143+
file_path, dtype=stream_datatype, mode="r", shape=(num_channels, n_samples)
144+
).T
143145
self._raw_data[stream_index] = signal_stream_memmap
144146

145147
# for one-file-per-channel we have one memory map / channel stored as a list / neo stream
@@ -153,7 +155,6 @@ def _parse_header(self):
153155
channel_memmap = np.memmap(file_path, dtype=stream_datatype, mode="r")
154156
self._raw_data[stream_index].append(channel_memmap)
155157

156-
157158
# check timestamp continuity
158159
if self.file_format == "header-attached":
159160
timestamp = self._raw_data["timestamp"].flatten()
@@ -174,7 +175,7 @@ def _parse_header(self):
174175
for c, chan_info in enumerate(self._ordered_channels):
175176
name = chan_info["custom_channel_name"]
176177
channel_id = chan_info["native_channel_name"]
177-
sig_dtype = chan_info['dtype']
178+
sig_dtype = chan_info["dtype"]
178179
stream_id = str(chan_info["signal_type"])
179180
signal_channels.append(
180181
(
@@ -236,7 +237,7 @@ def _segment_t_stop(self, block_index, seg_index):
236237
return t_stop
237238

238239
def _get_signal_size(self, block_index, seg_index, stream_index):
239-
240+
240241
if self.file_format == "header-attached":
241242
stream_id = self.header["signal_streams"][stream_index]["id"]
242243
mask = self.header["signal_channels"]["stream_id"] == stream_id
@@ -302,19 +303,18 @@ def _get_analogsignal_chunk_header_attached(self, i_start, i_stop, stream_index,
302303
dtype = self._raw_data[channel_id_0].dtype
303304
sigs_chunk = np.zeros((i_stop - i_start, len(channel_ids)), dtype=dtype)
304305

305-
306306
# This is False for Temperature and timestamps
307307
multiple_samples_per_block = len(shape) == 2
308308

309309
# In the header attached case the data for each channel comes interleaved in blocks
310-
# To avoid unecessary memory access we can calculate the blocks we need to access beforehand:
310+
# To avoid unecessary memory access we can calculate the blocks we need to access beforehand:
311311
if multiple_samples_per_block:
312312
block_size = shape[1]
313313
block_start = i_start // block_size
314314
block_stop = i_stop // block_size + 1
315315
sl0 = i_start % block_size
316316
sl1 = sl0 + (i_stop - i_start)
317-
317+
318318
# raw_data is a structured memmap with a field for each channel_id
319319
for chunk_index, channel_id in enumerate(channel_ids):
320320
data_chan = self._raw_data[channel_id]
@@ -325,7 +325,6 @@ def _get_analogsignal_chunk_header_attached(self, i_start, i_stop, stream_index,
325325

326326
return sigs_chunk
327327

328-
329328
def _get_analogsignal_chunk_one_file_per_channel(self, i_start, i_stop, stream_index, channel_indexes):
330329

331330
signal_data_memmap_list = self._raw_data[stream_index]
@@ -336,7 +335,7 @@ def _get_analogsignal_chunk_one_file_per_channel(self, i_start, i_stop, stream_i
336335
stop = channel_indexes.stop or num_channels
337336
step = channel_indexes.step or 1
338337
channel_indexes = range(start, stop, step)
339-
338+
340339
# We get the dtype from the first channel
341340
first_channel_index = channel_indexes[0]
342341
dtype = signal_data_memmap_list[first_channel_index].dtype
@@ -348,7 +347,6 @@ def _get_analogsignal_chunk_one_file_per_channel(self, i_start, i_stop, stream_i
348347

349348
return sigs_chunk
350349

351-
352350
def _get_analogsignal_chunk_one_file_per_signal(self, i_start, i_stop, stream_index, channel_indexes):
353351

354352
# One memmap per stream case
@@ -704,12 +702,11 @@ def read_rhd(filename, file_format: str):
704702
chan_info["offset"] = 0.0
705703
chan_info["dtype"] = "int16"
706704
ordered_channels.append(chan_info)
707-
705+
708706
if file_format == "header-attached":
709707
data_dtype += [(name, "uint16", BLOCK_SIZE)]
710708
else:
711709
data_dtype[0] = "int16"
712-
713710

714711
# 1: RHD2000 auxiliary input channel
715712
for chan_info in channels_by_type[1]:
@@ -725,7 +722,6 @@ def read_rhd(filename, file_format: str):
725722
else:
726723
data_dtype[1] = "uint16"
727724

728-
729725
# 2: RHD2000 supply voltage channel
730726
for chan_info in channels_by_type[2]:
731727
name = chan_info["native_channel_name"]
@@ -737,7 +733,7 @@ def read_rhd(filename, file_format: str):
737733
ordered_channels.append(chan_info)
738734
if file_format == "header-attached":
739735
data_dtype += [(name, "uint16")]
740-
else:
736+
else:
741737
data_dtype[2] = "uint16"
742738

743739
# temperature is not an official channel in the header
@@ -797,7 +793,6 @@ def read_rhd(filename, file_format: str):
797793
else:
798794
data_dtype[sig_type] = "uint16"
799795

800-
801796
if global_info["notch_filter_mode"] == 2 and version >= V("3.0"):
802797
global_info["notch_filter"] = "60Hz"
803798
elif global_info["notch_filter_mode"] == 1 and version >= V("3.0"):

neo/rawio/spikegadgetsrawio.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ def _parse_header(self):
107107
stream_bytes = {}
108108
for device in hconf:
109109
stream_id = device.attrib["name"]
110-
if 'numBytes' in device.attrib.keys():
111-
num_bytes = int(device.attrib["numBytes"])
112-
stream_bytes[stream_id] = packet_size
113-
packet_size += num_bytes
110+
if "numBytes" in device.attrib.keys():
111+
num_bytes = int(device.attrib["numBytes"])
112+
stream_bytes[stream_id] = packet_size
113+
packet_size += num_bytes
114114

115115
# timestamps 4 uint32
116116
self._timestamp_byte = packet_size
@@ -140,7 +140,7 @@ def _parse_header(self):
140140
# TODO LATER: deal with "headstageSensor" which have interleaved
141141
continue
142142

143-
if ('dataType' in channel.attrib.keys()) and (channel.attrib["dataType"] == "analog"):
143+
if ("dataType" in channel.attrib.keys()) and (channel.attrib["dataType"] == "analog"):
144144

145145
if stream_id not in stream_ids:
146146
stream_ids.append(stream_id)

neo/test/rawiotest/test_spikegadgetsrawio.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ class TestSpikeGadgetsRawIO(
1010
):
1111
rawioclass = SpikeGadgetsRawIO
1212
entities_to_download = ["spikegadgets"]
13-
entities_to_test = ["spikegadgets/20210225_em8_minirec2_ac.rec", "spikegadgets/W122_06_09_2019_1_fromSD.rec", "spikegadgets/SpikeGadgets_test_data_2xNpix1.0_20240318_173658.rec"]
13+
entities_to_test = [
14+
"spikegadgets/20210225_em8_minirec2_ac.rec",
15+
"spikegadgets/W122_06_09_2019_1_fromSD.rec",
16+
"spikegadgets/SpikeGadgets_test_data_2xNpix1.0_20240318_173658.rec",
17+
]
1418

1519

1620
if __name__ == "__main__":

0 commit comments

Comments
 (0)