Skip to content
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

Add thr pipeline #20

Merged
merged 6 commits into from
Jun 17, 2024
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
1 change: 0 additions & 1 deletion .github/workflows/check_on_PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ jobs:
sudo apt-get install build-essential graphviz libgraphviz-dev
pip install --upgrade pygraphviz graphviz


# pip install --no-deps --index-url https://test.pypi.org/simple/ --pre macapype

pip install -e .
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import re
from setuptools import find_packages, setup

required_packages = [
"macapype"]
required_packages = ["Cython",
"macapype"]

verstr = "unknown"
try:
Expand Down
39 changes: 39 additions & 0 deletions skullTo3d/pipelines/rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,42 @@ def rename_all_skull_t1_derivatives(params, main_workflow, segment_pnh_pipe,
main_workflow.connect(
rename_t1_head_mask, 'out_file',
datasink, '@t1_head_mask')

if "t1_skull_fov" in params["skull_t1_pipe"]:

# rename robustt1_skull_stl
rename_robustt1_skull_stl = pe.Node(
niu.Rename(), name="rename_robustt1_skull_stl")

rename_robustt1_skull_stl.inputs.format_string = \
pref_deriv + "_desc-robustt1_skullmask"
rename_robustt1_skull_stl.inputs.parse_string = parse_str
rename_robustt1_skull_stl.inputs.keep_ext = True

main_workflow.connect(
skull_t1_pipe, 'outputnode.robustt1_skull_stl',
rename_robustt1_skull_stl, 'in_file')

main_workflow.connect(
rename_robustt1_skull_stl, 'out_file',
datasink, '@robustt1_skull_stl')

# rename stereo_robustt1_skull_mask
rename_stereo_robustt1_skull_mask = pe.Node(
niu.Rename(), name="rename_stereo_robustt1_skullmask")

rename_stereo_robustt1_skull_mask.inputs.format_string = \
pref_deriv + "_space-stereo_desc-robustt1_skullmask"

rename_stereo_robustt1_skull_mask.inputs.parse_string = \
parse_str

rename_stereo_robustt1_skull_mask.inputs.keep_ext = True

main_workflow.connect(
skull_t1_pipe, 'outputnode.robustt1_skull_mask',
rename_stereo_robustt1_skull_mask, 'in_file')

main_workflow.connect(
rename_stereo_robustt1_skull_mask, 'out_file',
datasink, '@stereo_robustt1_skullmask')
89 changes: 78 additions & 11 deletions skullTo3d/pipelines/skull_pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,30 +276,79 @@ def create_skull_t1_pipe(name="skull_t1_pipe", params={}):
skull_t1_pipe.connect(t1_skull_fill, "out_file",
t1_skull_erode, "in_file")

# mesh_t1_skull_t1 #######
mesh_t1_skull_t1 = pe.Node(
# mesh_t1_skull #######
mesh_t1_skull = pe.Node(
interface=niu.Function(input_names=["nii_file"],
output_names=["stl_file"],
function=wrap_afni_IsoSurface),
name="mesh_t1_skull_t1")
name="mesh_t1_skull")

skull_t1_pipe.connect(t1_skull_erode, "out_file",
mesh_t1_skull_t1, "nii_file")
mesh_t1_skull, "nii_file")

if "t1_skull_fov" in params.keys():

# t1_skull_fov ####### [okey][json]

t1_skull_fov = NodeParams(
interface=RobustFOV(),
params=parse_key(params, "t1_skull_fov"),
name="t1_skull_fov")

skull_t1_pipe.connect(
t1_skull_erode, "out_file",
t1_skull_fov, "in_file")

# t1_skull_clean ####### [okey]
t1_skull_clean = pe.Node(
interface=niu.Function(input_names=["nii_file"],
output_names=["gcc_nii_file"],
function=keep_gcc),
name="t1_skull_clean")

skull_t1_pipe.connect(
t1_skull_fov, "out_roi",
t1_skull_clean, "nii_file")

# mesh_robustt1_skull #######
mesh_robustt1_skull = pe.Node(
interface=niu.Function(input_names=["nii_file"],
output_names=["stl_file"],
function=wrap_afni_IsoSurface),
name="mesh_robustt1_skull")

skull_t1_pipe.connect(
t1_skull_clean, "gcc_nii_file",
mesh_robustt1_skull, "nii_file")

# creating outputnode #######
outputnode = pe.Node(
niu.IdentityInterface(
fields=["t1_skull_mask", "t1_skull_stl", "t1_head_mask"]),
fields=["t1_skull_mask", "t1_skull_stl",
"robustt1_skull_mask", "robustt1_skull_stl",
"t1_head_mask"]),
name='outputnode')

skull_t1_pipe.connect(t1_head_erode, "out_file",
outputnode, "t1_head_mask")
skull_t1_pipe.connect(
t1_head_erode, "out_file",
outputnode, "t1_head_mask")

skull_t1_pipe.connect(mesh_t1_skull_t1, "stl_file",
outputnode, "t1_skull_stl")
skull_t1_pipe.connect(
mesh_t1_skull, "stl_file",
outputnode, "t1_skull_stl")

skull_t1_pipe.connect(t1_skull_erode, "out_file",
outputnode, "t1_skull_mask")
skull_t1_pipe.connect(
t1_skull_erode, "out_file",
outputnode, "t1_skull_mask")

if "t1_skull_fov" in params.keys():
skull_t1_pipe.connect(
t1_skull_fov, "out_roi",
outputnode, "robustt1_skull_mask")

skull_t1_pipe.connect(
mesh_robustt1_skull, "stl_file",
outputnode, "robustt1_skull_stl")

return skull_t1_pipe

Expand Down Expand Up @@ -685,6 +734,21 @@ def create_skull_petra_pipe(name="skull_petra_pipe", params={}):
skull_petra_pipe.connect(petra_fast, "restored_image",
petra_skull_auto_mask, "img_file")

elif "petra_skull_mask_thr" in params.keys():

# petra_skull_mask_thr
petra_skull_mask_thr = NodeParams(
interface=Threshold(),
params=parse_key(params, 'petra_skull_mask_thr'),
name="petra_skull_mask_thr")

skull_petra_pipe.connect(petra_fast, "restored_image",
petra_skull_mask_thr, "in_file")

skull_petra_pipe.connect(
inputnode, ('indiv_params', parse_key, "petra_skull_mask_thr"),
petra_skull_mask_thr, "indiv_params")

# petra_skull_mask_binary
petra_skull_mask_binary = pe.Node(interface=UnaryMaths(),
name="petra_skull_mask_binary")
Expand All @@ -695,6 +759,9 @@ def create_skull_petra_pipe(name="skull_petra_pipe", params={}):
if "petra_skull_auto_mask" in params.keys():
skull_petra_pipe.connect(petra_skull_auto_mask, "mask_img_file",
petra_skull_mask_binary, "in_file")
if "petra_skull_mask_thr" in params.keys():
skull_petra_pipe.connect(petra_skull_mask_thr, "out_file",
petra_skull_mask_binary, "in_file")
else:
skull_petra_pipe.connect(petra_fast,
("partial_volume_files", get_elem, 0),
Expand Down
9 changes: 4 additions & 5 deletions workflows/params_segment_macaque_ants_skull.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
},
"reg_T1_on_template":
{
},
"reg_T1_on_template2":
{
}
},
"resample_T1_pad":
"pad_template":
{
"pad_val": 30
"copy_header" : true,
"operation" : "PadImage",
"op2" : "70"
}
},
"N4debias":
Expand Down
20 changes: 19 additions & 1 deletion workflows/params_segment_marmo_ants_skull.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,39 @@
},
"short_preparation_pipe":
{
"aladin_T2_on_T1":{},

"use_T2":{},
"crop_aladin_pipe":
{
"reg_T1_on_template":
{
"nac_flag": true,
"rig_only_flag": true,
"nosym_flag": true,
"ln_val": 12,
"lp_val": 10,
"smoo_r_val": 1.0
},
"reg_T1_on_template2":
{
"rig_only_flag": true,
"nosym_flag": true,
"ln_val": 17,
"lp_val": 15,
"smoo_r_val": 1.0
},
"crop_z_T1":
{
"brainsize": 30
}
},
"resample_T1_pad": {}
"pad_template":
{
"copy_header" : true,
"operation" : "PadImage",
"op2" : "70"
}
},
"fast":
{
Expand Down
5 changes: 4 additions & 1 deletion workflows/segment_petra.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ def create_main_workflow(data_dir, process_dir, soft, species, subjects,
if 'template' in ssoft:
new_ssoft.remove('template')

if 'robustreg' in ssoft:
new_ssoft.remove('robustreg')

soft = "_".join(new_ssoft)

print("soft: ", soft)
Expand Down Expand Up @@ -285,7 +288,7 @@ def create_main_workflow(data_dir, process_dir, soft, species, subjects,
wf_name += "_CT"

if len(brain_dt) != 0:
wf_name += "_brain"
wf_name += "_segbrain"

if 't1' in brain_dt:
wf_name += "_t1"
Expand Down
Loading