Skip to content

mne make_scalp_surfaces does not recompute mkheadsurf #13014

@vferat

Description

@vferat

Description of the problem

When running mne make_scalp_surfaces with a new MRI specified using the -m argument, the command does not rerun mkheadsurf if it has already been run previously. Consequently, the changes to the MRI are not accounted for.

This behavior appears to be related to the check_seghead function (source code link). This function returns the previously computed lh.seghead or lh.smseghead file, which prevents mne make_scalp_surfaces from rerunning mkheadsurf.

The issue might also affect the threshold parameter.

Workaround:

The current workaround is to manually delete the lh.segheador lh.smseghead file.

Suggested Fix:

Force rerunning mkheadsurf when the overwrite parameter is set to True.

Steps to reproduce

Run
`mne make_scalp_surfaces --subject sample`

then run the same command specifying another MRI (or threshold):

`mne make_scalp_surfaces --subject sample -m orig.mgz`

Link to data

Context

I'm trying to compute scalp surfaces from a MP2RAGE scan. Because of the presence of noise outside the head, I need to provide another (manually preprocessed) MRI as an input to mne make_scalp_surfaces otherwise the head surface can't be used for coregistration.

Expected results

Recompute results using the new MRI/threshold

Actual results

Use previously computed results.

Additional information

Platform Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-with-glibc2.35
Python 3.11.9 | packaged by conda-forge | (main, Apr 19 2024, 18:36:13) [GCC 12.3.0]
Executable /opt/conda/envs/smriprep/bin/python3.11
CPU x86_64 (32 cores)
Memory 62.6 GB

Core
├☑ mne 1.8.0 (latest release)
├☑ numpy 1.26.4 (OpenBLAS 0.3.28 with 1 thread)
├☑ scipy 1.13.1
└☑ matplotlib 3.9.1 (backend=Agg)

Numerical (optional)
├☑ sklearn 1.4.2
├☑ nibabel 5.2.1
├☑ nilearn 0.10.4
├☑ pandas 2.2.2
├☑ h5io 0.2.4
├☑ h5py 3.11.0
└☐ unavailable numba, dipy, openmeeg, cupy

Visualization (optional)
├☑ pyvista 0.44.2 (OpenGL unavailable)
├☑ pyvistaqt 0.11.1
├☑ vtk 9.3.1
├☑ qtpy 2.4.2 (None=None)
└☐ unavailable ipympl, pyqtgraph, mne-qt-browser, ipywidgets, trame_client, trame_server, trame_vtk, trame_vuetify

Ecosystem (optional)
├☑ mne-bids 0.16.0
└☐ unavailable mne-nirs, mne-features, mne-connectivity, mne-icalabel, mne-bids-pipeline, neo, eeglabio, edfio, mffpy, pybv

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions