mne-tools / mne-tools/mne-python
potential maxfilter badchannel interpolation suboptimality
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.5k
- Forks
- 1.6k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 100
Description
Hi all,
First of all, I am an absolute noob w.r.t. python in general, and by consequence also w.r.t MNE-python, but I would like to take the opportunity to discuss something I came across while playing around with MNE-python's maxfilter functionality. In short, the context is a project in which my aim is to model simulated MEG time series on a synthetic sensor array (consisting of magnetometers, probably not relevant for the issue at hand), using a leave-one-out approach. In other words, given a simulated dataset, I want to model each channel's time series using all other channels. One way to do this, would be through the maxfilter, where iteratively each single channel is defined as 'bad'. Since I am a bit a sucker for the methods details, I wrote a matlab implementation of the maxfilter with basic functionality (no regularization etc.), which results in output that is numerically very similar to the MNE-python implementation. That is, only if I don't define a bad channel. Once I define one channel as bad, the outputs start deviating. I traced the cause of the difference down to the tSSS step, where the temporal projector is computed. In MNE-python, this is done using the reconstructed 'in' data and the residual data of the good chans only, my initial matlab implementation used all reconstructed channels (but note that the spatial projector was constructed while omitting the bad channel, i.e. the projection onto the multipolar expansion was done using n-1 channels).
When comparing the std of the cleaned data (note that I simulated data without a signal source within the 'in' compartment) for the all-channel versus the leave-one-out channel approach, the matlab implementation of the leave-one-out at first sight seems to behave much better (middle panel in attached screenshot). If I change the tSSS step to operate on the goodchans only, I get results (right panel) which are very similar to MNE-python (left panel), where overall the std of the cleaned data is larger when one of the channels was defined as bad.
Now my question is: should we be worried by this? If so, I'd be happy to continue discussing this. If not, it's fine with me to leave it at this :).

===================================================================================
System info:
Platform: Linux-4.19.94-300.el7.x86_64-x86_64-with-glibc2.10
Python: 3.8.8 (default, Apr 13 2021, 19:58:26) [GCC 7.3.0]
Executable: /project/3015999.02/jansch_sandbox/code/mne/venv/bin/python
CPU: x86_64: 20 cores
Memory: 251.9 GB
mne: 1.3.1
numpy: 1.23.5 {OpenBLAS 0.3.20 with 1 thread}
scipy: 1.10.1
matplotlib: 3.7.1QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/scratch/jansch/48809561.dccn-l029.dccn.nl/runtime-jansch'
Backend QtAgg is interactive backend. Turning interactive mode on.
{backend=QtAgg}
sklearn: 1.2.2
numba: 0.56.4
nibabel: 5.0.1
nilearn: 0.10.0
dipy: 1.6.0
openmeeg: Not found
cupy: Not found
pandas: 1.5.3
pyvista: 0.38.4 {OpenGL could not be initialized}
pyvistaqt: 0.9.1
ipyvtklink: 0.2.3
vtk: 9.2.6
qtpy: 2.3.0 {PyQt5=5.14.0}
ipympl: 0.9.3
pyqtgraph: /opt/pycharm/pro/2022.3.1/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py:21: RuntimeWarning: PyQtGraph supports Qt version >= 5.15, but 5.14.0 detected.
module = self._system_import(name, *args, **kwargs)
0.13.2
pooch: v1.7.0
mne_bids: Not found
mne_nirs: Not found
mne_features: Not found
mne_qt_browser: 0.4.0
mne_connectivity: Not found
mne_icalabel: Not found
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the maxfilter functionality and its tSSS temporal-projector computation described in the issue, then reproduce the comparison with and without a bad channel using the provided system context and screenshot. Determine whether the differing leave-one-out behavior is expected; done means reaching a maintainer-supported conclusion and, if needed, identifying the appropriate code or test change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100