BUG: SourceMorph spacing-attribute inconsistent

Open
#12,101 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
data

Research direction

Start at the compute_source_morph entry point and reproduce the two calls from the issue with oct6 and ico5 source spaces. Trace how src_to and spacing determine SourceMorph.spacing, then add or update coverage so the result matches the target source-space spacing in both directions.

Written by the indexing model from the issue text.

Description

BUG
Description of the problem

When src_to is supplied to compute_source_morph and is has a spacing other then "ico5", the spacing-attribute of the resulting SourceMorph doesn't seem to be consistent (see example below)

Steps to reproduce
import mne
from mne.datasets import sample

data_path = sample.data_path()
subjects_dir = data_path / "subjects"

# oct6 spacing
src_from = mne.read_source_spaces(subjects_dir / "sample" / "bem" / "sample-oct-6-src.fif")
subject_from = "sample"
# ico5 spacing
src_to = mne.read_source_spaces(subjects_dir / "fsaverage" / "bem" / "fsaverage-ico-5-src.fif")
subject_to = "fsaverage"
morph = mne.compute_source_morph(
    src_from,
    subject_from=subject_from,
    subject_to=subject_to,
    src_to=src_to,
    subjects_dir=subjects_dir,
)
assert morph.spacing == 5

# When you switch src_from and src_to, the spacing should be 6 since the target source-space has a spacing of oct6.
# But it is still 5.
morph = mne.compute_source_morph(
    src_to,
    subject_from=subject_to,
    subject_to=subject_from,
    src_to=src_from,
    subjects_dir=subjects_dir,
)
# This fails
assert morph.spacing == 6
Link to data

No response

Expected results

SourceMorph.spacing being consistent with spacing of src_to

Actual results

It's always 5 (or the value currently supplied to spacing, which should be ignored when src_to is supplied)

Additional information

Platform Windows-10-10.0.22621-SP0
Python 3.11.6 | packaged by conda-forge | (main, Oct 3 2023, 10:29:11) [MSC v.1935 64 bit (AMD64)]

Core
├☑ mne 1.6.0.dev24+g22ffe6f7a
├☑ numpy 1.24.4 (OpenBLAS 0.3.24 with 32 threads)
├☑ scipy 1.11.3
├☑ matplotlib 3.8.0 (backend=QtAgg)
├☑ pooch 1.7.0
└☑ jinja2 3.1.2

Numerical (optional)
├☑ sklearn 1.3.1
├☑ numba 0.57.1
├☑ nibabel 5.1.0
├☑ nilearn 0.10.2
├☑ dipy 1.7.0
├☑ openmeeg 2.5.6
├☑ pandas 2.1.1
└☐ unavailable cupy

Visualization (optional)
├☑ pyvista 0.42.3 (OpenGL 4.6.0 Compatibility Profile Context 23.9.3.230915 via AMD Radeon(TM) Graphics)
├☑ pyvistaqt 0.0.0
├☑ vtk 9.2.6
├☑ qtpy 2.4.0 (PyQt5=5.15.8)
├☑ ipympl 0.9.3
├☑ pyqtgraph 0.13.3
├☑ mne-qt-browser 0.6.0.dev13+g481264d
└☐ unavailable ipyvtklink

Ecosystem (optional)
├☑ mne-bids 0.14.dev0
├☑ mne-connectivity 0.6.0dev0
└☐ unavailable mne-nirs, mne-features, mne-icalabel, mne-bids-pipeline

Dominant language
Python
Stars
3.5k
Forks
1.6k
Avg merge
1d 6h
Merged PRs (30d)
100

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mne-tools/mne-python

All issues in mne-tools/mne-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.