-
Notifications
You must be signed in to change notification settings - Fork 42
REF: generalised anat references 2.0 #477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
da53f26
5d018e7
7af276b
fd7af1c
872b002
e186ecb
138d365
c21b2f3
59123d2
24b2236
eb18c5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -22,6 +22,8 @@ | |||||
# | ||||||
"""Self-contained utilities to be used within Function nodes.""" | ||||||
|
||||||
import typing as ty | ||||||
|
||||||
|
||||||
def apply_lut(in_dseg, lut, newpath=None): | ||||||
"""Map the input discrete segmentation to a new label set (lookup table, LUT).""" | ||||||
|
@@ -95,3 +97,48 @@ def fs_isRunning(subjects_dir, subject_id, mtime_tol=86400, logger=None): | |||||
if logger: | ||||||
logger.warn(f'Removed "IsRunning*" files found under {subj_dir}') | ||||||
return subjects_dir | ||||||
|
||||||
|
||||||
def collect_anat( | ||||||
subject_data: dict, precomputed: dict, reference_anat: ty.Literal['T1w', 'T2w'] = 'T1w' | ||||||
): | ||||||
""" | ||||||
Collects the anatomical inputs for a given subject and organises the | ||||||
files and associated information into ``reference`` and ``aux`` keys | ||||||
to pass to :py:func:`init_anat_fit_wf` | ||||||
|
||||||
Parameters | ||||||
---------- | ||||||
subject_data: :obj:`dict` | ||||||
lists of input data | ||||||
precomputed: :obj:`dict` | ||||||
cache of derivative files | ||||||
reference_anat: :obj:`str` | ||||||
MR image type (T1w, T2w, etc.) of primary anatomical scan | ||||||
|
||||||
Returns | ||||||
------- | ||||||
anat_inputs: :obj:`dict` | ||||||
""" | ||||||
ref_anat = reference_anat.lower() | ||||||
if ref_anat not in subject_data.keys(): | ||||||
raise FileNotFoundError | ||||||
|
||||||
anat_inputs = { | ||||||
modality: { | ||||||
'data': subject_data[modality], | ||||||
'n': len(subject_data[modality]), | ||||||
'precomputed': f'{modality}_preproc' in precomputed, | ||||||
'role': 'reference' if modality.capitalize() == reference_anat else 'aux', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can this just be a bool, since if not we will treat as auxillary
Suggested change
|
||||||
} | ||||||
for modality in ['t1w', 't2w', 'flair'] | ||||||
if modality in subject_data.keys() | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since i believe all keys are in subject_data, this will check if the list is not empty
Suggested change
|
||||||
} | ||||||
anat_inputs[reference_anat.lower()].update( | ||||||
{ | ||||||
f'have_{preproc}': f'{reference_anat.lower()}_{preproc}' in precomputed | ||||||
for preproc in ['mask', 'tpms', 'dseg'] | ||||||
} | ||||||
) | ||||||
Comment on lines
+137
to
+142
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looking at this, i wonder if this precomputed parsing would be better suited for a separate function |
||||||
|
||||||
return anat_inputs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wdyt about