Skip to content

Commit

Permalink
added GM mask from 5tt
Browse files Browse the repository at this point in the history
  • Loading branch information
GalKepler committed Nov 14, 2024
1 parent 4abc7a3 commit cf4981e
Show file tree
Hide file tree
Showing 6 changed files with 176 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

[tool.poetry]
name = "kepost"
version = "0.2.10"
version = "0.2.14"
description = "Post-processing for dMRI derivatives of the Strauss Neuroplasticity Brain Bank (SNBB)"
readme = "README.rst"
authors = ["Gal Kepler <[email protected]>"]
Expand Down
2 changes: 1 addition & 1 deletion src/kepost/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__author__ = """Gal Kepler"""
__email__ = "[email protected]"
__version__ = "0.2.10"
__version__ = "0.2.14"
39 changes: 28 additions & 11 deletions src/kepost/workflows/anatomical/anatomical.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
init_gm_cropping_wf,
init_registration_wf,
)
from kepost.workflows.anatomical.procedures.generate_gm import init_gm_from_5tt_wf


def init_anatomical_wf(
Expand Down Expand Up @@ -160,17 +161,6 @@ def init_anatomical_wf(

workflow.connect(
[
(
inputnode,
gm_cropping_wf,
[
(
"gm_probabilistic_segmentation",
"inputnode.gm_probabilistic_segmentation",
),
("probseg_threshold", "inputnode.probseg_threshold"),
],
),
(
registration_wf,
gm_cropping_wf,
Expand Down Expand Up @@ -240,6 +230,33 @@ def init_anatomical_wf(
]
)

gm_from_five_tissue = init_gm_from_5tt_wf()
workflow.connect(
[
(
five_tissue_type,
gm_from_five_tissue,
[
("outputnode.five_tissue_type", "inputnode.five_tissue_type"),
],
),
(
inputnode,
gm_cropping_wf,
[
("probseg_threshold", "inputnode.probseg_threshold"),
],
),
(
gm_from_five_tissue,
gm_cropping_wf,
[
("outputnode.gm_mask", "inputnode.gm_probabilistic_segmentation"),
],
),
]
)

derivatives_wf = init_derivatives_wf()
workflow.connect(
[
Expand Down
146 changes: 146 additions & 0 deletions src/kepost/workflows/anatomical/procedures/generate_gm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
from nipype.interfaces import utility as niu
from nipype.interfaces.fsl import ExtractROI, ImageMaths
from nipype.pipeline import engine as pe
from niworkflows.engine.workflows import LiterateWorkflow as Workflow

from kepost.interfaces.mrtrix3 import MRConvert


def init_gm_from_5tt_wf(name: str = "gm_from_5tt"):
"""
Initialize the gm from 5tt workflow.
Parameters
----------
name : str, optional
The name of the workflow, by default "gm_from_5tt"
Returns
-------
workflow : nipype.pipeline.engine.Workflow
The gm from 5tt workflow.
"""
workflow = Workflow(name=name)
inputnode = pe.Node(
interface=niu.IdentityInterface(
fields=[
"five_tissue_type",
]
),
name="inputnode",
)
outputnode = pe.Node(
interface=niu.IdentityInterface(
fields=[
"gm_mask",
]
),
name="outputnode",
)
mrconvert = pe.Node(
interface=MRConvert(
out_file="five_tissue_type.nii.gz",
),
name="mrconvert",
)
fslroi_cortical_gm = pe.Node(
interface=ExtractROI(
t_min=0,
t_size=1,
),
name="fslroi_cortical_gm",
)
fslroi_subcortical_gm = pe.Node(
interface=ExtractROI(
t_min=1,
t_size=1,
),
name="fslroi_subcortical_gm",
)
fslroi_pathological_gm = pe.Node(
interface=ExtractROI(
t_min=4,
t_size=1,
),
name="fslroi_pathological_gm",
)
fslmaths_cortical_subcortical = pe.Node(
interface=ImageMaths(
op_string="-add",
),
name="fslmaths_cortical_subcortical",
)
fslmaths_cortical_subcortical_pathological = pe.Node(
interface=ImageMaths(
op_string="-add",
),
name="fslmaths_cortical_subcortical_pathological",
)
workflow.connect(
[
(
inputnode,
mrconvert,
[
("five_tissue_type", "in_file"),
],
),
(
mrconvert,
fslroi_cortical_gm,
[
("out_file", "in_file"),
],
),
(
mrconvert,
fslroi_subcortical_gm,
[
("out_file", "in_file"),
],
),
(
mrconvert,
fslroi_pathological_gm,
[
("out_file", "in_file"),
],
),
(
fslroi_cortical_gm,
fslmaths_cortical_subcortical,
[
("roi_file", "in_file"),
],
),
(
fslroi_subcortical_gm,
fslmaths_cortical_subcortical,
[
("roi_file", "in_file2"),
],
),
(
fslroi_pathological_gm,
fslmaths_cortical_subcortical_pathological,
[
("roi_file", "in_file"),
],
),
(
fslmaths_cortical_subcortical,
fslmaths_cortical_subcortical_pathological,
[
("out_file", "in_file2"),
],
),
(
fslmaths_cortical_subcortical_pathological,
outputnode,
[
("out_file", "gm_mask"),
],
),
]
)
return workflow
Binary file not shown.
Binary file not shown.

0 comments on commit cf4981e

Please sign in to comment.