ants.segmentation.joint_label_fusion
- joint_label_fusion(target_image, target_image_mask, atlas_list, beta=4, rad=2, label_list=None, rho=0.01, usecor=False, r_search=3, nonnegative=False, no_zeroes=False, max_lab_plus_one=False, output_prefix=None, verbose=False)[source]
A multiple atlas voting scheme to customize labels for a new subject. This function will also perform intensity fusion. It almost directly calls the C++ in the ANTs executable so is much faster than other variants in ANTsR.
One may want to normalize image intensities for each input image before passing to this function. If no labels are passed, we do intensity fusion. Note on computation time: the underlying C++ is multithreaded. You can control the number of threads by setting the environment variable ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS e.g. to use all or some of your CPUs. This will improve performance substantially. For instance, on a macbook pro from 2015, 8 cores improves speed by about 4x.
ANTsR function: jointLabelFusion
- Parameters:
target_image (
ants.core.ANTsImage) – image to be approximatedtarget_image_mask (
ants.core.ANTsImage) – mask with value 1atlas_list (
listofANTsImage types) – list containing intensity imagesbeta (
scalar) – weight sharpness, default to 2rad (
scalar) – neighborhood radius, default to 2label_list (
listofANTsImage types (optional)) – list containing images with segmentation labelsrho (
scalar) – ridge penalty increases robustness to outliers but also makes image converge to averageusecor (
bool) – employ correlation as local similarityr_search (
scalar) – radius of search, default is 3nonnegative (
bool) – constrain weights to be non-negativeno_zeroes (
bool) – this will constrain the solution only to voxels that are always non-zero in the label listmax_lab_plus_one (
bool) – this will add max label plus one to the non-zero parts of each label where the target mask is greater than one. NOTE: this will have a side effect of adding to the original label images that are passed to the program. It also guarantees that every position in the labels have some label, rather than none. Ie it guarantees to explicitly parcellate the input data.output_prefix (
str) – file prefix for storing output probabilityimages to diskverbose (
bool) – whether to show status updates
- Returns:
- segmentationANTsImage
segmentation image
- intensityANTsImage
intensity image
- probabilityimageslist of ANTsImage types
probability map image for each label
- segmentation_numberslist of numbers
segmentation label (number, int) for each probability map
- Return type:
dictionary w/ following key/value pairs
Example
>>> import ants >>> ref = ants.image_read( ants.get_ants_data('r16')) >>> ref = ants.resample_image(ref, (50,50),1,0) >>> ref = ants.iMath(ref,'Normalize') >>> mi = ants.image_read( ants.get_ants_data('r27')) >>> mi2 = ants.image_read( ants.get_ants_data('r30')) >>> mi3 = ants.image_read( ants.get_ants_data('r62')) >>> mi4 = ants.image_read( ants.get_ants_data('r64')) >>> mi5 = ants.image_read( ants.get_ants_data('r85')) >>> refmask = ants.get_mask(ref) >>> refmask = ants.iMath(refmask,'ME',2) # just to speed things up >>> ilist = [mi,mi2,mi3,mi4,mi5] >>> seglist = [None]*len(ilist) >>> for i in range(len(ilist)): >>> ilist[i] = ants.iMath(ilist[i],'Normalize') >>> mytx = ants.registration(fixed=ref , moving=ilist[i] , >>> type_of_transform = ('Affine') ) >>> mywarpedimage = ants.apply_transforms(fixed=ref,moving=ilist[i], >>> transformlist=mytx['fwdtransforms']) >>> ilist[i] = mywarpedimage >>> seg = ants.threshold_image(ilist[i],'Otsu', 3) >>> seglist[i] = ( seg ) + ants.threshold_image( seg, 1, 3 ).morphology( operation='dilate', radius=3 ) >>> r = 2 >>> pp = ants.joint_label_fusion(ref, refmask, ilist, r_search=2, >>> label_list=seglist, rad=[r]*ref.dimension ) >>> pp = ants.joint_label_fusion(ref,refmask,ilist, r_search=2, rad=[r]*ref.dimension)