Skip to content

Commit c54f523

Browse files
committed
allow for default list of segs for a template
1 parent 9aa06df commit c54f523

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

spimquant/config/snakebids.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,11 @@ templates:
275275
YoPro: https://zenodo.org/records/18749025/files/tpl-ABAv3_level-5_stain-YoPro_SPIM.nii.gz
276276
Iba1: https://zenodo.org/records/18749025/files/tpl-ABAv3_level-5_stain-Iba1_SPIM.nii.gz
277277
Abeta: https://zenodo.org/records/18749025/files/tpl-ABAv3_level-5_stain-Abeta_SPIM.nii.gz
278+
default_segs:
279+
- all
280+
- coarse
281+
- mid
282+
- fine
278283
atlases:
279284
all:
280285
dseg: https://zenodo.org/records/18906782/files/tpl-ABAv3_seg-all_dseg.nii.gz

spimquant/workflow/Snakefile

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,13 @@ stains = get_stains_all_subjects()
5555

5656
stain_for_reg = None
5757

58+
template = config["templates"][config["template"]]
59+
60+
5861
# first, check if there are any SPIM templates defined
5962
# for the stains we have
6063
use_spim_template = False
61-
spim_templates = config["templates"][config["template"]].get("spim_templates", None)
64+
spim_templates = template.get("spim_templates", None)
6265

6366
if spim_templates is not None:
6467
for stain in spim_templates.keys():
@@ -103,36 +106,35 @@ else:
103106

104107

105108
# atlas segmentations to use
106-
all_atlas_segs = config["templates"][config["template"]]["atlases"].keys()
107109

108110
if config["atlas_segs"] is None:
109-
atlas_segs = all_atlas_segs
111+
atlas_segs = template.get("default_segs", template["atlases"].keys())
110112
else:
111113
atlas_segs = []
112114
for seg in config["atlas_segs"]:
113-
if seg not in all_atlas_segs:
115+
if seg not in template["atlases"]:
114116
raise ValueError(
115-
f"Chosen segmentation {seg} was not found in the template {config['template']}"
117+
f"Chosen segmentation {seg} was not found in the template {template}"
116118
)
117119
else:
118120
atlas_segs.append(seg)
119121

120122
# atlas segmentations to use for patches (defaults to roi22)
121123
patch_atlas_segs = []
122124
for seg in config["patch_atlas_segs"]:
123-
if seg not in all_atlas_segs:
125+
if seg not in template["atlases"]:
124126
raise ValueError(
125-
f"Chosen patch segmentation {seg} was not found in the template {config['template']}"
127+
f"Chosen patch segmentation {seg} was not found in the template {template}"
126128
)
127129
else:
128130
patch_atlas_segs.append(seg)
129131

130132
# atlas segmentations to use for Imaris crops (defaults to roi22)
131133
crop_atlas_segs = []
132134
for seg in config["crop_atlas_segs"]:
133-
if seg not in all_atlas_segs:
135+
if seg not in template["atlases"]:
134136
raise ValueError(
135-
f"Chosen crop segmentation {seg} was not found in the template {config['template']}"
137+
f"Chosen crop segmentation {seg} was not found in the template {template}"
136138
)
137139
else:
138140
crop_atlas_segs.append(seg)

0 commit comments

Comments
 (0)