9.2.1. Parcellations#

Provide functions for parcellation.

junifer.data.parcellations.list_parcellations()#

List all the available parcellations.

Returns:
list of str

A list with all available parcellations.

junifer.data.parcellations.load_parcellation(name, parcellations_dir=None, resolution=None, path_only=False)#

Load a brain parcellation (including a label file).

If it is a built-in parcellaions and file is not present in the parcellations_dir directory, it will be downloaded.

Parameters:
namestr

The name of the parcellation. Check valid options by calling list_parcellations().

parcellations_dirstr or pathlib.Path, optional

Path where the parcellations files are stored. The default location is “$HOME/junifer/data/parcellations” (default None).

resolutionfloat, optional

The desired resolution of the parcellation to load. If it is not available, the closest resolution will be loaded. Preferably, use a resolution higher than the desired one. By default, will load the highest one (default None).

path_onlybool, optional

If True, the parcellation image will not be loaded (default False).

Returns:
Nifti1Image or None

Loaded parcellation image.

list of str

Parcellation labels.

pathlib.Path

File path to the parcellation image.

junifer.data.parcellations.merge_parcellations(parcellations_list, parcellations_names, labels_lists)#

Merge all parcellations from a list into one parcellation.

Parameters:
parcellations_listlist of niimg-like object

List of parcellations to merge.

parcellations_names: list of str

List of names for parcellations at the corresponding indices.

labels_listslist of list of str

A list of lists. Each list in the list contains the labels for the parcellation at the corresponding index.

Returns:
parcellationniimg-like object

The parcellation that results from merging the list of input parcellations.

labelslist of str

List of labels for the resultant parcellation.

junifer.data.parcellations.register_parcellation(name, parcellation_path, parcels_labels, overwrite=False)#

Register a custom user parcellation.

Parameters:
namestr

The name of the parcellation.

parcellation_pathstr or pathlib.Path

The path to the parcellation file.

parcels_labelslist of str

The list of labels for the parcellation.

overwritebool, optional

If True, overwrite an existing parcellation with the same name. Does not apply to built-in parcellations (default False).

Raises:
ValueError

If the parcellation name is already registered and overwrite is set to False or if the parcellation name is a built-in parcellation.

9.2.2. Coordinates#

Provide functions for list of coordinates.

junifer.data.coordinates.list_coordinates()#

List all the available coordinates lists (VOIs).

Returns:
list of str

A list with all available coordinates names.

junifer.data.coordinates.load_coordinates(name)#

Load coordinates.

Parameters:
namestr

The name of the coordinates.

Returns:
numpy.ndarray

The coordinates.

list of str

The names of the VOIs.

junifer.data.coordinates.register_coordinates(name, coordinates, voi_names, overwrite=False)#

Register coordinates.

Parameters:
namestr

The name of the coordinates.

coordinatesnumpy.ndarray

The coordinates. This should be a 2-dimensional array with three columns. Each row corresponds to a volume-of-interest (VOI) and each column corresponds to a spatial dimension (i.e. x, y, and z-coordinates).

voi_nameslist of str

The names of the VOIs.

overwritebool, optional

If True, overwrite an existing list of coordinates with the same name. Does not apply to built-in coordinates (default False).

9.2.3. Masks#

Provide functions for masks.

junifer.data.masks.get_mask(masks, target_data, extra_input=None)#

Get mask, tailored for the target image.

Parameters:
masksstr, dict or list of dict or str

The name of the mask, or the name of a callable mask and the parameters of the mask as a dictionary. Several masks can be passed as a list.

target_datadict

The corresponding item of the data object to which the mask will be applied.

extra_inputdict, optional

The other fields in the data object. Useful for accessing other data kinds that needs to be used in the computation of masks (default None).

Returns:
Nifti1Image

The mask image.

junifer.data.masks.list_masks()#

List all the available masks.

Returns:
list of str

A list with all available masks names.

junifer.data.masks.load_mask(name, resolution=None, path_only=False)#

Load mask.

Parameters:
namestr

The name of the mask.

resolutionfloat, optional

The desired resolution of the mask to load. If it is not available, the closest resolution will be loaded. Preferably, use a resolution higher than the desired one. By default, will load the highest one (default None).

path_onlybool, optional

If True, the mask image will not be loaded (default False).

Returns:
Nifti1Image, Callable or None

Loaded mask image.

pathlib.Path or None

File path to the mask image.

junifer.data.masks.register_mask(name, mask_path, overwrite=False)#

Register a custom user mask.

Parameters:
namestr

The name of the mask.

mask_pathstr or pathlib.Path

The path to the mask file.

overwritebool, optional

If True, overwrite an existing mask with the same name. Does not apply to built-in mask (default False).

Raises:
ValueError

If the mask name is already registered and overwrite is set to False or if the mask name is a built-in mask.