mne-qt-browser icon indicating copy to clipboard operation
mne-qt-browser copied to clipboard

Add the ability to replace raw and replace ICA traces in plot

Open adam2392 opened this issue 3 years ago • 1 comments

Is your feature request related to a problem? Please describe. I would like to be able to use the mne-qt-browser and dynamically replace the trace (raw or ica) that is visualized. For example, I would like to plot the raw EEG or ica source based on which channel/component is selected by the user.

# pseudocode: this is a time-series plot from MNE QTBrowser
# it only selects the component in ICA instance that is currently selected
ts_plot.replace_ica(ica[curr_sel_comp, :])

# redraw, so the data shows up in the visualization (I think that's how QT / matplotlib canvases work)
ts_plot.re_draw()

Describe the solution you'd like @marsipu thanks for your help so far. Are you able to point out what changes you think will be needed in order for this refactoring to be enabled?

Additional context Discussion came up in: https://mne.discourse.group/t/embedding-time-series-plot-of-mne-qt-browser-into-our-own-gui/5090/10?u=adam2392

adam2392 avatar Jul 19 '22 21:07 adam2392

@adam2392 I think you need to go deeper and make this a change in mne itself. More specifically I think one could add a method like replace_data to BrowserBase. You would have to consider all relevant data-attributes like e.g. self._data and self._times and make it work for all possible data-instances (raw, epochs, ica).

Then you might want to refresh the view and set the time-back to 0. For qt-backend this would look something like this:

self.mne.t_start = 0
self.mne.plt.setXRange(self.mne.t_start, self.mne.t_start + self.mne.duration)

marsipu avatar Jul 19 '22 21:07 marsipu