Giving credit

4.5.1.1. nilearn.region.img_to_signals_labels

nilearn.region.img_to_signals_labels(niimgs, labels_img, mask_img=None, background_label=0, order='F')

Extract region signals from image.

This function is applicable to regions defined by labels.

labels, niimgs and mask shapes and affines must fit. This function performs no resampling.

Parameters :

niimgs: niimg :

input images.

labels_img: niimg :

regions definition as labels. By default, the label zero is used to denote an absence of region. Use background_label to change it.

mask_img: niimg :

mask to apply to labels before extracting signals. Every point outside the mask is considered as background (i.e. no region).

background_label: number :

number representing background in labels_img.

order: str :

ordering of output array (“C” or “F”). Defaults to “F”.

Returns :

signals: numpy.ndarray :

Signals extracted from each region. One output signal is the mean of all input signals in a given region. If some regions are entirely outside the mask, the corresponding signal is zero. Shape is: (scan number, number of regions)

labels: list or tuple :

corresponding labels for each signal. signal[:, n] was extracted from the region with label labels[n].