Skip to content

Commit

Permalink
pad and rename t1 skullmask
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmeunier79 committed Mar 15, 2024
1 parent 0e39f2b commit 0daee6a
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 10 deletions.
2 changes: 1 addition & 1 deletion skullTo3d/pipelines/rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def rename_all_skull_petra_derivatives(params, main_workflow, segment_pnh_pipe,
niu.Rename(), name="rename_stereo_robustpetra_skullmask")

rename_stereo_robustpetra_skull_mask.inputs.format_string = \
pref_deriv + "_desc-robustpetra_skullmask"
pref_deriv + "_space-stereo_desc-robustpetra_skullmask"

rename_stereo_robustpetra_skull_mask.inputs.parse_string = \
parse_str
Expand Down
67 changes: 58 additions & 9 deletions workflows/segment_petra.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,9 +547,6 @@ def create_main_workflow(data_dir, process_dir, soft, species, subjects,
"outputnode.stereo_to_native_trans",
pad_petra_skull_mask, "trans_file")

print("Using reg_aladin transfo \
to pad robustpetra_skull_mask back")

print("Using reg_aladin transfo to pad head_mask back")

pad_petra_head_mask = pe.Node(RegResample(inter_val="NN"),
Expand All @@ -567,6 +564,9 @@ def create_main_workflow(data_dir, process_dir, soft, species, subjects,
"outputnode.stereo_to_native_trans",
pad_petra_head_mask, "trans_file")

print("Using reg_aladin transfo \
to pad robustpetra_skull_mask back")

if "petra_skull_fov" in params["skull_petra_pipe"]:
pad_robustpetra_skull_mask = pe.Node(
RegResample(inter_val="NN"),
Expand Down Expand Up @@ -638,6 +638,37 @@ def create_main_workflow(data_dir, process_dir, soft, species, subjects,
if indiv_params:
main_workflow.connect(datasource, "indiv_params",
skull_t1_pipe, 'inputnode.indiv_params')
if pad and space == "native":

# output node
outputnode = pe.Node(
niu.IdentityInterface(
fields=["native_petra_skull_mask",
"native_robustpetra_skull_mask",
"native_petra_head_mask"]),
name='outputnode')

if "short_preparation_pipe" in params.keys():
if "crop_T1" in params["short_preparation_pipe"].keys():
pass
else:
print("Using reg_aladin transfo to pad skull_mask back")

pad_t1_skull_mask = pe.Node(RegResample(inter_val="NN"),
name="pad_t1_skull_mask")

main_workflow.connect(
skull_t1_pipe, "outputnode.t1_skull_mask",
pad_t1_skull_mask, "flo_file")

main_workflow.connect(
segment_brain_pipe, "outputnode.native_T1",
pad_t1_skull_mask, "ref_file")

main_workflow.connect(
segment_brain_pipe,
"outputnode.stereo_to_native_trans",
pad_t1_skull_mask, "trans_file")

if deriv:

Expand Down Expand Up @@ -679,19 +710,19 @@ def create_main_workflow(data_dir, process_dir, soft, species, subjects,
params, main_workflow, segment_brain_pipe, skull_petra_pipe,
datasink, pref_deriv, parse_str, space, pad)

if pad and space == "native":
if pad:

# rename petra_skull_mask
rename_petra_skull_mask = pe.Node(
niu.Rename(), name="rename_petra_skull_mask")

rename_petra_skull_mask.inputs.format_string = \
pref_deriv + "_space-{}_desc-petra_skullmask".format(space)
pref_deriv + "_space-native_desc-petra_skullmask"
rename_petra_skull_mask.inputs.parse_string = parse_str
rename_petra_skull_mask.inputs.keep_ext = True

main_workflow.connect(
pad_petra_head_mask, "out_file",
pad_petra_skull_mask, "out_file",
rename_petra_skull_mask, 'in_file')

main_workflow.connect(
Expand All @@ -702,7 +733,7 @@ def create_main_workflow(data_dir, process_dir, soft, species, subjects,
rename_petra_head_mask = pe.Node(
niu.Rename(), name="rename_petra_head_mask")
rename_petra_head_mask.inputs.format_string = \
pref_deriv + "_space-{}_desc-petra_headmask".format(space)
pref_deriv + "_space-native_desc-petra_headmask"
rename_petra_head_mask.inputs.parse_string = parse_str
rename_petra_head_mask.inputs.keep_ext = True

Expand All @@ -720,8 +751,7 @@ def create_main_workflow(data_dir, process_dir, soft, species, subjects,
niu.Rename(), name="rename_robustpetra_skull_mask")
rename_robustpetra_skull_mask.inputs.format_string = \
pref_deriv + \
"_space-{}_desc-robustpetra_skullmask".format(
space)
"_space-native_desc-robustpetra_skullmask"

rename_robustpetra_skull_mask.inputs.parse_string = \
parse_str
Expand All @@ -748,6 +778,25 @@ def create_main_workflow(data_dir, process_dir, soft, species, subjects,
params, main_workflow, segment_brain_pipe, skull_t1_pipe,
datasink, pref_deriv, parse_str, space, pad)

if pad:

# rename t1_skull_mask
rename_t1_skull_mask = pe.Node(
niu.Rename(), name="rename_t1_skull_mask")

rename_t1_skull_mask.inputs.format_string = \
pref_deriv + "_space-native_desc-t1_skullmask"
rename_t1_skull_mask.inputs.parse_string = parse_str
rename_t1_skull_mask.inputs.keep_ext = True

main_workflow.connect(
pad_t1_skull_mask, "out_file",
rename_t1_skull_mask, 'in_file')

main_workflow.connect(
rename_t1_skull_mask, 'out_file',
datasink, '@t1_skull_mask')

main_workflow.write_graph(graph2use="colored")
main_workflow.config['execution'] = {'remove_unnecessary_outputs': 'false'}

Expand Down

0 comments on commit 0daee6a

Please sign in to comment.