We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The example aux dataset used in the aux tutorial has /nirs/aux/dataTimeSeries in 1D format.
This means that read_snirf_aux_data() runs fine on this example dataset.
However, the snirf spec states that /nirs/aux/dataTimeSeries should be a 2D array.
Trying to read a /nirs/aux/dataTimeSeries 2D array with read_snirf_aux_data() fails on line 56 due to d containing 2D arrays
mne-nirs/mne_nirs/io/snirf/_aux.py
Lines 47 to 57 in 2fdddfe
Can't use the offical snirf samples for demonstration, because /nirs/aux/time in those files are 2D arrays, so this leads to another fail.
Use this file with the code below to reproduce .
import numpy as np import logging import h5py from scipy import interpolate from pandas import DataFrame from mne.io import Raw fname = r"04_25090.snirf" dat = h5py.File(fname, 'r') if 'nirs' in dat: basename = "nirs" elif 'nirs1' in dat: basename = "nirs1" else: raise RuntimeError("Data does not contain nirs field") all_keys = list(dat.get(basename).keys()) aux_keys = [i for i in all_keys if i.startswith('aux')] print(aux_keys) aux_names = [_decode_name(dat.get(f'{basename}/{k}/name')) for k in aux_keys] logging.debug(f"Found auxiliary channels {aux_names}") d = {'times': raw.times} for idx, aux in enumerate(aux_keys): print("idx:",idx) print("aux:",aux) aux_data = np.array(dat.get(f'{basename}/{aux}/dataTimeSeries')) aux_time = np.array(dat.get(f'{basename}/{aux}/time')) aux_data_interp = interpolate.interp1d(aux_time, aux_data, axis=0, bounds_error=False, fill_value='extrapolate') aux_data_matched_to_raw = aux_data_interp(raw.times) d[aux_names[idx]] = aux_data_matched_to_raw df = DataFrame(data=d) df = df.set_index('times')
Since /nirs/aux/dataTimeSeries should be 2D array it should work fine to read data stored in this way
Fail due to code expecting a 1D array
As a quick fix for my data I used .flatten() on the aux_data (line 48), but that's not really a fix in case the data is actually 2D.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
The example aux dataset used in the aux tutorial has /nirs/aux/dataTimeSeries in 1D format.
This means that read_snirf_aux_data() runs fine on this example dataset.
However, the snirf spec states that /nirs/aux/dataTimeSeries should be a 2D array.
Trying to read a /nirs/aux/dataTimeSeries 2D array with read_snirf_aux_data() fails on line 56 due to d containing 2D arrays
mne-nirs/mne_nirs/io/snirf/_aux.py
Lines 47 to 57 in 2fdddfe
Steps to reproduce
Can't use the offical snirf samples for demonstration, because /nirs/aux/time in those files are 2D arrays, so this leads to another fail.
Use this file with the code below to reproduce .
Expected results
Since /nirs/aux/dataTimeSeries should be 2D array it should work fine to read data stored in this way
Actual results
Fail due to code expecting a 1D array
Additional information
As a quick fix for my data I used .flatten() on the aux_data (line 48), but that's not really a fix in case the data is actually 2D.
The text was updated successfully, but these errors were encountered: