Skip to content

ENH: add spline interpolation motion correction for fNIRS (motion_correct_spline)#13693

Draft
leonardozaggia wants to merge 8 commits intomne-tools:mainfrom
leonardozaggia:nirs-motion-spline
Draft

ENH: add spline interpolation motion correction for fNIRS (motion_correct_spline)#13693
leonardozaggia wants to merge 8 commits intomne-tools:mainfrom
leonardozaggia:nirs-motion-spline

Conversation

@leonardozaggia
Copy link

@leonardozaggia leonardozaggia commented Feb 25, 2026

Reference issue (if any)

Nonne (new feature)

What does this implement/fix?

Adds motion_correct_spline (alias spline) to mne.preprocessing.nirs for spline interpolation-based motion correction of fNIRS data.

For each detected motion-artifact segment the signal is detrended with a smoothing spline, then consecutive segments are baseline-shifted so they connect smoothly. Accepts a per-channel artifact mask tIncCh; when None, only spline detrending is applied with no baseline shifting.

Based on Homer3 v1.80.2 hmrR_tInc_baselineshift_Ch_Nirs (Huppert et al. 2009).

Additional information

@leonardozaggia leonardozaggia changed the title WIP: ENH: add spline interpolation motion correction for fNIRS (motion_cor… ENH: add spline interpolation motion correction for fNIRS (motion_correct_spline) Feb 25, 2026
@larsoner
Copy link
Member

@leonardozaggia I wonder if these should live in https://github.com/mne-tools/mne-nirs/tree/main/mne_nirs/preprocessing instead... we can iterate and release faster over in mne-nirs than we can here, and at some point I think decided we should try to put newer functionality there when possible. WDYT?

@leonardozaggia
Copy link
Author

@arsoner thanks for your feedback.
I considered this point when first working on this PR. At the end I opted for mne-python because the only other motion regression technique available - TDDR - lives here and thought it best for users to have the motion correction techniques in the same place.

@leonardozaggia
Copy link
Author

But of course, I am open to cancel my PR and submit a new one to the dedicated mne-nirs repo if you think it's best :)

@larsoner
Copy link
Member

larsoner commented Mar 2, 2026

@scott-huberty @drammock any thoughts on where this should live? I'm inclined to add any new fNIRS algorithms to mne-nirs...

@drammock
Copy link
Member

drammock commented Mar 2, 2026

@scott-huberty @drammock any thoughts on where this should live? I'm inclined to add any new fNIRS algorithms to mne-nirs...

yeah, I think so too, unless the method is also valuable for other modalities

@scott-huberty
Copy link
Contributor

I'm inclined to add any new fNIRS algorithms to mne-nirs...

I agree that it makes most sense for newly added fNIRS specific utilities to live in mne-nirs!

@leonardozaggia
Copy link
Author

Great then, I will move the work to mne-nirs. I suppose these methods could also be implemented for different modalities with sufficient parameter tuning. But I think the most beneficial contribution would be to add them for the mne-based fnirs community to use out of the box.

Just a quick question, do you think it would make sense to port the already existing nirs specific modules here in mne-nirs?

@scott-huberty
Copy link
Contributor

Just a quick question, do you think it would make sense to port the already existing nirs specific modules here in mne-nirs?

Yeah I think that it would be a super nice idea to have all the functionality in one place!

I'll let @larsoner provide a more definitive answer, but I guess we could follow the mne.connectivity -> mne-connectivity example (xref #9493 ) and do a 2 minor version deprecation cycle for the mne.preprocessing.nirs sub package?

Or we can keep mne.preprocessing.nirs and just create wrappers in mne-nirs for the functions we want to port? That way users who want to do everything in one place can, but we don't break people's old scripts that use the mne.preprocessing.nirs namespace.

@drammock
Copy link
Member

drammock commented Mar 3, 2026

do you think it would make sense to port the already existing nirs specific modules here in mne-nirs?

yes but not yet. We have plans in the works for creating a proper plug-in architecture for MNE. When MNE-NIRS becomes a plugin would be the right time to migrate the functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants