brain.screenshot(time_viewer=True) crash
See original GitHub issueI was running the mne-bids-pipeline (so with mne-23dev cloned from GitHub in backend), but a bug appeared just after the creation of the reports of the first subject. After investigation, it turns out that the bug comes from MNE, from the option time_viewer=True in the screenshot method. By setting it to false, the image plots nicely.
I tried to make a reproducible example with sample data, but this does not reproduce the issue (Else). So I’ve also included here the (IF True) my stc file and my subjects file which isolate the code on my computer.
from pathlib import Path
import matplotlib
import matplotlib.pyplot as plt
import mne
from mne.datasets import sample
matplotlib.use('Qt5Agg')
if True:
stc_fname = Path("mne_data/ds003392/derivatives",
'mne-bids-pipeline/sub-01/meg/',
'sub-01_task-localizer_coherent+dSPM+hemi-lh.stc')
subjects_dir = Path("mne_data/ds003392/derivatives/freesurfer",
'subjects')
subject = 'sub-01'
stc = mne.read_source_estimate(stc_fname, subject=subject)
else:
data_path = sample.data_path()
fname = data_path + '/MEG/sample/sample_audvis-meg'
stc = mne.read_source_estimate(fname)
subject = "sample"
subjects_dir = Path("C:/Users/charb/mne_data/MNE-sample-data/subjects")
brain = stc.plot(subject=subject, subjects_dir=subjects_dir,
initial_time=0.13, views=['lat'], hemi='split')
brain.toggle_interface()
brain._renderer.plotter.reset_camera()
brain._renderer.plotter.subplot(0, 0)
brain._renderer.plotter.reset_camera()
figs, ax = plt.subplots(figsize=(15, 10))
# BUG : Set time_viewer to False to remove the Bug
image = brain.screenshot(time_viewer=True)
ax.imshow(image)
ax.axis('off')
plt.show()
Expected results
An interactive plot.
Actual results
When I run the code, the figure appears one second and then crashes
(mne_dev) C:\Users\charb\Desktop\parietal>C:/Users/charb/anaconda3/envs/mne_dev/python.exe c:/Users/charb/Desktop/parietal/test.py
Using pyvista 3d backend.
Using control points [13.01218636 16.52222281 48.36637508]
Traceback (most recent call last):
File "c:\Users\charb\Desktop\parietal\test.py", line 51, in <module>
image = brain.screenshot(time_viewer=True)
File "C:\Users\charb\anaconda3\envs\mne_dev\lib\site-packages\mne\viz\_brain\_brain.py", line 2631, in screenshot
trace_img = np.reshape(
File "<__array_function__ internals>", line 5, in reshape
File "C:\Users\charb\anaconda3\envs\mne_dev\lib\site-packages\numpy\core\fromnumeric.py", line 299, in reshape
return _wrapfunc(a, 'reshape', newshape, order=order)
File "C:\Users\charb\anaconda3\envs\mne_dev\lib\site-packages\numpy\core\fromnumeric.py", line 58, in _wrapfunc
return bound(*args, **kwds)
ValueError: cannot reshape array of size 1082952 into shape (1015,4)
(mne_dev) C:\Users\charb\Desktop\parietal>
Additional information
I’m working on Windows.
(mne_dev) C:\Users\charb\Desktop\parietal\mne-bids-pipeline>python
Python 3.9.2 | packaged by conda-forge | (default, Feb 21 2021, 04:59:43) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import mne; mne.sys_info()
Platform: Windows-10-10.0.19041-SP0
Python: 3.9.2 | packaged by conda-forge | (default, Feb 21 2021, 04:59:43) [MSC v.1916 64 bit (AMD64)]
Executable: C:\Users\charb\anaconda3\envs\mne_dev\python.exe
CPU: Intel64 Family 6 Model 158 Stepping 10, GenuineIntel: 8 cores
Memory: 7.9 GB
mne: 0.23.dev0
numpy: 1.20.2 {blas=NO_ATLAS_INFO, lapack=lapack}
scipy: 1.6.2
matplotlib: 3.4.1 {backend=Qt5Agg}
sklearn: 0.24.1
numba: 0.53.1
nibabel: 3.2.1
nilearn: 0.7.1
dipy: 1.4.0
cupy: Not found
pandas: 1.2.4
mayavi: 4.7.2
pyvista: 0.29.1 {pyvistaqt=0.3.0, OpenGL 4.5.0 - Build 26.20.100.6911 via Intel(R) UHD Graphics 630}
vtk: 9.0.1
PyQt5: 5.12.3
>>>
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:27 (16 by maintainers)
Top Results From Across the Web
Save Screen Shot crash | Apple Developer Forums
6 attempting to Save Screen Shot (⌘S) now results in a consistent crash across projects: "Simulator quit unexpectedly while using the libswiftFoundation.dylib ...
Read more >Rider is unexpectedly closed at the time of using screenshot tool
Some times Rider is unexpectedly closed when I doing a screenshot with Greenshot (same behavior with Lightshot). Precondition: Greenshot tool is installed ...
Read more >Screenshots capture crashes Steam Overlay in Beta ... - GitHub
Steps for reproducing this issue: Opt-in beta; Launch game; Take screenshot; Screenshot wasn't taken and Steam Overlay is crashed.
Read more >Screenshot Plugin crashes when taking screenshot of ... - GitLab
On the desktop PC, screeenshot.exe crashes whenever I try to take a single window screenshot of a window that is currently maximized (and...
Read more >How can we take screenshot of a visual in a brain? - Quora
I hope this answers your question:)) Berkeley scientists figured out a way to turn the way our brains interpret visual stimuli into a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
IIRC an
int
just gets turned into(size, size)
internally sosize=800
should give identical results to(800, 800)
Here is the right hemisphere : https://drive.google.com/file/d/1y7puZ7RPMGV6uB6tN_Pu-MgamuaAFvlb/view?usp=sharing
(In the script only left hemisphere is imported ? Weird, but ok…)