From 9bc58aeb65983308ffaf6863486f3c386ab62faa Mon Sep 17 00:00:00 2001 From: David Meunier Date: Thu, 12 Dec 2024 14:32:09 +0100 Subject: [PATCH 1/4] modif params --- examples_doc/params_skull.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/examples_doc/params_skull.json b/examples_doc/params_skull.json index 61cc498..3a0127b 100644 --- a/examples_doc/params_skull.json +++ b/examples_doc/params_skull.json @@ -109,6 +109,14 @@ "skull_ct_pipe": { + "align_ct_on_T1_2": + { + + "comment": "OPTIONAL", + "comment": "Cannot be modified", + "params": "RegAladin (NiftyReg)" + + }, "ct_head_mask_thr": { "params": "Threshold (FSL)", @@ -155,7 +163,6 @@ }, - "petra_head_mask_thr": { "params": "Threshold (FSL)", From f0192264fac2fd41f65c6f1908f12710614c19f3 Mon Sep 17 00:00:00 2001 From: David Meunier Date: Thu, 12 Dec 2024 17:28:38 +0100 Subject: [PATCH 2/4] optional petra_itk_debias for marmoset only --- examples_doc/params_skull.json | 9 +++- skullTo3d/pipelines/skull_pipe.py | 54 +++++++++++++------ .../params_segment_marmo_ants_skull.json | 2 +- 3 files changed, 48 insertions(+), 17 deletions(-) diff --git a/examples_doc/params_skull.json b/examples_doc/params_skull.json index 3a0127b..e719d9e 100644 --- a/examples_doc/params_skull.json +++ b/examples_doc/params_skull.json @@ -157,12 +157,19 @@ "avg_reorient_pipe": { - "comment": "OPTIONAL", "params": "see corresponding doc in short_preparation_pipe in macapype" }, + "petra_itk_debias": + { + "comment": "OPTIONAL", + "params": "SimpleITK N4BiasFieldCorrectionImageFilter dirty wrap (defined in macapype.nodes.correc_bias)", + "comment": "Should be made a proper nipype node ", + + }, + "petra_head_mask_thr": { "params": "Threshold (FSL)", diff --git a/skullTo3d/pipelines/skull_pipe.py b/skullTo3d/pipelines/skull_pipe.py index cd38a46..4b63276 100644 --- a/skullTo3d/pipelines/skull_pipe.py +++ b/skullTo3d/pipelines/skull_pipe.py @@ -682,17 +682,19 @@ def create_skull_petra_pipe(name="skull_petra_pipe", params={}): skull_petra_pipe.connect(inputnode, "stereo_T1", align_petra_on_stereo_T1, "ref_file") - # Adding early petra_debias - petra_itk_debias = NodeParams( - interface=niu.Function( - input_names=["img_file"], - output_names=["cor_img_file", "bias_img_file"], - function=itk_debias), - params=parse_key(params, "petra_itk_debias"), - name="petra_itk_debias") - - skull_petra_pipe.connect(align_petra_on_stereo_T1, "out_file", - petra_itk_debias, "img_file") + if "petra_itk_debias" in params.keys(): + + # Adding early petra_debias + petra_itk_debias = pe.Node( + interface=niu.Function( + input_names=["img_file"], + output_names=["cor_img_file", "bias_img_file"], + function=itk_debias), + name="petra_itk_debias") + + skull_petra_pipe.connect(align_petra_on_stereo_T1, "out_file", + petra_itk_debias, "img_file") + # ### head mask # headmask_threshold @@ -703,8 +705,15 @@ def create_skull_petra_pipe(name="skull_petra_pipe", params={}): params=parse_key(params, 'petra_head_mask_thr'), name="petra_head_mask_thr") - skull_petra_pipe.connect(petra_itk_debias, "cor_img_file", - petra_head_mask_thr, "in_file") + + if "petra_itk_debias" in params.keys(): + + skull_petra_pipe.connect(petra_itk_debias, "cor_img_file", + petra_head_mask_thr, "in_file") + else: + + skull_petra_pipe.connect(align_petra_on_stereo_T1, "out_file", + petra_head_mask_thr, "in_file") skull_petra_pipe.connect( inputnode, ('indiv_params', parse_key, "petra_head_mask_thr"), @@ -720,8 +729,14 @@ def create_skull_petra_pipe(name="skull_petra_pipe", params={}): params=parse_key(params, "petra_head_auto_mask"), name="petra_head_auto_mask") - skull_petra_pipe.connect(petra_itk_debias, "cor_img_file", - petra_head_auto_mask, "img_file") + if "petra_itk_debias" in params.keys(): + + skull_petra_pipe.connect(petra_itk_debias, "cor_img_file", + petra_head_auto_mask, "img_file") + else: + + skull_petra_pipe.connect(align_petra_on_stereo_T1, "out_file", + petra_head_auto_mask, "img_file") skull_petra_pipe.connect( inputnode, ('indiv_params', parse_key, "petra_head_auto_mask"), @@ -791,6 +806,15 @@ def create_skull_petra_pipe(name="skull_petra_pipe", params={}): petra_hmasked = pe.Node(interface=ApplyMask(), name="petra_hmasked") + if "petra_itk_debias" in params.keys(): + + skull_petra_pipe.connect(petra_itk_debias, "cor_img_file", + petra_hmasked, "in_file") + else: + + skull_petra_pipe.connect(align_petra_on_stereo_T1, "out_file", + petra_hmasked, "in_file") + skull_petra_pipe.connect(petra_itk_debias, "cor_img_file", petra_hmasked, "in_file") diff --git a/workflows/params_segment_marmo_ants_skull.json b/workflows/params_segment_marmo_ants_skull.json index 86f9e3e..9a379a8 100755 --- a/workflows/params_segment_marmo_ants_skull.json +++ b/workflows/params_segment_marmo_ants_skull.json @@ -98,7 +98,7 @@ } }, "skull_petra_pipe": - { + { "petra_itk_debias":{}, "petra_head_auto_mask": { "kmeans": true, From a9f971b638dc22b8a378f9ee75879e9bced63df5 Mon Sep 17 00:00:00 2001 From: David Meunier Date: Thu, 12 Dec 2024 17:35:16 +0100 Subject: [PATCH 3/4] if petra_itk_debias --- skullTo3d/pipelines/skull_pipe.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/skullTo3d/pipelines/skull_pipe.py b/skullTo3d/pipelines/skull_pipe.py index 4b63276..5a782e7 100644 --- a/skullTo3d/pipelines/skull_pipe.py +++ b/skullTo3d/pipelines/skull_pipe.py @@ -815,9 +815,6 @@ def create_skull_petra_pipe(name="skull_petra_pipe", params={}): skull_petra_pipe.connect(align_petra_on_stereo_T1, "out_file", petra_hmasked, "in_file") - skull_petra_pipe.connect(petra_itk_debias, "cor_img_file", - petra_hmasked, "in_file") - skull_petra_pipe.connect(petra_head_erode, "out_file", petra_hmasked, "mask_file") From 6ba9475305a02412252b9f9aaac2d41ab7334d6d Mon Sep 17 00:00:00 2001 From: David Meunier Date: Fri, 13 Dec 2024 09:50:55 +0100 Subject: [PATCH 4/4] flake8 --- skullTo3d/pipelines/skull_pipe.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/skullTo3d/pipelines/skull_pipe.py b/skullTo3d/pipelines/skull_pipe.py index 5a782e7..f8a9697 100644 --- a/skullTo3d/pipelines/skull_pipe.py +++ b/skullTo3d/pipelines/skull_pipe.py @@ -695,7 +695,6 @@ def create_skull_petra_pipe(name="skull_petra_pipe", params={}): skull_petra_pipe.connect(align_petra_on_stereo_T1, "out_file", petra_itk_debias, "img_file") - # ### head mask # headmask_threshold if "petra_head_mask_thr" in params.keys(): @@ -705,7 +704,6 @@ def create_skull_petra_pipe(name="skull_petra_pipe", params={}): params=parse_key(params, 'petra_head_mask_thr'), name="petra_head_mask_thr") - if "petra_itk_debias" in params.keys(): skull_petra_pipe.connect(petra_itk_debias, "cor_img_file",