9.4.1. Nilearn#
This package provides re-implementations of some of the functions in nilearn.
Provide imports for custom nilearn objects sub-package.
- class junifer.external.nilearn.JuniferNiftiSpheresMasker(seeds, radius=None, mask_img=None, agg_func=<function mean>, allow_overlap=False, dtype=None, **kwargs)#
Class for custom NiftiSpheresMasker.
Differs from
nilearn.maskers.NiftiSpheresMaskerin the following ways:it allows to pass any callable as the
agg_funcparameter.empty spheres do not create an error. Instead,
agg_funcis applied to an empty array and the result is passed.
- Parameters:
- seeds
listoffloat Seed definitions. List of coordinates of the seeds in the same space as the images (typically MNI or TAL).
- radius
float, optional Indicates, in millimeters, the radius for the sphere around the seed. If None, signal is extracted on a single voxel (default None).
- mask_imgNiimg-like object, optional
Mask to apply to regions before extracting signals (default None).
- agg_func
callable(), optional The function to aggregate signals using (default numpy.mean).
- allow_overlapbool, optional
If False, an error is raised if the maps overlap (default None).
- dtype
numpy.dtypeor “auto”, optional The dtype for the extraction. If “auto”, the data will be converted to int32 if dtype is discrete and float32 if it is continuous (default None).
- **kwargs
Keyword arguments are passed to the
nilearn.maskers.NiftiSpheresMasker.
- seeds
- inverse_transform(region_signals)#
Compute voxel signals from spheres signals.
- Parameters:
- region_signals1D/2D
numpy.ndarray Signal for each region. If a 1D array is provided, then the shape should be (number of elements,), and a 3D img will be returned. If a 2D array is provided, then the shape should be (number of scans, number of elements), and a 4D img will be returned.
- region_signals1D/2D
- Returns:
- voxel_signals
nibabel.nifti1.Nifti1Image Signal for each sphere. shape: (mask_img, number of scans).
- voxel_signals
- transform_single_imgs(imgs, confounds=None, sample_mask=None)#
Extract signals from a single 4D niimg.
- Parameters:
- imgs3D/4D Niimg-like object
Images to process. If a 3D niimg is provided, a singleton dimension will be added to the output to represent the single scan in the niimg.
- confounds
pandas.DataFrame, optional This parameter is passed to
nilearn.signal.clean(). Please see the related documentation for details. shape: (number of scans, number of confounds)- sample_mask
np.ndarray,listortuple, optional Masks the niimgs along time/fourth dimension to perform scrubbing (remove volumes with high motion) and/or non-steady-state volumes. This parameter is passed to
nilearn.signal.clean(). shape: (number of scans - number of volumes removed, )
- Returns:
- region_signals2D
numpy.ndarray Signal for each sphere. shape: (number of scans, number of spheres)
- region_signals2D
- Warns:
DeprecationWarningIf a 3D niimg input is provided, the current behavior (adding a singleton dimension to produce a 2D array) is deprecated. Starting in version 0.12, a 1D array will be returned for 3D inputs.