From 9f4234d044392376a845c3c3699ce24c81ec9528 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Mon, 28 Oct 2024 14:04:29 -0400 Subject: [PATCH] WIP --- mne/io/snirf/_snirf.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/mne/io/snirf/_snirf.py b/mne/io/snirf/_snirf.py index 566d610f803..dba28c9a3b4 100644 --- a/mne/io/snirf/_snirf.py +++ b/mne/io/snirf/_snirf.py @@ -340,16 +340,18 @@ def natural_keys(text): ch_types.append(ch_type) del ch_root, ch_name, ch_type - data_scale = None + # Create mne structure + info = create_info(chnames, sampling_rate, ch_types=ch_types) + if need_data_scale: snirf_data_unit = np.array( dat.get("nirs/data1/measurementList1/dataUnit", b"M") ) snirf_data_unit = snirf_data_unit.item().decode("utf-8") - data_scale = _get_dataunit_scaling(snirf_data_unit) - - # Create mne structure - info = create_info(chnames, sampling_rate, ch_types=ch_types) + scale = _get_dataunit_scaling(snirf_data_unit) + if scale is not None: + for ch in info["chs"]: + ch["cal"] = 1.0 / scale subject_info = {} names = np.array(dat.get("nirs/metaDataTags/SubjectID")) @@ -562,13 +564,11 @@ def natural_keys(text): with info._unlock(): info["subject_info"]["birthday"] = birthday - raw_extras = dict(data_scale=data_scale) super().__init__( info, preload, filenames=[fname], last_samps=[last_samps], - raw_extras=[raw_extras], verbose=verbose, ) @@ -596,10 +596,6 @@ def _read_segment_file(self, data, idx, fi, start, stop, cals, mult): _mult_cal_one(data, one, idx, cals, mult) - data_scale = self._raw_extras[fi]["data_scale"] - if data_scale is not None: - one *= data_scale - # Helper function for when the numpy array has shape (), i.e. just one element. def _correct_shape(arr):