antspymm 1.5.7__py3-none-any.whl → 1.5.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- antspymm/mm.py +66 -139
- {antspymm-1.5.7.dist-info → antspymm-1.5.9.dist-info}/METADATA +1 -1
- antspymm-1.5.9.dist-info/RECORD +6 -0
- antspymm-1.5.7.dist-info/RECORD +0 -6
- {antspymm-1.5.7.dist-info → antspymm-1.5.9.dist-info}/WHEEL +0 -0
- {antspymm-1.5.7.dist-info → antspymm-1.5.9.dist-info}/top_level.txt +0 -0
antspymm/mm.py
CHANGED
@@ -135,6 +135,10 @@ import tensorflow as tf
|
|
135
135
|
from multiprocessing import Pool
|
136
136
|
import glob as glob
|
137
137
|
|
138
|
+
antspyt1w.set_global_scientific_computing_random_seed(
|
139
|
+
antspyt1w.get_global_scientific_computing_random_seed( )
|
140
|
+
)
|
141
|
+
|
138
142
|
DATA_PATH = os.path.expanduser('~/.antspymm/')
|
139
143
|
|
140
144
|
def version( ):
|
@@ -1881,7 +1885,7 @@ def timeseries_transform(transform, image, reference, interpolation='linear'):
|
|
1881
1885
|
def timeseries_reg(
|
1882
1886
|
image,
|
1883
1887
|
avg_b0,
|
1884
|
-
type_of_transform=
|
1888
|
+
type_of_transform='antsRegistrationSyNRepro[r]',
|
1885
1889
|
total_sigma=1.0,
|
1886
1890
|
fdOffset=2.0,
|
1887
1891
|
trim = 0,
|
@@ -1993,7 +1997,7 @@ def timeseries_reg(
|
|
1993
1997
|
if temp.numpy().var() > 0:
|
1994
1998
|
myrig = ants.registration(
|
1995
1999
|
avg_b0, temp,
|
1996
|
-
type_of_transform='
|
2000
|
+
type_of_transform='antsRegistrationSyNRepro[r]',
|
1997
2001
|
outprefix=txprefix
|
1998
2002
|
)
|
1999
2003
|
if type_of_transform == 'SyN':
|
@@ -2520,7 +2524,7 @@ def dti_reg(
|
|
2520
2524
|
bvals=None,
|
2521
2525
|
bvecs=None,
|
2522
2526
|
b0_idx=None,
|
2523
|
-
type_of_transform="
|
2527
|
+
type_of_transform="antsRegistrationSyNRepro[r]",
|
2524
2528
|
total_sigma=3.0,
|
2525
2529
|
fdOffset=2.0,
|
2526
2530
|
mask_csf=False,
|
@@ -2651,7 +2655,7 @@ def dti_reg(
|
|
2651
2655
|
else:
|
2652
2656
|
bcsf = ab0 * 0 + 1
|
2653
2657
|
|
2654
|
-
initrig = ants.registration( avg_b0, ab0,'
|
2658
|
+
initrig = ants.registration( avg_b0, ab0,'antsRegistrationSyNRepro[r]',outprefix=ofnG)
|
2655
2659
|
deftx = ants.registration( avg_dwi, adw, 'SyNOnly',
|
2656
2660
|
syn_metric='CC', syn_sampling=2,
|
2657
2661
|
reg_iterations=[50,50,20],
|
@@ -2680,7 +2684,7 @@ def dti_reg(
|
|
2680
2684
|
if temp.numpy().var() > 0:
|
2681
2685
|
myrig = ants.registration(
|
2682
2686
|
fixed, temp,
|
2683
|
-
type_of_transform='
|
2687
|
+
type_of_transform='antsRegistrationSyNRepro[r]',
|
2684
2688
|
outprefix=txprefix,
|
2685
2689
|
**kwargs
|
2686
2690
|
)
|
@@ -2759,7 +2763,7 @@ def dti_reg(
|
|
2759
2763
|
def mc_reg(
|
2760
2764
|
image,
|
2761
2765
|
fixed=None,
|
2762
|
-
type_of_transform="
|
2766
|
+
type_of_transform="antsRegistrationSyNRepro[r]",
|
2763
2767
|
mask=None,
|
2764
2768
|
total_sigma=3.0,
|
2765
2769
|
fdOffset=2.0,
|
@@ -2862,7 +2866,7 @@ def mc_reg(
|
|
2862
2866
|
if temp.numpy().var() > 0:
|
2863
2867
|
myrig = ants.registration(
|
2864
2868
|
fixed, temp,
|
2865
|
-
type_of_transform='
|
2869
|
+
type_of_transform='antsRegistrationSyNRepro[r]',
|
2866
2870
|
outprefix=ofnL+str(k).zfill(4)+"_",
|
2867
2871
|
**kwargs
|
2868
2872
|
)
|
@@ -3227,7 +3231,7 @@ def dewarp_imageset( image_list, initial_template=None,
|
|
3227
3231
|
initial_template=initial_template,
|
3228
3232
|
image_list=avglist,
|
3229
3233
|
gradient_step=0.5, blending_weight=0.8,
|
3230
|
-
iterations=iterations, **kwargs )
|
3234
|
+
iterations=iterations, verbose=False, **kwargs )
|
3231
3235
|
|
3232
3236
|
# last - warp all images to this frame
|
3233
3237
|
mocoplist = []
|
@@ -3235,7 +3239,7 @@ def dewarp_imageset( image_list, initial_template=None,
|
|
3235
3239
|
reglist = []
|
3236
3240
|
for k in range(len(image_list)):
|
3237
3241
|
if imagetype == 3:
|
3238
|
-
moco0 = ants.motion_correction( image=image_list[k], fixed=btp, type_of_transform='
|
3242
|
+
moco0 = ants.motion_correction( image=image_list[k], fixed=btp, type_of_transform='antsRegistrationSyNRepro[r]' )
|
3239
3243
|
mocoplist.append( moco0['motion_parameters'] )
|
3240
3244
|
mocofdlist.append( moco0['FD'] )
|
3241
3245
|
locavg = ants.slice_image( moco0['motion_corrected'], axis=3, idx=0 ) * 0.0
|
@@ -3452,13 +3456,13 @@ def get_average_rsf( x, min_t=10, max_t=35 ):
|
|
3452
3456
|
max_t=x.shape[3]
|
3453
3457
|
for myidx in range(min_t,max_t):
|
3454
3458
|
b0 = ants.slice_image( x, axis=3, idx=myidx)
|
3455
|
-
bavg = bavg + ants.registration(oavg,b0,'
|
3459
|
+
bavg = bavg + ants.registration(oavg,b0,'antsRegistrationSyNRepro[r]',outprefix=ofn)['warpedmovout']
|
3456
3460
|
bavg = ants.iMath( bavg, 'Normalize' )
|
3457
3461
|
oavg = ants.image_clone( bavg )
|
3458
3462
|
bavg = oavg * 0.0
|
3459
3463
|
for myidx in range(min_t,max_t):
|
3460
3464
|
b0 = ants.slice_image( x, axis=3, idx=myidx)
|
3461
|
-
bavg = bavg + ants.registration(oavg,b0,'
|
3465
|
+
bavg = bavg + ants.registration(oavg,b0,'antsRegistrationSyNRepro[r]',outprefix=ofn)['warpedmovout']
|
3462
3466
|
import shutil
|
3463
3467
|
shutil.rmtree(output_directory, ignore_errors=True )
|
3464
3468
|
bavg = ants.iMath( bavg, 'Normalize' )
|
@@ -3497,16 +3501,16 @@ def get_average_dwi_b0( x, fixed_b0=None, fixed_dwi=None, fast=False ):
|
|
3497
3501
|
temp_dwi = ants.slice_image( x, axis=3, idx=non_b0_idx[0] )
|
3498
3502
|
xavg = fixed_b0 * 0.0
|
3499
3503
|
bavg = fixed_b0 * 0.0
|
3500
|
-
tempreg = ants.registration( fixed_b0, temp_b0,'
|
3504
|
+
tempreg = ants.registration( fixed_b0, temp_b0,'antsRegistrationSyNRepro[r]')
|
3501
3505
|
fixed_b0_use = tempreg['warpedmovout']
|
3502
3506
|
fixed_dwi_use = ants.apply_transforms( fixed_b0, temp_dwi, tempreg['fwdtransforms'] )
|
3503
3507
|
for myidx in range(x.shape[3]):
|
3504
3508
|
b0 = ants.slice_image( x, axis=3, idx=myidx)
|
3505
3509
|
if not fast:
|
3506
3510
|
if not myidx in b0_idx:
|
3507
|
-
xavg = xavg + ants.registration(fixed_dwi_use,b0,'
|
3511
|
+
xavg = xavg + ants.registration(fixed_dwi_use,b0,'antsRegistrationSyNRepro[r]',outprefix=ofn)['warpedmovout']
|
3508
3512
|
else:
|
3509
|
-
bavg = bavg + ants.registration(fixed_b0_use,b0,'
|
3513
|
+
bavg = bavg + ants.registration(fixed_b0_use,b0,'antsRegistrationSyNRepro[r]',outprefix=ofn)['warpedmovout']
|
3510
3514
|
else:
|
3511
3515
|
if not myidx in b0_idx:
|
3512
3516
|
xavg = xavg + b0
|
@@ -3518,7 +3522,7 @@ def get_average_dwi_b0( x, fixed_b0=None, fixed_dwi=None, fast=False ):
|
|
3518
3522
|
shutil.rmtree(output_directory, ignore_errors=True )
|
3519
3523
|
avgb0=ants.n4_bias_field_correction(bavg)
|
3520
3524
|
avgdwi=ants.n4_bias_field_correction(xavg)
|
3521
|
-
avgdwi=ants.registration( avgb0, avgdwi, '
|
3525
|
+
avgdwi=ants.registration( avgb0, avgdwi, 'antsRegistrationSyNRepro[r]' )['warpedmovout']
|
3522
3526
|
return avgb0, avgdwi
|
3523
3527
|
|
3524
3528
|
def dti_template(
|
@@ -3564,8 +3568,8 @@ def dti_template(
|
|
3564
3568
|
fimg2=bavg
|
3565
3569
|
mimg2=b_image_list[k] * bcsf[k]
|
3566
3570
|
w1 = ants.registration(
|
3567
|
-
fimg, mimg, type_of_transform='
|
3568
|
-
multivariate_extras= [ [ "
|
3571
|
+
fimg, mimg, type_of_transform='antsRegistrationSyNQuickRepro[s]',
|
3572
|
+
multivariate_extras= [ [ "CC", fimg2, mimg2, 1, 2 ]],
|
3569
3573
|
outprefix=mydeftx,
|
3570
3574
|
verbose=0 )
|
3571
3575
|
txname = ants.apply_transforms(wavg, wavg,
|
@@ -3621,7 +3625,7 @@ def t1_based_dwi_brain_extraction(
|
|
3621
3625
|
t1w,
|
3622
3626
|
dwi,
|
3623
3627
|
b0_idx = None,
|
3624
|
-
transform='
|
3628
|
+
transform='antsRegistrationSyNRepro[r]',
|
3625
3629
|
deform=None,
|
3626
3630
|
verbose=False
|
3627
3631
|
):
|
@@ -3659,7 +3663,7 @@ def t1_based_dwi_brain_extraction(
|
|
3659
3663
|
b0_avg = ants.slice_image( dwi, axis=3, idx=b0_idx[0] ).iMath("Normalize")
|
3660
3664
|
for n in range(1,len(b0_idx)):
|
3661
3665
|
temp = ants.slice_image( dwi, axis=3, idx=b0_idx[n] )
|
3662
|
-
reg = ants.registration( b0_avg, temp, '
|
3666
|
+
reg = ants.registration( b0_avg, temp, 'antsRegistrationSyNRepro[r]' )
|
3663
3667
|
b0_avg = b0_avg + ants.iMath( reg['warpedmovout'], "Normalize")
|
3664
3668
|
else:
|
3665
3669
|
b0_avg = ants.slice_image( dwi, axis=3, idx=b0_idx[0] )
|
@@ -4563,7 +4567,7 @@ def joint_dti_recon(
|
|
4563
4567
|
print("JHU reg",flush=True)
|
4564
4568
|
|
4565
4569
|
OR_FA2JHUreg = ants.registration( reconFA, jhu_atlas,
|
4566
|
-
type_of_transform = '
|
4570
|
+
type_of_transform = 'antsRegistrationSyNQuickRepro[s]',
|
4567
4571
|
reg_iterations=reg_its, verbose=False )
|
4568
4572
|
OR_FA_jhulabels = ants.apply_transforms( reconFA, jhu_labels,
|
4569
4573
|
OR_FA2JHUreg['fwdtransforms'], interpolator='genericLabel')
|
@@ -5555,7 +5559,7 @@ def tra_initializer( fixed, moving, n_simulations=32, max_rotation=30,
|
|
5555
5559
|
bestreg=compreg
|
5556
5560
|
initx = ants.read_transform( bestreg['fwdtransforms'][0] )
|
5557
5561
|
for mytx in transform:
|
5558
|
-
regtx = '
|
5562
|
+
regtx = 'antsRegistrationSyNRepro[r]'
|
5559
5563
|
with tempfile.NamedTemporaryFile(suffix='.h5') as tp:
|
5560
5564
|
if mytx == 'translation':
|
5561
5565
|
regtx = 'Translation'
|
@@ -5660,7 +5664,7 @@ def neuromelanin( list_nm_images, t1, t1_head, t1lab, brain_stem_dilation=8,
|
|
5660
5664
|
templateNM = ants.iMath( mm_read( fntNM ), "Normalize" )
|
5661
5665
|
templatebstem = mm_read( fntbst ).threshold_image( 1, 1000 )
|
5662
5666
|
# reg = ants.registration( t1, template, 'antsRegistrationSyNQuickRepro[s]' )
|
5663
|
-
reg = ants.registration( t1, template, '
|
5667
|
+
reg = ants.registration( t1, template, 'antsRegistrationSyNQuickRepro[s]' )
|
5664
5668
|
# map NM avg to t1 for neuromelanin processing
|
5665
5669
|
nmavg2t1 = ants.apply_transforms( t1, templateNM,
|
5666
5670
|
reg['fwdtransforms'], interpolator='linear' )
|
@@ -5696,7 +5700,7 @@ def neuromelanin( list_nm_images, t1, t1_head, t1lab, brain_stem_dilation=8,
|
|
5696
5700
|
if verbose:
|
5697
5701
|
print(str(k) + " of " + str(len( list_nm_images ) ) )
|
5698
5702
|
current_image = ants.registration( list_nm_images[k], nm_avg,
|
5699
|
-
type_of_transform = '
|
5703
|
+
type_of_transform = 'antsRegistrationSyNRepro[r]' )
|
5700
5704
|
txlist.append( current_image['fwdtransforms'][0] )
|
5701
5705
|
current_image = current_image['warpedfixout']
|
5702
5706
|
nm_avg_new = nm_avg_new + current_image / len( list_nm_images )
|
@@ -5706,7 +5710,7 @@ def neuromelanin( list_nm_images, t1, t1_head, t1lab, brain_stem_dilation=8,
|
|
5706
5710
|
print("do slab registration to map anatomy to NM space")
|
5707
5711
|
t1c = ants.crop_image( t1_head, slab2t1 ).iMath("Normalize") # old way
|
5708
5712
|
nmavg2t1c = ants.crop_image( nmavg2t1, slab2t1 ).iMath("Normalize")
|
5709
|
-
# slabreg = ants.registration( nm_avg, nmavg2t1c, '
|
5713
|
+
# slabreg = ants.registration( nm_avg, nmavg2t1c, 'antsRegistrationSyNRepro[r]' )
|
5710
5714
|
slabreg = tra_initializer( nm_avg, t1c, verbose=verbose )
|
5711
5715
|
if False:
|
5712
5716
|
slabregT1 = tra_initializer( nm_avg, t1c, verbose=verbose )
|
@@ -5766,7 +5770,7 @@ def neuromelanin( list_nm_images, t1, t1_head, t1lab, brain_stem_dilation=8,
|
|
5766
5770
|
myreg = ants.registration(
|
5767
5771
|
ants.iMath(nm_avg_cropped,"Normalize"),
|
5768
5772
|
ants.iMath(crop_nm_list[k],"Normalize"),
|
5769
|
-
'
|
5773
|
+
'antsRegistrationSyNRepro[r]' )
|
5770
5774
|
warpednext = ants.apply_transforms(
|
5771
5775
|
nm_avg_cropped_new,
|
5772
5776
|
crop_nm_list[k],
|
@@ -6080,7 +6084,7 @@ def resting_state_fmri_networks( fmri, fmri_template, t1, t1segmentation,
|
|
6080
6084
|
else:
|
6081
6085
|
nc=float(nc)
|
6082
6086
|
|
6083
|
-
type_of_transform=
|
6087
|
+
type_of_transform="antsRegistrationSyNQuickRepro[r]" # , # should probably not change this
|
6084
6088
|
remove_it=True
|
6085
6089
|
output_directory = tempfile.mkdtemp()
|
6086
6090
|
output_directory_w = output_directory + "/ts_t1_reg/"
|
@@ -6189,13 +6193,14 @@ def resting_state_fmri_networks( fmri, fmri_template, t1, t1segmentation,
|
|
6189
6193
|
trim = 8,
|
6190
6194
|
output_directory=None,
|
6191
6195
|
verbose=verbose,
|
6192
|
-
syn_metric='
|
6196
|
+
syn_metric='CC',
|
6193
6197
|
syn_sampling=2,
|
6194
6198
|
reg_iterations=[40,20,5],
|
6195
6199
|
return_numpy_motion_parameters=True )
|
6196
6200
|
|
6197
6201
|
if verbose:
|
6198
6202
|
print("End rsfmri motion correction")
|
6203
|
+
print("--maximum motion : " + str(corrmo['FD'].max()) )
|
6199
6204
|
print("=== next anatomically based mapping ===")
|
6200
6205
|
|
6201
6206
|
despiking_count = np.zeros( corrmo['motion_corrected'].shape[3] )
|
@@ -6215,7 +6220,7 @@ def resting_state_fmri_networks( fmri, fmri_template, t1, t1segmentation,
|
|
6215
6220
|
# anatomical mapping
|
6216
6221
|
und = fmri_template * bmask
|
6217
6222
|
t1reg = ants.registration( und, t1,
|
6218
|
-
|
6223
|
+
"antsRegistrationSyNQuickRepro[s]", outprefix=ofnt1tx )
|
6219
6224
|
if verbose:
|
6220
6225
|
print("t1 2 bold done")
|
6221
6226
|
gmseg = ants.threshold_image( t1segmentation, 2, 2 )
|
@@ -6750,17 +6755,18 @@ def bold_perfusion_minimal(
|
|
6750
6755
|
perf_total_sigma = 1.5
|
6751
6756
|
corrmo = timeseries_reg(
|
6752
6757
|
fmri, fmri_template,
|
6753
|
-
type_of_transform='
|
6758
|
+
type_of_transform='antsRegistrationSyNRepro[r]',
|
6754
6759
|
total_sigma=perf_total_sigma,
|
6755
6760
|
fdOffset=2.0,
|
6756
6761
|
trim = mytrim,
|
6757
6762
|
output_directory=None,
|
6758
6763
|
verbose=verbose,
|
6759
|
-
syn_metric='
|
6764
|
+
syn_metric='CC',
|
6760
6765
|
syn_sampling=2,
|
6761
6766
|
reg_iterations=[40,20,5] )
|
6762
6767
|
if verbose:
|
6763
6768
|
print("End rsfmri motion correction")
|
6769
|
+
print("--maximum motion : " + str(corrmo['FD'].max()) )
|
6764
6770
|
|
6765
6771
|
if m0_image is not None:
|
6766
6772
|
m0 = m0_image
|
@@ -6789,17 +6795,18 @@ def bold_perfusion_minimal(
|
|
6789
6795
|
fmri_template = ants.iMath( ants.get_average_of_timeseries( fmrimotcorr ), "Normalize" )
|
6790
6796
|
corrmo = timeseries_reg(
|
6791
6797
|
fmri, fmri_template,
|
6792
|
-
type_of_transform='
|
6798
|
+
type_of_transform='antsRegistrationSyNRepro[r]',
|
6793
6799
|
total_sigma=perf_total_sigma,
|
6794
6800
|
fdOffset=2.0,
|
6795
6801
|
trim = mytrim,
|
6796
6802
|
output_directory=None,
|
6797
6803
|
verbose=verbose,
|
6798
|
-
syn_metric='
|
6804
|
+
syn_metric='CC',
|
6799
6805
|
syn_sampling=2,
|
6800
6806
|
reg_iterations=[40,20,5] )
|
6801
6807
|
if verbose:
|
6802
6808
|
print("End 2nd rsfmri motion correction")
|
6809
|
+
print("--maximum motion : " + str(corrmo['FD'].max()) )
|
6803
6810
|
|
6804
6811
|
if outlier_threshold < 1.0 and outlier_threshold > 0.0:
|
6805
6812
|
corrmo['motion_corrected'] = remove_volumes_from_timeseries( corrmo['motion_corrected'], hlinds )
|
@@ -6853,7 +6860,7 @@ def bold_perfusion_minimal(
|
|
6853
6860
|
m0 = ants.get_average_of_timeseries( fmrimotcorr )
|
6854
6861
|
else:
|
6855
6862
|
# register m0 to current template
|
6856
|
-
m0reg = ants.registration( fmri_template, m0, '
|
6863
|
+
m0reg = ants.registration( fmri_template, m0, 'antsRegistrationSyNRepro[r]', verbose=False )
|
6857
6864
|
m0 = m0reg['warpedmovout']
|
6858
6865
|
|
6859
6866
|
if ntp == 2 :
|
@@ -6934,7 +6941,7 @@ def bold_perfusion(
|
|
6934
6941
|
FD_threshold=0.5,
|
6935
6942
|
spa = (0., 0., 0., 0.),
|
6936
6943
|
nc = 3,
|
6937
|
-
type_of_transform='
|
6944
|
+
type_of_transform='antsRegistrationSyNRepro[r]',
|
6938
6945
|
tc='alternating',
|
6939
6946
|
n_to_trim=0,
|
6940
6947
|
m0_image = None,
|
@@ -7069,7 +7076,7 @@ def bold_perfusion(
|
|
7069
7076
|
fmri_template, hlinds = loop_timeseries_censoring( fmri, 0.10 )
|
7070
7077
|
fmri_template = ants.get_average_of_timeseries( fmri_template )
|
7071
7078
|
del hlinds
|
7072
|
-
rig = ants.registration( fmri_template, t1head, '
|
7079
|
+
rig = ants.registration( fmri_template, t1head, 'antsRegistrationSyNRepro[r]' )
|
7073
7080
|
bmask = ants.apply_transforms( fmri_template, ants.threshold_image(t1segmentation,1,6), rig['fwdtransforms'][0], interpolator='genericLabel' )
|
7074
7081
|
if m0_indices is None:
|
7075
7082
|
if n_to_trim is None:
|
@@ -7086,7 +7093,7 @@ def bold_perfusion(
|
|
7086
7093
|
trim = mytrim,
|
7087
7094
|
output_directory=None,
|
7088
7095
|
verbose=verbose,
|
7089
|
-
syn_metric='
|
7096
|
+
syn_metric='CC',
|
7090
7097
|
syn_sampling=2,
|
7091
7098
|
reg_iterations=[40,20,5] )
|
7092
7099
|
if verbose:
|
@@ -7135,7 +7142,7 @@ def bold_perfusion(
|
|
7135
7142
|
print( 'fmri_template')
|
7136
7143
|
print( fmri_template )
|
7137
7144
|
|
7138
|
-
rig = ants.registration( fmri_template, t1head, '
|
7145
|
+
rig = ants.registration( fmri_template, t1head, 'antsRegistrationSyNRepro[r]' )
|
7139
7146
|
bmask = ants.apply_transforms( fmri_template,
|
7140
7147
|
ants.threshold_image(t1segmentation,1,6),
|
7141
7148
|
rig['fwdtransforms'][0],
|
@@ -7151,7 +7158,7 @@ def bold_perfusion(
|
|
7151
7158
|
trim = mytrim,
|
7152
7159
|
output_directory=None,
|
7153
7160
|
verbose=verbose,
|
7154
|
-
syn_metric='
|
7161
|
+
syn_metric='CC',
|
7155
7162
|
syn_sampling=2,
|
7156
7163
|
reg_iterations=[40,20,5] )
|
7157
7164
|
if verbose:
|
@@ -7264,7 +7271,7 @@ Where:
|
|
7264
7271
|
m0 = ants.get_average_of_timeseries( fmrimotcorr )
|
7265
7272
|
else:
|
7266
7273
|
# register m0 to current template
|
7267
|
-
m0reg = ants.registration( fmri_template, m0, '
|
7274
|
+
m0reg = ants.registration( fmri_template, m0, 'antsRegistrationSyNRepro[r]', verbose=False )
|
7268
7275
|
m0 = m0reg['warpedmovout']
|
7269
7276
|
|
7270
7277
|
if ntp == 2 :
|
@@ -7351,7 +7358,7 @@ Where:
|
|
7351
7358
|
|
7352
7359
|
def pet3d_summary( pet3d, t1head, t1, t1segmentation, t1dktcit,
|
7353
7360
|
spa = (0., 0., 0.),
|
7354
|
-
type_of_transform='
|
7361
|
+
type_of_transform='antsRegistrationSyNRepro[r]',
|
7355
7362
|
upsample=True,
|
7356
7363
|
verbose=False ):
|
7357
7364
|
"""
|
@@ -7401,7 +7408,7 @@ def pet3d_summary( pet3d, t1head, t1, t1segmentation, t1dktcit,
|
|
7401
7408
|
newspc = [minspc,minspc,minspc]
|
7402
7409
|
pet3dr = ants.resample_image( pet3d, newspc, interp_type=0 )
|
7403
7410
|
|
7404
|
-
rig = ants.registration( pet3dr, t1head, '
|
7411
|
+
rig = ants.registration( pet3dr, t1head, 'antsRegistrationSyNRepro[r]' )
|
7405
7412
|
bmask = ants.apply_transforms( pet3dr,
|
7406
7413
|
ants.threshold_image(t1segmentation,1,6),
|
7407
7414
|
rig['fwdtransforms'][0],
|
@@ -7536,7 +7543,7 @@ def mm(
|
|
7536
7543
|
group_template = None,
|
7537
7544
|
group_transform = None,
|
7538
7545
|
target_range = [0,1],
|
7539
|
-
dti_motion_correct = '
|
7546
|
+
dti_motion_correct = 'antsRegistrationSyNQuickRepro[r]',
|
7540
7547
|
dti_denoise = False,
|
7541
7548
|
perfusion_trim=10,
|
7542
7549
|
perfusion_m0_image=None,
|
@@ -7679,9 +7686,10 @@ def mm(
|
|
7679
7686
|
|
7680
7687
|
if do_kk:
|
7681
7688
|
if verbose:
|
7682
|
-
print('kk')
|
7683
|
-
output_dict['kk'] = antspyt1w.kelly_kapowski_thickness(
|
7689
|
+
print('kk in mm')
|
7690
|
+
output_dict['kk'] = antspyt1w.kelly_kapowski_thickness( t1_image,
|
7684
7691
|
labels=hier['dkt_parc']['dkt_cortex'], iterations=45 )
|
7692
|
+
|
7685
7693
|
if perfusion_image is not None:
|
7686
7694
|
if perfusion_image.shape[3] > 1: # FIXME - better heuristic?
|
7687
7695
|
output_dict['perf'] = bold_perfusion(
|
@@ -7706,7 +7714,7 @@ def mm(
|
|
7706
7714
|
verbose=verbose )
|
7707
7715
|
################################## do the rsf .....
|
7708
7716
|
if len(rsf_image) > 0:
|
7709
|
-
my_motion_tx = '
|
7717
|
+
my_motion_tx = 'antsRegistrationSyNRepro[r]'
|
7710
7718
|
rsf_image = [i for i in rsf_image if i is not None]
|
7711
7719
|
if verbose:
|
7712
7720
|
print('rsf length ' + str( len( rsf_image ) ) )
|
@@ -7728,6 +7736,7 @@ def mm(
|
|
7728
7736
|
boldTemplate = ants.build_template(
|
7729
7737
|
initial_template = init_temp,
|
7730
7738
|
image_list=[rsfavg1,rsfavg2],
|
7739
|
+
type_of_transform="antsRegistrationSyNQuickRepro[s]",
|
7731
7740
|
iterations=5, verbose=False )
|
7732
7741
|
if verbose:
|
7733
7742
|
print("join the 2 rsf")
|
@@ -7799,89 +7808,7 @@ def mm(
|
|
7799
7808
|
verbose=verbose ) # default
|
7800
7809
|
rsfprolist.append( rsf0 )
|
7801
7810
|
output_dict['rsf'] = rsfprolist
|
7802
|
-
|
7803
|
-
# Initialize the parameters DataFrame
|
7804
|
-
# first - no censoring - just explore compcor
|
7805
|
-
df = pd.DataFrame()
|
7806
|
-
cens=False
|
7807
|
-
HM=1.0 # best by PTBP
|
7808
|
-
hmsearch = [0.5, 1.0, 5.0 ]
|
7809
|
-
loopsearch = [ 0.25, 0.5, 0.75, 1.0 ]
|
7810
|
-
loop = 1.0
|
7811
|
-
CCsearch = [ 5, 0.80 ]
|
7812
|
-
defaultf = [ 0.008, 0.15 ]
|
7813
|
-
freqsearch = ['broad','mid','tight'] #
|
7814
|
-
# for debuggin
|
7815
|
-
# rsf_image = remove_volumes_from_timeseries( rsf_image, list(range(80,2000)))
|
7816
|
-
docens=True # explore censoring
|
7817
|
-
for ff in freqsearch:
|
7818
|
-
for CC in CCsearch:
|
7819
|
-
local_df = pd.DataFrame({"loop": [loop], "cens": [cens], "HM": [HM], "ff": [ff], "CC": [CC]})
|
7820
|
-
if verbose:
|
7821
|
-
print( local_df )
|
7822
|
-
if df.shape[0] == 0:
|
7823
|
-
df = local_df
|
7824
|
-
else:
|
7825
|
-
df = pd.concat([df, local_df], ignore_index=True)
|
7826
|
-
f = defaultf
|
7827
|
-
if ff == 'mid':
|
7828
|
-
f = [0.01,0.1]
|
7829
|
-
elif ff == 'tight':
|
7830
|
-
f = [0.03,0.08]
|
7831
|
-
rsf0 = resting_state_fmri_networks(
|
7832
|
-
rsf_image, boldTemplate, hier['brain_n4_dnz'], t1atropos,
|
7833
|
-
f=f,
|
7834
|
-
FD_threshold=HM,
|
7835
|
-
spa = None, spt = None,
|
7836
|
-
nc = CC,
|
7837
|
-
outlier_threshold=loop,
|
7838
|
-
ica_components = 0,
|
7839
|
-
impute = False,
|
7840
|
-
censor = cens,
|
7841
|
-
despike = 2.5,
|
7842
|
-
motion_as_nuisance = True,
|
7843
|
-
upsample=False,
|
7844
|
-
clean_tmp=0.66,
|
7845
|
-
verbose=verbose ) # default
|
7846
|
-
rsfprolist.append( rsf0 )
|
7847
|
-
|
7848
|
-
# test impact of censoring
|
7849
|
-
if docens:
|
7850
|
-
cens = True
|
7851
|
-
for loop in loopsearch:
|
7852
|
-
for HM in hmsearch:
|
7853
|
-
for ff in freqsearch:
|
7854
|
-
for CC in CCsearch:
|
7855
|
-
local_df = pd.DataFrame({"loop": [loop], "cens": [cens], "HM": [HM], "ff": [ff], "CC": [CC]})
|
7856
|
-
if verbose:
|
7857
|
-
print( local_df )
|
7858
|
-
df = pd.concat([df, local_df], ignore_index=True)
|
7859
|
-
f = defaultf
|
7860
|
-
if ff == 'mid':
|
7861
|
-
f = [0.01,0.1]
|
7862
|
-
elif ff == 'tight':
|
7863
|
-
f = [0.03,0.08]
|
7864
|
-
rsf0 = resting_state_fmri_networks(
|
7865
|
-
rsf_image,
|
7866
|
-
boldTemplate,
|
7867
|
-
hier['brain_n4_dnz'],
|
7868
|
-
t1atropos,
|
7869
|
-
f=f,
|
7870
|
-
FD_threshold=HM,
|
7871
|
-
spa = None,
|
7872
|
-
spt = None,
|
7873
|
-
nc = CC,
|
7874
|
-
outlier_threshold=loop,
|
7875
|
-
ica_components = 0,
|
7876
|
-
impute = False,
|
7877
|
-
censor = cens,
|
7878
|
-
despike = 2.5,
|
7879
|
-
motion_as_nuisance = True,
|
7880
|
-
upsample=False,
|
7881
|
-
clean_tmp=0.66,
|
7882
|
-
verbose=verbose ) # default
|
7883
|
-
rsfprolist.append( rsf0 )
|
7884
|
-
output_dict['rsf'] = rsfprolist
|
7811
|
+
|
7885
7812
|
if nm_image_list is not None:
|
7886
7813
|
if verbose:
|
7887
7814
|
print('nm')
|
@@ -7898,11 +7825,11 @@ def mm(
|
|
7898
7825
|
print("We have only one DTI: " + str(len(dw_image)))
|
7899
7826
|
dw_image = dw_image[0]
|
7900
7827
|
btpB0, btpDW = get_average_dwi_b0(dw_image)
|
7901
|
-
initrig = ants.registration( btpDW, hier['brain_n4_dnz'], '
|
7828
|
+
initrig = ants.registration( btpDW, hier['brain_n4_dnz'], 'antsRegistrationSyNRepro[r]' )['fwdtransforms'][0]
|
7902
7829
|
tempreg = ants.registration( btpDW, hier['brain_n4_dnz'], 'SyNOnly',
|
7903
|
-
syn_metric='
|
7830
|
+
syn_metric='CC', syn_sampling=2,
|
7904
7831
|
reg_iterations=[50,50,20],
|
7905
|
-
multivariate_extras=[ [ "
|
7832
|
+
multivariate_extras=[ [ "CC", btpB0, hier['brain_n4_dnz'], 1, 2 ]],
|
7906
7833
|
initial_transform=initrig
|
7907
7834
|
)
|
7908
7835
|
mybxt = ants.threshold_image( ants.iMath(hier['brain_n4_dnz'], "Normalize" ), 0.001, 1 )
|
@@ -7935,11 +7862,11 @@ def mm(
|
|
7935
7862
|
b_image_list=[a1b,a2b],
|
7936
7863
|
w_image_list=[a1w,a2w],
|
7937
7864
|
iterations=7, verbose=verbose )
|
7938
|
-
initrig = ants.registration( btpDW, hier['brain_n4_dnz'], '
|
7865
|
+
initrig = ants.registration( btpDW, hier['brain_n4_dnz'], 'antsRegistrationSyNRepro[r]' )['fwdtransforms'][0]
|
7939
7866
|
tempreg = ants.registration( btpDW, hier['brain_n4_dnz'], 'SyNOnly',
|
7940
|
-
syn_metric='
|
7867
|
+
syn_metric='CC', syn_sampling=2,
|
7941
7868
|
reg_iterations=[50,50,20],
|
7942
|
-
multivariate_extras=[ [ "
|
7869
|
+
multivariate_extras=[ [ "CC", btpB0, hier['brain_n4_dnz'], 1, 2 ]],
|
7943
7870
|
initial_transform=initrig
|
7944
7871
|
)
|
7945
7872
|
mybxt = ants.threshold_image( ants.iMath(hier['brain_n4_dnz'], "Normalize" ), 0.001, 1 )
|
@@ -8026,7 +7953,7 @@ def mm(
|
|
8026
7953
|
normalization_dict['kk_norm'] = ants.apply_transforms( group_template, output_dict['kk']['thickness_image'], group_transform )
|
8027
7954
|
if output_dict['DTI'] is not None:
|
8028
7955
|
mydti = output_dict['DTI']
|
8029
|
-
dtirig = ants.registration( hier['brain_n4_dnz'], mydti['recon_fa'], '
|
7956
|
+
dtirig = ants.registration( hier['brain_n4_dnz'], mydti['recon_fa'], 'antsRegistrationSyNRepro[r]' )
|
8030
7957
|
normalization_dict['MD_norm'] = ants.apply_transforms( group_template, mydti['recon_md'],group_transform+dtirig['fwdtransforms'] )
|
8031
7958
|
normalization_dict['FA_norm'] = ants.apply_transforms( group_template, mydti['recon_fa'],group_transform+dtirig['fwdtransforms'] )
|
8032
7959
|
output_directory = tempfile.mkdtemp()
|
@@ -8043,7 +7970,7 @@ def mm(
|
|
8043
7970
|
if output_dict['rsf'] is not None:
|
8044
7971
|
if False:
|
8045
7972
|
rsfpro = output_dict['rsf'] # FIXME
|
8046
|
-
rsfrig = ants.registration( hier['brain_n4_dnz'], rsfpro['meanBold'], '
|
7973
|
+
rsfrig = ants.registration( hier['brain_n4_dnz'], rsfpro['meanBold'], 'antsRegistrationSyNRepro[r]' )
|
8047
7974
|
for netid in get_antsimage_keys( rsfpro ):
|
8048
7975
|
rsfkey = netid + "_norm"
|
8049
7976
|
normalization_dict[rsfkey] = ants.apply_transforms(
|
@@ -8797,7 +8724,7 @@ def mm_csv(
|
|
8797
8724
|
srmodel_T1 = False, # optional - will add a great deal of time
|
8798
8725
|
srmodel_NM = False, # optional - will add a great deal of time
|
8799
8726
|
srmodel_DTI = False, # optional - will add a great deal of time
|
8800
|
-
dti_motion_correct = '
|
8727
|
+
dti_motion_correct = 'antsRegistrationSyNQuickRepro[r]',
|
8801
8728
|
dti_denoise = True,
|
8802
8729
|
nrg_modality_list = None,
|
8803
8730
|
normalization_template = None,
|
@@ -11005,7 +10932,7 @@ def wmh( flair, t1, t1seg,
|
|
11005
10932
|
"""
|
11006
10933
|
import numpy as np
|
11007
10934
|
import math
|
11008
|
-
t1_2_flair_reg = ants.registration(flair, t1, type_of_transform = '
|
10935
|
+
t1_2_flair_reg = ants.registration(flair, t1, type_of_transform = 'antsRegistrationSyNRepro[r]') # Register T1 to Flair
|
11009
10936
|
if probability_mask is None and model == 'sysu':
|
11010
10937
|
if verbose:
|
11011
10938
|
print('sysu')
|
@@ -12656,7 +12583,7 @@ def enantiomorphic_filling_without_mask( image, axis=0, intensity='low' ):
|
|
12656
12583
|
imagen = ants.iMath( imagen, "TruncateIntensity", 1e-6, 0.98 )
|
12657
12584
|
imagen = ants.iMath( imagen, 'Normalize' )
|
12658
12585
|
# Create a mirror image (flipping left and right)
|
12659
|
-
mirror_image = ants.reflect_image(imagen, axis=0, tx='
|
12586
|
+
mirror_image = ants.reflect_image(imagen, axis=0, tx='antsRegistrationSyNQuickRepro[s]' )['warpedmovout']
|
12660
12587
|
|
12661
12588
|
# Create a symmetric version of the image by averaging the original and the mirror image
|
12662
12589
|
symmetric_image = imagen * 0.5 + mirror_image * 0.5
|
@@ -0,0 +1,6 @@
|
|
1
|
+
antspymm/__init__.py,sha256=cTcqtGO0J5T2I0Chxe-Sy25QDlnHLDEQK8QEnJkkFRs,4900
|
2
|
+
antspymm/mm.py,sha256=uAtsfULH9PLB1_mPRTt2rMzZvuPl3X526FYwfSENNmc,541908
|
3
|
+
antspymm-1.5.9.dist-info/METADATA,sha256=QKbK0ypvBfQblG-6VJFnr8md_lmnMn14lz5bchmg-_0,26007
|
4
|
+
antspymm-1.5.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
5
|
+
antspymm-1.5.9.dist-info/top_level.txt,sha256=iyD1sRhCKzfwKRJLq5ZUeV9xsv1cGQl8Ejp6QwXM1Zg,9
|
6
|
+
antspymm-1.5.9.dist-info/RECORD,,
|
antspymm-1.5.7.dist-info/RECORD
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
antspymm/__init__.py,sha256=cTcqtGO0J5T2I0Chxe-Sy25QDlnHLDEQK8QEnJkkFRs,4900
|
2
|
-
antspymm/mm.py,sha256=eqMcRxQt03AbC3qRrubYBxGsbkKNfrS0dd9VgqXavCE,544991
|
3
|
-
antspymm-1.5.7.dist-info/METADATA,sha256=c-2SVYUIR2RGZ_XJXE8M1nxG94CpF9-fYBiRERaCHhQ,26007
|
4
|
-
antspymm-1.5.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
5
|
-
antspymm-1.5.7.dist-info/top_level.txt,sha256=iyD1sRhCKzfwKRJLq5ZUeV9xsv1cGQl8Ejp6QwXM1Zg,9
|
6
|
-
antspymm-1.5.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|