NIPY logo

Site Navigation

NIPY Community

Table Of Contents

Next topic

neurospin.spatial_models.parcellation

This Page

neurospin.spatial_models.parcel_io

Module: neurospin.spatial_models.parcel_io

Utility functions for mutli-subjectParcellation: this basically uses nipy io lib to perform IO opermation in parcel definition processes

Functions

nipy.neurospin.spatial_models.parcel_io.Parcellation_based_analysis(Pa, test_images, numbeta, swd='/tmp', DMtx=None, verbose=1, method_id=0)

This function computes parcel averages and RFX at the parcel-level

Parameters :

Pa Parcellation instance that is updated in this function :

test_images: double list of paths of functional images used :

as input to for inference. Normally these are contrast images. double list is [number of subjects [number of contrasts]]

numbeta: list of int of the associated ids :

swd=’/tmp’: write directory :

DMtx=None: array od shape (nsubj,ncon) :

a design matrix for second-level analyses

(not implemented yet)

verbose=1: verbosity level :

method_id = 0: an id of the method used. :

This is useful to compare the outcome of different Parcellation+RFX procedures

nipy.neurospin.spatial_models.parcel_io.Parcellation_output(Pa, mask_images, learning_images, coord, nbru, verbose=1, swd='/tmp')

Function that produces images that describe the spatial structure of the parcellation. It mainly produces label images at the group and subject level

Parameters :

Pa : Parcellation instance that describes the parcellation

mask_images: list of images paths that define the mask :

learning_images: list of float images containing the input data :

coord: array of shape (nvox,3) that contains(approximated) :

MNI-coordinates of the brain mask voxels considered in the parcellation process

nbru: list of subject ids :

verbose=1 : verbosity level

swd = ‘/tmp’: write directory :

nipy.neurospin.spatial_models.parcel_io.mask_parcellation(mask_images, nb_parcel, output_image=None)

Performs the parcellation of a certain mask

Parameters :

mask_images: list of strings, :

paths of the mask images that define the common space.

nb_parcel: int, :

number of desired parcels

output_image: string, optional :

path of the output image

Returns :

wim: Nifti1Imagine instance, the resulting parcellation :

nipy.neurospin.spatial_models.parcel_io.one_subj_parcellation(MaskImage, betas, nbparcel, nn=6, method='ward', write_dir=None, mu=10.0, verbose=0, fullpath=None)

Parcellation of a one-subject dataset Return: a tuple (Parcellation instance, parcellation labels)

Parameters :

MaskImage: path to the mask-defining_image of the subject :

betas: list of paths to activation images from the subject :

nbparcel, int : number fo desired parcels

nn=6: number of nearest neighbors to define the image topology :

(6, 18 or 26)

method=’ward’: clustering method used, to be chosen among :

‘ward’, ‘gkm’, ‘ward_and-gkm’ ‘ward’: Ward’s clustering algorithm ‘gkm’: Geodesic k-means algorithm, random initialization ‘gkm_and_ward’: idem, initialized by Ward’s clustering

write_dir=None: write directory. If fullpath is None too, then no file output. :

mu = 10., float: the relative weight of anatomical information :

verbose=0: verbosity mode :

fullpath=None, string, :

path of the output image If write_dir and fullpath are None then no file output. If only fullpath is None then it is the write dir + a name depending on the method.

Note :

—- :

Ward’s method takes time (about 6 minutes for a 60K voxels dataset) :

Geodesic k-means is ‘quick and dirty’ :

Ward’s + GKM is expensive but quite good :

To reduce CPU time, rather use nn=6 (especially with Ward) :

nipy.neurospin.spatial_models.parcel_io.parcel_input(mask_images, nbeta, learning_images, ths=0.5, fdim=3, affine=None)

Instantiating a Parcel structure from a give set of input

Parameters :

mask_images: list of strings, :

paths of the mask images that define the common space. These can be cortex segmentations (at the same resolution as the remainder of the data) Note that nsubj = len(mask_images)

nbeta: list of integers, :

ids of the contrast of under study

learning_images: path of functional images used as input to the :

parcellation procedure. normally these are statistics (student/normal) images.

ths=.5: threshold to select the regions that are common across subjects. :

if ths = .5, thethreshold is half the number of subjects

fdim=3, int :

dimension of the data used in subsequent analyses if smaller than len(nbeta), a PCA is perfomed to reduce the information in the data

affine=None provides the transformation to Talairach space. :

if affine==None, this is taken from the image header

nipy.neurospin.spatial_models.parcel_io.parcellation_output_with_paths(Pa, mask_images, group_path, indiv_path)

Function that produces images that describe the spatial structure of the parcellation. It mainly produces label images at the group and subject level

Parameters :

Pa : Parcellation instance that describes the parcellation

mask_images: list of images paths that define the mask :

coord: array of shape (nvox,3) that contains(approximated) :

MNI-coordinates of the brain mask voxels considered in the parcellation process

group_path, string, path of the group-level parcellation image :

indiv_path, list of strings, paths of the individual parcellation images :