mne-tools / mne-nirs

Process Near-Infrared Spectroscopy Data in MNE
https://mne.tools/mne-nirs/
BSD 3-Clause "New" or "Revised" License
79 stars 35 forks source link

Support blocking param for visualizations #553

Open alexk101 opened 3 months ago

alexk101 commented 3 months ago

Describe the new feature or enhancement

The main mne.viz module allows for the specification of the block param. mne-nirs visualization functions don't support this. Our workflow is primarily scripts in vscode, and not notebooks, which means that many of these plots, particularly this one...

https://github.com/mne-tools/mne-nirs/blob/d7978f1212ec829c67b27ab0c798cb34b810f8f1/mne_nirs/visualisation/_plot_nirs_source_detector.py#L12

immediately close upon running. I have read the discussion on this subject in the forums, and as was suggested there, would like to have a block param.

Describe your proposed implementation

Maybe implement in the abstract class

https://github.com/mne-tools/mne-python/blob/main/mne/viz/backends/_abstract.py#L16

and then added as a parameter to the various plotting functions in the mne_nirs.visualization. Or just add logic the functions themselves. I am unsure what the best way would be. Given that these are not matplotlib plots, but some unknown backend that varies from system to system, the abstract implementation makes the most sense to me.

larsoner commented 3 months ago

Agreed this should probably be part of the viz backend system. Rather than add a block param I think it would be nicer to have a function that you can just call. Currently we have stuff like mne.viz.set_3d_view. This could be something like mne.viz.block(kind="3d") or something maybe (where the default kind="matplotlib" would just wrap plt.show(block=True))?