junifer 0.0.6.dev330__py3-none-any.whl → 0.0.6.dev344__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.
- junifer/_version.py +2 -2
- junifer/data/masks/_ants_mask_warper.py +3 -3
- junifer/data/masks/_masks.py +141 -85
- junifer/data/masks/tests/test_masks.py +0 -1
- junifer/data/parcellations/_ants_parcellation_warper.py +1 -1
- junifer/data/parcellations/_parcellations.py +18 -1
- junifer/data/template_spaces.py +4 -5
- junifer/data/tests/test_template_spaces.py +8 -4
- junifer/preprocess/warping/_ants_warper.py +1 -1
- {junifer-0.0.6.dev330.dist-info → junifer-0.0.6.dev344.dist-info}/METADATA +1 -1
- {junifer-0.0.6.dev330.dist-info → junifer-0.0.6.dev344.dist-info}/RECORD +16 -16
- {junifer-0.0.6.dev330.dist-info → junifer-0.0.6.dev344.dist-info}/AUTHORS.rst +0 -0
- {junifer-0.0.6.dev330.dist-info → junifer-0.0.6.dev344.dist-info}/LICENSE.md +0 -0
- {junifer-0.0.6.dev330.dist-info → junifer-0.0.6.dev344.dist-info}/WHEEL +0 -0
- {junifer-0.0.6.dev330.dist-info → junifer-0.0.6.dev344.dist-info}/entry_points.txt +0 -0
- {junifer-0.0.6.dev330.dist-info → junifer-0.0.6.dev344.dist-info}/top_level.txt +0 -0
junifer/_version.py
CHANGED
@@ -12,5 +12,5 @@ __version__: str
|
|
12
12
|
__version_tuple__: VERSION_TUPLE
|
13
13
|
version_tuple: VERSION_TUPLE
|
14
14
|
|
15
|
-
__version__ = version = '0.0.6.
|
16
|
-
__version_tuple__ = version_tuple = (0, 0, 6, '
|
15
|
+
__version__ = version = '0.0.6.dev344'
|
16
|
+
__version_tuple__ = version_tuple = (0, 0, 6, 'dev344')
|
@@ -46,7 +46,7 @@ class ANTsMaskWarper:
|
|
46
46
|
The mask image to transform.
|
47
47
|
src : str
|
48
48
|
The data type or template space to warp from.
|
49
|
-
It should be empty string if ``dst="
|
49
|
+
It should be empty string if ``dst="native"``.
|
50
50
|
dst : str
|
51
51
|
The data type or template space to warp to.
|
52
52
|
`"native"` is the only allowed data type and it uses the resampled
|
@@ -58,7 +58,7 @@ class ANTsMaskWarper:
|
|
58
58
|
will be applied.
|
59
59
|
warp_data : dict or None
|
60
60
|
The warp data item of the data object. The value is unused if
|
61
|
-
``dst!="
|
61
|
+
``dst!="native"``.
|
62
62
|
|
63
63
|
Returns
|
64
64
|
-------
|
@@ -125,7 +125,7 @@ class ANTsMaskWarper:
|
|
125
125
|
# Get template space image
|
126
126
|
template_space_img = get_template(
|
127
127
|
space=dst,
|
128
|
-
|
128
|
+
target_img=mask_img,
|
129
129
|
extra_input=None,
|
130
130
|
)
|
131
131
|
# Save template to a tempfile
|
junifer/data/masks/_masks.py
CHANGED
@@ -44,23 +44,24 @@ _masks_path = Path(__file__).parent
|
|
44
44
|
|
45
45
|
def compute_brain_mask(
|
46
46
|
target_data: dict[str, Any],
|
47
|
-
|
47
|
+
warp_data: Optional[dict[str, Any]] = None,
|
48
48
|
mask_type: str = "brain",
|
49
49
|
threshold: float = 0.5,
|
50
50
|
) -> "Nifti1Image":
|
51
51
|
"""Compute the whole-brain, grey-matter or white-matter mask.
|
52
52
|
|
53
53
|
This mask is calculated using the template space and resolution as found
|
54
|
-
in the ``target_data``.
|
54
|
+
in the ``target_data``. If target space is native, then the template is
|
55
|
+
warped to native and then thresholded.
|
55
56
|
|
56
57
|
Parameters
|
57
58
|
----------
|
58
59
|
target_data : dict
|
59
60
|
The corresponding item of the data object for which mask will be
|
60
61
|
loaded.
|
61
|
-
|
62
|
-
The
|
63
|
-
|
62
|
+
warp_data : dict or None, optional
|
63
|
+
The warp data item of the data object. Needs to be provided if
|
64
|
+
``target_data`` is in native space (default None).
|
64
65
|
mask_type : {"brain", "gm", "wm"}, optional
|
65
66
|
Type of mask to be computed:
|
66
67
|
|
@@ -81,7 +82,7 @@ def compute_brain_mask(
|
|
81
82
|
------
|
82
83
|
ValueError
|
83
84
|
If ``mask_type`` is invalid or
|
84
|
-
if ``
|
85
|
+
if ``warp_data`` is None when ``target_data``'s space is native.
|
85
86
|
|
86
87
|
"""
|
87
88
|
logger.debug(f"Computing {mask_type} mask")
|
@@ -90,39 +91,45 @@ def compute_brain_mask(
|
|
90
91
|
raise_error(f"Unknown mask type: {mask_type}")
|
91
92
|
|
92
93
|
# Check pre-requirements for space manipulation
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
"data type to infer target template space."
|
103
|
-
)
|
104
|
-
# Set target standard space to warp file space source
|
105
|
-
for entry in extra_input["Warp"]:
|
106
|
-
if entry["dst"] == "native":
|
107
|
-
target_std_space = entry["src"]
|
94
|
+
if target_data["space"] == "native":
|
95
|
+
# Warp data check
|
96
|
+
if warp_data is None:
|
97
|
+
raise_error("No `warp_data` provided")
|
98
|
+
# Set space to fetch template using
|
99
|
+
target_std_space = warp_data["src"]
|
100
|
+
else:
|
101
|
+
# Set space to fetch template using
|
102
|
+
target_std_space = target_data["space"]
|
108
103
|
|
109
104
|
# Fetch template in closest resolution
|
110
105
|
template = get_template(
|
111
106
|
space=target_std_space,
|
112
|
-
|
113
|
-
extra_input=
|
107
|
+
target_img=target_data["data"],
|
108
|
+
extra_input=None,
|
114
109
|
template_type=mask_type,
|
115
110
|
)
|
111
|
+
|
112
|
+
# Resample and warp template if target space is native
|
113
|
+
if target_data["space"] == "native":
|
114
|
+
resampled_template = ANTsMaskWarper().warp(
|
115
|
+
mask_name=f"template_{target_std_space}_for_compute_brain_mask",
|
116
|
+
# use template here
|
117
|
+
mask_img=template,
|
118
|
+
src=target_std_space,
|
119
|
+
dst="native",
|
120
|
+
target_data=target_data,
|
121
|
+
warp_data=warp_data,
|
122
|
+
)
|
116
123
|
# Resample template to target image
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
124
|
+
else:
|
125
|
+
resampled_template = resample_to_img(
|
126
|
+
source_img=template, target_img=target_data["data"]
|
127
|
+
)
|
121
128
|
|
122
|
-
# Threshold and get mask
|
129
|
+
# Threshold resampled template and get mask
|
123
130
|
mask = (get_data(resampled_template) >= threshold).astype("int8")
|
124
131
|
|
125
|
-
return new_img_like(
|
132
|
+
return new_img_like(target_data["data"], mask) # type: ignore
|
126
133
|
|
127
134
|
|
128
135
|
class MaskRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
@@ -369,6 +376,8 @@ class MaskRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
369
376
|
"""
|
370
377
|
# Check pre-requirements for space manipulation
|
371
378
|
target_space = target_data["space"]
|
379
|
+
logger.debug(f"Getting masks: {masks} in {target_space} space")
|
380
|
+
|
372
381
|
# Extra data type requirement check if target space is native
|
373
382
|
if target_space == "native":
|
374
383
|
# Check for extra inputs
|
@@ -385,7 +394,13 @@ class MaskRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
385
394
|
)
|
386
395
|
# Set target standard space to warp file space source
|
387
396
|
target_std_space = warper_spec["src"]
|
397
|
+
logger.debug(
|
398
|
+
f"Target space is native. Will warp from {target_std_space}"
|
399
|
+
)
|
388
400
|
else:
|
401
|
+
# Set warper_spec so that compute_brain_mask does not fail when
|
402
|
+
# target space is non-native
|
403
|
+
warper_spec = None
|
389
404
|
# Set target standard space to target space
|
390
405
|
target_std_space = target_space
|
391
406
|
|
@@ -398,31 +413,33 @@ class MaskRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
398
413
|
masks = [masks]
|
399
414
|
|
400
415
|
# Check that masks passed as dicts have only one key
|
401
|
-
|
416
|
+
invalid_mask_specs = [
|
402
417
|
x for x in masks if isinstance(x, dict) and len(x) != 1
|
403
418
|
]
|
404
|
-
if
|
419
|
+
if invalid_mask_specs:
|
405
420
|
raise_error(
|
406
421
|
"Each of the masks dictionary must have only one key, "
|
407
422
|
"the name of the mask. The following dictionaries are "
|
408
|
-
f"invalid: {
|
423
|
+
f"invalid: {invalid_mask_specs}"
|
409
424
|
)
|
410
425
|
|
411
|
-
#
|
426
|
+
# Store params for nilearn.masking.intersect_mask()
|
412
427
|
intersect_params = {}
|
413
|
-
|
428
|
+
# Store all mask specs for further operations
|
429
|
+
mask_specs = []
|
414
430
|
for t_mask in masks:
|
415
431
|
if isinstance(t_mask, dict):
|
432
|
+
# Get params to pass to nilearn.masking.intersect_mask()
|
416
433
|
if "threshold" in t_mask:
|
417
434
|
intersect_params["threshold"] = t_mask["threshold"]
|
418
435
|
continue
|
419
|
-
|
436
|
+
if "connected" in t_mask:
|
420
437
|
intersect_params["connected"] = t_mask["connected"]
|
421
438
|
continue
|
422
|
-
#
|
423
|
-
|
439
|
+
# Add mask spec
|
440
|
+
mask_specs.append(t_mask)
|
424
441
|
|
425
|
-
if
|
442
|
+
if not mask_specs:
|
426
443
|
raise_error("No mask was passed. At least one mask is required.")
|
427
444
|
|
428
445
|
# Get the nested mask data type for the input data type
|
@@ -430,7 +447,7 @@ class MaskRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
430
447
|
|
431
448
|
# Get all the masks
|
432
449
|
all_masks = []
|
433
|
-
for t_mask in
|
450
|
+
for t_mask in mask_specs:
|
434
451
|
if isinstance(t_mask, dict):
|
435
452
|
mask_name = next(iter(t_mask.keys()))
|
436
453
|
mask_params = t_mask[mask_name]
|
@@ -441,33 +458,57 @@ class MaskRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
441
458
|
# If mask is being inherited from the datagrabber or a
|
442
459
|
# preprocessor, check that it's accessible
|
443
460
|
if mask_name == "inherit":
|
461
|
+
logger.debug("Using inherited mask.")
|
444
462
|
if inherited_mask_item is None:
|
445
463
|
raise_error(
|
446
464
|
"Cannot inherit mask from the target data. Either the "
|
447
465
|
"DataGrabber or a Preprocessor does not provide "
|
448
466
|
"`mask` for the target data type."
|
449
467
|
)
|
468
|
+
logger.debug(
|
469
|
+
f"Inherited mask is in {inherited_mask_item['space']} "
|
470
|
+
"space."
|
471
|
+
)
|
450
472
|
mask_img = inherited_mask_item["data"]
|
473
|
+
|
474
|
+
if inherited_mask_item["space"] != target_space:
|
475
|
+
raise_error(
|
476
|
+
"Inherited mask space does not match target space."
|
477
|
+
)
|
478
|
+
logger.debug("Resampling inherited mask to target image.")
|
479
|
+
# Resample inherited mask to target image
|
480
|
+
mask_img = resample_to_img(
|
481
|
+
source_img=mask_img,
|
482
|
+
target_img=target_data["data"],
|
483
|
+
)
|
451
484
|
# Starting with new mask
|
452
485
|
else:
|
453
486
|
# Load mask
|
487
|
+
logger.debug(f"Loading mask {t_mask}.")
|
454
488
|
mask_object, _, mask_space = self.load(
|
455
489
|
mask_name, path_only=False, resolution=resolution
|
456
490
|
)
|
457
|
-
#
|
458
|
-
#
|
459
|
-
if mask_space == "inherit":
|
460
|
-
mask_space = target_std_space
|
461
|
-
# If mask is callable like from nilearn
|
491
|
+
# If mask is callable like from nilearn; space will be inherit
|
492
|
+
# so no check for that
|
462
493
|
if callable(mask_object):
|
494
|
+
logger.debug("Computing mask (callable).")
|
463
495
|
if mask_params is None:
|
464
496
|
mask_params = {}
|
465
497
|
# From nilearn
|
466
|
-
if mask_name
|
498
|
+
if mask_name in [
|
499
|
+
"compute_epi_mask",
|
500
|
+
"compute_background_mask",
|
501
|
+
]:
|
467
502
|
mask_img = mask_object(target_img, **mask_params)
|
468
|
-
#
|
503
|
+
# custom compute_brain_mask
|
504
|
+
elif mask_name == "compute_brain_mask":
|
505
|
+
mask_img = mask_object(
|
506
|
+
target_data, warper_spec, **mask_params
|
507
|
+
)
|
508
|
+
# custom registered; arm kept for clarity
|
469
509
|
else:
|
470
|
-
mask_img = mask_object(
|
510
|
+
mask_img = mask_object(target_img, **mask_params)
|
511
|
+
|
471
512
|
# Mask is a Nifti1Image
|
472
513
|
else:
|
473
514
|
# Mask params provided
|
@@ -477,33 +518,68 @@ class MaskRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
477
518
|
"Cannot pass callable params to a non-callable "
|
478
519
|
"mask."
|
479
520
|
)
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
521
|
+
|
522
|
+
# Resample and warp mask to standard space
|
523
|
+
if mask_space != target_std_space:
|
524
|
+
logger.debug(
|
525
|
+
f"Warping {t_mask} to {target_std_space} space "
|
526
|
+
"using ants."
|
527
|
+
)
|
528
|
+
mask_img = ANTsMaskWarper().warp(
|
529
|
+
mask_name=mask_name,
|
530
|
+
mask_img=mask_object,
|
531
|
+
src=mask_space,
|
532
|
+
dst=target_std_space,
|
533
|
+
target_data=target_data,
|
534
|
+
warp_data=warper_spec,
|
535
|
+
)
|
536
|
+
|
537
|
+
else:
|
538
|
+
# Resample mask to target image; no further warping
|
539
|
+
logger.debug(f"Resampling {t_mask} to target image.")
|
540
|
+
if target_space != "native":
|
541
|
+
mask_img = resample_to_img(
|
542
|
+
source_img=mask_object,
|
543
|
+
target_img=target_data["data"],
|
544
|
+
)
|
545
|
+
# Set mask_img in case no warping happens before this
|
546
|
+
else:
|
547
|
+
mask_img = mask_object
|
548
|
+
# Resample and warp mask if target data is native
|
549
|
+
if target_space == "native":
|
550
|
+
logger.debug(
|
551
|
+
"Warping mask to native space using "
|
552
|
+
f"{warper_spec['warper']}."
|
553
|
+
)
|
554
|
+
mask_name = f"{mask_name}_to_native"
|
555
|
+
# extra_input check done earlier and warper_spec exists
|
556
|
+
if warper_spec["warper"] == "fsl":
|
557
|
+
mask_img = FSLMaskWarper().warp(
|
558
|
+
mask_name=mask_name,
|
559
|
+
mask_img=mask_img,
|
560
|
+
target_data=target_data,
|
561
|
+
warp_data=warper_spec,
|
562
|
+
)
|
563
|
+
elif warper_spec["warper"] == "ants":
|
564
|
+
mask_img = ANTsMaskWarper().warp(
|
565
|
+
mask_name=mask_name,
|
566
|
+
mask_img=mask_img,
|
567
|
+
src="",
|
568
|
+
dst="native",
|
569
|
+
target_data=target_data,
|
570
|
+
warp_data=warper_spec,
|
571
|
+
)
|
497
572
|
|
498
573
|
all_masks.append(mask_img)
|
499
574
|
|
500
575
|
# Multiple masks, need intersection / union
|
501
576
|
if len(all_masks) > 1:
|
502
577
|
# Intersect / union of masks
|
578
|
+
logger.debug("Intersecting masks.")
|
503
579
|
mask_img = intersect_masks(all_masks, **intersect_params)
|
504
580
|
# Single mask
|
505
581
|
else:
|
506
|
-
if
|
582
|
+
if intersect_params:
|
507
583
|
# Yes, I'm this strict!
|
508
584
|
raise_error(
|
509
585
|
"Cannot pass parameters to the intersection function "
|
@@ -511,26 +587,6 @@ class MaskRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
511
587
|
)
|
512
588
|
mask_img = all_masks[0]
|
513
589
|
|
514
|
-
# Warp mask if target data is native
|
515
|
-
if target_space == "native":
|
516
|
-
# extra_input check done earlier and warper_spec exists
|
517
|
-
if warper_spec["warper"] == "fsl":
|
518
|
-
mask_img = FSLMaskWarper().warp(
|
519
|
-
mask_name="native",
|
520
|
-
mask_img=mask_img,
|
521
|
-
target_data=target_data,
|
522
|
-
warp_data=warper_spec,
|
523
|
-
)
|
524
|
-
elif warper_spec["warper"] == "ants":
|
525
|
-
mask_img = ANTsMaskWarper().warp(
|
526
|
-
mask_name="native",
|
527
|
-
mask_img=mask_img,
|
528
|
-
src="",
|
529
|
-
dst="native",
|
530
|
-
target_data=target_data,
|
531
|
-
warp_data=warper_spec,
|
532
|
-
)
|
533
|
-
|
534
590
|
return mask_img
|
535
591
|
|
536
592
|
|
@@ -64,7 +64,6 @@ def test_compute_brain_mask(mask_type: str, threshold: float) -> None:
|
|
64
64
|
element_data = DefaultDataReader().fit_transform(dg["sub-01"])
|
65
65
|
mask = compute_brain_mask(
|
66
66
|
target_data=element_data["BOLD"],
|
67
|
-
extra_input=None,
|
68
67
|
mask_type=mask_type,
|
69
68
|
)
|
70
69
|
assert isinstance(mask, nib.nifti1.Nifti1Image)
|
@@ -400,6 +400,7 @@ class ParcellationRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
400
400
|
"""
|
401
401
|
# Check pre-requirements for space manipulation
|
402
402
|
target_space = target_data["space"]
|
403
|
+
logger.debug(f"Getting {parcellations} in {target_space} space.")
|
403
404
|
# Extra data type requirement check if target space is native
|
404
405
|
if target_space == "native":
|
405
406
|
# Check for extra inputs
|
@@ -416,6 +417,9 @@ class ParcellationRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
416
417
|
)
|
417
418
|
# Set target standard space to warp file space source
|
418
419
|
target_std_space = warper_spec["src"]
|
420
|
+
logger.debug(
|
421
|
+
f"Target space is native. Will warp from {target_std_space}"
|
422
|
+
)
|
419
423
|
else:
|
420
424
|
# Set target standard space to target space
|
421
425
|
target_std_space = target_space
|
@@ -433,6 +437,7 @@ class ParcellationRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
433
437
|
all_labels = []
|
434
438
|
for name in parcellations:
|
435
439
|
# Load parcellation
|
440
|
+
logger.debug(f"Loading parcellation {name}")
|
436
441
|
img, labels, _, space = self.load(
|
437
442
|
name=name,
|
438
443
|
resolution=resolution,
|
@@ -441,6 +446,9 @@ class ParcellationRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
441
446
|
# Convert parcellation spaces if required;
|
442
447
|
# cannot be "native" due to earlier check
|
443
448
|
if space != target_std_space:
|
449
|
+
logger.debug(
|
450
|
+
f"Warping {name} to {target_std_space} space using ants."
|
451
|
+
)
|
444
452
|
raw_img = ANTsParcellationWarper().warp(
|
445
453
|
parcellation_name=name,
|
446
454
|
parcellation_img=img,
|
@@ -452,6 +460,7 @@ class ParcellationRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
452
460
|
# Remove extra dimension added by ANTs
|
453
461
|
img = image.math_img("np.squeeze(img)", img=raw_img)
|
454
462
|
|
463
|
+
logger.debug(f"Resampling {name} to target image.")
|
455
464
|
# Resample parcellation to target image
|
456
465
|
img_to_merge = image.resample_to_img(
|
457
466
|
source_img=img,
|
@@ -469,6 +478,7 @@ class ParcellationRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
469
478
|
labels = all_labels[0]
|
470
479
|
# Parcellations are already transformed to target standard space
|
471
480
|
else:
|
481
|
+
logger.debug("Merging parcellations.")
|
472
482
|
resampled_parcellation_img, labels = merge_parcellations(
|
473
483
|
parcellations_list=all_parcellations,
|
474
484
|
parcellations_names=parcellations,
|
@@ -477,6 +487,10 @@ class ParcellationRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
477
487
|
|
478
488
|
# Warp parcellation if target space is native
|
479
489
|
if target_space == "native":
|
490
|
+
logger.debug(
|
491
|
+
"Warping parcellation to native space using "
|
492
|
+
f"{warper_spec['warper']}."
|
493
|
+
)
|
480
494
|
# extra_input check done earlier and warper_spec exists
|
481
495
|
if warper_spec["warper"] == "fsl":
|
482
496
|
resampled_parcellation_img = FSLParcellationWarper().warp(
|
@@ -1194,7 +1208,10 @@ def _retrieve_aicha(
|
|
1194
1208
|
|
1195
1209
|
# Load labels
|
1196
1210
|
labels = pd.read_csv(
|
1197
|
-
parcellation_lname,
|
1211
|
+
parcellation_lname,
|
1212
|
+
sep="\t",
|
1213
|
+
header=None,
|
1214
|
+
skiprows=[0], # type: ignore
|
1198
1215
|
)[0].to_list()
|
1199
1216
|
|
1200
1217
|
return parcellation_fname, labels
|
junifer/data/template_spaces.py
CHANGED
@@ -122,7 +122,7 @@ def get_xfm(
|
|
122
122
|
|
123
123
|
def get_template(
|
124
124
|
space: str,
|
125
|
-
|
125
|
+
target_img: nib.Nifti1Image,
|
126
126
|
extra_input: Optional[dict[str, Any]] = None,
|
127
127
|
template_type: str = "T1w",
|
128
128
|
) -> nib.Nifti1Image:
|
@@ -132,9 +132,9 @@ def get_template(
|
|
132
132
|
----------
|
133
133
|
space : str
|
134
134
|
The name of the template space.
|
135
|
-
|
136
|
-
The corresponding
|
137
|
-
|
135
|
+
target_img : Nifti1Image
|
136
|
+
The corresponding image for which the template space will be loaded.
|
137
|
+
This is used to obtain the best matching resolution.
|
138
138
|
extra_input : dict, optional
|
139
139
|
The other fields in the data object. Useful for accessing other data
|
140
140
|
types (default None).
|
@@ -163,7 +163,6 @@ def get_template(
|
|
163
163
|
raise_error(f"Unknown template type: {template_type}")
|
164
164
|
|
165
165
|
# Get the min of the voxels sizes and use it as the resolution
|
166
|
-
target_img = target_data["data"]
|
167
166
|
resolution = np.min(target_img.header.get_zooms()[:3]).astype(int)
|
168
167
|
|
169
168
|
# Fetch available resolutions for the template
|
@@ -61,7 +61,9 @@ def test_get_template(template_type: str) -> None:
|
|
61
61
|
bold = element_data["BOLD"]
|
62
62
|
# Get tailored parcellation
|
63
63
|
tailored_template = get_template(
|
64
|
-
space=bold["space"],
|
64
|
+
space=bold["space"],
|
65
|
+
target_img=bold["data"],
|
66
|
+
template_type=template_type,
|
65
67
|
)
|
66
68
|
assert isinstance(tailored_template, nib.Nifti1Image)
|
67
69
|
|
@@ -74,7 +76,7 @@ def test_get_template_invalid_space() -> None:
|
|
74
76
|
vbm_gm = element_data["VBM_GM"]
|
75
77
|
# Get tailored parcellation
|
76
78
|
with pytest.raises(ValueError, match="Unknown template space:"):
|
77
|
-
get_template(space="andromeda",
|
79
|
+
get_template(space="andromeda", target_img=vbm_gm["data"])
|
78
80
|
|
79
81
|
|
80
82
|
def test_get_template_invalid_template_type() -> None:
|
@@ -87,7 +89,7 @@ def test_get_template_invalid_template_type() -> None:
|
|
87
89
|
with pytest.raises(ValueError, match="Unknown template type:"):
|
88
90
|
get_template(
|
89
91
|
space=vbm_gm["space"],
|
90
|
-
|
92
|
+
target_img=vbm_gm["data"],
|
91
93
|
template_type="xenon",
|
92
94
|
)
|
93
95
|
|
@@ -100,5 +102,7 @@ def test_get_template_closest_resolution() -> None:
|
|
100
102
|
vbm_gm = element_data["VBM_GM"]
|
101
103
|
# Change header resolution to fetch closest resolution
|
102
104
|
element_data["VBM_GM"]["data"].header.set_zooms((3, 3, 3))
|
103
|
-
template = get_template(
|
105
|
+
template = get_template(
|
106
|
+
space=vbm_gm["space"], target_img=vbm_gm["data"]
|
107
|
+
)
|
104
108
|
assert isinstance(template, nib.Nifti1Image)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: junifer
|
3
|
-
Version: 0.0.6.
|
3
|
+
Version: 0.0.6.dev344
|
4
4
|
Summary: JUelich NeuroImaging FEature extractoR
|
5
5
|
Author-email: Fede Raimondo <f.raimondo@fz-juelich.de>, Synchon Mandal <s.mandal@fz-juelich.de>
|
6
6
|
Maintainer-email: Fede Raimondo <f.raimondo@fz-juelich.de>, Synchon Mandal <s.mandal@fz-juelich.de>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
junifer/__init__.py,sha256=2McgH1yNue6Z1V26-uN_mfMjbTcx4CLhym-DMBl5xA4,266
|
2
2
|
junifer/__init__.pyi,sha256=SsTvgq2Dod6UqJN96GH1lCphH6hJQQurEJHGNhHjGUI,508
|
3
|
-
junifer/_version.py,sha256=
|
3
|
+
junifer/_version.py,sha256=RGqwir9l9V0H5xa7pR6U_haLUliwgh-8bgB2fta2Qfs,428
|
4
4
|
junifer/conftest.py,sha256=PWYkkRDU8ly2lYwv7VBKMHje4et6HX7Yey3Md_I2KbA,613
|
5
5
|
junifer/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
6
|
junifer/stats.py,sha256=e9aaagMGtgpRfW3Wdpz9ocpnYld1IWylCDcjFUgX9Mk,6225
|
@@ -75,7 +75,7 @@ junifer/data/__init__.pyi,sha256=qYszjUYcbFi_2zO23MnbA2HhTW-Ad2oh1pqPQYd6yt0,542
|
|
75
75
|
junifer/data/_dispatch.py,sha256=O524U1R4MtbGhGJsL0HSh9EqisapBFJWK7uupXrJuMg,6158
|
76
76
|
junifer/data/pipeline_data_registry_base.py,sha256=G8bE3WTj4D_rKC4ZKZe6E48Sd96CGea1PS3SxmTgGK4,2010
|
77
77
|
junifer/data/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
78
|
-
junifer/data/template_spaces.py,sha256=
|
78
|
+
junifer/data/template_spaces.py,sha256=JPsrGyfbaVgZ75uB3ci2CUuVxUg3NDi6HhO_VTIHeOE,6508
|
79
79
|
junifer/data/utils.py,sha256=5r-0QGQCNZvDM1tVcl9xyrIdgAO85mww0plpM1RUaGA,3247
|
80
80
|
junifer/data/coordinates/__init__.py,sha256=ffM8rwcHLgHAWixJbKrATrbUKzX940V1UF6RAxZdUMg,186
|
81
81
|
junifer/data/coordinates/__init__.pyi,sha256=Z-Ti5XD3HigkZ8uYN6oYsLqw40-F1GvTVQ5QAy08Wng,88
|
@@ -104,22 +104,22 @@ junifer/data/coordinates/VOIs/meta/extDMN_VOIs.txt,sha256=Ogx1QvqZcnXDM3ncF2ha78
|
|
104
104
|
junifer/data/coordinates/tests/test_coordinates.py,sha256=_c2P4oaDGpsmui5gJBe_jN6HLGiKxONkYPR69sRBUlU,4219
|
105
105
|
junifer/data/masks/__init__.py,sha256=eEEhHglyVEx1LrqwXjq3cOmjf4sTsgBstRx5-k7zIQU,180
|
106
106
|
junifer/data/masks/__init__.pyi,sha256=lcgr8gmWDPibC4RxnWBXb8DDpIkO73Aax09u6VXiJJI,114
|
107
|
-
junifer/data/masks/_ants_mask_warper.py,sha256=
|
107
|
+
junifer/data/masks/_ants_mask_warper.py,sha256=Mwgc2_ZMf28vS_-fviRvZnHyT7JoQ1cQLozo7nUZSyM,5350
|
108
108
|
junifer/data/masks/_fsl_mask_warper.py,sha256=VApp-ofGBKePNmCdgTg1HoEA66lMQiAPT0ihkhB2ezY,2415
|
109
|
-
junifer/data/masks/_masks.py,sha256=
|
110
|
-
junifer/data/masks/tests/test_masks.py,sha256=
|
109
|
+
junifer/data/masks/_masks.py,sha256=QZ3bgxwir7W2XS3k1OuOjIeFRv9fpP4YM7gM1EfagQM,23560
|
110
|
+
junifer/data/masks/tests/test_masks.py,sha256=W0bzRB5Bp-iGO44VtEmaf7BuT-joe_2tQI0lma5NQHA,16090
|
111
111
|
junifer/data/masks/ukb/UKB_15K_GM_template.nii.gz,sha256=jcX1pDOrDsoph8cPMNFVKH5gZYio5G4rJNpOFXm9wJI,946636
|
112
112
|
junifer/data/masks/vickery-patil/CAT12_IXI555_MNI152_TMP_GS_GMprob0.2_clean.nii.gz,sha256=j6EY8EtRnUuRxeKgD65Q6B0GPEPIALKDJEIje1TfnAU,88270
|
113
113
|
junifer/data/masks/vickery-patil/CAT12_IXI555_MNI152_TMP_GS_GMprob0.2_clean_3mm.nii.gz,sha256=crb_y7YO1vjjf2PwbRJUm8KamPK6fx1y0B_l-E3g8FY,12862
|
114
114
|
junifer/data/masks/vickery-patil/GMprob0.2_cortex_3mm_NA_rm.nii.gz,sha256=jfMe_4H9XEnArYms5bSQbqS2V1_HbLHTfI5amQa_Pes,8700
|
115
115
|
junifer/data/parcellations/__init__.py,sha256=6-Ysil3NyZ69V6rWx4RO15_d-iDKizfbHuxSjsHNt24,188
|
116
116
|
junifer/data/parcellations/__init__.pyi,sha256=lhBHTbMDizzqUqVHrx2eyfPFodrTBgMFeTgxfESSkQ8,140
|
117
|
-
junifer/data/parcellations/_ants_parcellation_warper.py,sha256=
|
117
|
+
junifer/data/parcellations/_ants_parcellation_warper.py,sha256=YUCJC0_wutGw7j_n9JRU3LCwm9Ttg5PIlJUgqejfRhs,5806
|
118
118
|
junifer/data/parcellations/_fsl_parcellation_warper.py,sha256=JfJ022flg5OR48P4OAALVHHQgTVxdMBXT-fAqBl3nUM,2679
|
119
|
-
junifer/data/parcellations/_parcellations.py,sha256=
|
119
|
+
junifer/data/parcellations/_parcellations.py,sha256=xXCyJ9b_TTHzzXXChPvk9qakkjabxTb5wJaRNEjRgWY,66271
|
120
120
|
junifer/data/parcellations/tests/test_parcellations.py,sha256=crluGgUjocVZ0ZIkMpUVol27A-Px6oc2eflY5g0C4BY,38315
|
121
121
|
junifer/data/tests/test_data_utils.py,sha256=136iGPjGecCxyqgUwU8VZMHoE6imcYJ0WNC32PDGK4g,1063
|
122
|
-
junifer/data/tests/test_template_spaces.py,sha256=
|
122
|
+
junifer/data/tests/test_template_spaces.py,sha256=ZEicEcLqOJ-NpuBZ5SYh4yZ0xZRkhYHnYXiC_YSxjrY,3219
|
123
123
|
junifer/datagrabber/__init__.py,sha256=EHIK-lbjuvkt0V8ypFvLSt85OAAXSkaxBmVlCbNNz8M,323
|
124
124
|
junifer/datagrabber/__init__.pyi,sha256=zOQE4TaCKXBTHnNqgmECtsszWIOHYiQ1CUEeXXFU9F4,832
|
125
125
|
junifer/datagrabber/base.py,sha256=a3_fUZIN5Bqhq2f4ldpwk_eWeSVRDpDmx2QGIKzCtkg,6761
|
@@ -294,7 +294,7 @@ junifer/preprocess/smoothing/tests/test_smoothing.py,sha256=t1j3zEvJk5XLO4fzcb-w
|
|
294
294
|
junifer/preprocess/tests/test_preprocess_base.py,sha256=-0rpe8QjqYES36H6MHuDs3cv_6upHBdVHnFMgQsmEX4,2571
|
295
295
|
junifer/preprocess/warping/__init__.py,sha256=rzUUP7-6H_nygQ7a7TBZ4_RY7p0ELacosYsWQbSdVZk,214
|
296
296
|
junifer/preprocess/warping/__init__.pyi,sha256=Drbqp8N3uprvXcKSxqdfj90fesz9XYVLgivhPnKAYcc,65
|
297
|
-
junifer/preprocess/warping/_ants_warper.py,sha256=
|
297
|
+
junifer/preprocess/warping/_ants_warper.py,sha256=8-YzQmevZ_9vh4QnHDJgsXoEgitDtFV_atOZrVLQNtI,10170
|
298
298
|
junifer/preprocess/warping/_fsl_warper.py,sha256=dH1xd3jTRPREzgdh98Dz_4o2gwdrOgc0h5wbARSSB98,5226
|
299
299
|
junifer/preprocess/warping/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
300
300
|
junifer/preprocess/warping/space_warper.py,sha256=mf7SDu574R3TXNt82fqGl_hcEYx7SjXwz2TcmWObHQA,7706
|
@@ -341,10 +341,10 @@ junifer/utils/tests/test_config.py,sha256=7ltIXuwb_W4Mv_1dxQWyiyM10XgUAfsWKV6D_i
|
|
341
341
|
junifer/utils/tests/test_fs.py,sha256=WQS7cKlKEZ742CIuiOYYpueeAhY9PqlastfDVpVVtvE,923
|
342
342
|
junifer/utils/tests/test_helpers.py,sha256=k5qqfxK8dFyuewTJyR1Qn6-nFaYNuVr0ysc18bfPjyU,929
|
343
343
|
junifer/utils/tests/test_logging.py,sha256=duO4ou365hxwa_kwihFtKPLaL6LC5XHiyhOijrrngbA,8009
|
344
|
-
junifer-0.0.6.
|
345
|
-
junifer-0.0.6.
|
346
|
-
junifer-0.0.6.
|
347
|
-
junifer-0.0.6.
|
348
|
-
junifer-0.0.6.
|
349
|
-
junifer-0.0.6.
|
350
|
-
junifer-0.0.6.
|
344
|
+
junifer-0.0.6.dev344.dist-info/AUTHORS.rst,sha256=rmULKpchpSol4ExWFdm-qu4fkpSZPYqIESVJBZtGb6E,163
|
345
|
+
junifer-0.0.6.dev344.dist-info/LICENSE.md,sha256=MqCnOBu8uXsEOzRZWh9EBVfVz-kE9NkXcLCrtGXo2yU,34354
|
346
|
+
junifer-0.0.6.dev344.dist-info/METADATA,sha256=TjbEy9EnZ5YtMFwT1hq6xet_EhJvrEUnqpH6-2uz64c,8429
|
347
|
+
junifer-0.0.6.dev344.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
348
|
+
junifer-0.0.6.dev344.dist-info/entry_points.txt,sha256=6O8ru0BP-SP7YMUZiizFNoaZ2HvJpadO2G7nKk4PwjI,48
|
349
|
+
junifer-0.0.6.dev344.dist-info/top_level.txt,sha256=4bAq1R2QFQ4b3hohjys2JBvxrl0GKk5LNFzYvz9VGcA,8
|
350
|
+
junifer-0.0.6.dev344.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|