def _plot_3d_evoked_array(inst, ea, picks="hbo", value="Coef.", background='w', figure=None, clim='auto', mode='weighted', colormap='RdBu_r', surface='pial', hemi='both', size=800, view=None, colorbar=True, distance=0.03, subjects_dir=None, src=None, verbose=False): # TODO: mimic behaviour of other MNE-NIRS glm plotting options if picks is not None: ea = ea.pick(picks=picks) if subjects_dir is None: subjects_dir = get_subjects_dir(raise_error=True) if src is None: fname_src_fs = os.path.join(subjects_dir, 'fsaverage', 'bem', 'fsaverage-ico-5-src.fif') src = read_source_spaces(fname_src_fs) picks = np.arange(len(ea.info['ch_names'])) # Set coord frame for idx in range(len(ea.ch_names)): ea.info['chs'][idx]['coord_frame'] = FIFF.FIFFV_COORD_HEAD # Generate source estimate kwargs = dict(evoked=ea, subject='fsaverage', trans='fsaverage', distance=distance, mode=mode, surface=surface, subjects_dir=subjects_dir, src=src, project=True) stc = stc_near_sensors(picks=picks, **kwargs, verbose=verbose) # Produce brain plot brain = stc.plot(src=src, subjects_dir=subjects_dir, hemi=hemi, surface=surface, initial_time=0, clim=clim, size=size, colormap=colormap, figure=figure, background=background, colorbar=colorbar, verbose=verbose) if view is not None: brain.show_view(view) return brain
# As shown in the plot, the epileptiform activity starts in the temporal lobe, # progressing posteriorly. The seizure becomes generalized eventually, after # this example short time section. This dataset is available using # :func:`mne.datasets.epilepsy_ecog.data_path` for you to examine. # sphinx_gallery_thumbnail_number = 5 xyz_pts = np.array([dig['r'] for dig in evoked.info['dig']]) src = mne.read_source_spaces( op.join(subjects_dir, 'fsaverage', 'bem', 'fsaverage-ico-5-src.fif')) trans = None # identity transform stc = mne.stc_near_sensors(gamma_power_t, trans, 'fsaverage', src=src, mode='nearest', subjects_dir=subjects_dir, distance=0.02) vmin, vmid, vmax = np.percentile(gamma_power_t.data, [10, 25, 90]) clim = dict(kind='value', lims=[vmin, vmid, vmax]) brain = stc.plot(surface='pial', hemi='rh', colormap='inferno', colorbar=False, clim=clim, views=['lat', 'med'], subjects_dir=subjects_dir, size=(250, 250), smoothing_steps=20, time_viewer=False)
# # As shown in the plot, the epileptiform activity starts in the temporal lobe, # progressing posteriorly. The seizure becomes generalized eventually, after # this example short time section. This dataset is available using # :func:`mne.datasets.epilepsy_ecog.data_path` for you to examine. # sphinx_gallery_thumbnail_number = 3 xyz_pts = np.array([dig['r'] for dig in evoked.info['dig']]) src = mne.read_source_spaces(subjects_dir / 'fsaverage' / 'bem' / 'fsaverage-ico-5-src.fif') stc = mne.stc_near_sensors(gamma_power_t, trans='fsaverage', subject='fsaverage', subjects_dir=subjects_dir, src=src, surface='pial', mode='nearest', distance=0.02) vmin, vmid, vmax = np.percentile(gamma_power_t.data, [10, 25, 90]) clim = dict(kind='value', lims=[vmin, vmid, vmax]) brain = stc.plot(surface='pial', hemi='rh', colormap='inferno', colorbar=False, clim=clim, views=['lat', 'med'], subjects_dir=subjects_dir, size=(250, 250), smoothing_steps='nearest', time_viewer=False)
# We can visualize this raw data on the ``fsaverage`` brain (in MNI space) as # a heatmap. This works by first creating an ``Evoked`` data structure # from the data of interest (in this example, it is just the raw LFP). # Then one should generate a ``stc`` data structure, which will be able # to visualize source activity on the brain in various different formats. # get standard fsaverage volume (5mm grid) source space fname_src = op.join(subjects_dir, 'fsaverage', 'bem', 'fsaverage-vol-5-src.fif') vol_src = mne.read_source_spaces(fname_src) evoked = epochs.average() stc = mne.stc_near_sensors( evoked, trans, 'fsaverage', subjects_dir=subjects_dir, src=vol_src, verbose='error') # ignore missing electrode warnings stc = abs(stc) # just look at magnitude clim = dict(kind='value', lims=np.percentile(abs(evoked.data), [10, 50, 75])) # %% # Plot 3D source (brain region) visualization: # # By default, `stc.plot_3d() <mne.VolSourceEstimate.plot_3d>` will show a time # course of the source with the largest absolute value across any time point. # In this example, it is simply the source with the largest raw signal value. # Its location is marked on the brain by a small blue sphere. # sphinx_gallery_thumbnail_number = 6
show_power = gamma_power_t[:, 100:150] anim = animation.FuncAnimation(fig, animate, init_func=init, fargs=(show_power, ), frames=show_power.shape[1], interval=200, blit=True) ############################################################################### # Alternatively, we can project the sensor data to the nearest locations on # the pial surface and visualize that: # sphinx_gallery_thumbnail_number = 4 evoked = mne.EvokedArray(gamma_power_t, raw.info) stc = mne.stc_near_sensors(evoked, trans, subject, subjects_dir=subjects_dir) clim = dict(kind='value', lims=[vmin * 0.9, vmin, vmax]) brain = stc.plot(surface='pial', hemi='both', initial_time=0.68, colormap='viridis', clim=clim, views='parietal', subjects_dir=subjects_dir, size=(600, 600)) # You can save a movie like the one on our documentation website with: # brain.save_movie(time_dilation=20, tmin=0.62, tmax=0.72, # interpolation='linear', framerate=5, # time_viewer=True)