diff --git a/neo/rawio/intanrawio.py b/neo/rawio/intanrawio.py index a7b0e56bc..d1e987964 100644 --- a/neo/rawio/intanrawio.py +++ b/neo/rawio/intanrawio.py @@ -173,7 +173,7 @@ def _parse_header(self): self._block_size, channel_number_dict, ) = read_rhd(self.filename, self.file_format) - + ############################################# # memmap the raw data for each format type ############################################# @@ -207,7 +207,6 @@ def _parse_header(self): channel_file_paths = raw_file_paths_dict[stream_name] channel_memmap_list = [np.memmap(fp, dtype=stream_dtype, mode="r") for fp in channel_file_paths] self._raw_data[stream_name] = channel_memmap_list - # Data Integrity checks # strictness of check is controlled by ignore_integrity_checks @@ -747,12 +746,12 @@ def read_rhs(filename, file_format: str): # Build a dictionary with channel count special_cases_for_counting = [ - "DC Amplifier channel", - "Stim channel", + "DC Amplifier channel", + "Stim channel", ] names_to_count = [name for name in stream_names if name not in special_cases_for_counting] channel_number_dict = {name: len(stream_name_to_channel_info_list[name]) for name in names_to_count} - + # Both DC Amplifier and Stim streams have the same number of channels as the amplifier stream channel_number_dict["DC Amplifier channel"] = channel_number_dict["RHS2000 amplifier channel"] channel_number_dict["Stim channel"] = channel_number_dict["RHS2000 amplifier channel"] @@ -1204,6 +1203,7 @@ def create_one_file_per_signal_dict_rhd(dirname): return raw_file_paths_dict + stream_name_to_file_name_rhs = { "RHS2000 amplifier channel": "amplifier.dat", "RHS2000 auxiliary input channel": "auxiliary.dat", @@ -1214,6 +1214,7 @@ def create_one_file_per_signal_dict_rhd(dirname): "USB board digital output channel": "digitalout.dat", } + def create_one_file_per_signal_dict_rhs(dirname): """Function for One File Per Signal Type @@ -1275,10 +1276,10 @@ def create_one_file_per_channel_dict_rhd(dirname): for stream_name, file_prefix in stream_name_to_file_prefix_rhd.items(): stream_files = [file for file in files if file_prefix in file.name] # Map file name to channel name amp-A-000.dat -> A-000 amp-B-006.dat -> B-006 etc - file_path_to_channel_name = lambda x: '-'.join(x.stem.split('-')[1:]) + file_path_to_channel_name = lambda x: "-".join(x.stem.split("-")[1:]) sorted_stream_files = sorted(stream_files, key=file_path_to_channel_name) raw_file_paths_dict[stream_name] = sorted_stream_files - + raw_file_paths_dict["timestamp"] = [Path(dirname / "time.dat")] return raw_file_paths_dict @@ -1294,6 +1295,7 @@ def create_one_file_per_channel_dict_rhd(dirname): "USB board digital output channel": "board-DIGITAL-OUT", } + def create_one_file_per_channel_dict_rhs( dirname, ): @@ -1316,7 +1318,7 @@ def create_one_file_per_channel_dict_rhs( for stream_name, file_prefix in stream_name_to_file_prefix_rhs.items(): stream_files = [file for file in files if file_prefix in file.name] # Map file name to channel name amp-A-000.dat -> A-000 amp-B-006.dat -> B-006 etc - file_path_to_channel_name = lambda x: '-'.join(x.stem.split('-')[1:]) + file_path_to_channel_name = lambda x: "-".join(x.stem.split("-")[1:]) sorted_stream_files = sorted(stream_files, key=file_path_to_channel_name) raw_file_paths_dict[stream_name] = sorted_stream_files diff --git a/neo/test/rawiotest/test_intanrawio.py b/neo/test/rawiotest/test_intanrawio.py index 83b5f7678..3d86e5089 100644 --- a/neo/test/rawiotest/test_intanrawio.py +++ b/neo/test/rawiotest/test_intanrawio.py @@ -67,7 +67,6 @@ def test_annotations(self): ) np.testing.assert_array_equal(signal_array_annotations["board_stream_num"][:10], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) - def test_correct_reading_one_file_per_channel(self): "Issue: https://github.com/NeuralEnsemble/python-neo/issues/1599" # Test reading of one-file-per-channel format file. The channels should match the raw files @@ -77,7 +76,7 @@ def test_correct_reading_one_file_per_channel(self): # This should be the folder where the files of all the channels are stored folder_path = file_path.parent - + # The paths are named as amp-A-000.dat, amp-A-001.dat, amp-A-002.dat, ... amplifier_file_paths = [path for path in folder_path.iterdir() if "amp" in path.name] channel_names = [path.name[4:-4] for path in amplifier_file_paths] @@ -87,5 +86,6 @@ def test_correct_reading_one_file_per_channel(self): data_from_neo = intan_reader.get_analogsignal_chunk(channel_ids=[channel_name], stream_index=0).squeeze() np.testing.assert_allclose(data_raw, data_from_neo) + if __name__ == "__main__": unittest.main()