def test_plot_butterfly(): "Test plot.Butterfly" ds = datasets.get_uts(utsnd=True) p = plot.Butterfly('utsnd', ds=ds, show=False) p.close() p = plot.Butterfly('utsnd', 'A%B', ds=ds, show=False) p.close()
def test_plot_butterfly(): "Test plot.Butterfly" plot.configure_backend(False, False) ds = datasets.get_rand(utsnd=True) p = plot.Butterfly('utsnd', ds=ds) p.close() p = plot.Butterfly('utsnd', 'A%B', ds=ds) p.close()
def test_time_slicer(): "Test linked time axes" ds = datasets.get_uts(True) p1 = plot.Butterfly(ds['utsnd'], show=False) p2 = plot.Array('utsnd', 'A', ds=ds, show=False) p1.link_time_axis(p2) p1._set_time(.1, True) eq_(p2._current_time, .1) eq_(p2._time_fixed, True) p2._set_time(.2) eq_(p1._current_time, .2) eq_(p1._time_fixed, False) p1 = plot.TopoButterfly(ds['utsnd'], show=False) p2 = plot.Array('utsnd', 'A', ds=ds, show=False) p2.link_time_axis(p1) p1._set_time(.1, True) eq_(p2._current_time, .1) eq_(p2._time_fixed, True) p2._set_time(.2) eq_(p1._current_time, .2) eq_(p1._time_fixed, False)
def test_time_slicer(): "Test linked time axes" ds = datasets.get_uts(True) p1 = plot.Butterfly(ds['utsnd']) p2 = plot.Array('utsnd', 'A', ds=ds) p1.link_time_axis(p2) p1._set_time(.1, True) assert p2._current_time == .1 assert p2._time_fixed == True p2._set_time(.2) assert p1._current_time == .2 assert p1._time_fixed == False p1 = plot.TopoButterfly(ds['utsnd']) p2 = plot.Array('utsnd', 'A', ds=ds) p2.link_time_axis(p1) p1._set_time(.1, True) assert p2._current_time == .1 assert p2._time_fixed == True # merge another p3 = plot.TopoButterfly(ds[0, 'utsnd']) p3.link_time_axis(p2) p2._set_time(.2) assert p1._current_time == .2 assert p1._time_fixed == False
def test_plot_butterfly(): "Test plot.Butterfly" ds = datasets.get_uts(utsnd=True) p = plot.Butterfly('utsnd', ds=ds) p.close() p = plot.Butterfly('utsnd', 'A%B', ds=ds) p.close() # other y-dim stc = datasets.get_mne_stc(True, subject='fsaverage') p = plot.Butterfly(stc) p.close() # _ax_bfly_epoch (used in GUI, not part of a figure) fig = Figure(1) ax = _ax_bfly_epoch(fig._axes[0], ds[0, 'utsnd']) fig.show() ax.set_data(ds[1, 'utsnd']) fig.draw()
def test_plot_butterfly(): "Test plot.Butterfly" ds = datasets.get_uts(utsnd=True) p = plot.Butterfly('utsnd', ds=ds, show=False) p.close() p = plot.Butterfly('utsnd', 'A%B', ds=ds, show=False) p.close() # other y-dim stc = datasets.get_mne_stc(True) p = plot.Butterfly(stc, show=False) p.close() # _ax_bfly_epoch fig = Figure(1, show=False) ax = _ax_bfly_epoch(fig._axes[0], ds[0, 'utsnd']) fig.show() ax.set_data(ds[1, 'utsnd']) fig.draw()
raw_AEF.notch_filter(np.arange(60, 181, 60), fir_design='firwin') # band pass filtering 1-8 Hz raw_AEF.filter(1.0, 8.0, fir_design='firwin') # resample to 100 Hz raw_AEF.resample(100, npad="auto") ### LOAD RELEVANT VARIABLES AS eelbrain.NDVar # load as epochs for plot only ds = load.fiff.events(raw=raw_AEF, proj=True, stim_channel='UPPT001', events=event_fname) epochs = load.fiff.epochs(ds, tmin=-0.1, tmax=0.5, baseline=(None, 0)) plot.Butterfly(epochs) # pick MEG channels picks = mne.pick_types(raw_AEF.info, meg=True, eeg=False, stim=False, eog=False, ref_meg=False, exclude='bads') # Read as a single chunk of data y, t = raw_AEF.get_data(picks, return_times=True) sensor_dim = load.fiff.sensor_dim(raw_AEF.info, picks=picks) time = eelbrain.UTS.from_int(0, t.size - 1, raw_AEF.info['sfreq']) meg = eelbrain.NDVar(y, dims=(sensor_dim, time))
def source_trfs( ress: ResultCollection, heading: FMTextArg = None, brain_view: Union[str, Sequence[float]] = None, axw: float = None, surf: str = 'inflated', cortex: Any = ((1.00,) * 3, (.4,) * 3), vmax: float = None, xlim: Tuple[float, float] = None, times: Sequence[float] = None, cmap: str = None, labels: Dict[str, str] = None, rasterize: bool = None, brain_timewindow: float = 0.050 ): "Only used for TRFExperiment model-test" layout = BrainLayout(brain_view, axw) dt = brain_timewindow / 2 if heading is not None: doc = fmtxt.Section(heading) else: doc = fmtxt.FMText() if cmap is None: cmap = 'lux-a' if labels is None: labels = {} trf_table = fmtxt.Table('ll') for key, res in ress.items(): trf_resampled = resample(res.masked_difference(), 1000) label = labels.get(key, key) if rasterize is None: rasterize = len(trf_resampled.source) > 500 # times for anatomical plots if times is None: trf_tc = abs(trf_resampled).sum('source') trf_tc_mask = (~trf_resampled.get_mask()).sum('source') >= 10 times_ = find_peak_times(trf_tc, trf_tc_mask) else: times_ = times # butterfly-plot p = plot.Butterfly(trf_resampled, h=3, w=4, ylabel=False, title=label, vmax=vmax, xlim=xlim, show=False) for t in times_: p.add_vline(t, color='k') trf_table.cell(fmtxt.asfmtext(p, rasterize=rasterize)) p.close() # peak sources if not times_: trf_table.cell() sp = plot.brain.SequencePlotter() if layout.brain_view: sp.set_parallel_view(*layout.brain_view) sp.set_brain_args(surf=surf, cortex=cortex) for t in times_: yt = trf_resampled.mean(time=(t - dt, t + dt + 0.001)) if isinstance(cmap, str): vmax_ = vmax or max(-yt.min(), yt.max()) or 1 cmap_ = plot.soft_threshold_colormap(cmap, vmax_ / 10, vmax_) else: cmap_ = cmap sp.add_ndvar(yt, cmap=cmap_, label=f'{t * 1000:.0f} ms', smoothing_steps=10) p = sp.plot_table(view='lateral', orientation='vertical', **layout.table_args) trf_table.cell(p) p.close() doc.append(fmtxt.Figure(trf_table)) return doc