-
Notifications
You must be signed in to change notification settings - Fork 14
RF: Anatomical processing #286
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
Conversation
- Precomputed aseg should be connected via the inputnode, no need to validate the image again. - MCRIBS code will be moved to the MCRIBS-specific surface workflow
Codecov ReportPatch coverage:
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## master #286 +/- ##
==========================================
+ Coverage 32.07% 32.18% +0.11%
==========================================
Files 53 54 +1
Lines 4727 4748 +21
==========================================
+ Hits 1516 1528 +12
- Misses 3211 3220 +9
☔ View full report in Codecov by Sentry. |
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.
Some initial thoughts. Overall things look quite clean. It might be worth a detailed walkthrough of differences between infant and adult smriprep once MCRIBs is in and see if we can unify.
return os.path.join(base, basename) | ||
|
||
|
||
def get_file(pkg: str, src_path: Union[str, Path]) -> str: |
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.
I like this. But I would consider using a module-local ExitStack
and cached responses to avoid unnecessary duplicates.
Example:
import atexit
from contextlib import ExitStack
from functools import cache
try:
from importlib.resources import as_file, files
except ImportError:
from importlib_resources import as_file, files
# Module-scoped
exit_stack = ExitStack()
atexit.register(exit_stack.close)
@cache
def get_file(pkg: str, src_path: Union[str, Path]) -> str:
file_ref = files(pkg) / src_path
pathlike = exit_stack.enter_context(as_file(file_ref))
return str(pathlike)
from nipype.interfaces import utility as niu | ||
from nipype.pipeline import engine as pe | ||
from niworkflows.engine.workflows import LiterateWorkflow | ||
from niworkflows.utils.spaces import Reference, SpatialReferences |
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.
This can be an expensive import. I might use a from __future__ import annotations
to avoid runtime resolution of annotations, and then put this in an if ty.TYPE_CHECKING:
block.
t1w_preproc_wf = init_anat_preproc_wf(name="t1w_preproc_wf") | ||
t2w_preproc_wf = init_anat_preproc_wf(name="t2w_preproc_wf") |
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.
Are we making strong assumptions that num_t1w
and num_t2w
>0? Even if it's true for now, I would consider guarding these.
The anatomical workflow was starting to become a rats nest, with a variety of workflows that may or may not be called depending on the presence of precomputed derivatives (
--derivatives
). This is an attempt to untangle the workflow into clearer steps. A top-level breakdown of the major reorganization this PR addresses:Template workflows (T1w / T2w)
Create a canonically-oriented, conformed reference image. If multiple runs are found, intensity-nonuniform (INU) correction is run on a each volume, and are used to create a single volume structural reference. Additionally, if a precomputed mask / aseg are provided (only if a single T1w is found), they are reoriented and conformed as well.
Preproc workflows (T1w/T2w)
Clean up anatomical reference by performing intensity clipping, denoising, and INU correction.
Brain Extraction workflow (T2w)
If a precomputed mask is not available, register the T2w (higher contrast) to a skull-stripping template to create a brainmask.
Coregistration workflow (T2w -> T1w)
Align the T2w to T1w space, and optionally the mask (if the brain extraction workflow was needed).
No remarkable changes to the normalization, segmentation, and surface generation workflows.