diff --git a/neo/rawio/neuroscoperawio.py b/neo/rawio/neuroscoperawio.py index 0a303335b..fe3a3ec24 100644 --- a/neo/rawio/neuroscoperawio.py +++ b/neo/rawio/neuroscoperawio.py @@ -85,6 +85,11 @@ def _parse_header(self): nbits = int(acq.find("nBits").text) nb_channel = int(acq.find("nChannels").text) self._sampling_rate = float(acq.find("samplingRate").text) + # .lfp and .eeg files are downsampled and their rate is stored separately + if self.data_file_path.suffix in (".lfp", ".eeg"): + lfp_sampling_rate = root.find("fieldPotentials/lfpSamplingRate") + if lfp_sampling_rate is not None: + self._sampling_rate = float(lfp_sampling_rate.text) voltage_range = float(acq.find("voltageRange").text) # offset = int(acq.find('offset').text) amplification = float(acq.find("amplification").text) diff --git a/neo/test/rawiotest/test_neuroscoperawio.py b/neo/test/rawiotest/test_neuroscoperawio.py index 8b65049b9..e5f780028 100644 --- a/neo/test/rawiotest/test_neuroscoperawio.py +++ b/neo/test/rawiotest/test_neuroscoperawio.py @@ -29,6 +29,16 @@ def test_signal_scale(self): # scale is in mV = range of recording in volts * 1000 mV/V /(number of bits * ampification) self.assertAlmostEqual(20.0 * 1000 / (2**16 * 1000), gain) + def test_lfp_sampling_rate(self): + local_test_dir = get_local_testing_data_folder() + # the xml has samplingRate 20000 for the .dat and lfpSamplingRate 1250 for .eeg/.lfp + for suffix in (".eeg", ".lfp"): + fname = local_test_dir / f"neuroscope/dataset_1/YutaMouse42-151117{suffix}" + reader = NeuroScopeRawIO(filename=fname) + reader.parse_header() + assert reader.header["signal_channels"]["sampling_rate"][0] == 1250.0 + assert reader.segment_t_stop(0, 0) == 10 / 1250.0 + def test_binary_argument_with_non_canonical_xml_file(self): local_test_dir = get_local_testing_data_folder()