Reference API

nispace.api – NiSpace main class

NiSpace(x[, y, z, x_labels, y_labels, ...])

The NiSpace class.

nispace.datasets – Dataset fetchers

fetch_template([template, res, desc, hemi, ...])

Fetch a brain template.

fetch_parcellation([parcellation, space, ...])

Fetch a parcellation.

fetch_reference(dataset[, maps, space, ...])

fetch_collection(collection[, dataset, ...])

Fetch a collection that defines a subset (and optional grouping) of maps.

apply_collection(data, collection)

fetch_metadata(dataset[, maps, collection, ...])

fetch_example(example[, parcellation, ...])

Fetch an example dataset.

nispace.workflows – Workflows

simple_colocalization(y[, x, z, ...])

group_comparison(y, design[, x, z, ...])

simple_xsea(y[, x, z, x_collection, ...])

nispace.stats.coloc – Colocalization statistics

rank_array(array)

rank1d(arr)

Rank a 1D array using mid-ranks (average rank) for tied values.

rank2d(arr)

Rank a 2D array column-wise using mid-ranks.

corr(x, y[, rank])

Compute Pearson or Spearman correlation for two 1D arrays.

pearson(x, y)

Compute Pearson correlation for two 1D arrays.

partialcorr(x, y, z[, rank])

Computes partial correlation between {x} and {y} controlled for {z}

partialpearson(x, y, z)

Computes partial Pearson correlation between {x} and {y} controlled for {z}

mutualinfo(x, y[, n_neighbors])

Compute mutual information between x and y using sklearn.

mlr(x, y[, adj_r2, intercept])

Compute Regression of predictor(s) x on target y.

r2(x, y[, adj_r2])

Compute R2 for Regression of predictor(s) x on target y.

beta(x, y[, intercept])

Compute beta coefficients for Regression of predictor(s) x on target y.

dominance(x, y[, adj_r2, verbose])

pls(x, y[, n_components])

pcr(x, y[, adj_r2, n_components])

fast_pls1(x, y, n_components)

Fast PLS (SIMPLS) for a single target.

elasticnet(x, y[, cv, seed])

lasso(x, y[, cv, seed, kwargs])

ridge(x, y[, cv, seed, kwargs])

nispace.stats.effectsize – Effect size calculation

cohen(a, b)

cohen_nan(a, b)

cohen_paired(a, b)

cohen_paired_nan(a, b)

hedges(a, b)

hedges_nan(a, b)

zscore(a[, b])

zscore_nan(a[, b])

rzscore_nan(a[, b])

prc(a, b)

logfc_nan(a, b)

nispace.stats.misc – Miscellaneous stats functions

np_any_axis1(x)

Numba compatible version of np.any(x, axis=1).

residuals(x, y[, decenter])

Compute residuals for Regression with dependent variable y and independent variable(s) x.

residuals_nan(x, y[, decenter])

Compute residuals for Regression with dependent variable y and independent variable(s) x.

partial_residuals_nan(x_nuisance, x_protect, y)

Partial residuals: regress x_nuisance from y while controlling for x_protect.

rho_to_z(array[, replace_1])

Fisher's z-transformation of correlation coefficients.

z_to_rho(array)

Inverse Fisher's z-transformation of correlation coefficients.

zscore_df(df[, along, force_df])

Z-standardizes array and returns pandas dataframe.

permute_groups(groups[, strategy, paired, ...])

null_to_p(test_value, null_array[, tail, ...])

Return p-value for test value(s) against null array.

mc_correction(p_array[, alpha, method, how, ...])

compute_meff(X[, method])

Effective number of independent tests from data matrix via eigendecomposition.

meff_sidak_correction(p_array, meff[, ...])

Sidak correction using Meff effective number of tests.

maxT_correction(obs_stats, null_colocs, stat)

Max-T FWER correction (Westfall & Young 1993).

step_maxT_correction(obs_stats, null_colocs, ...)

Step-down Max-T FWER correction (Westfall & Young 1993).

nispace.io – Imaging data input

parcellate_data(data[, data_labels, ...])

Parcellates given imaging data using a specified parcellation.

read_json(json_path)

write_json(json_dict, json_path)

load_img(img[, override_file_format])

load_labels(labels[, concat, header, index])

load_distmat(distmat)

load_spinmat(spinmat)

load_l2rmap(l2rmap[, header, index, threshold])

to_pickle(obj, filepath[, use_dill])

Pickle, compress, and save to a file.

from_pickle(filepath[, use_dill])

Unpickle a python object.

nispace.parcellate – Parcellation class

Parcellater(parcellation, space[, ...])

Class for parcellating arbitrary volumetric / surface data.

nispace.nulls – Null map generation

generate_null_maps(method, data, parcellation)

nulls_moran(data_1d, dist_mat[, n_nulls, seed])

nulls_burt2020(data_1d, dist_mat[, n_nulls, ...])

nulls_burt2018(data_1d, dist_mat[, n_nulls, ...])

nulls_random(data_1d[, dist_mat, n_nulls, seed])

generate_spins(parc, parc_space[, n_perm, ...])

Generate spin resampling indices for a surface parcellation.

apply_spins(data_1d, spins_lh, spins_rh, ...)

Apply precomputed spin indices to a 1D data array.

get_distance_matrix(parc, parc_space[, ...])

find_vol_parc_centroids(parc[, affine, ...])

find_surf_parc_centroids(parc[, parc_space, ...])

correlate_hemis_parc(data[, parc_idc_lh, ...])

find_parcel_hemispheres(parcellation)

nispace.plotting – Plotting functions

brainplot(data[, parcellation, kind, space, ...])

Plot brain maps onto surfaces or anatomical volumes.

view_surf([data, parcellation, hemi, ...])

catplot(fig, ax, data_long[, ...])

nullplot(fig, ax, data_long[, ...])

heatmap(ax[, data_colors, data_sizes, ...])

nice_stats_labels(string[, add_dollars])

print_significance(ax, p_values[, q_values, ...])

Annotate a categorical axis plot with significance markers or p-value text.

move_legend_fig_to_ax(fig, ax, loc[, ...])

colors_from_values(values, palette_name)

hide_empty_axes(axes)

linewidth_from_data_units(linewidth, axis[, ...])

Convert a linewidth in data units to linewidth in points.

nispace.utils – Utility functions

set_log(lgr[, verbose])

nan_detector(*arrays)

remove_nan(data[, which])

fill_nan(data, idx[, idx_label, which])

mean_by_set_df(df[, mean_by_set, weighted, ...])

print_arg_pairs(**kwargs)

get_column_names(df_or_series[, force_list])

Get column names from a DataFrame, the name from a Series, or None if input is a numpy array.

lower(str_list)

get_background_value(img[, border_size])

vect_to_vol_arr(vect, parc_arr, parc_idc[, ...])

vol_to_vect_arr(vol_arr, parc_arr, parc_idc, ...)

Aggregate vol_arr into parcel means, excluding NaN and any values in bg_values.

parc_vect_to_vol(vect, parc)

relabel_gifti_parc(parc[, new_labels])

relabel_nifti_parc(parc[, new_order, ...])

merge_parcellations(parcellations[, labels, ...])

mirror_nifti(img[, affine, direction, ...])

mirror_gifti(img[, direction, match_r, mask])