antspymm 1.5.1__py3-none-any.whl → 1.5.2__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 +12 -12
- {antspymm-1.5.1.dist-info → antspymm-1.5.2.dist-info}/METADATA +1 -1
- antspymm-1.5.2.dist-info/RECORD +7 -0
- antspymm-1.5.1.dist-info/RECORD +0 -7
- {antspymm-1.5.1.dist-info → antspymm-1.5.2.dist-info}/WHEEL +0 -0
- {antspymm-1.5.1.dist-info → antspymm-1.5.2.dist-info}/licenses/LICENSE +0 -0
- {antspymm-1.5.1.dist-info → antspymm-1.5.2.dist-info}/top_level.txt +0 -0
antspymm/mm.py
CHANGED
@@ -3655,8 +3655,8 @@ def efficient_tensor_fit( gtab, fit_method, imagein, maskin, diffusion_model='DT
|
|
3655
3655
|
|
3656
3656
|
|
3657
3657
|
def efficient_dwi_fit(gtab, diffusion_model, imagein, maskin,
|
3658
|
-
|
3659
|
-
|
3658
|
+
model_params=None, bvals_to_use=None,
|
3659
|
+
chunk_size=1024, num_threads=1, verbose=True):
|
3660
3660
|
"""
|
3661
3661
|
Efficient and optionally parallelized diffusion model reconstruction using DiPy.
|
3662
3662
|
|
@@ -3675,7 +3675,7 @@ def efficient_dwi_fit(gtab, diffusion_model, imagein, maskin,
|
|
3675
3675
|
bvals_to_use : list of int, optional
|
3676
3676
|
Subset of b-values to use for the fit (e.g., [0, 1000, 2000]).
|
3677
3677
|
chunk_size : int, optional
|
3678
|
-
|
3678
|
+
Maximum number of voxels per chunk (default 1024).
|
3679
3679
|
num_threads : int, optional
|
3680
3680
|
Number of parallel threads.
|
3681
3681
|
verbose : bool, optional
|
@@ -3707,23 +3707,25 @@ def efficient_dwi_fit(gtab, diffusion_model, imagein, maskin,
|
|
3707
3707
|
img_data = imagein.numpy()
|
3708
3708
|
mask = maskin.numpy().astype(bool)
|
3709
3709
|
X, Y, Z, N = img_data.shape
|
3710
|
+
inplane_size = X * Y
|
3711
|
+
|
3712
|
+
# Convert chunk_size from voxel count to number of slices
|
3713
|
+
slices_per_chunk = max(1, chunk_size // inplane_size)
|
3710
3714
|
|
3711
3715
|
if verbose:
|
3712
3716
|
print(f"[INFO] Image shape: {img_data.shape}")
|
3713
3717
|
print(f"[INFO] Using model: {diffusion_model}")
|
3714
|
-
print(f"[INFO]
|
3718
|
+
print(f"[INFO] Max voxels per chunk: {chunk_size} (→ {slices_per_chunk} slices) | Threads: {num_threads}")
|
3715
3719
|
|
3716
|
-
# Filter shells if specified
|
3717
3720
|
if bvals_to_use is not None:
|
3718
3721
|
bvals_to_use = set(bvals_to_use)
|
3719
3722
|
sel = np.isin(gtab.bvals, list(bvals_to_use))
|
3720
3723
|
img_data = img_data[..., sel]
|
3721
|
-
gtab = gradient_table(gtab.bvals[sel], gtab.bvecs[sel])
|
3724
|
+
gtab = gradient_table(gtab.bvals[sel], bvecs=gtab.bvecs[sel])
|
3722
3725
|
if verbose:
|
3723
3726
|
print(f"[INFO] Selected b-values: {sorted(bvals_to_use)}")
|
3724
3727
|
print(f"[INFO] Selected volumes: {sel.sum()} / {N}")
|
3725
3728
|
|
3726
|
-
# Choose model
|
3727
3729
|
def get_model(name, gtab, **params):
|
3728
3730
|
if name == 'DTI':
|
3729
3731
|
return dti.TensorModel(gtab, **params)
|
@@ -3736,14 +3738,13 @@ def efficient_dwi_fit(gtab, diffusion_model, imagein, maskin,
|
|
3736
3738
|
|
3737
3739
|
model = get_model(diffusion_model, gtab, **model_params)
|
3738
3740
|
|
3739
|
-
# Output volumes initialized to zero
|
3740
3741
|
FA_vol = np.zeros((X, Y, Z), dtype=np.float32)
|
3741
3742
|
MD_vol = np.zeros((X, Y, Z), dtype=np.float32)
|
3742
3743
|
RGB_vol = np.zeros((X, Y, Z, 3), dtype=np.float32)
|
3743
3744
|
has_tensor_metrics = diffusion_model in ['DTI', 'FreeWater']
|
3744
3745
|
|
3745
3746
|
def process_chunk(z_start):
|
3746
|
-
z_end = min(Z, z_start +
|
3747
|
+
z_end = min(Z, z_start + slices_per_chunk)
|
3747
3748
|
local_data = img_data[:, :, z_start:z_end, :]
|
3748
3749
|
local_mask = mask[:, :, z_start:z_end]
|
3749
3750
|
masked_data = local_data * local_mask[..., None]
|
@@ -3758,8 +3759,7 @@ def efficient_dwi_fit(gtab, diffusion_model, imagein, maskin,
|
|
3758
3759
|
return z_start, z_end, FA, MD, RGB
|
3759
3760
|
return z_start, z_end, None, None, None
|
3760
3761
|
|
3761
|
-
|
3762
|
-
chunks = range(0, Z, chunk_size)
|
3762
|
+
chunks = range(0, Z, slices_per_chunk)
|
3763
3763
|
if num_threads > 1:
|
3764
3764
|
with ThreadPoolExecutor(max_workers=num_threads) as executor:
|
3765
3765
|
futures = {executor.submit(process_chunk, z): z for z in chunks}
|
@@ -4455,7 +4455,7 @@ def dwi_deterministic_tracking(
|
|
4455
4455
|
gtab = gradient_table(bvals, bvecs=bvecs, atol=2.0 )
|
4456
4456
|
if mask is None:
|
4457
4457
|
mask = ants.threshold_image( fa, fa_thresh, 2.0 ).iMath("GetLargestComponent")
|
4458
|
-
dwi_data = dwi.numpy()
|
4458
|
+
dwi_data = dwi.numpy()
|
4459
4459
|
dwi_mask = mask.numpy() == 1
|
4460
4460
|
dti_model = dti.TensorModel(gtab,fit_method=fit_method)
|
4461
4461
|
if verbose:
|
@@ -0,0 +1,7 @@
|
|
1
|
+
antspymm/__init__.py,sha256=DnkidUfEu3Dl0tuWNTA-9VOUkBtH_cROKiPGNNXNagU,4637
|
2
|
+
antspymm/mm.py,sha256=NbT1IBiuEMtMoanr_8yO3kLNpSSfV0j1_155gykGOM0,526972
|
3
|
+
antspymm-1.5.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
4
|
+
antspymm-1.5.2.dist-info/METADATA,sha256=3Ttc-cPytZsiNct2MRz4PZwe5JmdZzaEsEgu7hxKxvA,25939
|
5
|
+
antspymm-1.5.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
6
|
+
antspymm-1.5.2.dist-info/top_level.txt,sha256=iyD1sRhCKzfwKRJLq5ZUeV9xsv1cGQl8Ejp6QwXM1Zg,9
|
7
|
+
antspymm-1.5.2.dist-info/RECORD,,
|
antspymm-1.5.1.dist-info/RECORD
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
antspymm/__init__.py,sha256=DnkidUfEu3Dl0tuWNTA-9VOUkBtH_cROKiPGNNXNagU,4637
|
2
|
-
antspymm/mm.py,sha256=oPHhV70IhFXCKI26rP5HgKpkb2OjqCWkqoy4cSxJXqA,526866
|
3
|
-
antspymm-1.5.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
4
|
-
antspymm-1.5.1.dist-info/METADATA,sha256=_I4UmZGWLM6KkmTJc21wKW1DrjT2TY723C1jr7LA3Fw,25939
|
5
|
-
antspymm-1.5.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
6
|
-
antspymm-1.5.1.dist-info/top_level.txt,sha256=iyD1sRhCKzfwKRJLq5ZUeV9xsv1cGQl8Ejp6QwXM1Zg,9
|
7
|
-
antspymm-1.5.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|