nispace.api.NiSpace#

class nispace.api.NiSpace(x, y=None, z=None, x_labels=None, y_labels=None, z_labels=None, data_space='mni152', standardize='xz', drop_nan=False, parcellation=None, parcellation_labels=None, parcellation_space='MNI152NLin2009cAsym', parcellation_hemi=['L', 'R'], parcellation_symmetric=False, parcellation_l2rmap=None, parcellation_idc_lh=None, parcellation_idc_rh=None, parcellation_idc_sc=None, parcellation_dist_mat=None, resampling_target='data', n_proc=1, verbose=True, dtype=<class 'numpy.float32'>, **kwargs)[source]#

Bases: object

The NiSpace class. To be imported via from nispace import NiSpace. Docs under construction.

Parameters:
  • x (ndarray | DataFrame | Series | List[str | Path | Nifti1Image | GiftiImage] | Dict[str, str | Path | Nifti1Image | GiftiImage]) –

  • y (ndarray | DataFrame | Series | List[str | Path | Nifti1Image | GiftiImage] | Dict[str, str | Path | Nifti1Image | GiftiImage]) –

  • z (Literal['gm'] | ~numpy.ndarray | ~pandas.core.frame.DataFrame | ~pandas.core.series.Series | ~typing.List[str | ~pathlib.Path | ~nibabel.nifti1.Nifti1Image | ~nibabel.gifti.gifti.GiftiImage] | ~typing.Dict[str, str | ~pathlib.Path | ~nibabel.nifti1.Nifti1Image | ~nibabel.gifti.gifti.GiftiImage]) –

  • x_labels (Sequence[str]) –

  • y_labels (Sequence[str]) –

  • z_labels (Sequence[str]) –

  • data_space (Literal['mni152', 'fsaverage', 'fslr']) –

  • standardize (Literal['x', 'y', 'z', 'xy', 'xz', 'yz', 'xyz'] | bool) –

  • drop_nan (bool) –

  • parcellation (str | Path | Nifti1Image | GiftiImage) –

  • parcellation_labels (Sequence[str]) –

  • parcellation_space (Literal['mni152', 'fsaverage', 'fslr']) –

  • parcellation_hemi (Literal['R', 'L'] | ~typing.Sequence[~typing.Literal['L', 'R']]) –

  • parcellation_symmetric (bool) –

  • parcellation_l2rmap (DataFrame) –

  • parcellation_idc_lh (Sequence[int]) –

  • parcellation_idc_rh (Sequence[int]) –

  • parcellation_idc_sc (Sequence[int]) –

  • parcellation_dist_mat (ndarray | DataFrame) –

  • resampling_target (Literal['data', 'parcellation']) –

  • n_proc (int) –

  • verbose (bool) –

  • dtype (type | str) –

clean_y(how, covariates_within=None, covariates_between=None, combat=False, combat_keep=None, combat_train=None, combat_model=None, combat_kwargs={}, n_proc=None, replace=True, verbose=None)[source]#
colocalize(method=None, X_reduction=None, Y_transform=None, xsea=None, xsea_aggregation_method='mean', X=None, Y=None, Z=None, Z_regression=True, store=True, n_proc=None, seed=None, verbose=None, dist_mat_kwargs={}, force_dict=False, **kwargs)[source]#
copy(deep=True, verbose=True)[source]#
correct_p(method=None, mc_alpha=0.05, mc_method='fdr_bh', mc_dimension='array', store=True, verbose=None)[source]#
fit()[source]#

“Fit” the NiSpace class instance, i.e., check input and apply parcellation if necessary. Input and parameters are set on initialization.

Parameters:

None

Returns:

self – Returns the instance itself.

Return type:

object

static from_pickle(filepath, verbose=True)[source]#

Load a NiSpace object from a pickle file.

Parameters:
  • filepath (str) – Filepath to load the NiSpace object from.

  • verbose (bool, optional) – Whether to print verbose output. Defaults to True.

Returns:

nispace_object – The loaded NiSpace object.

Return type:

NiSpace

get_colocalizations(method=None, stats=None, X_reduction=None, Y_transform=None, xsea=None, get_nulls=False, nulls_permute_what=None, force_dict=False, verbose=None)[source]#
get_p_values(method=None, permute_what=None, stats=None, xsea=None, norm=False, mc_method=None, X_reduction=None, Y_transform=None, force_dict=False, verbose=None)[source]#
get_x(X_reduction=None, verbose=None)[source]#
get_y(Y_transform=None, verbose=None)[source]#
get_z(verbose=None)[source]#
permute(what, method=None, X_reduction=None, Y_transform=None, xsea=None, n_perm=10000, maps_which='X', maps_nulls=None, maps_method='moran', dist_mat=None, sets_X_background=None, p_tails=None, p_from_average_y_coloc='auto', n_proc=None, seed=None, store=True, verbose=None, force_dict=False, **kwargs)[source]#
plot(kind='categorical', method=None, stats=None, X_reduction=None, Y_transform=None, xsea=None, Y_labels=None, X_labels=None, plot_nulls=True, plot_p=True, permute_what=None, title='auto', sort_colocs=False, colocalizations_dict=None, nulls_dict=None, p_dict=None, pc_dict=None, mc_method='fdr_bh', fig=None, ax=None, figsize=None, show=True, plot_kwargs={}, nullplot_kwargs={}, verbose=None)[source]#
reduce_x(reduction, mean_by_set=False, weighted_mean=False, n_components=None, min_ev=None, fa_method='minres', fa_rotation='promax', seed=None, store=True, verbose=None)[source]#

Performs dimensionality reduction on X data. Under construction.

to_pickle(filepath, save_nulls=True, verbose=None)[source]#

Save the NiSpace object to a pickle file.

Parameters:
  • filepath (str) – Filepath to save the NiSpace object to.

  • save_nulls (bool, optional) – Whether to save the nulls. Defaults to True.

  • verbose (bool, optional) –

transform_y(transform, groups=None, subjects=None, Y=None, Y_name='Y', store=True, verbose=None)[source]#
transform_z(transform='Y', groups='Y', subjects='Y', replace=True, verbose=None)[source]#