mne-tools / mne-tools/mne-python

Volume plots: axis ticks are overlapping

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

Nobody has claimed this yet.

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

Description

Description of the problem

When plotting source reconstruction results on volume MRIs, the axis labels are often mangled and overlap each other both on the colorbar but also on the y-axis of the time series plot.
Furthermore, the MRI seems and colorbar seem to be shifted relative to the black background. The axis values of the MRI are shifted, too.

Steps to reproduce
import mne
from mne.beamformer import make_lcmv, apply_lcmv

sample_path = mne.datasets.sample.data_path()
data_path = sample_path / 'MEG' / 'sample'
subjects_dir = sample_path / 'subjects'

# read raw data
fname_raw = data_path / 'sample_audvis_raw.fif'
raw = mne.io.read_raw_fif(fname_raw)
raw.pick(picks=['mag', 'stim'])

# make epochs
events = mne.find_events(raw)
epochs = mne.Epochs(raw, events, event_id=[3, 4])
evoked = epochs.average()

# load the precomputed MEG forward model from disk
fname_fwd = data_path / 'sample_audvis-meg-vol-7-fwd.fif'
fwd_meg = mne.read_forward_solution(fname_fwd)

# compute covariance matrix
data_cov = mne.compute_covariance(epochs, tmin=0.0, tmax=0.15, method='empirical')

# compute beamformer, apply, and plot
filters = make_lcmv(epochs.info, fwd_meg, data_cov=data_cov, pick_ori='max-power')
stc = apply_lcmv(evoked=evoked, filters=filters)
stc.crop(-0.05, 0.15).plot(subjects_dir=subjects_dir, subject='sample', src=fwd_meg['src']);
Link to data

No response

Expected results

A pretty plot 🙂

Actual results

image

Additional information

This has been confirmed to happen in Jupyter notebooks and from a plain script (see MWE, run inside VSCode). Problem has been reproduced by @drammock .

This was done in a fresh conda install of the latest release, 1.8.0

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.

Research direction

Start by running the provided MWE and inspect the volume source estimate's stc.crop(...).plot(...) entry point in a notebook and plain script. Compare the colorbar, time-series y-axis, MRI positioning, and axis values with the expected alignment; done means the labels no longer overlap and the plotted MRI and axes align with the black background.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.