mne_nirs.preprocessing.motion_correct_spline#
- mne_nirs.preprocessing.motion_correct_spline(raw, mask=None, smoothing=0.99, *, verbose=None)[source]#
Apply spline interpolation motion correction to fNIRS data.
Each motion segment is detrended with a cubic smoothing spline and the segments are then shifted so that the signal is continuous across their boundaries [1]. This is a port of Homer3’s
hmrR_MotionCorrectSpline[2] and reproduces its output to numerical precision.- Parameters:
- rawinstance of
Raw The raw fNIRS data (optical density or hemoglobin).
- mask
ndarrayof bool, shape (n_channels, n_times) |None Per-channel motion mask for the fNIRS channels, where
Truemeans a clean sample, as returned bydetect_motion_artifacts(). IfNone,detect_motion_artifacts()is called with its default parameters.- smoothing
float Smoothing parameter of the spline between 0 and 1 (
pin Homer3 and MATLAB’scsaps), where 1 interpolates the data (no correction) and 0 fits a straight line.- verbosebool |
str|int|None Control verbosity of the logging output. If
None, use the default verbosity level. See the logging documentation andmne.verbose()for details. Should only be passed as a keyword argument.
- rawinstance of
- Returns:
- rawinstance of
Raw The corrected data (a copy).
- rawinstance of
Notes
Motion segments shorter than five samples are not detrended.
Homer3 differs from Scholkmann et al.[1] in the number of samples over which the segment means used for the shifts are taken (0.3 s and 3 s rather than 1/3 s and 2 s as the limits between the cases). The paper also describes
pwith the reverse of thecsapsconvention used here, so its recommended value of 0.01 corresponds to the default of 0.99.References