API Reference
nispace.api – NiSpace main class
|
Main analysis object for spatial colocalization / imaging-transcriptomics-style workflows between a set of X (predictor) maps and a set of Y (target) maps, with optional Z covariate maps. |
nispace.datasets – Dataset fetchers
|
Fetch a brain template. |
|
Fetch a parcellation, as a |
|
Fetch reference/annotation maps (or parcellated data derived from them) for a dataset. |
|
Fetch a collection that defines a subset (and optional grouping) of maps. |
|
Re-index a parcellated-data DataFrame by a collection's set/weight structure. |
|
Deprecated alias for fetch_map_info(). |
|
Fetch a dataset's per-map metadata table (e.g. |
|
Fetch the overview plot PNG for a parcellation or reference dataset. |
|
Fetch an integrated example dataset, pre-parcellated with a given parcellation. |
nispace.workflows – Workflows
|
Colocalization workflow. |
|
Group-comparison colocalization workflow. |
|
Within-pair colocalization workflow (SPICE test). |
|
Set enrichment analysis (XSEA) workflow for group-level map(s). |
|
Group-comparison set enrichment analysis (XSEA) workflow. |
|
NiMARE colocalization workflow. |
|
NiMARE X-set enrichment analysis (XSEA) workflow. |
|
Deprecated wrapper for |
|
Deprecated wrapper for |
|
Deprecated wrapper for |
nispace.stats.coloc – Colocalization statistics
|
Backwards-compatibility alias for rank1d (same signature/behavior). |
|
Rank a 1D array using mid-ranks (average rank) for tied values. |
|
Rank a 2D array column-wise using mid-ranks, skipping NaN per column. |
|
Compute Pearson (or, with rank=True, Spearman) correlation for two 1D arrays. |
|
Compute Pearson correlation for two 1D arrays. |
|
Closed-form partial correlation between x and y, controlling for z. |
|
Closed-form partial Pearson correlation between x and y, controlling for z. |
|
Compute mutual information between x and y via sklearn's k-NN estimator. |
|
Multiple linear regression of predictor(s) x on target y (via pseudo-inverse). |
|
R2 of the regression of predictor(s) x on target y (see mlr). |
|
Beta coefficients for the regression of predictor(s) x on target y (see mlr). |
|
Dominance analysis: decompose R2 into each predictor's average contribution. |
|
Partial least squares regression of x on y via scikit-learn's NIPALS PLSRegression. |
|
Principal component regression: PCA-reduce x, then regress on y via r2. |
|
Fast PLS via the SIMPLS algorithm for a single target. |
|
Elastic-net regularized regression of x on y via sklearn.linear_model.ElasticNetCV. |
|
Lasso-regularized regression of x on y via sklearn.linear_model.LassoCV. |
|
Ridge-regularized regression of x on y via sklearn.linear_model.RidgeCV. |
nispace.stats.effectsize – Effect size calculation
|
Cohen's d for independent groups: pooled-SD standardized mean difference. |
|
NaN-aware Cohen's d for independent groups (see cohen). |
|
Cohen's d for paired/dependent samples: mean difference over SD of differences. |
|
NaN-aware Cohen's d for paired/dependent samples (see cohen_paired). |
|
Hedges' g: small-sample bias-corrected Cohen's d for independent groups. |
|
NaN-aware Hedges' g for independent groups (see hedges). |
|
Standard (mean/SD) z-score of a, optionally against a reference b. |
|
NaN-aware standard z-score of a, optionally against a reference b. |
|
NaN-aware robust z-score of a (median/MAD), optionally against a reference b. |
|
Percent change (a - b) / a * 100, element-wise. |
|
NaN-aware log fold-change log((a + c) / (b + c)), with an auto-computed shift c. |
nispace.stats.misc – Miscellaneous stats functions
|
Numba-compatible |
|
OLS residuals of |
|
OLS residuals of |
|
Partial residuals: regress x_nuisance from y while controlling for x_protect. |
|
Fisher's z-transformation of correlation coefficients. |
|
Inverse Fisher's z-transformation of correlation coefficients. |
|
Z-standardize a DataFrame/Series/ndarray, preserving its type. |
|
Permute group-membership labels for group-comparison null distributions. |
|
Return p-value for test value(s) against null array. |
|
Multiple-comparison correction via |
|
Effective number of independent tests from data matrix via eigendecomposition. |
|
Sidak correction using Meff effective number of tests. |
|
Max-T FWER correction ([31]). |
|
Step-down Max-T FWER correction ([31]). |
nispace.io – Imaging data input
|
Parcellates given imaging data using a specified parcellation. |
|
Load a JSON file, or pass through a dict-like object as a dict. |
|
Write a dict to a JSON file (pretty-printed, indent=4). |
|
Load one or more nifti/gifti images, passing through already-loaded objects. |
|
Load one or more label lists from paths, arrays, or Series. |
|
Load one or more distance matrices from paths, arrays, or DataFrames. |
|
Load one or more spin-permutation index/weight arrays from paths or arrays. |
|
Pickle, compress, and save to a file. |
|
Unpickle a python object saved with |
nispace.parcellate – Parcellation class
|
Class for parcellating arbitrary volumetric / surface data. |
nispace.nulls – Null map generation
|
Generate spatially-constrained (or fully random) null maps for one or more parcellated inputs. |
|
Moran Spectral Randomization (MSR) surrogate maps (Wagner & Dray 2015). |
|
Variogram-matched surrogate maps (Burt et al. 2020, brainsmash). |
|
Spatial autoregressive surrogate maps (Burt et al. 2018). |
|
Fully random (spatially unconstrained) null maps. |
|
Generate spin resampling indices for a surface parcellation. |
|
Apply precomputed spin indices to a 1D data array. |
|
Compute a parcel-by-parcel distance matrix for a volumetric or surface parcellation. |
|
Compute per-parcel mean voxel coordinates in world (MNI) space. |
|
Compute per-parcel mean vertex coordinates on a standard cortical surface. |
|
Per-row left/right-hemisphere correlation of parcellated data. |
|
Auto-detect per-parcel hemisphere membership for a parcellation. |
nispace.plotting – Plotting functions
|
Plot brain maps onto surfaces or anatomical volumes. |
|
Quick interactive nilearn surface viewer for parcellated or vertex-wise data on a fetched template/parcellation. |
|
Draw a categorical plot combining any mix of bars, violins, scatter points, summary dots, and errorbars, built on top of seaborn.objects. |
|
Draw a null distribution as shaded percentile bands with a median line (and optionally overlaid violins), per level of categorical_var. |
|
Draw a heatmap-style grid of markers whose color, size, and/or shape each independently encode a separate 2D array (data_colors, data_sizes, data_shapes), with an optional boolean mask and automatic legends for each encoded dimension. |
|
Map an internal stat/method name (e.g. |
|
Annotate a categorical axis plot with significance markers or p-value text. |
|
Move a figure-level legend (as produced by |
|
Map a numeric array to RGB colors from a seaborn palette, linearly normalizing values to [0, 1] before indexing into the palette. |
|
Turn off any axes in a 2D array of subplot axes that were never drawn into (i.e. |
|
Convert a linewidth in data units to linewidth in points. |
nispace.transforms – MNI space transforms
|
Transform a NIfTI image between MNI template spaces using EasyReg fields. |
|
Compute a voxel-wise displacement magnitude map for a MNI space transform. |
nispace.helpers – Third-party integration helpers
Note
Functions in this module require optional dependencies not installed with
NiSpace by default. Install them separately as needed (e.g.
pip install nimare for the NiMARE helpers).
|
Generate parcellated null maps from a fitted NiMARE MetaResult. |
|
Extract voxel z-threshold and cluster extent threshold from a NiMARE FWE-corrected result. |
|
Extract a binary (0/1) cluster mask from a NiMARE FWE-corrected MetaResult. |
nispace.utils – Utility functions
|
Set the "nispace" root logger's level and return whether INFO is enabled. |
|
Build a combined 1D NaN mask across one or more arrays sharing dim-0 length. |
|
Drop rows or columns containing NaN from an array/DataFrame/Series. |
|
Re-insert all-NaN rows/columns at given positions (inverse of dropping them). |
|
(Weighted) mean/median aggregation of a DataFrame grouped by a "set" index level. |
|
Format keyword arguments as an aligned two-row key/value log table. |
|
Get column names from a DataFrame, the name from a Series, or None if input is a numpy array. |
|
Lowercase a string, or each string element of a list (non-strings passed through). |
|
Auto-detect a volumetric image's background value from its border voxels. |
|
Broadcast a per-parcel value vector back into a full volume array. |
|
Aggregate vol_arr into parcel means, excluding NaN and any values in bg_values. |
|
Convert a per-parcel value vector into a full volumetric NIfTI image. |
|
Reassign a surface parcellation's integer labels to a new label sequence. |
|
Reassign a volumetric parcellation's integer labels to a new label sequence. |
|
Combine two or more NIfTI parcellation images into one labeled volume. |
|
Mirror/flip a volumetric image across the (affine-derived) x=0 hemisphere boundary. |
|
Mirror/flip a bilateral surface image pair across hemispheres. |