Skip to content

Commit 970ef77

Browse files
Noisy petra for marmo (#64)
* marmo skullnoisypetra * from previous version, matching wirh modifs in macapype * gcc erode/dilate for skull also * using li_thresholding and inversion --------- Signed-off-by: David Meunier <david.meunier@univ-amu.fr>
1 parent 98139e4 commit 970ef77

3 files changed

Lines changed: 305 additions & 30 deletions

File tree

skullTo3d/pipelines/skull_pipe.py

Lines changed: 67 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from nipype.interfaces.fsl.maths import (
99
DilateImage, ErodeImage,
10-
ApplyMask, UnaryMaths, Threshold)
10+
ApplyMask, UnaryMaths, Threshold, MathsCommand)
1111

1212

1313
import nipype.interfaces.fsl as fsl
@@ -39,9 +39,9 @@
3939

4040
from macapype.utils.misc import parse_key, get_elem
4141

42-
#################################################
43-
# #################### T1 #####################
44-
#################################################
42+
##############################################################################
43+
# #################################### T1 ##################################
44+
##############################################################################
4545

4646

4747
def _create_headmask_t1_pipe(name="headmask_t1_pipe", params={}):
@@ -613,9 +613,9 @@ def create_skull_t1_pipe(name="skull_t1_pipe", params={}):
613613

614614
return skull_t1_pipe
615615

616-
###############################################################################
617-
# #################### CT ######################
618-
###############################################################################
616+
##############################################################################
617+
# #################################### CT ##################################
618+
##############################################################################
619619

620620

621621
def _create_skullmask_ct_pipe(name="skullmask_ct_pipe", params={}):
@@ -1255,29 +1255,61 @@ def _create_petra_skull_mask(name="skullmask_petra_pipe", params={}):
12551255
inputnode, ('indiv_params', parse_key, "petra_denoise"),
12561256
petra_denoise, "indiv_params")
12571257

1258-
petra_fast = NodeParams(interface=FAST(),
1259-
params=parse_key(params, "petra_fast"),
1260-
name="petra_fast")
1258+
if "petra_fast" in params.keys():
1259+
1260+
petra_fast = NodeParams(interface=FAST(),
1261+
params=parse_key(params, "petra_fast"),
1262+
name="petra_fast")
1263+
1264+
if "petra_denoise" in params.keys():
1265+
skullmask_petra_pipe.connect(
1266+
petra_denoise, "output_image",
1267+
petra_fast, "in_files")
1268+
else:
1269+
skullmask_petra_pipe.connect(
1270+
inputnode, "headmasked_petra",
1271+
petra_fast, "in_files")
1272+
1273+
# petra_skull_mask_binary
1274+
petra_skull_mask_binary = pe.Node(
1275+
interface=UnaryMaths(),
1276+
name="petra_skull_mask_binary")
1277+
1278+
petra_skull_mask_binary.inputs.operation = 'bin'
1279+
petra_skull_mask_binary.inputs.output_type = 'NIFTI_GZ'
12611280

1262-
if "petra_denoise" in params.keys():
12631281
skullmask_petra_pipe.connect(
1264-
petra_denoise, "output_image",
1265-
petra_fast, "in_files")
1282+
petra_fast, ("partial_volume_files", get_elem, 0),
1283+
petra_skull_mask_binary, "in_file")
1284+
12661285
else:
1267-
skullmask_petra_pipe.connect(
1268-
inputnode, "headmasked_petra",
1269-
petra_fast, "in_files")
1286+
# petra_skull_li_mask
1287+
petra_skull_li_mask = pe.Node(
1288+
interface=niu.Function(
1289+
input_names=["orig_img_file"],
1290+
output_names=["lithr_img_file"],
1291+
function=apply_li_thresh),
1292+
name="petra_skull_li_mask")
1293+
1294+
if "petra_denoise" in params.keys():
1295+
skullmask_petra_pipe.connect(
1296+
petra_denoise, "output_image",
1297+
petra_skull_li_mask, "orig_img_file")
1298+
else:
1299+
skullmask_petra_pipe.connect(
1300+
inputnode, "headmasked_petra",
1301+
petra_skull_li_mask, "orig_img_file")
12701302

1271-
# petra_skull_mask_binary
1272-
petra_skull_mask_binary = pe.Node(interface=UnaryMaths(),
1273-
name="petra_skull_mask_binary")
1303+
# fslmaths mask -mul -1 -add 1 invmask
1304+
petra_skull_inv = pe.Node(
1305+
interface=MathsCommand(),
1306+
name="petra_skull_inv")
12741307

1275-
petra_skull_mask_binary.inputs.operation = 'bin'
1276-
petra_skull_mask_binary.inputs.output_type = 'NIFTI_GZ'
1308+
petra_skull_inv.inputs.args = " -mul -1 -add 1"
12771309

1278-
skullmask_petra_pipe.connect(
1279-
petra_fast, ("partial_volume_files", get_elem, 0),
1280-
petra_skull_mask_binary, "in_file")
1310+
skullmask_petra_pipe.connect(
1311+
petra_skull_li_mask, "lithr_img_file",
1312+
petra_skull_inv, "in_file")
12811313

12821314
# petra_skull_auto_thresh
12831315
if "petra_head_erode_skin" in params.keys():
@@ -1296,18 +1328,24 @@ def _create_petra_skull_mask(name="skullmask_petra_pipe", params={}):
12961328
petra_head_erode_skin, "indiv_params")
12971329

12981330
# ### Masking with petra_head mask
1299-
# petra_hmasked ####### [okey]
1331+
# petra_skin_masked ####### [okey]
13001332
petra_skin_masked = pe.Node(interface=ApplyMask(),
13011333
name="petra_skin_masked")
13021334

1303-
skullmask_petra_pipe.connect(
1304-
petra_skull_mask_binary, "out_file",
1305-
petra_skin_masked, "in_file")
1306-
13071335
skullmask_petra_pipe.connect(
13081336
petra_head_erode_skin, "out_file",
13091337
petra_skin_masked, "mask_file")
13101338

1339+
if "petra_fast" in params.keys():
1340+
skullmask_petra_pipe.connect(
1341+
petra_skull_mask_binary, "out_file",
1342+
petra_skin_masked, "in_file")
1343+
1344+
else:
1345+
skullmask_petra_pipe.connect(
1346+
petra_skull_inv, "out_file",
1347+
petra_skin_masked, "in_file")
1348+
13111349
if "petra_skull_gcc_erode" in params and \
13121350
"petra_skull_gcc_dilate" in params:
13131351

workflows/params_segment_macaque_ants_skullnoisypetra.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179

180180
"petra_fast":
181181
{
182-
"args": " -l 10",
182+
"bias_lowpass": 10,
183183
"img_type": 3,
184184
"output_biascorrected": true,
185185
"output_biasfield": true
Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
{
2+
"general":
3+
{
4+
"template_name": "MBM_v3.0.1_6seg_stereoINT"
5+
},
6+
"short_preparation_pipe":
7+
{
8+
"aladin_T2_on_T1": {},
9+
"crop_aladin_pipe":
10+
{
11+
"reg_T1_on_template":
12+
{
13+
"rig_only_flag":true
14+
},
15+
"reg_T1_on_template2":
16+
{
17+
"rig_only_flag":true
18+
}
19+
},
20+
"pad_template":
21+
{
22+
"operation" : "PadImage",
23+
"op2" : "90"
24+
},
25+
"denoise":
26+
{
27+
},
28+
"fast":
29+
{
30+
"args": "-l 3"
31+
}
32+
},
33+
"extract_pipe":
34+
{
35+
"atlas_brex":
36+
{
37+
"f": 0.62,
38+
"reg": 1,
39+
"msk": "b,0.5,0,0",
40+
"wrp": "5,5,5",
41+
"dil": 4,
42+
"vox": 1
43+
}
44+
},
45+
"debias":
46+
{
47+
"s": 4
48+
},
49+
"brain_segment_pipe":
50+
{
51+
"reg":
52+
{
53+
"n": 2,
54+
"m": "ref",
55+
"dof": 12
56+
},
57+
"segment_atropos_pipe":
58+
{
59+
"use_priors":0.0,
60+
61+
"Atropos":
62+
{
63+
"dimension": 3
64+
},
65+
66+
"tissue_dict":
67+
{
68+
"gm": [1,2],
69+
"wm": 3,
70+
"csf": 4
71+
}
72+
}
73+
},
74+
"export_5tt_pipe":
75+
{
76+
},
77+
"IsoSurface_brain_pipe":
78+
{
79+
"merge_brain_tissues":
80+
{
81+
"keep_indexes": [1,2,3]
82+
}
83+
},
84+
"IsoSurface_tissues_pipe":
85+
{
86+
},
87+
88+
"skull_t1_pipe":
89+
{
90+
"headmask_t1_pipe":
91+
{
92+
"t1_head_dilate":
93+
{
94+
"operation": "modal",
95+
"kernel_shape": "boxv",
96+
"kernel_size": 9.0
97+
},
98+
"t1_head_erode":
99+
{
100+
"kernel_shape": "boxv",
101+
"kernel_size": 9.0
102+
}
103+
},
104+
"skullmask_t1_pipe":
105+
{
106+
"t1_fast":
107+
{
108+
"args": "-l 4 -O 4 -t 1",
109+
"output_biascorrected": true,
110+
"output_biasfield": true
111+
},
112+
"t1_head_erode_skin":
113+
{
114+
"kernel_shape": "boxv",
115+
"kernel_size": 6.0
116+
},
117+
"t1_skull_dilate":
118+
{
119+
"operation": "modal",
120+
"kernel_shape": "boxv",
121+
"kernel_size": 4.0
122+
},
123+
"t1_skull_erode":
124+
{
125+
"kernel_shape": "boxv",
126+
"kernel_size": 4.0
127+
}
128+
}
129+
},
130+
131+
"skull_petra_pipe":
132+
{
133+
"headmask_petra_pipe":
134+
{
135+
136+
"petra_itk_debias":
137+
{
138+
},
139+
"petra_head_gcc_erode":
140+
{
141+
"kernel_shape": "boxv",
142+
"kernel_size": 3.0
143+
},
144+
"petra_head_gcc_dilate":
145+
{
146+
"operation": "modal",
147+
"kernel_shape": "boxv",
148+
"kernel_size": 3.0
149+
},
150+
151+
"petra_head_dilate":
152+
{
153+
"operation": "modal",
154+
"kernel_shape": "boxv",
155+
"kernel_size": 7.0
156+
},
157+
"petra_head_erode":
158+
{
159+
"kernel_shape": "boxv",
160+
"kernel_size": 7.0
161+
}
162+
},
163+
"skullmask_petra_pipe":
164+
{
165+
"petra_fast":
166+
{
167+
"bias_lowpass": 4,
168+
"iters_afterbias": 4,
169+
"img_type": 3,
170+
171+
"output_biascorrected": true,
172+
"output_biasfield": true
173+
},
174+
"petra_head_erode_skin":
175+
{
176+
"kernel_shape": "boxv",
177+
"kernel_size": 8.0
178+
},
179+
180+
181+
"petra_skull_gcc_erode":
182+
{
183+
"kernel_shape": "boxv",
184+
"kernel_size": 3.0
185+
},
186+
"petra_skull_gcc_dilate":
187+
{
188+
"operation": "modal",
189+
"kernel_shape": "boxv",
190+
"kernel_size": 3.0
191+
},
192+
193+
194+
"petra_skull_dilate":
195+
{
196+
"operation": "modal",
197+
"kernel_shape": "boxv",
198+
"kernel_size": 7.0
199+
},
200+
"petra_skull_erode":
201+
{
202+
"kernel_shape": "boxv",
203+
"kernel_size": 7.0
204+
}
205+
}
206+
},
207+
208+
"skull_ct_pipe":
209+
{
210+
"skullmask_ct_pipe":
211+
{
212+
"ct_skull_auto_mask":
213+
{
214+
"kmeans": true,
215+
"sample_bins": 30,
216+
"distance": 10,
217+
"operation": "lower",
218+
"index": 2
219+
},
220+
"ct_skull_dilate":
221+
{
222+
"operation" : "modal",
223+
"kernel_shape" : "boxv",
224+
"kernel_size" : 3.0
225+
},
226+
"ct_skull_erode":
227+
{
228+
"kernel_shape" : "boxv",
229+
"kernel_size" : 3.0
230+
},
231+
"ct_skull_fov":
232+
{
233+
"brainsize" : 45
234+
}
235+
}
236+
}
237+
}

0 commit comments

Comments
 (0)