CAP.caps2plot#

CAP.caps2plot(output_dir=None, suffix_title=None, suffix_filename=None, plot_options='outer_product', visual_scope='regions', show_figs=True, subplots=False, as_pickle=False, **kwargs)[source]#

Generate Heatmaps and Outer Product Plots for CAPs.

Plot CAPs as heatmaps or outer products at the node or region levels. Separate plots are generated for each group.

Parameters:
  • output_dir (str or None, default=None) – Directory for saving plots as png files. The directory will be created if it does not exist. If None, plots will not be saved.

  • suffix_title (str or None, default=None) – Appended to the title of each plot.

  • suffix_filename (str or None, default=None) – Appended to the filename of each saved plot if output_dir is provided.

  • plot_options ({“outer_product”, “heatmap”} or list["outer_product", "heatmap"], default=”outer_product”) – Type of plots to create. Options are “outer_product” or “heatmap”.

  • visual_scope ({“regions”, “nodes”} or list["regions", "nodes"], default=”regions”) – Determines whether plotting is done at the region level or node level. For “regions”, the values of all nodes in the same regions (including both hemispheres) are averaged together then plotted. For “nodes”, plots individual node values separately.

  • show_figs (bool, default=True) – Display figures.

  • subplots (bool, default=True) – Produce subplots for outer product plots, combining all plots into a single figure.

  • as_pickle (bool, default=False) –

    When output_dir is specified, plots are saved as pickle files, which can be further modified, instead of png images.

    Added in version 0.26.5.

  • **kwargs

    Keyword arguments used when saving figures. Valid keywords include:

    • dpi: int, default=300 – Dots per inch for the figure.

    • figsize: tuple, default=(8, 6) – Size of the figure in inches.

    • fontsize: int, default=14 – Font size for the title of individual plots or subplots.

    • hspace: float, default=0.4 – Height space between subplots.

    • wspace: float, default=0.4 – Width space between subplots.

    • xticklabels_size: int, default=8 – Font size for x-axis tick labels.

    • yticklabels_size: int, default=8 – Font size for y-axis tick labels.

    • shrink: float, default=0.8 – Fraction by which to shrink the colorbar.

    • cbarlabels_size: int, default=8 – Font size for the colorbar labels.

    • nrow: int, default=varies (max 5) – Number of rows for subplots. Default varies but the maximum is 5.

    • ncol: int or None, default=None – Number of columns for subplots. Default varies but the maximum is 5.

    • suptitle_fontsize: float, default=0.7 – Font size for the main title when subplot is True.

    • tight_layout: bool, default=True – Use tight layout for subplots.

    • rect: list[int], default=[0, 0.03, 1, 0.95] – Rectangle parameter for tight_layout when subplots are True. Fixes whitespace issues.

    • sharey: bool, default=True – Share y-axis labels for subplots.

    • xlabel_rotation: int, default=0 – Rotation angle for x-axis labels.

    • ylabel_rotation: int, default=0 – Rotation angle for y-axis labels.

    • annot: bool, default=False – Add values to cells.

    • annot_kws: dict, default=None – Customize the annotations.

    • fmt: str, default=”.2g” – Modify how the annotated vales are presented.

    • linewidths: float, default=0 – Padding between each cell in the plot.

    • borderwidths: float, default=0 – Width of the border around the plot.

    • linecolor: str, default=”black” – Color of the line that seperates each cell.

    • edgecolors: str or None, default=None – Color of the edges.

    • alpha: float or None, default=None – Controls transparency and ranges from 0 (transparent) to 1 (opaque).

    • bbox_inches: str or None, default=”tight” – Alters size of the whitespace in the saved image.

    • hemisphere_labels: bool, default=False – When visual_scope="nodes", shows simplified left/right hemisphere division line instead of individual node labels (only for Custom and Schaefer parcellations). For Custom parcellations, assumes labels are ordered such that all left hemisphere nodes come before right hemisphere nodes. Ignores edgecolors; linewidths/linecolor only affect division line.

    • cmap: str, callable default=”coolwarm” – Color map for the plot cells. Options include strings to call seaborn’s pre-made palettes, seaborn.diverging_palette function to generate custom palettes, and matplotlib.color.LinearSegmentedColormap to generate custom palettes.

    • vmin: float or None, default=None – The minimum value to display in colormap.

    • vmax: float or None, default=None – The maximum value to display in colormap.

Returns:

self

Note

Parcellation Approach: the “nodes” and “regions” subkeys are required in parcel_approach for this method.

Color Palettes: Refer to seaborn’s Color Palettes for valid pre-made palettes.