Skip to content

Commit

Permalink
initial atempt, not yet wetrun tested
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan DeKraker committed Dec 17, 2024
1 parent f642963 commit 3c93675
Show file tree
Hide file tree
Showing 8 changed files with 284 additions and 412 deletions.
2 changes: 1 addition & 1 deletion hippunfold/workflow/rules/gifti.smk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# lookup tables for structure:
hemi_to_structure = {"L": "CORTEX_LEFT", "Lflip": "CORTEX_LEFT", "R": "CORTEX_RIGHT"}
hemi_to_structure = {"L": "CORTEX_LEFT", "R": "CORTEX_RIGHT"}
surf_to_secondary_type = {
"midthickness": "MIDTHICKNESS",
"inner": "PIAL",
Expand Down
45 changes: 2 additions & 43 deletions hippunfold/workflow/rules/nnunet.smk
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ rule run_inference:
suffix="dseg.nii.gz",
desc="nnunet",
space="corobl",
hemi="{hemi,Lflip|R}"
hemi="{hemi}"
),
log:
bids(
root="logs",
**inputs.subj_wildcards,
suffix="nnunet.txt",
space="corobl",
hemi="{hemi,Lflip|R}"
hemi="{hemi}"
),
shadow:
"minimal"
Expand Down Expand Up @@ -171,47 +171,6 @@ rule run_inference:
"cp {params.temp_lbl} {output.nnunet_seg}"


rule unflip_nnunet_nii:
"""Unflip the Lflip nnunet seg"""
input:
nnunet_seg=bids(
root=work,
datatype="anat",
**inputs.subj_wildcards,
suffix="dseg.nii.gz",
desc="nnunet",
space="corobl",
hemi="{hemi}flip"
),
unflip_ref=(
bids(
root=work,
datatype="anat",
**inputs.subj_wildcards,
suffix="{modality}.nii.gz".format(modality=config["modality"]),
space="corobl",
desc="preproc",
hemi="{hemi}",
),
),
output:
nnunet_seg=bids(
root=work,
datatype="anat",
**inputs.subj_wildcards,
suffix="dseg.nii.gz",
desc="nnunet",
space="corobl",
hemi="{hemi,L}"
),
container:
config["singularity"]["autotop"]
group:
"subj"
shell:
"c3d {input.nnunet_seg} -flip x -popas FLIPPED "
" {input.unflip_ref} -push FLIPPED -copy-transform -o {output.nnunet_seg} "


def get_f3d_ref(wildcards, input):
if config["modality"] == "T2w":
Expand Down
26 changes: 0 additions & 26 deletions hippunfold/workflow/rules/preproc_hippb500.smk
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,6 @@ rule resample_hippdwi_to_template:
" -trim 0vox -o {output}"


rule lr_flip_b500:
input:
nii=bids(
root=work,
datatype="dwi",
**inputs.subj_wildcards,
suffix="b500.nii.gz",
space="corobl",
hemi="{hemi}"
),
output:
nii=bids(
root=work,
datatype="dwi",
**inputs.subj_wildcards,
suffix="b500.nii.gz",
space="corobl",
hemi="{hemi,L}flip"
),
container:
config["singularity"]["autotop"]
group:
"subj"
shell:
"c3d {input} -flip x -o {output}"


rule cp_b500_to_anat_dir:
input:
Expand Down
27 changes: 0 additions & 27 deletions hippunfold/workflow/rules/preproc_manualseg.smk
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,3 @@ rule import_manualseg_to_corobl:
shell:
"ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS={threads} "
"antsApplyTransforms -d 3 --interpolation MultiLabel -i {input.in_img} -o {output.nii} -r {params.ref} -t {params.std_to_cor}"


rule lr_flip_seg:
input:
nii=bids(
root=work,
datatype="anat",
**inputs.subj_wildcards,
suffix="dseg.nii.gz",
space="corobl",
hemi="{hemi}"
),
output:
nii=bids(
root=work,
datatype="anat",
**inputs.subj_wildcards,
suffix="dseg.nii.gz",
space="corobl",
hemi="{hemi,L}flip"
),
container:
config["singularity"]["autotop"]
group:
"subj"
shell:
"c3d {input} -flip x -o {output}"
28 changes: 0 additions & 28 deletions hippunfold/workflow/rules/preproc_t1.smk
Original file line number Diff line number Diff line change
Expand Up @@ -103,31 +103,3 @@ rule warp_t1_to_corobl_crop:
"ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS={threads} "
"antsApplyTransforms -d 3 --interpolation Linear -i {input.t1} -o {output.t1} -r {params.ref} -t {input.xfm}"


rule lr_flip_t1:
input:
nii=bids(
root=work,
datatype="anat",
**inputs.subj_wildcards,
suffix="T1w.nii.gz",
space="corobl",
desc="{desc}",
hemi="{hemi}"
),
output:
nii=bids(
root=work,
datatype="anat",
**inputs.subj_wildcards,
suffix="T1w.nii.gz",
space="corobl",
desc="{desc}",
hemi="{hemi,L}flip"
),
container:
config["singularity"]["autotop"]
group:
"subj"
shell:
"c3d {input} -flip x -o {output}"
28 changes: 0 additions & 28 deletions hippunfold/workflow/rules/preproc_t2.smk
Original file line number Diff line number Diff line change
Expand Up @@ -413,31 +413,3 @@ rule warp_t2_to_corobl_crop:
"ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS={threads} "
"antsApplyTransforms -d 3 --interpolation Linear -i {input.nii} -o {output.nii} -r {params.ref} -t {input.xfm}"


rule lr_flip_t2:
input:
nii=bids(
root=work,
datatype="anat",
**inputs.subj_wildcards,
suffix="T2w.nii.gz",
space="corobl",
desc="{desc}",
hemi="{hemi}"
),
output:
nii=bids(
root=work,
datatype="anat",
**inputs.subj_wildcards,
suffix="T2w.nii.gz",
space="corobl",
desc="{desc}",
hemi="{hemi,L}flip"
),
container:
config["singularity"]["autotop"]
group:
"subj"
shell:
"c3d {input} -flip x -o {output}"
Loading

0 comments on commit 3c93675

Please sign in to comment.