Skip to content

mode parameter in get_cross_talk and get_point_spread does not work as intended #13128

Open

Description

@giulianogiari

Description of the problem

Hello, i think i found i bug in the the functions get_cross_talk and get_point_spread.
the mode parameter accepts, according to the documentation, one of these options: [None] | ‘mean’ | ‘max’ | ‘svd’.
if mode is not None, the function _summarise_psf_ctf is called to compute a summary of the vertices. this function instead seem to accept different values for mode, namely "maxval", "maxnorm", "sum", "mean", "pca".
if one uses the function get_cross_talk (or get_point_spread) with e.g., mode="svd" then, no summary across vertices is computed, resulting in an stc object of shape n_source_vertices x n_idx (if vertices are passed) or n_source_vertices x n_label_vertices (if passing a label as idx). no warning or error is raised in case of a wrong mode parameter.
let me know what you think. i would be happy to fix this in case is needed.

Steps to reproduce

import mne
import numpy as np
from mne.datasets import sample
from mne.minimum_norm import (
    get_point_spread,
    make_inverse_resolution_matrix,
)

print(__doc__)

data_path = sample.data_path()
subjects_dir = data_path / "subjects"
meg_path = data_path / "MEG" / "sample"
fname_fwd = meg_path / "sample_audvis-meg-eeg-oct-6-fwd.fif"
fname_cov = meg_path / "sample_audvis-cov.fif"
fname_evo = meg_path / "sample_audvis-ave.fif"

# read forward solution
forward = mne.read_forward_solution(fname_fwd)
# forward operator with fixed source orientations
mne.convert_forward_solution(forward, surf_ori=True, force_fixed=True, copy=False)

# noise covariance matrix
noise_cov = mne.read_cov(fname_cov)

# evoked data for info
evoked = mne.read_evokeds(fname_evo, 0)

# make inverse operator from forward solution
# free source orientation
inverse_operator = mne.minimum_norm.make_inverse_operator(
    info=evoked.info, forward=forward, noise_cov=noise_cov, loose=0.0, depth=None
)

# regularisation parameter
snr = 3.0
lambda2 = 1.0 / snr**2

# compute resolution matrix for sLORETA
rm_lor = make_inverse_resolution_matrix(
    forward, inverse_operator, method="sLORETA", lambda2=lambda2
)

# get PSF for sLORETA at multiple source points
sources = np.arange(1, 10)

for mode in ["svd", "pca", "max", "maxval"]:
    stc_psf = get_point_spread(rm_lor, forward["src"], sources, mode=mode)
    print("Using mode", mode, "psf is of shape:", stc_psf.data.shape)

Link to data

No response

Expected results

Only max and svd should work, returning the summarised psf. Other mode values should return a ValueError.

Actual results

All mode values return a psf, but if svd or max all the vertices are returned.

Using mode svd psf is of shape: (7498, 9)
Using mode pca psf is of shape: (7498, 1)
Using mode max psf is of shape: (7498, 9)
Using mode maxval psf is of shape: (7498, 1)

Additional information

reproduced on both mne 1.3.1 and 1.8.0

Activity

  1. welcome commented on Feb 25, 2025

    @welcome

    Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴

  2. drammock commented on Feb 25, 2025

    @drammock
    Member

    @olafhauk do you have time to look into this one?

  3. Famous077 commented on Mar 5, 2026

    @Famous077
    Contributor

    Hi @giulianogiari , Are you currently working on this issue? If not, I'd love to take it up. Please let me know, and I'll wait for your confirmation before proceeding. Thank you

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

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