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

bugfix: subfield+tissue for new atlases, and tsv files #208

Merged
merged 2 commits into from
Aug 14, 2022
Merged
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
22 changes: 22 additions & 0 deletions hippunfold/config/snakebids.yml
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,28 @@ atlas_files:
label_list: resources/freesurfer/freesurfer_labellist.txt


#values to use for re-mapping tissue labels when combining with subfields.
# set the SRLM and Cyst labels to always be higher than any label in the atlas (so they override)
tissue_atlas_mapping:
tissue:
dg: 8
srlm: 2
cyst: 7
bigbrain:
dg: 6
srlm: 7
cyst: 8
magdeburg:
dg: 3
srlm: 9
cyst: 10
freesurfer:
dg: 209
srlm: 227
cyst: 228



rigid_reg_template: False
no_reg_template: False

Expand Down
9 changes: 9 additions & 0 deletions hippunfold/resources/desc-subfields_atlas-bigbrain_dseg.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
index name abbreviation
1 subiculum Sub
2 CA1 CA1
3 CA2 CA2
4 CA3 CA3
5 CA4 CA4
6 dentate gyrus DG
7 SRLM or 'dark band' SRLM
8 cysts Cyst
10 changes: 10 additions & 0 deletions hippunfold/resources/desc-subfields_atlas-freesurfer_dseg.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
index name abbreviation
203 parasubiculum ParaSub
204 presubiculum PreSub
205 subiculum Sub
206 CA1 CA1
208 CA3 CA3
209 CA4 and dentate gyrus CA4_DG
226 tail Tail
227 SRLM or 'dark band' SRLM
228 cysts Cyst
9 changes: 9 additions & 0 deletions hippunfold/resources/desc-subfields_atlas-magdeburg_dseg.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
index name abbreviation
1 CA1 CA1
2 CA2 CA2
3 dentate gyrus DG
4 CA3 CA3
5 tail Tail
8 subiculum Sub
9 SRLM or 'dark band' SRLM
10 cysts Cyst
5 changes: 4 additions & 1 deletion hippunfold/workflow/rules/qc.smk
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ rule get_subfield_vols_subj:
allow_missing=True,
),
lookup_tsv=os.path.join(
workflow.basedir, "..", "resources", "desc-subfields_dseg.tsv"
workflow.basedir,
"..",
"resources",
"desc-subfields_atlas-{atlas}_dseg.tsv",
),
group:
"subj"
Expand Down
24 changes: 17 additions & 7 deletions hippunfold/workflow/rules/subfields.smk
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,25 @@ rule label_subfields_from_vol_coords_corobl:
"../scripts/label_subfields_from_vol_coords.py"


def get_tissue_atlas_remapping(wildcards):

mapping = config["tissue_atlas_mapping"]

remap = []

for label in mapping["tissue"].keys():
in_label = mapping["tissue"][label]
out_label = mapping[wildcards.atlas][label]

remap.append(f"-threshold {in_label} {in_label} {out_label} 0 -popas {label}")

return " ".join(remap)


rule combine_tissue_subfield_labels_corobl:
"""Combine subfield labels with the DG, SRLM and Cyst tissue labels

add srlm, cyst, dg from postproc labels to subfields
input dg label 8, output 6
input srlm label 2, output 7
input cyst label 7, output 8

first remap tissue labels to get three sep labels
then, we just need to add those in, using max(old,new) to override old with new in case of conflict
Expand All @@ -76,9 +88,7 @@ rule combine_tissue_subfield_labels_corobl:
**config["subj_wildcards"]
),
params:
remap_dg="-threshold 8 8 6 0 -popas dg",
remap_srlm="-threshold 2 2 7 0 -popas srlm",
remap_cyst="-threshold 7 7 8 0 -popas cyst",
remap=get_tissue_atlas_remapping,
output:
combined=bids(
root=work,
Expand All @@ -95,7 +105,7 @@ rule combine_tissue_subfield_labels_corobl:
group:
"subj"
shell:
"c3d {input.tissue} -dup {params.remap_dg} -dup {params.remap_srlm} {params.remap_cyst} {input.subfields} -push dg -max -push srlm -max -push cyst -max -type uchar -o {output}"
"c3d {input.tissue} -dup -dup {params.remap} {input.subfields} -push dg -max -push srlm -max -push cyst -max -type uchar -o {output}"


rule resample_subfields_to_native:
Expand Down