Skip to content

Commit

Permalink
PEP 8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alejoe91 committed Nov 3, 2023
1 parent b99037a commit 03a3886
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
19 changes: 13 additions & 6 deletions neo/rawio/openephysbinaryrawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ def _parse_header(self):
self._sig_streams[block_index][seg_index][stream_index] = info_cnt

# check for SYNC channel for Neuropixels streams
has_sync_trace = any(["SYNC" in ch["channel_name"] for ch in info_cnt["channels"]])
self._sig_streams[block_index][seg_index][stream_index]['has_sync_trace'] = has_sync_trace
has_sync_trace = any(["SYNC" in ch["channel_name"]
for ch in info_cnt["channels"]])
self._sig_streams[block_index][seg_index][stream_index]['has_sync_trace'] \
= has_sync_trace
for i, stream_name in enumerate(event_stream_names):
info_evt = all_streams[block_index][seg_index]['events'][stream_name]
info_evt['stream_name'] = stream_name
Expand Down Expand Up @@ -146,10 +148,12 @@ def _parse_header(self):
num_channels = len(info['channels'])
memmap_sigs = np.memmap(info['raw_filename'], info['dtype'],
order='C', mode='r').reshape(-1, num_channels)
has_sync_trace = self._sig_streams[block_index][seg_index][stream_index]['has_sync_trace']
has_sync_trace = \
self._sig_streams[block_index][seg_index][stream_index]['has_sync_trace']

# check sync channel validity (only for AP and LF)
if not has_sync_trace and self.load_sync_channel and "NI-DAQ" not in info["stream_name"]:
if not has_sync_trace and self.load_sync_channel \
and "NI-DAQ" not in info["stream_name"]:
raise ValueError("SYNC channel is not present in the recording. "
"Set load_sync_channel to False")
info['memmap'] = memmap_sigs
Expand Down Expand Up @@ -204,7 +208,9 @@ def _parse_header(self):
# ttl case use states
info['labels'] = info['states'].astype('U')
else:
raise ValueError(f'There is no possible labels for this event: {stream_name}')
raise ValueError(
f'There is no possible labels for this event!'
)

# # If available, use 'states' to compute event duration
if 'states' in info and info["states"].size:
Expand Down Expand Up @@ -297,7 +303,8 @@ def _parse_header(self):
for stream_index, stream_name in enumerate(sig_stream_names):
sig_ann = seg_ann['signals'][stream_index]
info = self._sig_streams[block_index][seg_index][stream_index]
has_sync_trace = self._sig_streams[block_index][seg_index][stream_index]['has_sync_trace']
has_sync_trace = \
self._sig_streams[block_index][seg_index][stream_index]['has_sync_trace']

for k in ('identifier', 'history', 'source_processor_index',
'recorded_processor_index'):
Expand Down
6 changes: 4 additions & 2 deletions neo/rawio/spikeglxrawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ def _parse_header(self):
# one fake channel for "sys0"
loc = np.concatenate((loc, [[0., 0.]]), axis=0)
for ndim in range(loc.shape[1]):
sig_ann['__array_annotations__'][f'channel_location_{ndim}'] = loc[:, ndim]
sig_ann['__array_annotations__'][f'channel_location_{ndim}'] = \
loc[:, ndim]

def _segment_t_start(self, block_index, seg_index):
return 0.
Expand Down Expand Up @@ -389,7 +390,8 @@ def extract_stream_info(meta_file, meta):
# metad['imroTbl'] contain two gain per channel AP and LF
# except for the last fake channel
per_channel_gain = np.ones(num_chan, dtype='float64')
if 'imDatPrb_type' not in meta or meta['imDatPrb_type'] == '0' or meta['imDatPrb_type'] in ('1015', '1022', '1030', '1031', '1032'):
if 'imDatPrb_type' not in meta or meta['imDatPrb_type'] == '0' or meta['imDatPrb_type'] \
in ('1015', '1022', '1030', '1031', '1032'):
# This work with NP 1.0 case with different metadata versions
# https://github.com/billkarsh/SpikeGLX/blob/15ec8898e17829f9f08c226bf04f46281f106e5f/Markdown/Metadata_30.md
if stream_kind == 'ap':
Expand Down
12 changes: 8 additions & 4 deletions neo/test/rawiotest/test_openephysbinaryrawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ class TestOpenEphysBinaryRawIO(BaseTestRawIO, unittest.TestCase):

def test_sync(self):
rawio_with_sync = OpenEphysBinaryRawIO(
self.get_local_path("openephysbinary/v0.6.x_neuropixels_with_sync"), load_sync_channel=True
self.get_local_path("openephysbinary/v0.6.x_neuropixels_with_sync"),
load_sync_channel=True
)
rawio_with_sync.parse_header()
stream_name = [s_name for s_name in rawio_with_sync.header["signal_streams"]["name"] if "AP" in s_name][0]
stream_name = [s_name for s_name in rawio_with_sync.header["signal_streams"]["name"]
if "AP" in s_name][0]
stream_index = list(rawio_with_sync.header["signal_streams"]["name"]).index(stream_name)

# AP stream has 385 channels
Expand All @@ -30,7 +32,8 @@ def test_sync(self):
assert chunk.shape[1] == 385

rawio_no_sync = OpenEphysBinaryRawIO(
self.get_local_path("openephysbinary/v0.6.x_neuropixels_with_sync"), load_sync_channel=False
self.get_local_path("openephysbinary/v0.6.x_neuropixels_with_sync"),
load_sync_channel=False
)
rawio_no_sync.parse_header()

Expand All @@ -44,7 +47,8 @@ def test_no_sync(self):
# requesting sync channel when there is none raises an error
with self.assertRaises(ValueError):
rawio_no_sync = OpenEphysBinaryRawIO(
self.get_local_path("openephysbinary/v0.6.x_neuropixels_multiexp_multistream"), load_sync_channel=True
self.get_local_path("openephysbinary/v0.6.x_neuropixels_multiexp_multistream"),
load_sync_channel=True
)
rawio_no_sync.parse_header()

Expand Down

0 comments on commit 03a3886

Please sign in to comment.