Skip to content
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
3 changes: 1 addition & 2 deletions spimquant/config/snakebids.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ parse_args:
help: "Method to use for microscopy segmentation (e.g. plaques, protein deposits, cells) applied to 'stains_for_seg' channels, and used to calculate field fractions. "
default:
- otsu+k3i2
- th900
nargs: '+'

--seg_hist_range:
Expand Down Expand Up @@ -189,7 +188,7 @@ parse_args:
choices:
- threads
- distributed
default: threads
default: distributed

--sloppy:
help: "Use low-quality parameters for speed (USE FOR TESTING ONLY)"
Expand Down
15 changes: 14 additions & 1 deletion spimquant/workflow/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,20 @@ rule all_vessels:
),


# inputs["spim"].expand(
# bids(
# root=root,
# datatype="micr",
# stain="{stain}",
# desc="{desc}",
# suffix="mask.ozx",
# **inputs["spim"].wildcards,
# ),
# desc=config["vessel_seg_method"],
# stain=stains_for_vessels,
# )


rule all_segment:
input:
inputs["spim"].expand(
Expand Down Expand Up @@ -676,7 +690,6 @@ rule all_participant:
rules.all_register.input,
rules.all_vessels.input if do_vessels else [],
rules.all_segment.input if do_seg else [],
rules.all_spim_patches.input if do_seg else [],
rules.all_mri_reg.input if config["register_to_mri"] else [],
rules.all_segment_coloc.input if do_coloc else [],
rules.all_segment_maskcoloc.input if do_maskcoloc else [],
Expand Down
30 changes: 11 additions & 19 deletions spimquant/workflow/rules/groupstats.smk
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ rule perform_group_stats:
),
threads: 1
resources:
mem_mb=16000,
mem_mb=1500,
runtime=10,
script:
"../scripts/perform_group_stats.py"
Expand Down Expand Up @@ -89,7 +89,7 @@ rule create_stats_heatmap:
threads: 1
resources:
mem_mb=8000,
runtime=5,
runtime=15,
script:
"../scripts/create_stats_heatmap.py"

Expand Down Expand Up @@ -131,7 +131,7 @@ rule map_groupstats_to_template_nii:
threads: 8
resources:
mem_mb=16000,
runtime=5,
runtime=15,
script:
"../scripts/map_tsv_dseg_to_nii.py"

Expand Down Expand Up @@ -167,7 +167,7 @@ rule concat_subj_parquet:
),
threads: 1
resources:
mem_mb=16000,
mem_mb=1500,
runtime=10,
script:
"../scripts/concat_subj_parquet.py"
Expand Down Expand Up @@ -196,12 +196,10 @@ rule group_counts_per_voxel:
desc="{desc}",
suffix="{stain}+count.nii.gz",
),
group:
"subj"
threads: 16
resources:
mem_mb=15000,
runtime=10,
mem_mb=200000,
runtime=30,
script:
"../scripts/counts_per_voxel_template.py"

Expand Down Expand Up @@ -229,8 +227,6 @@ rule group_coloc_counts_per_voxel:
desc="{desc}",
suffix="coloccount.nii.gz",
),
group:
"subj"
threads: 16
resources:
mem_mb=15000,
Expand Down Expand Up @@ -275,7 +271,7 @@ rule concat_subj_parquet_contrast:
),
threads: 1
resources:
mem_mb=16000,
mem_mb=1500,
runtime=10,
script:
"../scripts/concat_subj_parquet_contrast.py"
Expand Down Expand Up @@ -306,12 +302,10 @@ rule group_counts_per_voxel_contrast:
contrast="{contrast_column}+{contrast_value}",
suffix="{stain}+count.nii.gz",
),
group:
"subj"
threads: 16
resources:
mem_mb=15000,
runtime=10,
mem_mb=200000,
runtime=30,
script:
"../scripts/counts_per_voxel_template.py"

Expand Down Expand Up @@ -341,8 +335,6 @@ rule group_coloc_counts_per_voxel_contrast:
contrast="{contrast_column}+{contrast_value}",
suffix="coloccount.nii.gz",
),
group:
"subj"
threads: 16
resources:
mem_mb=15000,
Expand Down Expand Up @@ -395,7 +387,7 @@ rule concat_subj_segstats_contrast:
),
threads: 1
resources:
mem_mb=16000,
mem_mb=1500,
runtime=10,
script:
"../scripts/concat_subj_segstats_contrast.py"
Expand Down Expand Up @@ -441,6 +433,6 @@ rule map_groupavg_segstats_to_template_nii:
threads: 8
resources:
mem_mb=16000,
runtime=5,
runtime=15,
script:
"../scripts/map_tsv_dseg_to_nii.py"
32 changes: 15 additions & 17 deletions spimquant/workflow/rules/import.smk
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ rule get_downsampled_nii:
suffix="SPIM.nii.gz",
**inputs["spim"].wildcards,
),
group:
"subj"
threads: 32
resources:
mem_mb=16000,
runtime=5,
runtime=15,
script:
"../scripts/ome_zarr_to_nii.py"

Expand Down Expand Up @@ -77,8 +75,8 @@ rule import_template_anat:
anat=bids_tpl(root=root, template="{template}", suffix="anat.nii.gz"),
threads: 1
resources:
mem_mb=16000,
runtime=5,
mem_mb=1500,
runtime=15,
log:
bids_tpl(
root="logs",
Expand Down Expand Up @@ -109,8 +107,8 @@ rule import_template_spim:
),
threads: 1
resources:
mem_mb=16000,
runtime=5,
mem_mb=1500,
runtime=15,
log:
bids_tpl(
root="logs",
Expand All @@ -133,8 +131,8 @@ rule import_mask:
),
threads: 1
resources:
mem_mb=16000,
runtime=5,
mem_mb=1500,
runtime=15,
log:
bids_tpl(
root="logs",
Expand All @@ -153,8 +151,8 @@ rule generic_lut_bids_to_itksnap:
lut="{prefix}_dseg.itksnap.txt",
threads: 1
resources:
mem_mb=16000,
runtime=5,
mem_mb=1500,
runtime=15,
script:
"../scripts/lut_bids_to_itksnap.py"

Expand Down Expand Up @@ -182,8 +180,8 @@ rule import_dseg:
),
threads: 1
resources:
mem_mb=16000,
runtime=5,
mem_mb=1500,
runtime=15,
script:
"../scripts/copy_nii.py"

Expand All @@ -201,8 +199,8 @@ rule import_lut_tsv:
tsv=bids_tpl(root=root, template="{template}", seg="{seg}", suffix="dseg.tsv"),
threads: 1
resources:
mem_mb=16000,
runtime=5,
mem_mb=1500,
runtime=15,
shell:
"cp {input} {output}"

Expand All @@ -214,7 +212,7 @@ rule import_DSURQE_tsv:
tsv=bids_tpl(root=root, template="DSURQE", seg="all", suffix="dseg.tsv"),
threads: 1
resources:
mem_mb=16000,
runtime=5,
mem_mb=1500,
runtime=15,
script:
"../scripts/import_DSURQE_dseg_tsv.py"
56 changes: 21 additions & 35 deletions spimquant/workflow/rules/masking.smk
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ rule pre_atropos:
desc="preAtropos",
suffix="SPIM.nii.gz",
**inputs["spim"].wildcards,
)
),
),
mask=temp(
bids(
Expand All @@ -60,14 +60,12 @@ rule pre_atropos:
desc="preAtropos",
suffix="mask.nii",
**inputs["spim"].wildcards,
)
),
),
group:
"subj"
threads: 1
resources:
mem_mb=16000,
runtime=5,
mem_mb=3000,
runtime=15,
conda:
"../envs/c3d.yaml"
shell:
Expand Down Expand Up @@ -98,7 +96,7 @@ rule atropos_seg:
k="{k}",
suffix="dseg.nii",
**inputs["spim"].wildcards,
)
),
),
posteriors_dir=temp(
directory(
Expand All @@ -112,18 +110,16 @@ rule atropos_seg:
suffix="posteriors",
**inputs["spim"].wildcards,
)
)
),
),
group:
"subj"
conda:
"../envs/ants.yaml"
shadow:
"minimal"
threads: 1
threads: 16
resources:
mem_mb=8000,
runtime=15,
mem_mb=32000,
runtime=45,
shell:
"mkdir -p {output.posteriors_dir} && "
"ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS={threads} "
Expand Down Expand Up @@ -155,14 +151,12 @@ rule post_atropos:
k="{k}",
suffix="dseg.nii",
**inputs["spim"].wildcards,
)
),
),
group:
"subj"
threads: 1
resources:
mem_mb=16000,
runtime=5,
mem_mb=3000,
runtime=15,
conda:
"../envs/c3d.yaml"
shell:
Expand Down Expand Up @@ -199,7 +193,7 @@ rule init_affine_reg:
desc="initaffine",
suffix="xfm.txt",
**inputs["spim"].wildcards,
)
),
),
warped=temp(
bids(
Expand All @@ -209,10 +203,8 @@ rule init_affine_reg:
desc="initaffinewarped",
suffix="SPIM.nii.gz",
**inputs["spim"].wildcards,
)
),
),
group:
"subj"
log:
bids(
root="logs",
Expand All @@ -224,7 +216,7 @@ rule init_affine_reg:
threads: 32
resources:
mem_mb=16000,
runtime=5,
runtime=15,
shell:
"greedy -threads {threads} -d 3 -i {input.template} {input.subject} "
" -a -dof 12 -ia-image-centers -m NMI -o {output.xfm_ras} -n {params.iters} && "
Expand Down Expand Up @@ -254,14 +246,12 @@ rule affine_transform_template_mask_to_subject:
from_="{template}",
suffix="mask.nii.gz",
**inputs["spim"].wildcards,
)
),
),
group:
"subj"
threads: 32
resources:
mem_mb=16000,
runtime=5,
runtime=15,
shell:
" greedy -threads {threads} -d 3 -rf {input.ref} "
" -ri NN"
Expand Down Expand Up @@ -307,12 +297,10 @@ rule create_mask_from_gmm_and_prior:
suffix="mask.nii.gz",
**inputs["spim"].wildcards,
),
group:
"subj"
threads: 1
resources:
mem_mb=16000,
runtime=5,
mem_mb=4000,
runtime=15,
script:
"../scripts/create_mask_from_gmm_and_prior.py"

Expand Down Expand Up @@ -341,12 +329,10 @@ rule create_mask_from_gmm:
suffix="mask.nii.gz",
**inputs["spim"].wildcards,
),
group:
"subj"
threads: 1
resources:
mem_mb=16000,
runtime=5,
mem_mb=4000,
runtime=15,
conda:
"../envs/c3d.yaml"
shell:
Expand Down
Loading