Bases: object
This is a class to represent multiple ROI objects, where the reference to a given domain is explicit.
A mutliple ROI object is a set of ROI defined on a given domain, each having its own ‘region-level’ characteristics (ROI features).
Every voxel of the domain can have its own characteristics yet, defined at the ‘voxel-level’, but those features can only be accessed familywise (i.e. the values are grouped by ROI).
Parameters: | k : int
label : array of shape (domain.size), dtype=np.int
features : dict {str: list of object, length=self.k}
roi_features : dict {str: array-like, shape=(self.k, roi_feature_dim)
|
---|
Methods
copy() | Returns a copy of self. |
feature_to_voxel_map(fid[, roi, method]) | Convert a feature to a flat voxel-mapping array. |
get_coord([id]) | Get coordinates of ROI’s voxels |
get_feature(fid[, id]) | Return a voxel-wise feature, grouped by ROI. |
get_id() | Return ROI’s id list. |
get_local_volume([id]) | Get volume of ROI’s voxels |
get_roi_feature(fid[, id]) | |
get_size([id]) | Get ROI size (counted in terms of voxels) |
get_volume([id]) | Get ROI volume |
integrate([fid, id]) | Integrate certain feature on each ROI and return the k results |
plot_feature(fid[, ax]) | Boxplot the distribution of features within ROIs. |
recompute_labels() | Redefine labels so that they are consecutive integers. |
remove_feature(fid) | Remove a certain feature |
remove_roi_feature(fid) | Remove a certain ROI feature. |
representative_feature(fid[, method, id, ...]) | Compute a ROI representative of a given feature. |
select_id(id[, roi]) | Convert a ROI id into an index to be used to index features safely. |
select_roi(id_list) | Returns an instance of MROI with only the subset of chosen ROIs. |
set_feature(fid, data[, id, override]) | Append or modify a feature |
set_roi_feature(fid, data[, id, override]) | Append or modify a ROI feature |
to_image([fid, roi, method, descrip]) | Generates a label image that represents self. |
Initialize subdomains instance
Parameters: | domain: ROI instance :
label: array of shape (domain.size), dtype=np.int, :
id: array of shape (n_roi) :
|
---|
Returns a copy of self.
Note that self.domain is not copied.
Convert a feature to a flat voxel-mapping array.
Parameters: | fid: str :
roi: bool, optional :
method: str, optional :
|
---|---|
Returns: | res: array-like, shape=(domain.size, feature_dim) :
|
Get coordinates of ROI’s voxels
Parameters: | id: any hashable type :
|
---|---|
Returns: | coords: array-like, shape=(roi_size, domain_dimension) :
|
Return a voxel-wise feature, grouped by ROI.
Parameters: | fid: str, :
id: any hashable type :
|
---|---|
Returns: | feature: array-like, shape=(roi_size, feature_dim) :
|
Return ROI’s id list.
Users must access ROIs with the use of the identifiers of this list and the methods that give access to their properties/features.
Get volume of ROI’s voxels
Parameters: | id: any hashable type :
|
---|---|
Returns: | loc_volume: array-like, shape=(roi_size, ), :
|
Get ROI size (counted in terms of voxels)
Parameters: | id: any hashable type :
|
---|---|
Returns: | size: int :
|
Get ROI volume
Parameters: | id: any hashable type :
|
---|---|
Returns: | volume : float
|
Integrate certain feature on each ROI and return the k results
Parameters: | fid : str
id: any hashable type :
|
---|---|
Returns: | lsum = array of shape (self.k, self.feature[fid].shape[1]), :
|
Boxplot the distribution of features within ROIs. Note that this assumes 1-d features.
Parameters: | fid: string :
ax: axis handle, optional : |
---|
Redefine labels so that they are consecutive integers.
Labels are used as a map to associate voxels to a given ROI. It is an inner object that should not be accessed outside this class. The number of nodes is updated appropriately.
Notes
This method must be called everytime the MROI structure is modified.
Remove a certain feature
Parameters: | fid: str :
|
---|---|
Returns: | f : object
|
Remove a certain ROI feature.
The id ROI feature cannot be removed.
Returns: | f : object
|
---|
Compute a ROI representative of a given feature.
Parameters: | fid : str
method : str, optional
id : any hashable type, optional
assess_quality: bool, optional :
|
---|---|
Returns: | summary_feature: np.ndarray, shape=(self.k, feature_dim) :
|
Convert a ROI id into an index to be used to index features safely.
Parameters: | id : any hashable type, must be in self.get_id()
roi : bool
|
---|---|
Returns: | index : int or np.array of shape (roi.size, )
|
Returns an instance of MROI with only the subset of chosen ROIs.
Parameters: | id_list: list of id (any hashable type) :
|
---|
Append or modify a feature
Parameters: | fid : str
data: list or array :
id: any hashable type, optional :
override: bool, optional :
Note that we cannot create a feature having the same name than : a ROI feature. : |
---|
Append or modify a ROI feature
Parameters: | fid: str, :
data: list of self.k features or a single feature :
id: any hashable type :
override: bool, optional, :
Note that we cannot create a ROI feature having the same name than : a feature. : Note that the `id` feature cannot be modified as an internal : component. : |
---|
Generates a label image that represents self.
Parameters: | fid: str, :
roi: bool, :
method: str, :
descrip: str, :
|
---|---|
Returns: | nim : nibabel nifti image
|
Notes
Requires that self.dom is an ddom.NDGridDomain
Return a SubDomain from an n-d int array
Parameters: | label: np.array instance :
affine: np.array, optional :
nn: int, :
|
---|
Notes
Only labels > -1 are considered.
Create discrete ROIs as a set of balls within a certain coordinate systems.
Parameters: | domain: StructuredDomain instance, :
positions: array of shape(k, dim): :
radii: array of shape(k): :
|
---|
Return a SubDomain instance from the input mask image.
Parameters: | mim: NiftiIImage instance, or string path toward such an image :
nn: int, optional :
|
---|---|
Returns: | The MultipleROI instance : |
Notes
Only labels > -1 are considered
Keep the set of labels of the image corresponding to a certain index so that their position is closest to the prescribed one.
Parameters: | mim: NiftiIImage instance, or string path toward such an image :
pos: array of shape(3) or list of length 3, :
|
---|