-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
Description
Describe the bug
When importing SNIRF data, the timeUnit field is ignored and seconds are silently assumed when computing the sampling frequency of the input data. This is contrary to the specification.
The consequence is that the computed sample rate may be incorrect.
Cause
Rather than demonstrate reproduction, one can observe the cause of this behaviour in the codebase, which makes no reference to timeUnit and computes the sampling rate assuming seconds. From master:
samplingrate_raw = np.array(dat.get('nirs/data1/time'))
sampling_rate = 0
if samplingrate_raw.shape == (2, 1):
# specified as onset/samplerate
warn("Onset/sample rate SNIRF not yet supported.")
else:
# specified as time points
fs_diff = np.around(np.diff(samplingrate_raw), decimals=4)
if len(np.unique(fs_diff)) == 1:
# Uniformly sampled data
sampling_rate = 1. / np.unique(fs_diff)
else:
# print(np.unique(fs_diff))
warn("Non uniform sampled data not supported.")
if sampling_rate == 0:
warn("Unable to extract sample rate from SNIRF file.")Expected results
Either:
- Throw an error if a
timeUnitis both present and not equal to 's', or, - Correctly manipulate time vector according to unit specified.
Actual results
The timeUnit is silently ignored and the resulting sampling frequency is incorrect.
Additional information
Error present on master.