Skip to content

Commit

Permalink
removed segT*w
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan DeKraker committed Dec 12, 2024
1 parent f1e90ab commit a95ee40
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 143 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/python-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,13 @@ jobs:
run: |
poetry run hippunfold test_data/bids_singleT2w_longitudinal test_out participant -np --modality T2w
- name: Test manual seg T2w bids
run: |
poetry run hippunfold test_data/bids_segT2w test_out participant -np --modality segT2w
- name: Test cropseg bids, with path override
run: |
poetry run hippunfold . test_out participant -np --modality cropseg --path_cropseg test_data/data_cropseg/sub-{subject}_hemi-{hemi}_dseg.nii.gz
poetry run hippunfold test_data/data_cropseg test_out participant -np --modality cropseg --path_cropseg test_data/data_cropseg/sub-{subject}_hemi-{hemi}_dseg.nii.gz
- name: Test cropseg bids, with path override, left hemi
- name: Test cropseg bids, one hemisphere hemi
run: |
poetry run hippunfold . test_out participant -np --modality cropseg --path_cropseg test_data/data_cropseg_1hemi/sub-{subject}_hemi-{hemi}_dseg.nii.gz --hemi L
poetry run hippunfold test_data/data_cropseg_1hemi test_out participant -np --modality cropseg --hemi L
- name: Test T2w with T1w template registration
run: |
Expand Down
16 changes: 1 addition & 15 deletions hippunfold/config/snakebids.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,6 @@ pybids_inputs:
- acquisition
- run

seg:
filters:
suffix: 'dseg'
extension: '.nii.gz'
datatype: 'anat'
invalid_filters: 'allow'
wildcards:
- subject
- session
- acquisition
- run

cropseg:
filters:
suffix: 'dseg'
Expand All @@ -100,14 +88,12 @@ pybids_inputs:
parse_args:

--modality:
help: 'Type of image to run hippunfold on. Modality prefixed with seg will import an existing (manual) hippocampal tissue segmentation from that space, instead of running neural network (default: %(default)s)'
help: 'Type of image to run hippunfold on. For manual segmentations, use cropseg and be sure to match the label scheme applied in the look up table (lut) online. For best performance, please also make sure the input is approximately aligned to the template space, with hemi-L|R in the name. (default: %(default)s)'
required: True
choices:
- T1w
- T2w
- hippb500
- segT1w
- segT2w
- cropseg


Expand Down
9 changes: 9 additions & 0 deletions hippunfold/resources/label_lut/manual_dseg.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
index name abbreviation
1 hippocampal grey matter GM
2 SRLM or 'dark band' SRLM
3 neocortex (entorhinal or parahippocampal) MTLC
4 pial surface Pial
5 hippocampal-amygdalar transition area HATA
6 indusium griseum IndGris
7 cysts Cyst
8 dentate gyrus DG
9 changes: 9 additions & 0 deletions hippunfold/resources/label_lut/subfields_dseg .tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#No. Label R G B A
1 subiculum 41 43 252 0
2 CA1 102 209 216 0
3 CA2 0 179 60 0
4 CA3 255 182 0 0
5 CA4 255 43 23 0
6 dentate_gyrus 245 236 0 0
7 SRLM 119 54 155 0
8 cysts 255 255 255 0
13 changes: 1 addition & 12 deletions hippunfold/workflow/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@ if config["skip_inject_template_labels"]: # TODO do we need this?
config["autotop_labels"] = ["hipp"]


# add seg (if chosen) and the modality to the inputs
if config["modality"][:3] == "seg": # if modality is segT2w, then add seg
limit_to_list.add("seg")
limit_to_list.add(config["modality"][3:])
else:
limit_to_list.add(config["modality"])

# if atlas doesn't contain alignment features
if not config["atlas"] == ["multihist7"]:
config["no_unfolded_reg"] = True
Expand Down Expand Up @@ -118,11 +111,7 @@ if "T1w" in limit_to_list:


# include rules only as they are needed..
if config["modality"] == "segT1w" or config["modality"] == "segT2w":

include: "rules/preproc_seg.smk"

elif config["modality"] == "cropseg":
if config["modality"] == "cropseg":

include: "rules/preproc_cropseg.smk"

Expand Down
18 changes: 13 additions & 5 deletions hippunfold/workflow/rules/preproc_cropseg.smk
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@

rule import_cropseg:
rule import_cropseg_to_corobl:
input:
in_img=partial(get_single_bids_input, component="cropseg"),
template_dir=Path(download_dir) / "template" / config["template"],
params:
std_to_cor=lambda wildcards: config["template_files"][config["template"]][
"xfm_corobl"
].format(**wildcards),
ref=lambda wildcards, input: Path(input.template_dir)
/ config["template_files"][config["template"]]["crop_ref"].format(**wildcards),
output:
nii=bids(
root=work,
datatype="anat",
**inputs.subj_wildcards,
suffix="dseg.nii.gz",
space="corobl",
hemi="{hemi,L|R}"
hemi="{hemi,L|R}",
),
group:
"subj"
container:
config["singularity"]["autotop"]
group:
"subj"
shell:
"cp {input} {output}"
"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:
Expand Down
79 changes: 0 additions & 79 deletions hippunfold/workflow/rules/preproc_seg.smk

This file was deleted.

25 changes: 0 additions & 25 deletions hippunfold/workflow/rules/shape_inject.smk
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,6 @@ def get_input_for_shape_inject(wildcards):
space="corobl",
hemi="{hemi}",
).format(**wildcards)
elif get_modality_key(config["modality"]) == "seg":
modality_suffix = get_modality_suffix(config["modality"])
seg = (
bids(
root=work,
datatype="anat",
**inputs.subj_wildcards,
suffix="dseg.nii.gz",
space="corobl",
hemi="{hemi}",
from_="{modality_suffix}",
).format(**wildcards, modality_suffix=modality_suffix),
)
else:
seg = bids(
root=work,
Expand All @@ -77,18 +64,6 @@ def get_input_splitseg_for_shape_inject(wildcards):
space="corobl",
hemi="{hemi}",
).format(**wildcards)

elif get_modality_key(config["modality"]) == "seg":
modality_suffix = get_modality_suffix(config["modality"])
seg = bids(
root=work,
datatype="anat",
**inputs.subj_wildcards,
suffix="dsegsplit",
space="corobl",
hemi="{hemi}",
from_="{modality_suffix}",
).format(**wildcards, modality_suffix=modality_suffix)
else:
seg = bids(
root=work,
Expand Down

0 comments on commit a95ee40

Please sign in to comment.