Skip to content

Commit

Permalink
[BUG, MRG] Fix tutorial + example show_view to use correct keyword ar…
Browse files Browse the repository at this point in the history
…gs (mne-tools#9599)

* fix tutorial + example show_view

* clean up paths to touch examples

* seg fault
  • Loading branch information
alexrockhill authored and marsipu committed Aug 2, 2021
1 parent 24123b0 commit 2b61919
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 19 deletions.
12 changes: 7 additions & 5 deletions examples/connectivity/mne_inverse_coherence_epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

# %%

import os.path as op
import numpy as np

import mne
Expand All @@ -32,12 +33,13 @@
# compute the event-related coherence.

data_path = sample.data_path()
subjects_dir = data_path + '/subjects'
fname_inv = data_path + '/MEG/sample/sample_audvis-meg-oct-6-meg-inv.fif'
fname_raw = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif'
fname_event = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw-eve.fif'
subjects_dir = op.join(data_path, 'subjects')
sample_dir = op.join(data_path, 'MEG', 'sample')
fname_inv = op.join(sample_dir, 'sample_audvis-meg-oct-6-meg-inv.fif')
fname_raw = op.join(sample_dir, 'sample_audvis_filt-0-40_raw.fif')
fname_event = op.join(sample_dir, 'sample_audvis_filt-0-40_raw-eve.fif')
label_name_lh = 'Aud-lh'
fname_label_lh = data_path + '/MEG/sample/labels/%s.label' % label_name_lh
fname_label_lh = op.join(sample_dir, 'labels', f'{label_name_lh}.label')

event_id, tmin, tmax = 1, -0.2, 0.5
method = "dSPM" # use dSPM method (could also be MNE or sLORETA)
Expand Down
16 changes: 10 additions & 6 deletions examples/inverse/covariance_whitening_dspm.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

# %%

import os.path as op
import numpy as np
import matplotlib.pyplot as plt

Expand All @@ -43,11 +44,12 @@
# Get data

data_path = spm_face.data_path()
subjects_dir = data_path + '/subjects'
subjects_dir = op.join(data_path, 'subjects')

raw_fname = data_path + '/MEG/spm/SPM_CTF_MEG_example_faces%d_3D.ds'
raw_fname = op.join(data_path, 'MEG', 'spm',
'SPM_CTF_MEG_example_faces{run}_3D.ds')

raw = io.read_raw_ctf(raw_fname % 1) # Take first run
raw = io.read_raw_ctf(raw_fname.format(run=1)) # Take first run
# To save time and memory for this demo, we'll just use the first
# 2.5 minutes (all we need to get 30 total events) and heavily
# resample 480->60 Hz (usually you wouldn't do either of these!)
Expand Down Expand Up @@ -103,12 +105,14 @@
del epochs

# Make forward
trans = data_path + '/MEG/spm/SPM_CTF_MEG_example_faces1_3D_raw-trans.fif'
trans = op.join(data_path, 'MEG', 'spm',
'SPM_CTF_MEG_example_faces1_3D_raw-trans.fif')
# oct5 and add_dist are just for speed, not recommended in general!
src = mne.setup_source_space(
'spm', spacing='oct5', subjects_dir=data_path + '/subjects',
'spm', spacing='oct5', subjects_dir=subjects_dir,
add_dist=False)
bem = data_path + '/subjects/spm/bem/spm-5120-5120-5120-bem-sol.fif'
bem = op.join(data_path, 'subjects', 'spm', 'bem',
'spm-5120-5120-5120-bem-sol.fif')
forward = mne.make_forward_solution(evokeds[0][0].info, trans, src, bem)
del src
for noise_covs_, evokeds_ in zip(noise_covs, evokeds):
Expand Down
2 changes: 1 addition & 1 deletion examples/time_frequency/source_power_spectrum_opm.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def plot_band(kind, band):
time_label=title, title=title, colormap='inferno',
time_viewer=False, show_traces=False,
clim=dict(kind='percent', lims=(70, 85, 99)), smoothing_steps=10)
brain.show_view(dict(azimuth=0, elevation=0), roll=0)
brain.show_view(azimuth=0, elevation=0, roll=0)
return fig, brain


Expand Down
3 changes: 2 additions & 1 deletion mne/viz/_brain/_brain.py
Original file line number Diff line number Diff line change
Expand Up @@ -2699,7 +2699,8 @@ def show_view(self, view=None, roll=None, distance=None,
elevation = view['elevation']
view = None
if (row == 'deprecated' or col == 'deprecated') and \
len([_ for h in self._hemis for _ in self._iter_views(h)]) > 1:
len(set([_ for h in self._hemis
for _ in self._iter_views(h)])) > 1:
warn('`row` and `col` default behavior is changing, in version '
'0.25 the default behavior will be to apply `show_view` to '
'all views', DeprecationWarning)
Expand Down
2 changes: 1 addition & 1 deletion tutorials/clinical/20_seeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
brain = mne.viz.Brain('fsaverage', alpha=0.1, cortex='low_contrast',
subjects_dir=subjects_dir, units='m', figure=fig)
brain.add_volume_labels(aseg='aparc+aseg', labels=labels)
brain.show_view(dict(azimuth=120, elevation=90, distance=0.25))
brain.show_view(azimuth=120, elevation=90, distance=0.25)
brain.enable_depth_peeling()

# %%
Expand Down
2 changes: 1 addition & 1 deletion tutorials/inverse/60_visualize_stc.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
brain = mne.viz.Brain('sample', hemi='both', surf='pial', alpha=0.5,
cortex='low_contrast', subjects_dir=subjects_dir)
brain.add_volume_labels(aseg='aparc.a2009s+aseg', labels=labels)
brain.show_view(dict(azimuth=250, elevation=40, distance=400))
brain.show_view(azimuth=250, elevation=40, distance=400)
brain.enable_depth_peeling()

# %%
Expand Down
6 changes: 2 additions & 4 deletions tutorials/simulation/80_dics.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ def coh_signal_gen():
brain.add_foci(vertices[1][0], coords_as_verts=True, hemi='rh')

# Rotate the view and add a title.
brain.show_view(view={'azimuth': 0, 'elevation': 0, 'distance': 550,
'focalpoint': [0, 0, 0]})
brain.show_view(azimuth=0, elevation=0, distance=550, focalpoint=(0, 0, 0))

# %%
# We will now compute the cortical power map at 10 Hz. using a DICS beamformer.
Expand Down Expand Up @@ -280,8 +279,7 @@ def plot_approach(power, n):
brain.add_foci(vertices[0][0], coords_as_verts=True, hemi='lh', color='b')
brain.add_foci(vertices[1][0], coords_as_verts=True, hemi='rh', color='b')
# Rotate the view and add a title.
brain.show_view(view={'azimuth': 0, 'elevation': 0, 'distance': 550,
'focalpoint': [0, 0, 0]})
brain.show_view(azimuth=0, elevation=0, distance=550, focalpoint=(0, 0, 0))
return brain


Expand Down

0 comments on commit 2b61919

Please sign in to comment.