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

Test with sheep #258

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
197 changes: 127 additions & 70 deletions macapype/pipelines/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,100 +654,157 @@ def create_short_preparation_pipe(params, params_template={},

# resample T1 to higher dimension
if "resample_T1_pad" in params.keys():
if "crop_T1" in params.keys():
resample_T1_pad = NodeParams(
niu.Function(
input_names=["img_file", "pad_val", "const"],
output_names=["padded_img_file"],
function=pad_zero_mri),
params=parse_key(params, "resample_T1_pad"),
name="resample_T1_pad")

resample_T1_pad = pe.Node(
regutils.RegResample(),
name="resample_T1_pad")
resample_T2_pad = NodeParams(
niu.Function(
input_names=["img_file", "pad_val", "const"],
output_names=["padded_img_file"],
function=pad_zero_mri),
params=parse_key(params, "resample_T2_pad"),
name="resample_T2_pad")

resample_T2_pad = pe.Node(
regutils.RegResample(),
name="resample_T2_pad")
# T1 to pad
if "avg_reorient_pipe" in params.keys():
data_preparation_pipe.connect(
av_T1, 'outputnode.std_img',
resample_T1_pad, "img_file")

# T1 to pad
if "avg_reorient_pipe" in params.keys():
else:
data_preparation_pipe.connect(
av_T1, 'avg_img',
resample_T1_pad, "img_file")

data_preparation_pipe.connect(
av_T1, 'outputnode.std_img',
resample_T1_pad, "flo_file")
# T2 to pad
if "avg_reorient_pipe" in params.keys():
data_preparation_pipe.connect(
av_T2, 'outputnode.std_img',
resample_T2_pad, "img_file")

else:
data_preparation_pipe.connect(
av_T1, 'avg_img',
resample_T1_pad, "flo_file")
else:
data_preparation_pipe.connect(
av_T2, 'avg_img',
resample_T2_pad, "img_file")

# T2 to pad
if 'aladin_T2_on_T1' in params.keys():
data_preparation_pipe.connect(
align_T2_on_T1, "res_file",
resample_T2_pad, "flo_file")
# outputnode
if "use_T2" in params.keys():
data_preparation_pipe.connect(
resample_T1_pad, 'padded_img_file',
outputnode, 'stereo_padded_T2')

else:
data_preparation_pipe.connect(
align_T2_on_T1, "out_file",
resample_T2_pad, "flo_file")
data_preparation_pipe.connect(
resample_T2_pad, 'padded_img_file',
outputnode, 'stereo_padded_T1')

if "padded_template_head" in params_template.keys():
resample_T1_pad.inputs.ref_file = \
params_template["padded_template_head"]
else:
data_preparation_pipe.connect(
resample_T1_pad, 'padded_img_file',
outputnode, 'stereo_padded_T1')

resample_T2_pad.inputs.ref_file = \
params_template["padded_template_head"]
data_preparation_pipe.connect(
resample_T2_pad, 'padded_img_file',
outputnode, 'stereo_padded_T2')

elif "template_head" in params_template.keys():
# padding versio of the template
pad_template = NodeParams(
niu.Function(
input_names=["img_file", "pad_val", "const"],
output_names=["padded_img_file"],
function=pad_zero_mri),
params=parse_key(params, "resample_T1_pad"),
name="pad_template")
elif "crop_aladin_pipe" in params.keys():

pad_template.inputs.img_file = params_template["template_head"]
resample_T1_pad = pe.Node(
regutils.RegResample(),
name="resample_T1_pad")

# resample_T1_pad
data_preparation_pipe.connect(
pad_template, 'padded_img_file',
resample_T1_pad, "ref_file")
resample_T2_pad = pe.Node(
regutils.RegResample(),
name="resample_T2_pad")

# resample_T2_pad
data_preparation_pipe.connect(
pad_template, 'padded_img_file',
resample_T2_pad, "ref_file")
# T1 to pad
if "avg_reorient_pipe" in params.keys():
data_preparation_pipe.connect(
av_T1, 'outputnode.std_img',
resample_T1_pad, "flo_file")

else:
print("Error, template_head or padded_template_head should be \
defined in template")
exit(-1)
else:
data_preparation_pipe.connect(
av_T1, 'avg_img',
resample_T1_pad, "flo_file")

data_preparation_pipe.connect(
crop_aladin_pipe, 'outputnode.native_to_stereo_trans',
resample_T1_pad, "trans_file")
# T2 to pad
if 'aladin_T2_on_T1' in params.keys():
data_preparation_pipe.connect(
align_T2_on_T1, "res_file",
resample_T2_pad, "flo_file")

data_preparation_pipe.connect(
crop_aladin_pipe, 'outputnode.native_to_stereo_trans',
resample_T2_pad, "trans_file")
else:
data_preparation_pipe.connect(
align_T2_on_T1, "out_file",
resample_T2_pad, "flo_file")

# outputnode
if "use_T2" in params.keys():
if "padded_template_head" in params_template.keys():
resample_T1_pad.inputs.ref_file = \
params_template["padded_template_head"]

data_preparation_pipe.connect(
resample_T1_pad, 'out_file',
outputnode, 'stereo_padded_T2')
resample_T2_pad.inputs.ref_file = \
params_template["padded_template_head"]

data_preparation_pipe.connect(
resample_T2_pad, 'out_file',
outputnode, 'stereo_padded_T1')
elif "template_head" in params_template.keys():
# padding versio of the template
pad_template = NodeParams(
niu.Function(
input_names=["img_file", "pad_val", "const"],
output_names=["padded_img_file"],
function=pad_zero_mri),
params=parse_key(params, "resample_T1_pad"),
name="pad_template")

else:
pad_template.inputs.img_file = params_template["template_head"]

# resample_T1_pad
data_preparation_pipe.connect(
pad_template, 'padded_img_file',
resample_T1_pad, "ref_file")

# resample_T2_pad
data_preparation_pipe.connect(
pad_template, 'padded_img_file',
resample_T2_pad, "ref_file")

else:
print("Error, template_head or padded_template_head should be \
defined in template")
exit(-1)

data_preparation_pipe.connect(
resample_T1_pad, 'out_file',
outputnode, 'stereo_padded_T1')
crop_aladin_pipe, 'outputnode.native_to_stereo_trans',
resample_T1_pad, "trans_file")

data_preparation_pipe.connect(
resample_T2_pad, 'out_file',
outputnode, 'stereo_padded_T2')
crop_aladin_pipe, 'outputnode.native_to_stereo_trans',
resample_T2_pad, "trans_file")

# outputnode
if "use_T2" in params.keys():
data_preparation_pipe.connect(
resample_T1_pad, 'out_file',
outputnode, 'stereo_padded_T2')

data_preparation_pipe.connect(
resample_T2_pad, 'out_file',
outputnode, 'stereo_padded_T1')

else:

data_preparation_pipe.connect(
resample_T1_pad, 'out_file',
outputnode, 'stereo_padded_T1')

data_preparation_pipe.connect(
resample_T2_pad, 'out_file',
outputnode, 'stereo_padded_T2')

return data_preparation_pipe

Expand Down
20 changes: 10 additions & 10 deletions macapype/utils/subs.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{
"T1w_roi_noise_corrected_debiased_BET_FLIRT-to_inia19-t1-brain": "space-inia19_desc-brain_T1w",
"T1w_roi_corrected_debiased_BET_FLIRT-to_Haiko89_Asymmetric.Template_n89_flirt_thresh_fillh_indexed_mask":"space-orig_desc-brain_dseg",
"T1w_roi_corrected_debiased_BET_FLIRT-to_Haiko89_Asymmetric.Template_n89_flirt_thresh_fillh_indexed_mask":"space-stereo_desc-brain_dseg",

"BET_mask_": "",

"T1w_roi_restore_debiased_brain_SegmentationPosteriors02_thresh_5tt": "space-orig_desc-5tt_dseg",
"T1w_roi_corrected_restore_debiased_brain_SegmentationPosteriors02_thresh_5tt": "space-orig_desc-5tt_dseg",
"T1w_roi_restore_debiased_brain_SegmentationPosteriors02_thresh_5tt": "space-stereo_desc-5tt_dseg",
"T1w_roi_corrected_restore_debiased_brain_SegmentationPosteriors02_thresh_5tt": "space-stereo_desc-5tt_dseg",
"T1w_flirt_res_restore_debiased_brain_Segmentation_1_merged_bin_5tt.nii.gz": "space-native_desc-5tt_dseg",

"T1w_roi_restore_brain_bin_bin": "space-orig_desc-brain_mask",
"T1w_roi_corrected_restore_brain_bin_bin": "space-orig_desc-brain_mask",
"T1w_roi_restore_brain_bin_bin": "space-stereo_desc-brain_mask",
"T1w_roi_corrected_restore_brain_bin_bin": "space-stereo_desc-brain_mask",

"T1w_roi_restore_debiased_brain.nii.gz": "space-orig_desc-preproc_desc-brain_T1w.nii.gz",
"T1w_roi_corrected_restore_debiased_brain.nii.gz": "space-orig_desc-preproc_desc-brain_T1w.nii.gz",
"T1w_roi_restore_debiased_brain.nii.gz": "space-stereo_desc-preproc_desc-brain_T1w.nii.gz",
"T1w_roi_corrected_restore_debiased_brain.nii.gz": "space-stereo_desc-preproc_desc-brain_T1w.nii.gz",

"T1w_roi_restore.nii.gz": "space-orig_desc-preproc_T1w.nii.gz",
"T1w_roi_corrected_restore.nii.gz": "space-orig_desc-preproc_T1w.nii.gz",
"T1w_roi_restore.nii.gz": "space-stereo_desc-preproc_T1w.nii.gz",
"T1w_roi_corrected_restore.nii.gz": "space-stereo_desc-preproc_T1w.nii.gz",

"Segmentation_allineate": "space-template_desc-brain_dseg",
"indexed_mask": "space-orig_desc-brain_dseg",
"FLAIR_flirt_flirt": "space-inia19_FLAIR",

"T1w_":"",
"T2w_":"",
"PDw_":"",
"_roi":"",
"_ROI":"",
"_indexed_mask": "",
"_restore_debiased_brain":"",
"_restore_debiased":"",
"_restore_brain": "",
Expand Down
56 changes: 56 additions & 0 deletions workflows/params_segment_dog_ants.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"general":
{
},
"short_preparation_pipe":
{
"crop_aladin_pipe":
{
"reg_T1_on_template":
{
}
}
},
"fast":
{
"args": "-l 3"
},
"extract_pipe":
{
"atlas_brex":
{
"f": 0.62,
"reg": 1,
"msk": "b,0.5,0,0",
"wrp": "5,5,5",
"dil": 4,
"vox": 1
}
},
"brain_segment_pipe":
{
"reg":
{
"n": 2,
"m": "ref",
"dof": 12
},
"segment_atropos_pipe":
{
"use_priors":0.5,
"Atropos":
{
"dimension": 3
},
"tissue_dict":
{
"gm": 2,
"wm": 3,
"csf": 1
}
},
"export_5tt_pipe":
{
}
}
}
60 changes: 60 additions & 0 deletions workflows/params_segment_dog_spm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"general":
{
},
"short_preparation_pipe":
{
"aladin_T2_on_T1":{},
"crop_aladin_pipe":
{
"reg_T1_on_template":
{
}
}
},
"debias":
{
"s": 4
},
"reg":
{
"n": 2,
"m": "ref",
"dof": 12
},
"old_segment_pipe":
{
"segment":
{
"gm_output_type": [false, false, true],
"wm_output_type": [false, false, true],
"csf_output_type": [false, false, true]
},
"threshold_gm":
{
"thresh": 0.5
},
"threshold_wm":
{
"thresh": 0.5
},
"threshold_csf":
{
"thresh": 0.5
},
"export_5tt_pipe": {}
},
"mask_from_seg_pipe":
{
"dilate_mask":
{
"kernel_shape": "sphere",
"kernel_size": 2
},
"erode_mask":
{
"kernel_shape": "sphere",
"kernel_size": 2
}
}
}
Loading
Loading