neurocaps.analysis.CAP#
- class CAP(parcel_approach=None, groups=None)[source]#
Co-Activation Patterns (CAPs) Class.
Performs k-means clustering for CAP identification, computes temporal dynamics metrics, and provides visualization tools for analyzing brain activation patterns.
- Parameters:
parcel_approach (
ParcelConfig,ParcelApproach, orstr, default=None) – Specifies the parcellation approach to use. Options are “Schaefer”, “AAL”, or “Custom”. Can be initialized with parameters, as a nested dictionary, or loaded from a pickle file. For detailed documentation on the expected structure, see the type definitions forParcelConfigandParcelApproachin the “See Also” section.groups (
dict[str, list[str]]orNone, default=None) – Optional mapping of group names to lists of subject IDs for group-specific analyses.
Properties#
- parcel_approach:
ParcelApproach Parcellation information with “maps” (path to parcellation file), “nodes” (labels), and “regions” (anatomical regions or networks).
- groups:
dict[str, list[str]]orNone: Mapping of groups names to lists of subject IDs.
- subject_table:
dict[str, str]orNone Lookup table mapping subject IDs to their groups. Defined after running
self.get_caps().- n_clusters:
int,list[int], orNone An integer or list of integers representing the number of clusters used for k-means.
- cluster_selection_method:
strorNone: Method used to identify the optimal number of clusters.
- n_cores:
intorNone Number of cores specified used for multiprocessing with Joblib.
- runs:
int,list[int | str], orNone Run IDs specified in the analysis.
- standardize:
boolorNone Whether region-of-interests (ROIs)/columns were standardized during analysis.
- means:
dict[str, np.array]orNone Group-specific feature means if standardization was applied.
{"GroupName": np.array(shape=[1, ROIs])}
- stdev:
dict[str, np.array]orNone Group-specific feature standard deviations if standardization was applied.
{"GroupName": np.array(shape=[1, ROIs])}
- concatenated_timeseries:
dict[str, np.array]orNone Group-specific concatenated timeseries data.
{"GroupName": np.array(shape=[(participants x TRs), ROIs])}
- kmeans:
dict[str, sklearn.cluster.KMeans]orNone Group-specific k-means models.
{"GroupName": sklearn.cluster.KMeans}
- caps:
dict[str, dict[str, np.array]]orNone Cluster centroids for each group and CAP.
{"GroupName": {"CAP-1": np.array(shape=[1, ROIs]), "CAP-2": np.array(shape=[1, ROIs])}}
- cluster_scores:
dict[str, str | dict[str, float]]orNone Scores for different cluster sizes by group.
{"Cluster_Selection_Method": str, "Scores": {"GroupName": {2: float, 3: float}}}
- optimal_n_clusters:
dict[str, int]orNone Optimal number of clusters by group if cluster selection was used.
{"GroupName": int}
- variance_explained:
dict[str, float]orNone Total variance explained by each group’s model.
{"GroupName": float}
- region_means:
dict[str, dict[str, list[str] | np.array]]orNone Region-averaged values used for visualization. Defined after running
self.caps2plot().{"GroupName": {"Regions": [...], "CAP-1": np.array(shape=[1, Regions]), "CAP-2": np.array(shape=[1, Regions])}}
Changed in version 0.23.4: Replaces
region_capsand adds the “Regions” key for each group. For backwards compatibility,region_caps, which doesn’t include the “Regions” key is still available.- outer_products:
dict[str, dict[str, np.array]]orNone Outer product matrices for visualization. Defined after running
self.caps2plot().{"GroupName": {"CAP-1": np.array(shape=[ROIs, ROIs]), "CAP-2": np.array(shape=[ROIs, ROIs])}}
- cosine_similarity:
dict[str, dict[str, list[str] | np.array]]orNone Cosine similarities between CAPs and the regions specified in
parcel_approach. Defined after runningself.caps2radar().{"GroupName": {"Regions": [...], "CAP-1": {"High Amplitude": np.array(shape=[1, Regions]), "Low Amplitude": np.array(shape=[1, Regions])}}
See also
neurocaps.typing.ParcelConfigType definition representing the configuration options and structure for the Schaefer and AAL parcellations.
neurocaps.typing.ParcelApproachType definition representing the structure of the Schaefer, AAL, and Custom parcellation approaches.
Note
Default Group Name: The default group name is “All Subjects” when no groups are specified.
Custom Parcellations: Refer to the NeuroCAPs’ Parcellation Documentation for detailed explanations and example structures for Custom parcellations.
Methods
calculate_metrics(subject_timeseries[, tr, ...])Compute Participant-wise CAP Metrics.
caps2corr([output_dir, suffix_title, ...])Generate Pearson Correlation Matrix for CAPs.
caps2niftis(output_dir[, suffix_filename, ...])Convert CAPs to NifTI Statistical Maps.
caps2plot([output_dir, suffix_title, ...])Generate Heatmaps and Outer Product Plots for CAPs.
caps2radar([output_dir, suffix_title, ...])Generate Radar Plots for CAPs using Cosine Similarity.
caps2surf([output_dir, suffix_title, ...])Project CAPs onto Surface Plots.
get_caps(subject_timeseries[, runs, ...])Perform K-Means Clustering to Identify CAPs.