mvpure_py.viz#

mvpure_py.viz.group_viz#

Functions for group results visualizations.

mvpure_py.viz.group_viz.group_plot_add_foci(data_dict: dict, localizer: str, hemi: str = 'both', surf: str = 'inflated', delta: float = None, subjects_dir: str = None, **kwargs)[source]#

Create group plot presenting localized dipoles using mne.viz.Brain.add_foci().

Parameters:
  • data_dict (dict) –

    Dictionary with data from localization analysis in a form:

    {
        'subject': {
            'localizer_1': mvpure_py.Localized,
            ...
            'localizer_n': mvpure_py.Localized
        }
    }
    

  • localizer (str) – Localizer type to plot results for

  • hemi (str) – Hemisphere to plot.

  • surf (str) – FreeSurfer surface mesh name

  • delta (float) – Optimization parameter used during analysis. Is only used for setting title of the plot.

  • subjects_dir (str) – Directory where subject folder is being stored

  • **kwargs (dict) –

    Additional keyword arguments passed to:
    • mne.viz.Brain constructor

    • Brain.add_foci method

mvpure_py.viz.group_viz.group_plot_regions(data_dict: dict, localizer: str, n_sources_to_loc: int, hemi: str, parc: str, subjects_dir: str = None, surf: str = 'inflated', cmap: str = 'Reds', none_color: str = 'gainsboro', return_df_info: bool = False, **kwargs)[source]#

Plot the fsaverage brain with results from group-level EEG source localization.

Function visualizes the fsaverage brain and highlights cortical regions based on their accumulated scores from a group-level source localization analysis. The regions are scored as follows:

  • The region corresponding to the strongest source gets n_sources_to_loc points,

  • The second-strongest gets n_sources_to_loc - 1 points,

  • The weakest among the top n_sources_to_loc gets 1 point.

Points are accumulated across subjects. Regions with more points are shown with more intense colors on the brain surface using cmap.

Parameters:
  • data_dict (dict) –

    Dictionary with data from localization analysis in a form:

    {
        'subject': {
            'localizer_1': mvpure_py.Localized,
            ...
            'localizer_n': mvpure_py.Localized
        }
    }
    

  • localizer (str) – Localizer type to plot results for

  • n_sources_to_loc (int) – Number of sources that were localized

  • hemi (str) – Hemisphere to plot.

  • parc (str) – Name of parcellation to was performed and should be read for fsaverage brain

  • subjects_dir (str) – Directory where subject folder is being stored

  • surf (str) – FreeSurfer surface mesh name

  • cmap (str) – Matplotlib cmap to use.

  • none_color (str) – Matplotlib-valid color to use for regions that were not identified in single-subjects

  • return_df_info (bool) – Whether to return pandas dataframe with information about regions scoring

  • kwargs – Additional keyword arguments passed to mne.viz.Brain constructor

mvpure_py.viz.viz#

mvpure_py.viz.viz.plot_RN_eigenvalues(R: ndarray, N: ndarray, figsize: tuple = (12, 6), return_eigvals: bool = False, n_sources_threshold: float = 1.0, rank_threshold: float = 1.5, subject: str = None, **kwargs) tuple[Figure, ndarray] | Figure[source]#

Plot eigenvalues of matrix \(RN^{-1}\) where R is data covariance and N is noise covariance in descending order. Adding horizontal lines for the cut-off values: n_sources_to_localize and rank_threshold.

Parameters:
  • R (array-like) – Data covariance matrix

  • N (array-like) – Noise covariance matrix

  • figsize (tuple) – Size of the figure in the format (width, height) in inches. Default to (12,6).

  • return_eigvals (bool) – Whether to rerun array with eigenvalues sorted in descending order. Default to False.

  • n_sources_threshold (float) – Number of eigenvalues of the \(RN^{-1}\) matrix below this threshold corresponds to the suggested number of sources to localize. Default to 1.0. For more details see Observation 1 in [1]_..

  • rank_threshold (float) – Number of eigenvalues of the \(RN^{-1}\) matrix below this threshold corresponds to the suggested rank optimization parameter. Default to 1.5. For more details see Proposition 3 in [1]_.

  • subject (str) – Subject name the analysis is performed for. Optional.

References

mvpure_py.viz.viz.plot_localized_sources(subject: str, lh_vertices: list = None, rh_vertices: list = None, hemi: str = 'both', color='crimson', **kwargs) Brain[source]#

Display mne.viz.Brain with foci corresponding to positions of localized sources.

Parameters:
  • subject (str) – Subject name the analysis is performed for.

  • lh_vertices (list (optional)) – List of localized vertices in left hemisphere.

  • rh_vertices (list (optional)) – List of localized vertices in right hemisphere.

  • hemi (str (default: "both")) – Hemisphere to show.

  • color (default ("crimson")) – Color to use for foci plotting. Can be anything matplotlib accepts.

Returns:

mne.viz.Brain

Return type:

mne.viz.Brain object with foci added on localized sources coordinates.

mvpure_py.viz.viz.plot_sources_with_activity(subject: str, stc: SourceEstimate, hemi: str = 'both', show_source_locations: bool = True, **kwargs) Brain[source]#

Display mne.SourceEstimate.plot() with additional option to preview localized sources as black dots. This functionality helps when the user wants to view time series for individual sources, because user knows where to click. If show_source_locations is set to False, it is equivalent to mne.SourceEstimate.plot().

Parameters:
  • subject (str) – Subject name the analysis is performed for. Optional.

  • stc (mne.SourceEstimate) – Source estimate obtained from signal reconstruction.

  • hemi (str) – Hemisphere to show. Default to ‘both’

  • show_source_locations (bool) – Whether to preview positions of localized sources as black dots. Default to True.

Returns:

mne.viz.Brain

Return type:

mne.viz.Brain object

Module contents#