myvoxes = range(powers_areal_mni_itk.shape[0]) anat = powers_areal_mni_itk['Anatomy'] syst = powers_areal_mni_itk['SystemName'] Brod = powers_areal_mni_itk['Brodmann'] xAAL = powers_areal_mni_itk['AAL'] ch2 = ants.image_read( ants.get_ants_data( "ch2" ) ) treg = ants.registration( t1 * t1mask, ch2, 'SyN' ) concatx2 = treg['invtransforms'] + t1reg['invtransforms'] pts2bold = ants.apply_transforms_to_points( 3, powers_areal_mni_itk, concatx2,whichtoinvert = ( True, False, True, False ) ) locations = pts2bold.iloc[:,:3].values ptImg = ants.make_points_image( locations, bmask, radius = 3 ) networks = powers_areal_mni_itk['SystemName'].unique() dfnpts = np.where( powers_areal_mni_itk['SystemName'] == networks[5] ) dfnImg = ants.mask_image( ptImg, ptImg, level = dfnpts[0].tolist(), binarize=False ) # plot( und, ptImg, axis=3, window.overlay = range( ptImg ) ) bold2ch2 = ants.apply_transforms( ch2, und, concatx2, whichtoinvert = ( True, False, True, False ) ) # Extracting canonical functional network maps ## preprocessing csfAndWM = ( ants.threshold_image( boldseg, 1, 1 ) + ants.threshold_image( boldseg, 3, 3 ) ).morphology("erode",1) bold = ants.image_read( boldfnsR ) boldList = ants.ndimage_to_list( bold ) avgBold = ants.get_average_of_timeseries( bold, range( 5 ) ) boldUndTX = ants.registration( und, avgBold, "SyN", regIterations = (15,4),
def __init__(self, ants_image=[[0.0]], mask=[[0.0]], level=1, **options): import ants self.masking = ants.mask_image(ants_image, mask, level, **options)
def test_mask_image_example(self): myimage = ants.image_read(ants.get_ants_data('r16')) mask = myimage > myimage.mean() myimage_mask = ants.mask_image(myimage, mask, 3) seg = ants.kmeans_segmentation(myimage, 3) myimage_mask = ants.mask_image(myimage, seg['segmentation'], (1, 3))
def test_mask_image_example(self): myimage = ants.image_read(ants.get_ants_data("r16")) mask = ants.get_mask(myimage) myimage_mask = ants.mask_image(myimage, mask, (2, 3)) seg = ants.kmeans_segmentation(myimage, 3) myimage_mask = ants.mask_image(myimage, seg["segmentation"], (1, 3))