From 367f0239f36079dea135577f3e0df126f22a1a06 Mon Sep 17 00:00:00 2001 From: ncullen93 Date: Tue, 7 May 2024 22:32:07 +0200 Subject: [PATCH 1/2] remove LabelImage class --- ants/core/__init__.py | 1 - ants/core/ants_image.py | 197 +------------------------------ tests/test_core_label_image.py | 83 ------------- tutorials/tutorial_LabelImage.py | 154 ------------------------ 4 files changed, 1 insertion(+), 434 deletions(-) delete mode 100644 tests/test_core_label_image.py delete mode 100644 tutorials/tutorial_LabelImage.py diff --git a/ants/core/__init__.py b/ants/core/__init__.py index 9fddd447..79b10ac8 100644 --- a/ants/core/__init__.py +++ b/ants/core/__init__.py @@ -19,7 +19,6 @@ from .ants_image import ( ANTsImage, - LabelImage, copy_image_info, set_origin, get_origin, diff --git a/ants/core/ants_image.py b/ants/core/ants_image.py index 7e5ab683..7284ea80 100644 --- a/ants/core/ants_image.py +++ b/ants/core/ants_image.py @@ -1,7 +1,6 @@ __all__ = ['ANTsImage', - 'LabelImage', 'copy_image_info', 'set_origin', 'get_origin', @@ -45,7 +44,7 @@ class ANTsImage(object): - def __init__(self, pixeltype='float', dimension=3, components=1, pointer=None, is_rgb=False, label_image=None): + def __init__(self, pixeltype='float', dimension=3, components=1, pointer=None, is_rgb=False): """ Initialize an ANTsImage @@ -63,9 +62,6 @@ def __init__(self, pixeltype='float', dimension=3, components=1, pointer=None, i pointer : py::capsule (optional) pybind11 capsule holding the pointer to the underlying ITK image object - label_image : LabelImage - a discrete label image for mapping locations to atlas regions - """ ## Attributes which cant change without creating a new ANTsImage object self.pointer = pointer @@ -87,11 +83,6 @@ def __init__(self, pixeltype='float', dimension=3, components=1, pointer=None, i self.shape = utils.get_lib_fn('getShape%s'%self._libsuffix)(self.pointer) self.physical_shape = tuple([round(sh*sp,3) for sh,sp in zip(self.shape, self.spacing)]) - if label_image is not None: - if not isinstance(label_image, LabelImage): - raise ValueError('label_image argument must be a LabelImage type') - self.label_image = label_image - self._array = None @property @@ -379,9 +370,6 @@ def apply(self, fn): new_array = fn(this_array) return self.new_image_like(new_array) - def as_label_image(self, label_info=None): - return LabelImage(image=self, label_info=label_info) - ## NUMPY FUNCTIONS ## def abs(self, axis=None): """ Return absolute value of image """ @@ -641,189 +629,6 @@ def __setitem__(self, key, value): super(Dictlist, self).__setitem__(key, []) self[key].append(value) -class LabelImage(ANTsImage): - """ - A LabelImage is a special class of ANTsImage which has discrete values - and string labels or other metadata (e.g. another string label such as the - "lobe" of the region) associated with each of the discrete values. - A canonical example of a LabelImage is a brain label_image or parcellation. - - This class provides convenient functionality for manipulating and visualizing - images where you have real values associated with aggregated image regions (e.g. - if you have cortical thickness values associated with brain regions) - - Commonly-used functionality for LabelImage types: - - create publication-quality figures of an label_image - - Nomenclature - ------------ - - key : a string representing the name of the associated index in the atlas image - - e.g. if the index is 1001 and the key may be InferiorTemporalGyrus` - - value : an integer value in the atlas image - - metakey : a string representing one of the possible sets of label key - - e.g. 'Lobes' or 'Regions' - Notes - ----- - - indexing works by creating a separate dict for each metakey, where - """ - def __init__(self, label_image, label_info=None, template=None): - """ - Initialize a LabelImage - - ANTsR function: N/A - - Arguments - --------- - label_image : ANTsImage - discrete (integer) image as label_image - - label_info : dict or pandas.DataFrame - mapping between discrete values in `image` and string names - - if dict, the keys should be the discrete integer label values - and the values should be the label names or another dict with - any metadata - - if pd.DataFrame, the index (df.index) should be the discrete integer - label values and the other column(s) should be the label names and - any metadata - - template : ANTsImage - default real-valued image to use for plotting or creating new images. - This image should be in the same space as the `label_image` image and the - two should be aligned. - - Example - ------- - >>> import ants - >>> square = np.zeros((20,20)) - >>> square[:10,:10] = 0 - >>> square[:10,10:] = 1 - >>> square[10:,:10] = 2 - >>> square[10:,10:] = 3 - >>> img = ants.from_numpy(square).astype('uint8') - >>> label_image = ants.LabelImage(label_image=img, label_info=label_dict) - """ - if label_image.pixeltype not in {'unsigned char', 'unsigned int'}: - raise ValueError('Label images must have discrete pixeltype - got %s' % label_image.pixeltype) - if label_image.components > 1: - raise ValueError('Label images must have only one component - got %i' % label_image.components) - - if label_info is None: - label_info = {k:'Label%i'%k for k in range(len(label_image.unique()))} - - if isinstance(label_info, pd.DataFrame): - pass - elif isinstance(label_info, dict): - if isinstance(label_info[list(label_info.keys())[0]], dict): - label_info = pd.DataFrame(label_info).T.to_dict() - else: - label_info = pd.DataFrame(label_info, index=np.arange(len(label_info))).T.to_dict() - else: - raise ValueError('label_label_info argument must be pd.DataFrame') - - self.label_info = label_info - self.label_image = label_image - self.template = template - self.generate_data() - - super(LabelImage, self).__init__(pixeltype=label_image.pixeltype, dimension=label_image.dimension, - components=label_image.components, pointer=label_image.pointer) - - def generate_data(self): - self._metakeys = list(self.label_info.columns) - self._uniquekeys = {mk:list(np.unique(self.label_info[mk])) for mk in self._metakeys} - self._keys = {mk:list(self.label_info[mk]) for mk in self._metakeys} - self._values = list(self.label_info.index) - self._n_values = len(self._values) - - items = {} - for mk in self._metakeys: - items[mk] = {} - for k, v in zip(self.keys(mk), self.values()): - if k in items[mk]: - if isinstance(items[mk][k], list): - items[mk][k].append(v) - else: - items[mk][k] = [items[mk][k]] + [v] - else: - items[mk][k] = v - self._items = items - - def uniquekeys(self, metakey=None): - """ - Get keys for a given metakey - """ - if metakey is None: - return self._uniquekeys - else: - if metakey not in self.metakeys(): - raise ValueError('metakey %s does not exist' % metakey) - return self._uniquekeys[metakey] - - def keys(self, metakey=None): - if metakey is None: - return self._keys - else: - if metakey not in self.metakeys(): - raise ValueError('metakey %s does not exist' % metakey) - return self._keys[metakey] - - def metakeys(self): - return self._metakeys - - def parentkey(self, key): - parent = None - for mk in self.metakeys(): - if key in self.keys(mk): - parent = mk - if parent is None: - raise ValueError('key does not have a parent') - return parent - - def values(self): - return self._values - - def items(self, metakey): - if metakey not in self.metakeys(): - raise ValueError('metakey %s does not exist' % metakey) - return self._items[metakey] - - def n_values(self): - return self._n_values - - def __getitem__(self, key): - # get metakey of key - metakey = self.parentkey(key) - # get key,value pairs for metakey - items = self.items(metakey) - # return value at the given key - return items[key] - - def __setitem__(self, key, value): - label_value = self.__getitem__(key) - if isinstance(label_value, list): - if isinstance(value, list): - if len(value) != len(label_value): - raise ValueError('must give either single value or one value '+\ - 'for each index (got %i, expected %i)' % (len(value), len(label_value))) - for old_val, new_val in zip(label_value, value): - self.label_image[self.label_image==old_val] = new_val - else: - for lv in label_value: - self.label_image[self.label_image==lv] = value - else: - self.label_image[self.label_image==label_value] = value - - def __repr__(self): - s = 'LabelImage\n' +\ - '\t {:<10} : {} ({})\n'.format('Pixel Type', self.pixeltype, self.dtype)+\ - '\t {:<10} : {}\n'.format('Components', self.components)+\ - '\t {:<10} : {}\n'.format('Dimensions', self.shape)+\ - '\t {:<10} : {}\n'.format('Spacing', self.spacing)+\ - '\t {:<10} : {}\n'.format('Origin', self.origin)+\ - '\t {:<10} : {}\n'.format('Direction', self.direction.flatten())+\ - '\t {:<10} : {}\n'.format('Num Values', self.n_values()) - return s - def copy_image_info(reference, target): """ diff --git a/tests/test_core_label_image.py b/tests/test_core_label_image.py deleted file mode 100644 index e70d427c..00000000 --- a/tests/test_core_label_image.py +++ /dev/null @@ -1,83 +0,0 @@ -""" -Test ants_image.py - -nptest.assert_allclose -self.assertEqual -self.assertTrue - -""" - -import os -import unittest -from common import run_tests - -from tempfile import mktemp - -import numpy as np -import numpy.testing as nptest -import pandas as pd - -import ants - - -class TestClass_LabelImage(unittest.TestCase): - """ - Test ants.ANTsImage class - """ - def setUp(self): - square2d = np.ones((20,20)) - square2d[:10,:] += 1 - square2d[:,:10] += 2 - img2d = ants.from_numpy(square2d).astype('uint8') - info2d = [] - for i in img2d.unique(): - info2d.append(['Value=%i'%i, 'ModTwo=%i'%int(i%2), 'ModThree=%i'%int(i%3)]) - info2d = pd.DataFrame(info2d, index=img2d.unique(), columns=['Value','ModTwo','ModThree']) - - self.img2d = img2d - self.info2d = info2d - - square3d = np.ones((20,20,20)) - square3d[:10,...] += 1 - square3d[:,:10,:] += 2 - square3d[...,:10] += 3 - img3d = ants.from_numpy(square3d).astype('uint8') - - info3d = [] - for i in img3d.unique(): - info3d.append(['Value=%i'%i, 'ModTwo=%i'%int(i%2), 'ModThree=%i'%int(i%3)]) - info3d = pd.DataFrame(info2d, index=img2d.unique(), columns=['Value','ModTwo','ModThree']) - - self.img3d = img3d - self.info3d = info3d - - def tearDown(self): - pass - - def test_init(self): - lbl_img2d = ants.LabelImage(label_image=self.img2d, label_info=self.info2d) - lbl_img3d = ants.LabelImage(label_image=self.img2d, label_info=self.info2d) - - def test_init_with_template(self): - arr2d = np.abs(np.random.randn(*self.img2d.shape)) - template2d = ants.from_numpy(arr2d) - lbl_img2d = ants.LabelImage(label_image=self.img2d, label_info=self.info2d, - template=template2d) - - arr3d = np.abs(np.random.randn(*self.img3d.shape)) - template3d = ants.from_numpy(arr3d) - lbl_img3d = ants.LabelImage(label_image=self.img3d, label_info=self.info3d, - template=template3d) - - def test__repr__(self): - lbl_img2d = ants.LabelImage(label_image=self.img2d, label_info=self.info2d) - lbl_img3d = ants.LabelImage(label_image=self.img2d, label_info=self.info2d) - - r1 = lbl_img2d.__repr__() - r2 = lbl_img3d.__repr__() - self.assertTrue(isinstance(r1,str)) - self.assertTrue(isinstance(r2,str)) - - -if __name__ == '__main__': - run_tests() diff --git a/tutorials/tutorial_LabelImage.py b/tutorials/tutorial_LabelImage.py deleted file mode 100644 index b5ed1cc8..00000000 --- a/tutorials/tutorial_LabelImage.py +++ /dev/null @@ -1,154 +0,0 @@ -""" -# A tutorial about Label Images in ANTsPy - -In ANTsPy, we have a special class for dealing with what I call -"Label Images" - a brain image where each pixel/voxel is associated with -a specific label. For instance, an atlas or parcellation is the prime example -of a label image. But `LabelImage` types dont just have labels... they -also can have real values associated with those labels. For instance, suppose -you have a set of Cortical Thickness values derived from an atlas, and you want -to assign those regional values *back* onto an actual brain image for plotting -or to perform analysis tasks which require some notion of spatial location. -`LabelImage` types let you do this. - -Basically, to create a label image in *ANTsPy*, you need two things (one is -optional but highly recommended): -- a discrete atlas image (a normal `ANTsImage` type) -- (optionally) a pandas dataframe or python dictionary with a mapping - from discrete values in the atlas image to string atlas labels - -This tutorial will show you all the beautiful things you can do with `LabelImage` types. -""" - - -""" -## A simple example - -We will start with a simple example to demonstrate label images - a 2D square -with four regions -""" - -import ants -import os -import numpy as np -import pandas as pd - - -# create discrete image -square = np.zeros((20,20)) -square[:10,:10] = 0 -square[:10,10:] = 1 -square[10:,:10] = 2 -square[10:,10:] = 3 - -# create regular ANTsImage from numpy array -img = ants.from_numpy(square).astype('uint8') - -# plot image -#img.plot(cmap=None) - -""" -Above, we created our discrete "atlas" image. Next, we will -create a dictionary containing the names for each value in -the atlas. We will make simple names. -""" - -label_df = np.asarray([['TopRight', 'Right', 'Top'], - ['BottomRight', 'Right', 'Bottom'], - ['TopLeft', 'Left', 'Top'], - ['BottomLeft', 'Left', 'Bottom']]) - -label_df = pd.DataFrame(label_df, index=[1,2,3,4], - columns=['Quadrant', 'Right/Left', 'Top/Bottom']) - -atlas = ants.LabelImage(label_image=img, label_info=label_df) - - -""" -You can index a label image like a dictionary, and it will return -the unique image values corresponding to that label, or more than -one if appropriate. -""" -up_right_idx = atlas['UpperRight'] -print(up_right_idx) # should be 1 - -right_idxs = atlas['Right'] -print(right_idxs) # should be [1, 2] - - -""" -## A real example - -Now that we have the basics of the `ants.LabelImage` class down, we -can move on to a real example to show how this would work in practice. - -In this example, we have a Freesurfer atlas (the Desikan-killany atlas, -aka "aparc+aseg.mgz") and a data frame of aggregated cortical thickness values -for a subset of those regions for a collection of subjects. - -Our first task is to create a LabelImage for this atlas. -""" - -""" -We start by loading in the label info as a pandas dataframe -""" - -proc_dir = '/users/ncullen/desktop/projects/tadpole/data/processed/' -raw_dir = '/users/ncullen/desktop/projects/tadpole/data/raw/' - -label_df = pd.read_csv(os.path.join(proc_dir, 'UCSF_FS_Map.csv'), index_col=0) - -print(label_df.head()) - -""" -As you can see, the label dataframe has the the atlas values as the dataframe -index and a set of columns with different labels for each index. - -Next, we load in the discrete atlas image. -""" - -atlas_img = ants.image_read(os.path.join(raw_dir, 'freesurfer/aparc+aseg.mgz')).astype('uint32') -atlas_img.plot() - -label_img = ants.LabelImage(image=atlas_img, info=label_df) - -""" -Let's see this in action on a template -""" -t1_img = ants.image_read(os.path.join(raw_dir,'freesurfer/T1.mgz')) -t1_img.plot() - -# set the label image -t1_img.set_label_image(atlas_img) - - - - -""" -Our second task is create an image for each subject that fills in the brain -region locations with the associated region's cortical thickness -""" -data = pd.read_csv(os.path.join()) - - - - - - - - - - - - - - - - - - - - - - - From 664ae0ddc9b74787d8c6c970a1dc9fbacb8d28de Mon Sep 17 00:00:00 2001 From: ncullen93 Date: Tue, 7 May 2024 22:38:13 +0200 Subject: [PATCH 2/2] remove unused function --- ants/lib/__init__.py | 1 - ants/utils/__init__.py | 2 - ants/utils/invariant_image_similarity.py | 258 ----------------------- docs/source/ants.utils.rst | 7 - docs/source/utils.rst | 2 - tests/test_registration.py | 6 +- tests/test_utils.py | 22 -- 7 files changed, 4 insertions(+), 294 deletions(-) delete mode 100644 ants/utils/invariant_image_similarity.py diff --git a/ants/lib/__init__.py b/ants/lib/__init__.py index fc1059eb..bba659c4 100644 --- a/ants/lib/__init__.py +++ b/ants/lib/__init__.py @@ -19,7 +19,6 @@ from .hausdorffDistance import * from .histogramMatchImage import * from .invertDisplacementField import * -# from .invariantImageSimilarity import * from .labelOverlapMeasures import * from .labelStats import * from .mergeChannels import * diff --git a/ants/utils/__init__.py b/ants/utils/__init__.py index 3f3faadb..a8f36ff8 100644 --- a/ants/utils/__init__.py +++ b/ants/utils/__init__.py @@ -51,8 +51,6 @@ iMath_propagate_labels_through_mask) from .impute import impute from .integrate_velocity_field import integrate_velocity_field -from .invariant_image_similarity import (invariant_image_similarity, - convolve_image) from .invert_displacement_field import invert_displacement_field from .label_clusters import label_clusters from .label_image_centroids import label_image_centroids diff --git a/ants/utils/invariant_image_similarity.py b/ants/utils/invariant_image_similarity.py deleted file mode 100644 index 4df3438e..00000000 --- a/ants/utils/invariant_image_similarity.py +++ /dev/null @@ -1,258 +0,0 @@ - -__all__ = ['invariant_image_similarity', - 'convolve_image'] - -import math -from tempfile import mktemp - -import numpy as np -import pandas as pd - -from .. import utils -from ..core import ants_image as iio - - -def invariant_image_similarity(image1, image2, - local_search_iterations=0, metric='MI', - thetas=np.linspace(0,360,5), - thetas2=np.linspace(0,360,5), - thetas3=np.linspace(0,360,5), - scale_image=1, do_reflection=False, - txfn=None, transform='Affine'): - """ - Similarity metrics between two images as a function of geometry - - Compute similarity metric between two images as image is rotated about its - center w/ or w/o optimization - - ANTsR function: `invariantImageSimilarity` - - Arguments - --------- - image1 : ANTsImage - reference image - - image2 : ANTsImage - moving image - - local_search_iterations : integer - integer controlling local search in multistart - - metric : string - which metric to use - MI - GC - thetas : 1D-ndarray/list/tuple - numeric vector of search angles in degrees - - thetas2 : 1D-ndarray/list/tuple - numeric vector of search angles in degrees around principal axis 2 (3D) - - thetas3 : 1D-ndarray/list/tuple - numeric vector of search angles in degrees around principal axis 3 (3D) - - scale_image : scalar - global scale - - do_reflection : boolean - whether to reflect image about principal axis - - txfn : string (optional) - if present, write optimal tx to .mat file - - transform : string - type of transform to use - Rigid - Similarity - Affine - - Returns - ------- - pd.DataFrame - dataframe with metric values and transformation parameters - - Example - ------- - >>> import ants - >>> img1 = ants.image_read(ants.get_ants_data('r16')) - >>> img2 = ants.image_read(ants.get_ants_data('r64')) - >>> metric = ants.invariant_image_similarity(img1,img2) - """ - if transform not in {'Rigid', 'Similarity', 'Affine'}: - raise ValueError('transform must be one of Rigid/Similarity/Affine') - - if image1.pixeltype != 'float': - image1 = image1.clone('float') - if image2.pixeltype != 'float': - image2 = image2.clone('float') - - if txfn is None: - txfn = mktemp(suffix='.mat') - - # convert thetas to radians - thetain = (thetas * math.pi) / 180. - thetain2 = (thetas2 * math.pi) / 180. - thetain3 = (thetas3 * math.pi) / 180. - - image1 = utils.iMath(image1, 'Normalize') - image2 = utils.iMath(image2, 'Normalize') - - idim = image1.dimension - fpname = ['FixedParam%i'%i for i in range(1,idim+1)] - - if not do_reflection: - libfn = utils.get_lib_fn('invariantImageSimilarity_%s%iD' % (transform, idim)) - r1 = libfn(image1.pointer, - image2.pointer, - list(thetain), - list(thetain2), - list(thetain3), - local_search_iterations, - metric, - scale_image, - int(do_reflection), - txfn) - r1 = np.asarray(r1) - - pnames = ['Param%i'%i for i in range(1,r1.shape[1])] - pnames[(len(pnames)-idim):len(pnames)] = fpname - - r1 = pd.DataFrame(r1, columns=['MetricValue']+pnames) - return r1, txfn - else: - txfn1 = mktemp(suffix='.mat') - txfn2 = mktemp(suffix='.mat') - txfn3 = mktemp(suffix='.mat') - txfn4 = mktemp(suffix='.mat') - - libfn = utils.get_lib_fn('invariantImageSimilarity_%s%iD' % (transform, idim)) - ## R1 ## - r1 = libfn(image1.pointer, - image2.pointer, - list(thetain), - list(thetain2), - list(thetain3), - local_search_iterations, - metric, - scale_image, - 0, - txfn1) - r1 = np.asarray(r1) - pnames = ['Param%i'%i for i in range(1,r1.shape[1])] - pnames[(len(pnames)-idim):len(pnames)] = fpname - r1 = pd.DataFrame(r1, columns=['MetricValue']+pnames) - - ## R2 ## - r2 = libfn(image1.pointer, - image2.pointer, - list(thetain), - list(thetain2), - list(thetain3), - local_search_iterations, - metric, - scale_image, - 1, - txfn2) - r2 = np.asarray(r2) - r2 = pd.DataFrame(r2, columns=['MetricValue']+pnames) - - ## R3 ## - r3 = libfn(image1.pointer, - image2.pointer, - list(thetain), - list(thetain2), - list(thetain3), - local_search_iterations, - metric, - scale_image, - 2, - txfn3) - r3 = np.asarray(r3) - r3 = pd.DataFrame(r3, columns=['MetricValue']+pnames) - - ## R4 ## - r4 = libfn(image1.pointer, - image2.pointer, - list(thetain), - list(thetain2), - list(thetain3), - local_search_iterations, - metric, - scale_image, - 3, - txfn4) - r4 = np.asarray(r4) - r4 = pd.DataFrame(r4, columns=['MetricValue']+pnames) - - rmins = [np.min(r1.iloc[:,0]), np.min(r2.iloc[:,0]), np.min(r3.iloc[:,0]), np.min(r4.iloc[:,0])] - ww = np.argmin(rmins) - - if ww == 0: - return r1, txfn1 - elif ww == 1: - return r2, txfn2 - elif ww == 2: - return r3, txfn3 - elif ww == 3: - return r4, txfn4 - - -def convolve_image(image, kernel_image, crop=True): - """ - Convolve one image with another - - ANTsR function: `convolveImage` - - Arguments - --------- - image : ANTsImage - image to convolve - - kernel_image : ANTsImage - image acting as kernel - - crop : boolean - whether to automatically crop kernel_image - - Returns - ------- - ANTsImage - - Example - ------- - >>> import ants - >>> fi = ants.image_read(ants.get_ants_data('r16')) - >>> convimg = ants.make_image( (3,3), (1,0,1,0,-4,0,1,0,1) ) - >>> convout = ants.convolve_image( fi, convimg ) - >>> convimg2 = ants.make_image( (3,3), (0,1,0,1,0,-1,0,-1,0) ) - >>> convout2 = ants.convolve_image( fi, convimg2 ) - """ - if not isinstance(image, iio.ANTsImage): - raise ValueError('image must be ANTsImage type') - if not isinstance(kernel_image, iio.ANTsImage): - raise ValueError('kernel must be ANTsImage type') - - orig_ptype = image.pixeltype - if image.pixeltype != 'float': - image = image.clone('float') - if kernel_image.pixeltype != 'float': - kernel_image = kernel_image.clone('float') - - if crop: - kernel_image_mask = utils.get_mask(kernel_image) - kernel_image = utils.crop_image(kernel_image, kernel_image_mask) - kernel_image_mask = utils.crop_image(kernel_image_mask, kernel_image_mask) - kernel_image[kernel_image_mask==0] = kernel_image[kernel_image_mask==1].mean() - - libfn = utils.get_lib_fn('convolveImageF%i' % image.dimension) - conv_itk_image = libfn(image.pointer, kernel_image.pointer) - conv_ants_image = iio.ANTsImage(pixeltype=image.pixeltype, dimension=image.dimension, - components=image.components, pointer=conv_itk_image) - - if orig_ptype != 'float': - conv_ants_image = conv_ants_image.clone(orig_ptype) - - return conv_ants_image - - - diff --git a/docs/source/ants.utils.rst b/docs/source/ants.utils.rst index b4f8268d..4dbb3f63 100644 --- a/docs/source/ants.utils.rst +++ b/docs/source/ants.utils.rst @@ -108,13 +108,6 @@ ants.utils.impute module :undoc-members: :show-inheritance: -ants.utils.invariant\_image\_similarity module ----------------------------------------------- - -.. automodule:: ants.utils.invariant_image_similarity - :members: - :undoc-members: - :show-inheritance: ants.utils.label\_clusters module --------------------------------- diff --git a/docs/source/utils.rst b/docs/source/utils.rst index 326e2996..cfddaa82 100644 --- a/docs/source/utils.rst +++ b/docs/source/utils.rst @@ -21,8 +21,6 @@ Utilities .. autofunction:: image_to_cluster_images .. autofunction:: iMath .. autofunction:: impute -.. autofunction:: invariant_image_similarity -.. autofunction:: convolve_image .. autofunction:: label_clusters .. autofunction:: label_image_centroids .. autofunction:: label_overlap_measures diff --git a/tests/test_registration.py b/tests/test_registration.py index 8f4e8223..6a12eae9 100644 --- a/tests/test_registration.py +++ b/tests/test_registration.py @@ -370,7 +370,8 @@ def test_landmark_transforms(self): fixed = np.array([[50.0,50.0],[200.0,50.0],[200.0,200.0]]) moving = np.array([[50.0,50.0],[50.0,200.0],[200.0,200.0]]) xfrm = ants.fit_transform_to_paired_points(moving, fixed, transform_type="syn", - domain_image=ants.image_read(ants.get_data('r16'))) + domain_image=ants.image_read(ants.get_data('r16')), + verbose=True) xfrm = ants.fit_transform_to_paired_points(moving, fixed, transform_type="tv", domain_image=ants.image_read(ants.get_data('r16'))) xfrm = ants.fit_transform_to_paired_points(moving, fixed, transform_type="affine") @@ -381,7 +382,8 @@ def test_landmark_transforms(self): xfrm = ants.fit_transform_to_paired_points(moving, fixed, transform_type="diffeo", domain_image=domain_image, number_of_fitting_levels=6) res = ants.fit_time_varying_transform_to_point_sets([fixed, moving, moving], - domain_image=ants.image_read(ants.get_data('r16'))) + domain_image=ants.image_read(ants.get_data('r16')), + verbose=True) def test_deformation_gradient(self): fi = ants.image_read( ants.get_ants_data('r16')) diff --git a/tests/test_utils.py b/tests/test_utils.py index 46dfce47..57438726 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -580,28 +580,6 @@ def test_impute_example(self): # data_imputed = ants.impute(data, method='constant', value=12.) -# class TestModule_invariant_image_similarity(unittest.TestCase): -# def setUp(self): -# pass -# -# def tearDown(self): -# pass -# -# def test_invariate_image_similarity_example(self): -# img1 = ants.image_read(ants.get_ants_data("r16")) -# img2 = ants.image_read(ants.get_ants_data("r64")) -# metric1 = ants.invariant_image_similarity(img1, img2, do_reflection=False) -# -# img1 = ants.image_read(ants.get_ants_data("r16")) -# img2 = ants.image_read(ants.get_ants_data("r64")) -# metric2 = ants.invariant_image_similarity(img1, img2, do_reflection=True) -# -# def test_convolve_image_example(self): -# fi = ants.image_read(ants.get_ants_data("r16")) -# convimg = ants.make_image((3, 3), (1, 0, 1, 0, -4, 0, 1, 0, 1)) -# convout = ants.convolve_image(fi, convimg) - - class TestModule_label_clusters(unittest.TestCase): def setUp(self): pass