Skip to content

Compute a deformable registration, warp a segmentation and compute overlap with a reference segmentation

stnava edited this page May 21, 2021 · 1 revision

this example automatically

  1. reads two image
  2. segments each into three tissue classes
  3. performs deformable registration
  4. transforms the moving image segmentation to the fixed space
  5. computes overlap measurements
fi = ants.image_read(ants.get_ants_data('r16'))
mi = ants.image_read(ants.get_ants_data('r64'))
segm = ants.threshold_image( mi, "Otsu", 3 )
segf = ants.threshold_image( fi, "Otsu", 3 )
mytx = ants.registration(fixed=fi, moving=mi, type_of_transform = 'SyN' )
print( mytx['warpedmovout'].max() )
warpedseg = ants.apply_transforms( fi, segm, mytx['fwdtransforms'],
  interpolator='nearestNeighbor')
print( ants.label_overlap_measures( segf, warpedseg ) )