Skip to content

Commit 73987c1

Browse files
committed
ENH: Set MNI Infant as the default output space
1 parent 7ebe595 commit 73987c1

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

nibabies/config.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,12 @@ def init_spaces(checkpoint=True):
684684
if checkpoint and not spaces.is_cached():
685685
spaces.checkpoint()
686686

687+
if workflow.age_months is not None:
688+
from .utils.misc import cohort_by_months
689+
690+
if "MNIInfant" not in spaces.get_spaces(nonstandard=False, dim=(3,)):
691+
cohort = cohort_by_months("MNIInfant", workflow.age_months)
692+
spaces.add(Reference("MNIInfant", {"cohort": cohort}))
687693
# # Add the default standard space if not already present (required by several sub-workflows)
688694
# if "MNI152NLin2009cAsym" not in spaces.get_spaces(nonstandard=False, dim=(3,)):
689695
# spaces.add(Reference("MNI152NLin2009cAsym", {}))
@@ -695,10 +701,9 @@ def init_spaces(checkpoint=True):
695701
# # Make sure there's a normalization to FSL for AROMA to use.
696702
# spaces.add(Reference("MNI152NLin6Asym", {"res": "2"}))
697703

698-
cifti_output = workflow.cifti_output
699704
if workflow.cifti_output:
700705
# CIFTI grayordinates to corresponding FSL-MNI resolutions.
701-
vol_res = "2" if cifti_output == "91k" else "1"
706+
vol_res = "2" if workflow.cifti_output == "91k" else "1"
702707
spaces.add(Reference("fsaverage", {"den": "164k"}))
703708
spaces.add(Reference("MNI152NLin6Asym", {"res": vol_res}))
704709

nibabies/utils/misc.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,29 @@ def check_deps(workflow):
4141

4242

4343
def cohort_by_months(template, months):
44+
"""
45+
Produce a recommended cohort based on partipants age
46+
"""
4447
cohort_key = {
45-
'MNIInfant': (2, 5, 8, 11, 14, 17, 21, 27, 33, 44, 60),
46-
'UNCInfant': (8, 12, 24),
48+
'MNIInfant': (
49+
# upper bound of template | cohort
50+
2, # 1
51+
5, # 2
52+
8, # 3
53+
11, # 4
54+
14, # 5
55+
17, # 6
56+
21, # 7
57+
27, # 8
58+
33, # 9
59+
44, # 10
60+
60, # 11
61+
),
62+
'UNCInfant': (
63+
8, # 1
64+
12, # 2
65+
24, # 3
66+
),
4767
}
4868
ages = cohort_key.get(template)
4969
if ages is None:
@@ -52,7 +72,6 @@ def cohort_by_months(template, months):
5272
for cohort, age in enumerate(ages, 1):
5373
if months <= age:
5474
return cohort
55-
5675
raise KeyError("Age exceeds all cohorts!")
5776

5877

0 commit comments

Comments
 (0)