Skip to content

Conversation

@larsoner
Copy link
Member

On this PR this code snippet correctly sets the render area to the requested size=(800, 600), and yet is resizeable afterward:

MWE
import os.path as op
import mne

data_path = mne.datasets.sample.data_path()
sample_dir = op.join(data_path, 'MEG', 'sample')
subjects_dir = op.join(data_path, 'subjects')
inv = mne.minimum_norm.read_inverse_operator(op.join(
    sample_dir, 'sample_audvis-meg-oct-6-meg-inv.fif'))
evoked = mne.read_evokeds(op.join(sample_dir, 'sample_audvis-ave.fif'))[0]
evoked.apply_baseline((None, 0))
stc = mne.minimum_norm.apply_inverse(
    evoked, inv, method='dSPM', verbose='debug', pick_ori='vector')  # 'vector')
initial_time = 0.1

size = (800, 600)
with mne.viz.use_3d_backend('pyvista'):
    brain = stc.plot(subjects_dir=subjects_dir, initial_time=initial_time,
                     clim='auto', views='lat', hemi='lh',
                     smoothing_steps='nearest', verbose=True,
                     size=size)
sc = brain.screenshot()
assert sc.shape[:2] == size[::-1]

Screenshot from 2020-05-12 14-17-05

@GuillaumeFavelier can you take over to actually incorporate this properly? For example this also needs to work when time_viewer=False (it does not currently) -- you can probably use similar techniques. But I'll let you decide how to refactor to make it work for both cases.

@GuillaumeFavelier GuillaumeFavelier self-assigned this May 13, 2020
@larsoner larsoner added this to the 0.21 milestone May 28, 2020
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
@larsoner
Copy link
Member Author

larsoner commented Jun 3, 2020

@GuillaumeFavelier can you add tests for size? I started to add some but the size was wrong for one run, things don't work with latest pyvista + pyvistaqt, etc. so it was not trivial

@GuillaumeFavelier
Copy link
Contributor

I'll take care of it

GuillaumeFavelier and others added 4 commits June 3, 2020 18:19
* upstream/master: (23 commits)
  MAINT: Add mne.surface to docstring tests (mne-tools#7930)
  MRG: Add smoothing controller to TimeViewer for the notebook backend (mne-tools#7928)
  MRG: TimeViewer matplotlib figure color (mne-tools#7925)
  fix typos (mne-tools#7924)
  MRG, ENH: Add method to project onto max power ori (mne-tools#7883)
  WIP: Warn if untested NIRX device (mne-tools#7905)
  MRG, BUG: Fix bug with volume morph and subject_to!="fsaverage" (mne-tools#7896)
  MRG, MAINT: Clean up use of bool, float, int (mne-tools#7917)
  ENH: Better error message for incompatible Evoked objects (mne-tools#7910)
  try to fix nullcontext (mne-tools#7908)
  WIP: Fix Travis (mne-tools#7906)
  WIP: Prototype of notebook viz (screencast) (mne-tools#7758)
  MRG, FIX: Speed up I/O tests, mark some slow (mne-tools#7904)
  Proper attribution for Blender tutorial (mne-tools#7900)
  MAINT: Check usage [ci skip] (mne-tools#7902)
  Allow find_bad_channels_maxwell() to return scores (mne-tools#7845)
  Warn if NIRx directory structure has been modified from original format (mne-tools#7898)
  Pin pvyista to 0.24.3 (mne-tools#7899)
  MRG: Add support for reading and writing sufaces to .obj (mne-tools#7824)
  Fix _auto_topomap_coords docstring. (mne-tools#7895)
  ...
larsoner added 2 commits June 25, 2020 16:40
* upstream/master:
  MRG: Prepare migration to PyVista 0.25 (mne-tools#7791)
  MAINT: Simpler VTK [circle front] (mne-tools#7931)
  MRG, ENH: Add arbitrary connectivity for stats (mne-tools#7916)
@larsoner larsoner changed the title WIP: Add resizing when time_viewer is present MRG, ENH: Add resizing when time_viewer is present Jun 25, 2020
@larsoner larsoner merged commit de3237c into mne-tools:master Jun 25, 2020
larsoner added a commit to larsoner/mne-python that referenced this pull request Jun 25, 2020
* upstream/master:
  MRG, ENH: Add resizing when time_viewer is present (mne-tools#7775)
@larsoner larsoner deleted the resize branch June 25, 2020 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants