Bases: object
Temporary ROI class for nipy Ultimately, it should be merged with the nipy class
ROI definition requires an identifier an affine transform and a shape that can be used to
translate grid coordinates to position and to generate images from the DiscreteROI structure
The ROI can be derived from a image
roi.features is a dictionary of informations on the ROI elements. It is assumed that the ROI is sampled on a discrete grid, so that each feature is in fact a (voxel,feature_dimension) array
Methods
checks that the image is in the header of self
| Parameters: | image_path: (string) the path of an image (nifti) : |
|---|---|
| Returns: | True if the affine and shape of the given nifti file correpond : to the ROI’s. : |
Take all the <>0 sites of the image as the ROI
| Parameters: | image_path: string :
|
|---|
Define the ROI as the set of voxels of the image that have the pre-defined label
| Parameters: | image_path: ndarray :
label: int :
|
|---|
Define the ROI as the set of voxels of the image that is closest to the provided position
| Parameters: | image_path: string, :
position: array of shape (3,) :
|
|---|
Notes
everything could be performed in the image space
write a binary nifty image where the nonzero values are the ROI mask
| Parameters: | image_path: string, optional :
|
|---|
Given an array of data that is assumed to comprise the ROI, get the subset of values that correponds to voxel-based data in the ROI
| Parameters: | fid: string :
|
|---|---|
| Returns: | ldata: ndarray of shape (roi.nbvox, dim) :
|
Notes
this function creates a reduced feature array corresponding to the ROI item.
extract some roi-related information from an image
| Parameters: | fid: string :
image: string :
|
|---|
Bases: object
This class describes multiple ROIs that are not ‘discretized’, i.e. sampled on a discrete grid there are only 3 main members: self.id: an identifier self.k the number of ROIs under consideration self.roi_features : a dictionary of roi properties
fixme : currently lacks an __add__ method, and a method to be transformed to a multiple_discrete_roi
Methods
| append_roi | |
| as_multiple_balls | |
| check_features | |
| clean | |
| complete_roi_feature | |
| plot_roi_feature | |
| to_multiple_roi |
| Parameters: | id=”multiple_roi” string, roi identifier : k=1, int, number of rois that are included in the structure : |
|---|
self.as_multiple_balls(position, radius) Given a set of positions and radii, defines one roi at each (position/radius) couple
| Parameters: | position: array of shape (k,3): the set of positions : radius: array of shape (k): the set of radii : |
|---|
remove the regions for which valid==0
| Parameters: | valid: (boolean) array of shape self.k : |
|---|
boxplot the feature within the ROI Note that this assumes a 1-d feature
| Parameters: | fid the feature identifier : |
|---|
Bases: object
This is a class to deal with multiple discrete ROIs defined in a given space (mroi.affine, mroi.shape) provide the necessary referential information so that the mroi is basically defined as a multiple sets of 3D coordinates finally, there is two associated feature dictionaries:
fixme : - can create an ROI with k =0 ? Deal with taht case properly - merge append_balls and as_multiple_balls
Methods
self.as_multiple_balls(position, radius) Given a set of positions and radii, defines one roi at each (position/radius) couple
| Parameters: | position: array of shape (k,3): the set of positions : radius: array of shape (k): the set of radii : |
|---|
Check the consistency of the input values: affine should be a (4,4) array
all values of xyz should be in the range [0,d1]*[0,d2]*[0,d3] where self.shape = (d1,d2,d3), if shape is defined
check that self.roi_features have the coorect size i.e. f.shape[0]=self.k for f in self.roi_features and that self.discrete features have the correct size i.e. for f in self.roi_features: f is a list of length self.k f[i] is an array with dimensions consistent with xyz
Note: features that are not found consistent are removed
checks that the image is in the header of self
| Parameters: | image_path: (string) the path of an image : |
|---|
remove the regions for which valid==0
| Parameters: | valid: (boolean) array of shape self.k : |
|---|
Create a ‘position’ feature based on self.affine and self.indexes, which is simply an affine transform from self.xyz to the space of self
fixme : if a position is already available it does not need to be computed
the computed position is returned
Compute an ROI-level feature given the discrete features
| Parameters: | fid(string) the discrete feature under consideration : method=’average’ the assessment method : |
|---|---|
| Returns: | ldata: array of shape [self.k,fdim ] :
|
All the voxels of the image that have non-zero-value self.k becomes the number of values of the (discrete) image
| Parameters: | image_path: string :
labels=None : array of shape (nlabels)
|
|---|
write a int image where the nonzero values are the ROIs
| Parameters: | path: string, optional :
|
|---|---|
| Returns: | brifti image instance : |
boxplot the distribution of features within ROIs Note that this assumes 1-d features
| Parameters: | fid: string, :
ax: axis handle, optional : |
|---|
boxplot the feature within the ROI Note that this assumes a 1-d feature
| Parameters: | fid string, :
|
|---|
| Parameters: | fid (string): feature identifier : data: list of self.k arrays with shape(nk,p),with p>0 :
|
|---|
extract some discrete information from an image
| Parameters: | fid: string, feature id : image_path, string, optional :
image, brfiti image path, :
Note that either image_path or image has to be provided : |
|---|
Assuming that self.discrete_feature[‘index’] exists this extracts the values from data corresponding to the index and sets these are self.discrete_feature[fid]
| Parameters: | fid (string): feature id : data: array of shape(nbitem,k) where nbitem is supposed :
|
|---|
this function simply stores data
| Parameters: | fid (string): feature identifier, e.g. : data: array of shape(self.k,p),with p>0 : |
|---|
extract some roi-related information from an image
| Parameters: | fid: feature id : image_path(string): path of the feature-defining image : method=’average’ (string) : take the roi feature as
|
|---|