Skip to content

Commit 041c86f

Browse files
authored
black formatting
1 parent 3e1716f commit 041c86f

File tree

3 files changed

+23
-26
lines changed

3 files changed

+23
-26
lines changed

neo/rawio/plexon2rawio/plexon2rawio.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,12 @@ def _parse_header(self):
234234

235235
# In a PL2 spike channel header, the field "m_NumberOfUnits" denotes the number
236236
# of units to which spikes detected on that channel have been assigned. It does
237-
# not account for unsorted spikes, i.e., spikes that have not been assigned to
238-
# a unit. It is Plexon's convention to assign unsorted spikes to channel_unit_id=0,
239-
# and sorted spikes to channel_unit_id's 1, 2, 3...etc. Therefore, for a given value of
240-
# m_NumberOfUnits, there are m_NumberOfUnits+1 channel_unit_ids to consider - 1
241-
# unsorted channel_unit_id (0) + the m_NumberOfUnits sorted channel_unit_ids.
242-
for channel_unit_id in range(schannel_info.m_NumberOfUnits+1):
237+
# not account for unsorted spikes, i.e., spikes that have not been assigned to
238+
# a unit. It is Plexon's convention to assign unsorted spikes to channel_unit_id=0,
239+
# and sorted spikes to channel_unit_id's 1, 2, 3...etc. Therefore, for a given value of
240+
# m_NumberOfUnits, there are m_NumberOfUnits+1 channel_unit_ids to consider - 1
241+
# unsorted channel_unit_id (0) + the m_NumberOfUnits sorted channel_unit_ids.
242+
for channel_unit_id in range(schannel_info.m_NumberOfUnits + 1):
243243
unit_name = f"{schannel_info.m_Name.decode()}.{channel_unit_id}"
244244
unit_id = f"unit{schannel_info.m_Channel}.{channel_unit_id}"
245245
wf_units = schannel_info.m_Units

neo/rawio/plexonrawio.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545

4646
from neo.core.baseneo import NeoReadWriteError
4747

48+
4849
class PlexonRawIO(BaseRawIO):
4950
extensions = ["plx"]
5051
rawmode = "one-file"
@@ -232,18 +233,18 @@ def _parse_header(self):
232233

233234
# signals channels
234235
source_id = []
235-
236+
236237
# Scanning sources and populating signal channels at the same time. Sources have to have
237238
# same sampling rate and number of samples to belong to one stream.
238239
signal_channels = []
239240
channel_num_samples = []
240-
241+
241242
# We will build the stream ids based on the channel prefixes
242243
# The channel prefixes are the first characters of the channel names which have the following format:
243244
# WB{number}, FPX{number}, SPKCX{number}, AI{number}, etc
244245
# We will extract the prefix and use it as stream id
245246
regex_prefix_pattern = r"^\D+" # Match any non-digit character at the beginning of the string
246-
247+
247248
if self.progress_bar:
248249
chan_loop = trange(nb_sig_chan, desc="Parsing signal channels", leave=True)
249250
else:
@@ -271,7 +272,7 @@ def _parse_header(self):
271272
offset = 0.0
272273
channel_prefix = re.match(regex_prefix_pattern, name).group(0)
273274
stream_id = channel_prefix
274-
275+
275276
signal_channels.append((name, str(chan_id), sampling_rate, sig_dtype, units, gain, offset, stream_id))
276277

277278
signal_channels = np.array(signal_channels, dtype=_signal_channel_dtype)
@@ -312,7 +313,7 @@ def _parse_header(self):
312313
self._stream_index_to_stream_id[stream_index] = stream_id
313314

314315
mask = signal_channels["stream_id"] == stream_id
315-
316+
316317
signal_num_samples = np.unique(channel_num_samples[mask])
317318
if signal_num_samples.size > 1:
318319
raise NeoReadWriteError(f"Channels in stream {stream_id} don't have the same number of samples")
@@ -322,7 +323,7 @@ def _parse_header(self):
322323
if signal_sampling_frequency.size > 1:
323324
raise NeoReadWriteError(f"Channels in stream {stream_id} don't have the same sampling frequency")
324325
self._stream_id_sampling_frequency[stream_id] = signal_sampling_frequency[0]
325-
326+
326327
self._global_ssampling_rate = global_header["ADFrequency"]
327328

328329
# Determine number of units per channels
@@ -425,8 +426,6 @@ def _get_analogsignal_chunk(self, block_index, seg_index, i_start, i_stop, strea
425426
if i_stop is None:
426427
i_stop = self._stream_id_samples[stream_id]
427428

428-
429-
430429
mask = signal_channels["stream_id"] == stream_id
431430
signal_channels = signal_channels[mask]
432431
if channel_indexes is not None:

neo/test/rawiotest/test_plexon2rawio.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,24 @@ class TestPlexon2RawIO(
2626
):
2727
rawioclass = Plexon2RawIO
2828
entities_to_download = ["plexon"]
29-
entities_to_test = ["plexon/4chDemoPL2.pl2",
30-
"plexon/NC16FPSPKEVT_1m.pl2"
31-
]
32-
29+
entities_to_test = ["plexon/4chDemoPL2.pl2", "plexon/NC16FPSPKEVT_1m.pl2"]
3330

3431
def test_check_enabled_flags(self):
3532
"""
3633
This test loads a 1-minute PL2 file with 16 channels' each
37-
of field potential (FP), and spike (SPK) data. The channels
38-
cycle through 4 possible combinations of m_ChannelEnabled
39-
and m_ChannelRecordingEnabled - (True, True), (True, False),
40-
(False, True), and (False, False). With 16 channels for each
41-
source, each combination of flags occurs 4 times. Only the
34+
of field potential (FP), and spike (SPK) data. The channels
35+
cycle through 4 possible combinations of m_ChannelEnabled
36+
and m_ChannelRecordingEnabled - (True, True), (True, False),
37+
(False, True), and (False, False). With 16 channels for each
38+
source, each combination of flags occurs 4 times. Only the
4239
first combination (True, True) causes data to be recorded to
4340
disk. Therefore, we expect the following channels to be loaded by
4441
Neo: FP01, FP05, FP09, FP13, SPK01, SPK05, SPK09, and SPK13.
45-
42+
4643
Note: the file contains event (EVT) data as well. Although event
4744
channel headers do contain m_ChannelEnabled and m_ChannelRecording-
4845
Enabled flags, the UI for recording PL2 files does not expose any
49-
controls by which these flags can be changed from (True, True).
46+
controls by which these flags can be changed from (True, True).
5047
Therefore, no test for event channels is necessary here.
5148
"""
5249

@@ -58,13 +55,14 @@ def test_check_enabled_flags(self):
5855

5956
# Check that the names of the loaded signal channels match what we expect
6057
signal_channel_names = reader.header["signal_channels"]["name"].tolist()
61-
expected_signal_channel_names = ["FP01","FP05","FP09","FP13"]
58+
expected_signal_channel_names = ["FP01", "FP05", "FP09", "FP13"]
6259
assert_equal(signal_channel_names, expected_signal_channel_names)
6360

6461
# Check that the names of the loaded spike channels match what we expect
6562
spike_channel_names = reader.header["spike_channels"]["name"].tolist()
6663
expected_spike_channel_names = ["SPK01.0", "SPK05.0", "SPK09.0", "SPK13.0"]
6764
assert_equal(spike_channel_names, expected_spike_channel_names)
6865

66+
6967
if __name__ == "__main__":
7068
unittest.main()

0 commit comments

Comments
 (0)