Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions nibabies/workflows/anatomical/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import nipype.interfaces.utility as niu
import nipype.pipeline.engine as pe
from niworkflows.engine import tag
from smriprep.workflows.outputs import (
init_ds_anat_volumes_wf,
init_ds_grayord_metrics_wf,
Expand All @@ -25,6 +26,7 @@
LOGGER = config.loggers.workflow


@tag('anat.apply')
def init_infant_anat_apply_wf(
*,
bids_root: str,
Expand Down
2 changes: 2 additions & 0 deletions nibabies/workflows/anatomical/brain_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

from nipype.interfaces import utility as niu
from nipype.pipeline import engine as pe
from niworkflows.engine import tag


@tag('anat.brain-extraction')
def init_infant_brain_extraction_wf(
*,
omp_nthreads: int,
Expand Down
4 changes: 3 additions & 1 deletion nibabies/workflows/anatomical/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from nipype.interfaces import utility as niu
from nipype.pipeline import engine as pe
from niworkflows.anat.ants import init_n4_only_wf
from niworkflows.engine.workflows import LiterateWorkflow as Workflow
from niworkflows.engine import Workflow, tag
from niworkflows.interfaces.fixes import FixHeaderApplyTransforms as ApplyTransforms
from niworkflows.interfaces.header import ValidateImage
from niworkflows.interfaces.nibabel import ApplyMask, Binarize
Expand Down Expand Up @@ -53,6 +53,7 @@
LOGGER = logging.getLogger('nipype.workflow')


@tag('anat.fit')
def init_infant_anat_fit_wf(
*,
age_months: int,
Expand Down Expand Up @@ -1374,6 +1375,7 @@ def init_infant_anat_fit_wf(
return workflow


@tag('anat.fit')
def init_infant_single_anat_fit_wf(
*,
age_months: int,
Expand Down
5 changes: 4 additions & 1 deletion nibabies/workflows/anatomical/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from nipype.interfaces import utility as niu
from nipype.pipeline import engine as pe
from niworkflows.engine.workflows import LiterateWorkflow as Workflow
from niworkflows.engine import Workflow, tag
from niworkflows.interfaces.fixes import FixHeaderApplyTransforms as ApplyTransforms
from smriprep.workflows.outputs import init_template_iterator_wf

Expand All @@ -21,6 +21,7 @@
BIDS_TISSUE_ORDER = ('GM', 'WM', 'CSF')


@tag('anat.coreg-report')
def init_coreg_report_wf(*, output_dir, name='coreg_report_wf'):
"""
Generate and store a report in the right location.
Expand Down Expand Up @@ -85,6 +86,7 @@ def init_coreg_report_wf(*, output_dir, name='coreg_report_wf'):
return workflow


@tag('anat.reports')
def init_anat_reports_wf(
*,
spaces: SpatialReferences,
Expand Down Expand Up @@ -283,6 +285,7 @@ def init_anat_reports_wf(
return workflow


@tag('anat.derivatives')
def init_anat_derivatives_wf(
*,
bids_root: Path | str,
Expand Down
12 changes: 7 additions & 5 deletions nibabies/workflows/anatomical/preproc.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import nipype.interfaces.utility as niu
import nipype.pipeline.engine as pe
from niworkflows.engine.workflows import LiterateWorkflow
from niworkflows.engine import Workflow, tag


@tag('anat.preproc')
def init_anat_preproc_wf(
*,
bspline_fitting_distance: int = 200,
name: str = 'anat_preproc_wf',
) -> LiterateWorkflow:
) -> Workflow:
"""Polish up raw anatomical data.

This workflow accepts T1w/T2w images as inputs (either raw or a merged template) and performs:
Expand All @@ -30,7 +31,7 @@
from niworkflows.interfaces.header import ValidateImage
from niworkflows.interfaces.nibabel import IntensityClip

wf = LiterateWorkflow(name=name)
wf = Workflow(name=name)

Check warning on line 34 in nibabies/workflows/anatomical/preproc.py

View check run for this annotation

Codecov / codecov/patch

nibabies/workflows/anatomical/preproc.py#L34

Added line #L34 was not covered by tests
inputnode = pe.Node(
niu.IdentityInterface(fields=['in_anat']),
name='inputnode',
Expand Down Expand Up @@ -68,10 +69,11 @@
return wf


def init_csf_norm_wf(name: str = 'csf_norm_wf') -> LiterateWorkflow:
@tag('anat.csf_norm')
def init_csf_norm_wf(name: str = 'csf_norm_wf') -> Workflow:
"""Replace low intensity voxels within the CSF mask with the median value."""

workflow = LiterateWorkflow(name=name)
workflow = Workflow(name=name)
workflow.__desc__ = (
'The CSF mask was used to normalize the anatomical template by the median of voxels '
'within the mask.'
Expand Down
5 changes: 4 additions & 1 deletion nibabies/workflows/anatomical/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
)
from nipype.interfaces.ants.base import Info as ANTsInfo
from nipype.pipeline import engine as pe
from niworkflows.engine.workflows import LiterateWorkflow as Workflow
from niworkflows.engine import Workflow, tag
from niworkflows.interfaces.fixes import FixHeaderApplyTransforms as ApplyTransforms
from smriprep.workflows.fit.registration import (
TemplateDesc,
Expand All @@ -21,6 +21,7 @@
)


@tag('anat.coreg')
def init_coregistration_wf(
*,
bspline_fitting_distance: int = 200,
Expand Down Expand Up @@ -249,6 +250,7 @@ def init_coregistration_wf(
return workflow


@tag('anat.coreg-derivatives')
def init_coregister_derivatives_wf(
*, t1w_mask: bool, t1w_aseg: bool, t2w_aseg: bool, name: str = 'coregister_derivatives_wf'
):
Expand Down Expand Up @@ -301,6 +303,7 @@ def init_coregister_derivatives_wf(
return workflow


@tag('anat.concat-reg')
def init_concat_registrations_wf(
*,
templates,
Expand Down
18 changes: 8 additions & 10 deletions nibabies/workflows/anatomical/resampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import nipype.interfaces.utility as niu
import nipype.pipeline.engine as pe
import templateflow.api as tf
from niworkflows.engine.workflows import LiterateWorkflow
from niworkflows.engine import Workflow, tag
from smriprep.interfaces.workbench import SurfaceResample
from smriprep.workflows.surfaces import init_morph_grayords_wf

Expand All @@ -12,11 +12,12 @@
from nibabies.interfaces.utils import CiftiSelect


@tag('anat.resample-surfs')
def init_anat_fsLR_resampling_wf(
grayord_density: ty.Literal['91k'], mcribs: bool, name='anat_fsLR_resampling_wf'
) -> LiterateWorkflow:
) -> Workflow:
"""Resample the surfaces into fsLR space"""
workflow = LiterateWorkflow(name=name)
workflow = Workflow(name=name)

Check warning on line 20 in nibabies/workflows/anatomical/resampling.py

View check run for this annotation

Codecov / codecov/patch

nibabies/workflows/anatomical/resampling.py#L20

Added line #L20 was not covered by tests
fslr_density = '32k' if grayord_density == '91k' else '59k'

workflow.__desc__ = """\
Expand Down Expand Up @@ -93,20 +94,18 @@
# resample surfaces / morphometrics to 32k
if mcribs:
morph_grayords_wf = init_mcribs_morph_grayords_wf(grayord_density)
# fmt:off

workflow.connect([
(inputnode, morph_grayords_wf, [
('morphometrics', 'inputnode.morphometrics'),
('surfaces', 'inputnode.surfaces'),
('sphere_reg_fsLR', 'inputnode.sphere_reg')]),
(joinnode, morph_grayords_wf, [
('midthickness_fsLR', 'inputnode.midthickness_fsLR')]),
])
# fmt:on
]) # fmt:skip
else:
morph_grayords_wf = init_morph_grayords_wf(grayord_density)

# fmt:off
workflow.connect([
(inputnode, select_surfaces, [
('surfaces', 'surfaces'),
Expand All @@ -126,11 +125,11 @@
(morph_grayords_wf, outputnode, [
('outputnode.cifti_morph', 'cifti_morph'),
('outputnode.cifti_metadata', 'cifti_metadata')]),
])
# fmt:on
]) # fmt:skip
return workflow


@tag('anat.resample-morphs-grayords')
def init_mcribs_morph_grayords_wf(
grayord_density: ty.Literal['91k'], # Only 91k supported ATM
name: str = 'morph_grayords_wf',
Expand Down Expand Up @@ -174,7 +173,6 @@

"""
from nipype.interfaces.workbench import MetricResample
from niworkflows.engine.workflows import LiterateWorkflow as Workflow
from smriprep.interfaces.cifti import GenerateDScalar

from nibabies.interfaces.workbench import SurfaceVertexAreas
Expand Down
4 changes: 3 additions & 1 deletion nibabies/workflows/anatomical/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from nipype.interfaces.ants.segmentation import JointFusion
from nipype.pipeline import engine as pe
from niworkflows.data import load as load_nwf
from niworkflows.engine.workflows import LiterateWorkflow as Workflow
from niworkflows.engine import Workflow, tag
from niworkflows.interfaces.fixes import FixHeaderApplyTransforms as ApplyTransforms
from niworkflows.interfaces.fixes import FixHeaderRegistration as Registration
from niworkflows.utils.connections import listify
Expand All @@ -23,6 +23,7 @@
LOGGER = config.loggers.workflow


@tag('anat.segmentation')
def init_segmentation_wf(
*,
sloppy: bool,
Expand Down Expand Up @@ -129,6 +130,7 @@ def init_segmentation_wf(
return workflow


@tag('anat.segmentation.jlf')
def init_jlf_wf(
jlf_template_dir: Path,
sloppy: bool,
Expand Down
15 changes: 10 additions & 5 deletions nibabies/workflows/anatomical/surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from nipype.interfaces import utility as niu
from nipype.interfaces.ants import N4BiasFieldCorrection
from nipype.pipeline import engine as pe
from niworkflows.engine.workflows import LiterateWorkflow
from niworkflows.engine import Workflow, tag
from niworkflows.interfaces.freesurfer import (
PatchedLTAConvert as LTAConvert,
)
Expand Down Expand Up @@ -41,6 +41,7 @@
]


@tag('anat.recon')
def init_mcribs_surface_recon_wf(
*,
omp_nthreads: int,
Expand All @@ -67,7 +68,7 @@
inputnode = pe.Node(niu.IdentityInterface(fields=SURFACE_INPUTS), name='inputnode')
outputnode = pe.Node(niu.IdentityInterface(fields=SURFACE_OUTPUTS), name='outputnode')

workflow = LiterateWorkflow(name=name)
workflow = Workflow(name=name)

Check warning on line 71 in nibabies/workflows/anatomical/surfaces.py

View check run for this annotation

Codecov / codecov/patch

nibabies/workflows/anatomical/surfaces.py#L71

Added line #L71 was not covered by tests
workflow.__desc__ = (
'Brain surfaces were reconstructed with a modified `MCRIBReconAll` [M-CRIB-S, @mcribs]'
'workflow, using the reference T2w and a pre-computed anatomical segmentation'
Expand Down Expand Up @@ -224,6 +225,7 @@
return workflow


@tag('anat.fslr-reg')
def init_mcribs_dhcp_wf(*, name='mcribs_dhcp_wf'):
"""
Generate GIFTI registration files to dhcp (42-week) space.
Expand All @@ -233,7 +235,7 @@
"""
from smriprep.interfaces.workbench import SurfaceSphereProjectUnproject

workflow = LiterateWorkflow(name=name)
workflow = Workflow(name=name)

Check warning on line 238 in nibabies/workflows/anatomical/surfaces.py

View check run for this annotation

Codecov / codecov/patch

nibabies/workflows/anatomical/surfaces.py#L238

Added line #L238 was not covered by tests

inputnode = pe.Node(
niu.IdentityInterface(['sphere_reg', 'sulc']),
Expand Down Expand Up @@ -294,6 +296,7 @@
return workflow


@tag('anat.recon')
def init_infantfs_surface_recon_wf(
*,
age_months: int,
Expand All @@ -304,7 +307,7 @@
):
from nibabies.interfaces.freesurfer import InfantReconAll

workflow = LiterateWorkflow(name=name)
workflow = Workflow(name=name)
inputnode = pe.Node(niu.IdentityInterface(fields=SURFACE_INPUTS), name='inputnode')
outputnode = pe.Node(niu.IdentityInterface(fields=SURFACE_OUTPUTS), name='outputnode')

Expand Down Expand Up @@ -382,6 +385,7 @@
return workflow


@tag('anat.midthickness')
def init_make_midthickness_wf(
*, omp_nthreads: int, name: str = 'make_midthickness_wf'
) -> pe.Workflow:
Expand Down Expand Up @@ -435,6 +439,7 @@
return workflow


@tag('anat.resample-surfs')
def init_resample_surfaces_dhcp_wf(
surfaces: list[str],
grayord_density: ty.Literal['91k', '170k'],
Expand Down Expand Up @@ -470,7 +475,7 @@
midthickness
GIFTI surface mesh corresponding to the midthickness surface, resampled to fsLR
"""
workflow = LiterateWorkflow(name=name)
workflow = Workflow(name=name)

Check warning on line 478 in nibabies/workflows/anatomical/surfaces.py

View check run for this annotation

Codecov / codecov/patch

nibabies/workflows/anatomical/surfaces.py#L478

Added line #L478 was not covered by tests

fslr_density = '32k' if grayord_density == '91k' else '59k'

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies = [
"nireports >= 23.2.0",
"nitime",
"nitransforms >= 24.1.1",
"niworkflows >= 1.12.2",
"niworkflows >= 1.13.1",
"numpy >= 1.21.0",
"packaging",
"pandas",
Expand Down
Loading