Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the user guide for the big picture.

nilearn.regions.img_to_signals_labels#

nilearn.regions.img_to_signals_labels(imgs, labels_img, mask_img=None, background_label=0, order='F', strategy='mean')[source]#

Extract region signals from image.

This function is applicable to regions defined by labels.

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

Parameters
imgslist of Niimg-like objects

See input-output. Input images.

labels_imgNiimg-like object

See http://nilearn.github.io/manipulating_images/input_output.html regions definition as labels. By default, the label zero is used to denote an absence of region. Use background_label to change it.

mask_imgNiimg-like object, optional

See http://nilearn.github.io/manipulating_images/input_output.html Mask to apply to labels before extracting signals. Every point outside the mask is considered as background (i.e. no region).

background_labelnumber, optional

Number representing background in labels_img. Default=0.

orderstr, optional

Ordering of output array (“C” or “F”). Default=”F”.

strategystr, optional

The name of a valid function to reduce the region with. Must be one of: sum, mean, median, minimum, maximum, variance, standard_deviation. Default=’mean’.

Returns
signalsnumpy.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)

labelslist or tuple

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