neurocaps.analysis.CAP.caps2corr
- CAP.caps2corr(output_dir=None, suffix_title=None, suffix_filename=None, show_figs=True, save_plots=True, return_df=False, save_df=False, **kwargs)[source]
Generate Pearson Correlation Matrix for CAPs.
Produces a correlation matrix of all CAPs and visualizes it using
seaborn.heatmap. Can also produce a pandas Dataframe of the correlation matrix where each element contains its uncorrected p-value in parenthesis, with a single asterisk if < 0.05, a double asterisk if < 0.01, and a triple asterisk < 0.001. Note, if groups were given when theCAPclass was initialized, separate correlation matrices will be generated for all groups.- Parameters:
output_dir (
os.PathLikeorNone, default=None) -- Directory to save plots (ifsave_plotsis True) and correlation matrices DataFrames (ifsave_dfis True). The directory will be created if it does not exist. If None, plots and dataFrame will not be saved.suffix_title (
strorNone, default=None) -- Appended to the title of each plot.suffix_filename (
strorNone, default=None) --Appended to the filename of each saved plot if
output_diris provided.Added in version 0.19.0.
show_figs (
bool, default=True) -- Display figures.save_plots (
bool, default=True) -- If True, plots are saves as png images. For this to be used,output_dirmust be specified.return_df (
bool, default=False) -- If True, returns a dictionary with a correlation matrix for each group.save_df (
bool, default=False,) -- If True, saves the correlation matrix contained in the DataFrames as csv files. For this to be used,output_dirmust be specified.**kwargs --
Keyword arguments used when modifying 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 each plot.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.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 each cell.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:
strorNone, default=None -- Color of the edges.alpha:
floatorNone, default=None -- Controls transparency and ranges from 0 (transparent) to 1 (opaque).bbox_inches:
strorNone, default="tight" -- Alters size of the whitespace in the saved image.cmap:
str,callabledefault="coolwarm" -- Color map for the plot cells. Options include strings to call seaborn's pre-made palettes,seaborn.diverging_palettefunction to generate custom palettes, andmatplotlib.color.LinearSegmentedColormapto generate custom palettes.vmin:
floatorNone, default=None -- The minimum value to display in colormap.vmax:
floatorNone, default=None -- The maximum value to display in colormap.
- Returns:
dict[str, pd.DataFrame] -- An instance of a pandas DataFrame for each group.
Note
Color Palettes: Refer to seaborn's Color Palettes for valid pre-made palettes.