From 741a76440da9eb0d34b6ce4907b96ae699773217 Mon Sep 17 00:00:00 2001 From: apdavison Date: Sun, 13 Oct 2024 12:13:45 +0000 Subject: [PATCH 1/2] black formatting --- neo/io/igorproio.py | 2 +- neo/rawio/axographrawio.py | 12 +++++++++++- neo/rawio/axonrawio.py | 4 +++- neo/rawio/baserawio.py | 5 ++++- neo/rawio/brainvisionrawio.py | 4 +++- neo/rawio/elanrawio.py | 13 +++++++++++-- neo/rawio/intanrawio.py | 1 - neo/rawio/maxwellrawio.py | 8 ++++---- neo/rawio/micromedrawio.py | 4 +++- neo/rawio/neuralynxrawio/neuralynxrawio.py | 12 +++++++++++- neo/rawio/neuronexusrawio.py | 4 ++-- neo/rawio/neuroscoperawio.py | 4 +++- neo/rawio/openephysrawio.py | 2 +- neo/rawio/plexonrawio.py | 5 +++-- neo/rawio/rawbinarysignalrawio.py | 2 +- neo/rawio/spike2rawio.py | 4 +++- neo/rawio/spikegadgetsrawio.py | 1 - neo/rawio/tdtrawio.py | 4 +++- neo/rawio/winedrrawio.py | 6 ++++-- neo/rawio/winwcprawio.py | 6 ++++-- neo/test/rawiotest/rawio_compliance.py | 3 ++- neo/test/rawiotest/test_neuronexusrawio.py | 2 +- 22 files changed, 78 insertions(+), 30 deletions(-) diff --git a/neo/io/igorproio.py b/neo/io/igorproio.py index f084496bd..71f197d72 100644 --- a/neo/io/igorproio.py +++ b/neo/io/igorproio.py @@ -142,7 +142,7 @@ def _wave_to_analogsignal(self, content, dirpath): _time_unit_structure = header["dimUnits"].ravel() # For the files we've seen so far, the first element of _time_unit_structure contains the units. # If someone has a file for which this assumption does not hold an Exception will be raised. - if not all([element == b'' for element in _time_unit_structure[1:]]): + if not all([element == b"" for element in _time_unit_structure[1:]]): raise Exception( "Neo cannot yet handle the units in this file. " "Please create a new issue in the Neo issue tracker at " diff --git a/neo/rawio/axographrawio.py b/neo/rawio/axographrawio.py index 6656b95e9..e11151ab1 100644 --- a/neo/rawio/axographrawio.py +++ b/neo/rawio/axographrawio.py @@ -814,7 +814,17 @@ def _scan_axograph_file(self): # channel_info will be cast to _signal_channel_dtype buffer_id = "" stream_id = "0" - channel_info = (name, str(i), 1 / sampling_period, f.byte_order + dtype, units, gain, offset, stream_id, buffer_id) + channel_info = ( + name, + str(i), + 1 / sampling_period, + f.byte_order + dtype, + units, + gain, + offset, + stream_id, + buffer_id, + ) self.logger.debug("channel_info: {channel_info}") self.logger.debug("") diff --git a/neo/rawio/axonrawio.py b/neo/rawio/axonrawio.py index 67af44e3f..8caf8554c 100644 --- a/neo/rawio/axonrawio.py +++ b/neo/rawio/axonrawio.py @@ -229,7 +229,9 @@ def _parse_header(self): gain, offset = 1.0, 0.0 stream_id = "0" buffer_id = "0" - signal_channels.append((name, str(chan_id), self._sampling_rate, sig_dtype, units, gain, offset, stream_id, buffer_id)) + signal_channels.append( + (name, str(chan_id), self._sampling_rate, sig_dtype, units, gain, offset, stream_id, buffer_id) + ) signal_channels = np.array(signal_channels, dtype=_signal_channel_dtype) diff --git a/neo/rawio/baserawio.py b/neo/rawio/baserawio.py index b09e922cb..e875d7aa2 100644 --- a/neo/rawio/baserawio.py +++ b/neo/rawio/baserawio.py @@ -94,7 +94,10 @@ _signal_stream_dtype = [ ("name", "U64"), # not necessarily unique ("id", "U64"), # must be unique - ("buffer_id", "U64"), # should be "" (empty string) when the stream is not nested under a buffer or the buffer is undefined for some reason. + ( + "buffer_id", + "U64", + ), # should be "" (empty string) when the stream is not nested under a buffer or the buffer is undefined for some reason. ] _signal_channel_dtype = [ diff --git a/neo/rawio/brainvisionrawio.py b/neo/rawio/brainvisionrawio.py index 27081e689..9cfcf615b 100644 --- a/neo/rawio/brainvisionrawio.py +++ b/neo/rawio/brainvisionrawio.py @@ -118,7 +118,9 @@ def _parse_header(self): offset = 0 stream_id = "0" buffer_id = "0" - sig_channels.append((name, chan_id, self._sampling_rate, sig_dtype, units, gain, offset, stream_id, buffer_id)) + sig_channels.append( + (name, chan_id, self._sampling_rate, sig_dtype, units, gain, offset, stream_id, buffer_id) + ) sig_channels = np.array(sig_channels, dtype=_signal_channel_dtype) # No spikes diff --git a/neo/rawio/elanrawio.py b/neo/rawio/elanrawio.py index b44d77075..18de2472d 100644 --- a/neo/rawio/elanrawio.py +++ b/neo/rawio/elanrawio.py @@ -158,7 +158,6 @@ def _parse_header(self): # unique buffer and stream signal_buffers = np.array([("Signals", "0")], dtype=_signal_buffer_dtype) signal_streams = np.array([("Signals", "0", "0")], dtype=_signal_stream_dtype) - sig_channels = [] for c, chan_info in enumerate(channel_infos[:-2]): @@ -172,7 +171,17 @@ def _parse_header(self): stream_id = "0" buffer_id = "0" sig_channels.append( - (chan_name, chan_id, self._sampling_rate, sig_dtype, chan_info["units"], gain, offset, stream_id, buffer_id) + ( + chan_name, + chan_id, + self._sampling_rate, + sig_dtype, + chan_info["units"], + gain, + offset, + stream_id, + buffer_id, + ) ) sig_channels = np.array(sig_channels, dtype=_signal_channel_dtype) diff --git a/neo/rawio/intanrawio.py b/neo/rawio/intanrawio.py index 5be322b6c..77879e69b 100644 --- a/neo/rawio/intanrawio.py +++ b/neo/rawio/intanrawio.py @@ -242,7 +242,6 @@ def _parse_header(self): stream_ids = np.unique(signal_channels["stream_id"]) signal_streams = np.zeros(stream_ids.size, dtype=_signal_stream_dtype) - # we need to sort the data because the string of stream_index 10 is mis-sorted. buffer_ids = [] diff --git a/neo/rawio/maxwellrawio.py b/neo/rawio/maxwellrawio.py index c093c795f..7224f27af 100644 --- a/neo/rawio/maxwellrawio.py +++ b/neo/rawio/maxwellrawio.py @@ -111,13 +111,12 @@ def _parse_header(self): raise NotImplementedError(f"This version {version} is not supported") signal_streams = np.array(signal_streams, dtype=_signal_stream_dtype) - + # one stream per buffer signal_buffers = np.zeros(signal_streams.size, dtype=_signal_buffer_dtype) signal_buffers["id"] = signal_streams["id"] signal_buffers["name"] = signal_streams["name"] - # create signal channels max_sig_length = 0 self._signals = {} @@ -160,7 +159,6 @@ def _parse_header(self): warnings.warn(f"No 'routed' group found for well {stream_id}") well_indices_to_remove.append(stream_index) continue - channel_ids = np.array(mapping["channel"]) electrode_ids = np.array(mapping["electrode"]) @@ -173,7 +171,9 @@ def _parse_header(self): ch_name = f"ch{chan_id} elec{elec_id}" offset_uV = 0 buffer_id = stream_id - sig_channels.append((ch_name, str(chan_id), sr, "uint16", "uV", gain_uV, offset_uV, stream_id, buffer_id)) + sig_channels.append( + (ch_name, str(chan_id), sr, "uint16", "uV", gain_uV, offset_uV, stream_id, buffer_id) + ) self._signals[stream_id] = sigs max_sig_length = max(max_sig_length, sigs.shape[1]) diff --git a/neo/rawio/micromedrawio.py b/neo/rawio/micromedrawio.py index 39d932f09..c92e3ea72 100644 --- a/neo/rawio/micromedrawio.py +++ b/neo/rawio/micromedrawio.py @@ -130,7 +130,9 @@ def _parse_header(self): chan_id = str(c) stream_id = "0" buffer_id = "0" - signal_channels.append((chan_name, chan_id, sampling_rate, sig_dtype, units, gain, offset, stream_id, buffer_id)) + signal_channels.append( + (chan_name, chan_id, sampling_rate, sig_dtype, units, gain, offset, stream_id, buffer_id) + ) signal_channels = np.array(signal_channels, dtype=_signal_channel_dtype) diff --git a/neo/rawio/neuralynxrawio/neuralynxrawio.py b/neo/rawio/neuralynxrawio/neuralynxrawio.py index b3b1b2c4d..75f0df730 100644 --- a/neo/rawio/neuralynxrawio/neuralynxrawio.py +++ b/neo/rawio/neuralynxrawio/neuralynxrawio.py @@ -279,7 +279,17 @@ def _parse_header(self): gain *= -1 offset = 0.0 signal_channels.append( - (chan_name, str(chan_id), info["sampling_rate"], "int16", units, gain, offset, stream_id, buffer_id) + ( + chan_name, + str(chan_id), + info["sampling_rate"], + "int16", + units, + gain, + offset, + stream_id, + buffer_id, + ) ) self.ncs_filenames[chan_uid] = filename keys = [ diff --git a/neo/rawio/neuronexusrawio.py b/neo/rawio/neuronexusrawio.py index 9763d5e74..7d7f6e970 100644 --- a/neo/rawio/neuronexusrawio.py +++ b/neo/rawio/neuronexusrawio.py @@ -191,7 +191,7 @@ def _parse_header(self): 1, # no gain 0, # no offset stream_id, - buffer_id + buffer_id, ) ) @@ -203,7 +203,7 @@ def _parse_header(self): stream_ids = np.unique(signal_channels["stream_id"]) signal_streams = np.zeros(stream_ids.size, dtype=_signal_stream_dtype) signal_streams["id"] = [str(stream_id) for stream_id in stream_ids] - # One unique buffer + # One unique buffer signal_streams["buffer_id"] = buffer_id for stream_index, stream_id in enumerate(stream_ids): diff --git a/neo/rawio/neuroscoperawio.py b/neo/rawio/neuroscoperawio.py index 9582bb5db..78f12b4ae 100644 --- a/neo/rawio/neuroscoperawio.py +++ b/neo/rawio/neuroscoperawio.py @@ -121,7 +121,9 @@ def _parse_header(self): offset = 0.0 stream_id = "0" buffer_id = "0" - sig_channels.append((name, chan_id, self._sampling_rate, sig_dtype, units, gain, offset, stream_id, buffer_id)) + sig_channels.append( + (name, chan_id, self._sampling_rate, sig_dtype, units, gain, offset, stream_id, buffer_id) + ) sig_channels = np.array(sig_channels, dtype=_signal_channel_dtype) # No events diff --git a/neo/rawio/openephysrawio.py b/neo/rawio/openephysrawio.py index 802aa2875..4c3e84496 100644 --- a/neo/rawio/openephysrawio.py +++ b/neo/rawio/openephysrawio.py @@ -230,7 +230,7 @@ def _parse_header(self): signal_streams = [] signal_streams = np.array(signal_streams, dtype=_signal_stream_dtype) # no buffer handling in this format because one channel per file - signal_buffers = np.array( [], dtype=_signal_buffer_dtype) + signal_buffers = np.array([], dtype=_signal_buffer_dtype) # scan for spikes files spike_channels = [] diff --git a/neo/rawio/plexonrawio.py b/neo/rawio/plexonrawio.py index a354bed74..62b0a1a88 100644 --- a/neo/rawio/plexonrawio.py +++ b/neo/rawio/plexonrawio.py @@ -272,11 +272,12 @@ def _parse_header(self): ) offset = 0.0 - channel_prefix = re.match(regex_prefix_pattern, name).group(0) stream_id = channel_prefix buffer_id = "" - signal_channels.append((name, str(chan_id), sampling_rate, sig_dtype, units, gain, offset, stream_id, buffer_id)) + signal_channels.append( + (name, str(chan_id), sampling_rate, sig_dtype, units, gain, offset, stream_id, buffer_id) + ) signal_channels = np.array(signal_channels, dtype=_signal_channel_dtype) diff --git a/neo/rawio/rawbinarysignalrawio.py b/neo/rawio/rawbinarysignalrawio.py index ad9fa9c2f..1797772e9 100644 --- a/neo/rawio/rawbinarysignalrawio.py +++ b/neo/rawio/rawbinarysignalrawio.py @@ -105,7 +105,7 @@ def _parse_header(self): self.signal_gain, self.signal_offset, stream_id, - buffer_id + buffer_id, ) ) diff --git a/neo/rawio/spike2rawio.py b/neo/rawio/spike2rawio.py index 545a109d9..3ee694dae 100644 --- a/neo/rawio/spike2rawio.py +++ b/neo/rawio/spike2rawio.py @@ -256,7 +256,9 @@ def _parse_header(self): sig_dtype = "float32" stream_id = "0" # set it after the loop buffer_id = "" - signal_channels.append((name, str(chan_id), sampling_rate, sig_dtype, units, gain, offset, stream_id, buffer_id)) + signal_channels.append( + (name, str(chan_id), sampling_rate, sig_dtype, units, gain, offset, stream_id, buffer_id) + ) elif chan_info["kind"] in [2, 3, 4, 5, 8]: # Event diff --git a/neo/rawio/spikegadgetsrawio.py b/neo/rawio/spikegadgetsrawio.py index a0e6bd3b7..3204f2725 100644 --- a/neo/rawio/spikegadgetsrawio.py +++ b/neo/rawio/spikegadgetsrawio.py @@ -271,7 +271,6 @@ def _parse_header(self): self._mask_channels_bytes[stream_id] = mask self._mask_streams[stream_id] = np.any(mask, axis=0) - signal_streams = np.array(signal_streams, dtype=_signal_stream_dtype) signal_channels = np.array(signal_channels, dtype=_signal_channel_dtype) # no buffer concept here data are too fragmented diff --git a/neo/rawio/tdtrawio.py b/neo/rawio/tdtrawio.py index 9629a6026..d69feddf9 100644 --- a/neo/rawio/tdtrawio.py +++ b/neo/rawio/tdtrawio.py @@ -311,7 +311,9 @@ def _parse_header(self): gain = 1.0 offset = 0.0 buffer_id = "" - signal_channels.append((chan_name, str(chan_id), sampling_rate, dtype, units, gain, offset, stream_id, buffer_id)) + signal_channels.append( + (chan_name, str(chan_id), sampling_rate, dtype, units, gain, offset, stream_id, buffer_id) + ) if missing_sev_channels: warnings.warn(f"Could not identify sev files for channels {missing_sev_channels}.") diff --git a/neo/rawio/winedrrawio.py b/neo/rawio/winedrrawio.py index 00b0d31c2..58f78bb7c 100644 --- a/neo/rawio/winedrrawio.py +++ b/neo/rawio/winedrrawio.py @@ -94,7 +94,9 @@ def _parse_header(self): offset = -YZ * gain stream_id = "0" buffer_id = "0" - signal_channels.append((name, str(chan_id), self._sampling_rate, "int16", units, gain, offset, stream_id, buffer_id)) + signal_channels.append( + (name, str(chan_id), self._sampling_rate, "int16", units, gain, offset, stream_id, buffer_id) + ) signal_channels = np.array(signal_channels, dtype=_signal_channel_dtype) @@ -104,7 +106,7 @@ def _parse_header(self): for i in range(unique_characteristics.size): mask = unique_characteristics[i] == characteristics signal_channels["stream_id"][mask] = str(i) - # unique buffer for all streams + # unique buffer for all streams buffer_id = "0" signal_streams.append((f"stream {i}", str(i), buffer_id)) signal_streams = np.array(signal_streams, dtype=_signal_stream_dtype) diff --git a/neo/rawio/winwcprawio.py b/neo/rawio/winwcprawio.py index 83e5a25d3..a760c8bf0 100644 --- a/neo/rawio/winwcprawio.py +++ b/neo/rawio/winwcprawio.py @@ -119,7 +119,9 @@ def _parse_header(self): offset = 0.0 stream_id = "0" buffer_id = "0" - signal_channels.append((name, chan_id, self._sampling_rate, "int16", units, gain, offset, stream_id, buffer_id)) + signal_channels.append( + (name, chan_id, self._sampling_rate, "int16", units, gain, offset, stream_id, buffer_id) + ) signal_channels = np.array(signal_channels, dtype=_signal_channel_dtype) @@ -129,7 +131,7 @@ def _parse_header(self): for i in range(unique_characteristics.size): mask = unique_characteristics[i] == characteristics signal_channels["stream_id"][mask] = str(i) - # unique buffer for all streams + # unique buffer for all streams buffer_id = "0" signal_streams.append((f"stream {i}", str(i), buffer_id)) signal_streams = np.array(signal_streams, dtype=_signal_stream_dtype) diff --git a/neo/test/rawiotest/rawio_compliance.py b/neo/test/rawiotest/rawio_compliance.py index 57a917bad..a4d7131f8 100644 --- a/neo/test/rawiotest/rawio_compliance.py +++ b/neo/test/rawiotest/rawio_compliance.py @@ -78,6 +78,7 @@ def header_is_total(reader): for k, _ in _event_channel_dtype: assert k in dt.fields, f"{k} not in event_channels.dtype" + def check_signal_stream_buffer_hierachy(reader): # rules: # * a channel always belong to a stream @@ -95,7 +96,7 @@ def check_signal_stream_buffer_hierachy(reader): assert channel["stream_id"] in h["signal_streams"]["id"] if channel["buffer_id"] != "": assert channel["buffer_id"] in h["signal_buffers"]["id"] - + stream_ids = h["signal_streams"]["id"] if stream_ids.size > 0: assert stream_ids.size == np.unique(stream_ids).size diff --git a/neo/test/rawiotest/test_neuronexusrawio.py b/neo/test/rawiotest/test_neuronexusrawio.py index 317d72cc5..0bb571a87 100644 --- a/neo/test/rawiotest/test_neuronexusrawio.py +++ b/neo/test/rawiotest/test_neuronexusrawio.py @@ -15,4 +15,4 @@ class TestNeuroNexusRawIO( if __name__ == "__main__": - unittest.main() \ No newline at end of file + unittest.main() From 024d199e9a79336cecb916df6ebda446a89b882e Mon Sep 17 00:00:00 2001 From: zm711 <92116279+zm711@users.noreply.github.com> Date: Wed, 16 Oct 2024 07:48:53 -0400 Subject: [PATCH 2/2] limit dhn_med_py --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 40ff91a28..75374cf0f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,7 +45,7 @@ iocache = [ ] test = [ - "dhn_med_py>=1.0.0", + "dhn_med_py<2.0", # ci failing with 2.0 test future version when stable "pytest", "pytest-cov", # datalad # this dependency is covered by conda (environment_testing.yml) @@ -100,13 +100,13 @@ ced = ["sonpy"] nwb = ["pynwb"] maxwell = ["h5py"] biocam = ["h5py"] -med = ["dhn_med_py>=1.0.0"] +med = ["dhn_med_py<2.0"] # ci failing with 2.0 test future version when stable plexon2 = ["zugbruecke>=0.2; sys_platform!='win32'", "wenv; sys_platform!='win32'"] all = [ "coverage", "coveralls", - "dhn_med_py>=1.0.0", + "dhn_med_py<2.0", # ci failing with 2.0 test future version when stable "h5py", "igor2", "ipython",