antspymm 1.5.2__tar.gz → 1.5.3__tar.gz
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-1.5.2/antspymm.egg-info → antspymm-1.5.3}/PKG-INFO +1 -1
- {antspymm-1.5.2 → antspymm-1.5.3}/antspymm/mm.py +16 -13
- {antspymm-1.5.2 → antspymm-1.5.3/antspymm.egg-info}/PKG-INFO +1 -1
- {antspymm-1.5.2 → antspymm-1.5.3}/pyproject.toml +1 -1
- antspymm-1.5.3/tests/dwi_run_ptbp_scrub.py +80 -0
- antspymm-1.5.2/tests/dwi_run_ptbp_scrub.py +0 -43
- {antspymm-1.5.2 → antspymm-1.5.3}/LICENSE +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/MANIFEST.in +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/README.md +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/antspymm/__init__.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/antspymm.egg-info/SOURCES.txt +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/antspymm.egg-info/dependency_links.txt +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/antspymm.egg-info/requires.txt +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/antspymm.egg-info/top_level.txt +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/docs/adni_rsfmri_2_nrg_conversion.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/docs/antspymm_annotated_output_tree.pages +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/docs/antspymm_annotated_output_tree.txt +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/docs/antspymm_data_dictionary.csv +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/docs/bids_cohort_example.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/docs/blind_qc.Rmd +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/docs/blind_qc.html +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/docs/convert_adni_dti_to_nrg.R +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/docs/deepnbm.jpg +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/docs/describe_mm_data.R +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/docs/example_antspymm_output.csv +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/docs/example_run_from_directory.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/docs/make_dict_table.Rmd +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/docs/make_dict_table.html +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/docs/nrg_cohort_example.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/docs/ptbp_nrg.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/docs/roi_visualization.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/docs/roi_visualization_ppmi.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/docs/step1_blind_qc.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/docs/step2_outlierness.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/docs/step3_mm_nrg_csv.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/docs/step4_aggregate.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/docs/template_overlays.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/docs/ukbb_to_nrg_processing.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/docs/ukbb_to_nrg_processing2.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/setup.cfg +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/bids_2_nrg.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/blind_qc.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/deformation_gradient_reo.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/dipy_dti_recon.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/dti_recon.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/dti_reg.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/dwi_rebasing.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/dwi_run.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/flair_run.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/joint_dti_recon.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/mm.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/mm_csv.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/mm_nrg.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/nrg_validation.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/outlierness.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/parallel_study_aggregation_example.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/perfusion_ptbp.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/perfusion_run.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/perfusion_run_nnl.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/rsfmri_run.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/rsfmri_run_minimal.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/test_loop.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/test_reference_run.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/test_rsfmri_run_minimal_ptbp.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/testsr.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/ukbb_rsfmri.py +0 -0
- {antspymm-1.5.2 → antspymm-1.5.3}/tests/visualize_tractogram.py +0 -0
@@ -2198,9 +2198,10 @@ def dti_numpy_to_image( reference_image, tensorarray, upper_triangular=True):
|
|
2198
2198
|
def transform_and_reorient_dti( fixed, moving_dti, composite_transform, py_based=True, verbose=False, **kwargs):
|
2199
2199
|
"""
|
2200
2200
|
apply a transform to DTI in the style of ants.apply_transforms. this function
|
2201
|
-
expects a pre-computed composite transform which it will use to reorient
|
2202
|
-
the DTI using preservation of principle directions.
|
2203
|
-
|
2201
|
+
expects a pre-computed composite transform which it will use to reorient
|
2202
|
+
the DTI using preservation of principle directions. BUG fix by cookpa 2025
|
2203
|
+
06 18.
|
2204
|
+
|
2204
2205
|
fixed : antsImage reference space
|
2205
2206
|
|
2206
2207
|
moving_dti : antsImage DTI in upper triangular format
|
@@ -2224,34 +2225,36 @@ def transform_and_reorient_dti( fixed, moving_dti, composite_transform, py_based
|
|
2224
2225
|
dtiw = []
|
2225
2226
|
for k in range(len(dtsplit)):
|
2226
2227
|
dtiw.append( ants.apply_transforms( fixed, dtsplit[k], composite_transform ) )
|
2227
|
-
dtiw=ants.merge_channels(dtiw)
|
2228
|
+
dtiw=ants.merge_channels(dtiw) # resampled into fixed space but still based in moving index space
|
2228
2229
|
if verbose:
|
2229
2230
|
print("reorient tensors locally: compose and get reo image")
|
2230
|
-
locrot = ants.deformation_gradient( ants.image_read(composite_transform),
|
2231
|
+
locrot = ants.deformation_gradient( ants.image_read(composite_transform),
|
2231
2232
|
to_rotation = True, py_based=py_based ).numpy()
|
2232
|
-
|
2233
|
+
# rebases from moving index to fixed index space. Not quite what we need here
|
2234
|
+
# rebaser = np.dot( np.transpose( fixed.direction ), moving_dti.direction )
|
2233
2235
|
if verbose:
|
2234
2236
|
print("convert UT to full tensor")
|
2235
2237
|
dtiw2tensor = triangular_to_tensor( dtiw )
|
2236
2238
|
if verbose:
|
2237
|
-
print("rebase tensors to new space via iterator")
|
2239
|
+
print("rebase tensors to new space and apply reorientation via iterator")
|
2238
2240
|
it = np.ndindex( fixed.shape )
|
2239
2241
|
for i in it:
|
2240
|
-
# direction * dt * direction.transpose();
|
2241
2242
|
mmm = dtiw2tensor[i]
|
2242
|
-
#
|
2243
|
+
# Rebase mmm to physical space
|
2244
|
+
mmm = np.dot( mmm, np.transpose( moving_dti.direction ) )
|
2245
|
+
mmm = np.dot( moving_dti.direction, mmm )
|
2246
|
+
# Now apply local rotation
|
2243
2247
|
locrotx = np.reshape( locrot[i], [3,3] )
|
2244
2248
|
mmm = np.dot( mmm, np.transpose( locrotx ) )
|
2245
2249
|
mmm = np.dot( locrotx, mmm )
|
2246
|
-
#
|
2247
|
-
mmm = np.dot( mmm, np.transpose(
|
2248
|
-
mmm = np.dot(
|
2250
|
+
# Now rebase to fixed index space
|
2251
|
+
mmm = np.dot( mmm, np.transpose( fixed.direction ) )
|
2252
|
+
mmm = np.dot( fixed.direction, mmm )
|
2249
2253
|
dtiw2tensor[i] = mmm
|
2250
2254
|
if verbose:
|
2251
2255
|
print("done with rebasing")
|
2252
2256
|
return dti_numpy_to_image( fixed, dtiw2tensor )
|
2253
2257
|
|
2254
|
-
|
2255
2258
|
def dti_reg(
|
2256
2259
|
image,
|
2257
2260
|
avg_b0,
|
@@ -0,0 +1,80 @@
|
|
1
|
+
import sys, os
|
2
|
+
import unittest
|
3
|
+
|
4
|
+
os.environ["TF_NUM_INTEROP_THREADS"] = "8"
|
5
|
+
os.environ["TF_NUM_INTRAOP_THREADS"] = "8"
|
6
|
+
os.environ["ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS"] = "8"
|
7
|
+
|
8
|
+
import tempfile
|
9
|
+
import shutil
|
10
|
+
import tensorflow as tf
|
11
|
+
import antspymm
|
12
|
+
import antspyt1w
|
13
|
+
import antspynet
|
14
|
+
import ants
|
15
|
+
from dipy.io.gradients import read_bvals_bvecs
|
16
|
+
|
17
|
+
import glob
|
18
|
+
from typing import List
|
19
|
+
|
20
|
+
downloaddir = os.path.expanduser( "~/data/PTBP/images/" )
|
21
|
+
|
22
|
+
import glob
|
23
|
+
import os
|
24
|
+
from typing import List
|
25
|
+
|
26
|
+
def extract_dti_prefix_paths(base_pattern: str) -> List[str]:
|
27
|
+
"""
|
28
|
+
Find DTI-related files matching a pattern and extract the full path
|
29
|
+
with the filename minus its extension.
|
30
|
+
|
31
|
+
Args:
|
32
|
+
base_pattern (str): Glob pattern to find files (e.g., *.bval, *.nii.gz)
|
33
|
+
|
34
|
+
Returns:
|
35
|
+
List[str]: List of full prefix paths (without file extension)
|
36
|
+
"""
|
37
|
+
files = glob.glob(base_pattern)
|
38
|
+
prefix_paths = []
|
39
|
+
|
40
|
+
for filepath in files:
|
41
|
+
root, _ = os.path.splitext(filepath) # removes .bval, .nii.gz, etc.
|
42
|
+
prefix_paths.append(root)
|
43
|
+
|
44
|
+
return sorted(prefix_paths)
|
45
|
+
|
46
|
+
files = extract_dti_prefix_paths(downloaddir + 'PEDS*/20*/DWI/*.bval')
|
47
|
+
|
48
|
+
|
49
|
+
testingClass = unittest.TestCase( )
|
50
|
+
islocal = False
|
51
|
+
if not "prefix" in globals():
|
52
|
+
prefix = files[0]
|
53
|
+
print( "process: " + prefix )
|
54
|
+
# prefix = downloaddir + "PEDS097/20130215/DWI/PEDS097_20130215_0021_DTI_1_1x0_30x1000." # has problems
|
55
|
+
# prefix = downloaddir + "PEDS022/20131101/DWI/PEDS022_20131101_0015_DTI_1_1x0_30x1000." # "normal" quality
|
56
|
+
imgfn = prefix + ".nii.gz"
|
57
|
+
dwi = ants.image_read( imgfn )
|
58
|
+
dwi = ants.motion_correction( dwi )['motion_corrected']
|
59
|
+
dd = antspymm.dipy_dti_recon( dwi, prefix + ".bval", prefix + ".bvec", verbose=True )
|
60
|
+
|
61
|
+
bvalr, bvecr = read_bvals_bvecs( prefix + ".bval", prefix + ".bvec" )
|
62
|
+
mask=None
|
63
|
+
mask=dd['dwi_mask']
|
64
|
+
th=0.20
|
65
|
+
# th=0.05
|
66
|
+
for mask in [None,dd['dwi_mask']]:
|
67
|
+
print("Mask is" + str( mask ) )
|
68
|
+
# scrub example
|
69
|
+
# def censor_dwi( dwi, bval, bvec, threshold = 0.20, imputeb0=False, mask=None, verbose=False ):
|
70
|
+
dwi_sc, bval_sc, bvec_sc = antspymm.censor_dwi( dwi, bvalr, bvecr, threshold=th, mask=mask, verbose=True )
|
71
|
+
## this is the right answer for PEDS097_20130215_0021_DTI_1_1x0_30x1000
|
72
|
+
# censoring: [4, 5, 6, 28]
|
73
|
+
antspymm.write_bvals_bvecs( bvals=bval_sc, bvecs=bvec_sc, prefix='/tmp/temp' )
|
74
|
+
ee = antspymm.dipy_dti_recon( dwi_sc, '/tmp/temp.bval', '/tmp/temp.bvec', verbose=True )
|
75
|
+
# impute example
|
76
|
+
dwi_imp = antspymm.impute_dwi( dwi, threshold=th, mask=mask, verbose=True )
|
77
|
+
ff = antspymm.dipy_dti_recon( dwi_imp, prefix + ".bval", prefix + ".bvec", verbose=True )
|
78
|
+
ants.image_write( dd['FA'], '/tmp/temp0.nii.gz' )
|
79
|
+
ants.image_write( ee['FA'], '/tmp/temp1.nii.gz' )
|
80
|
+
ants.image_write( ff['FA'], '/tmp/temp2.nii.gz' )
|
@@ -1,43 +0,0 @@
|
|
1
|
-
import sys, os
|
2
|
-
import unittest
|
3
|
-
|
4
|
-
os.environ["TF_NUM_INTEROP_THREADS"] = "8"
|
5
|
-
os.environ["TF_NUM_INTRAOP_THREADS"] = "8"
|
6
|
-
os.environ["ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS"] = "8"
|
7
|
-
|
8
|
-
import tempfile
|
9
|
-
import shutil
|
10
|
-
import tensorflow as tf
|
11
|
-
import antspymm
|
12
|
-
import antspyt1w
|
13
|
-
import antspynet
|
14
|
-
import ants
|
15
|
-
from dipy.io.gradients import read_bvals_bvecs
|
16
|
-
|
17
|
-
testingClass = unittest.TestCase( )
|
18
|
-
islocal = False
|
19
|
-
downloaddir = os.path.expanduser( "~/data/PTBP/images/" )
|
20
|
-
if not "prefix" in globals():
|
21
|
-
prefix = downloaddir + "PEDS097/20130215/DWI/PEDS097_20130215_0021_DTI_1_1x0_30x1000." # has problems
|
22
|
-
# prefix = downloaddir + "PEDS022/20131101/DWI/PEDS022_20131101_0015_DTI_1_1x0_30x1000." # "normal" quality
|
23
|
-
imgfn = prefix + "nii.gz"
|
24
|
-
dwi = ants.image_read( imgfn )
|
25
|
-
dwi = ants.motion_correction( dwi )['motion_corrected']
|
26
|
-
dd = antspymm.dipy_dti_recon( dwi, prefix + "bval", prefix + "bvec", verbose=True )
|
27
|
-
|
28
|
-
bvalr, bvecr = read_bvals_bvecs( prefix + "bval", prefix + "bvec" )
|
29
|
-
mask=None
|
30
|
-
mask=dd['dwi_mask']
|
31
|
-
th=0.20
|
32
|
-
for mask in [None,dd['dwi_mask']]:
|
33
|
-
print("Mask is" + str( mask ) )
|
34
|
-
# scrub example
|
35
|
-
dwi_sc, bval_sc, bvec_sc = antspymm.scrub_dwi( dwi, bvalr, bvecr, threshold=th, mask=mask, verbose=True )
|
36
|
-
antspymm.write_bvals_bvecs( bvals=bval_sc, bvecs=bvec_sc, prefix='/tmp/temp' )
|
37
|
-
ee = antspymm.dipy_dti_recon( dwi_sc, '/tmp/temp.bval', '/tmp/temp.bvec', verbose=True )
|
38
|
-
# impute example
|
39
|
-
dwi_imp = antspymm.impute_dwi( dwi, threshold=th, mask=mask, verbose=True )
|
40
|
-
ff = antspymm.dipy_dti_recon( dwi_imp, prefix + "bval", prefix + "bvec", verbose=True )
|
41
|
-
ants.image_write( dd['FA'], '/tmp/temp0.nii.gz' )
|
42
|
-
ants.image_write( ee['FA'], '/tmp/temp1.nii.gz' )
|
43
|
-
ants.image_write( ff['FA'], '/tmp/temp2.nii.gz' )
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|