Skip to content

Commit

Permalink
remove fiji from workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
akhanf committed Sep 28, 2024
1 parent 5928f7c commit 1ff3be8
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 321 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Takes TIF images (tiled or prestitched) and outputs a validated BIDS Microscopy
- Python >= 3.11
- Lightsheet data:
- Raw Ultramicroscope Blaze OME TIFF files (include `blaze` in the acquisition tag)
- can be 2D or 3D TIFF files
- Prestitched TIFF files (include `prestitched` in the acquisition tag)


Expand Down Expand Up @@ -63,10 +64,8 @@ or for snakemake<8.0, use:
snakemake -c all --use-singularity
```

Note: if you run the workflow on a system with large memory, you will need to set the heap size for the stitching and fusion rules. This can be done with e.g.: `--set-resources bigstitcher_spark_stitching:mem_mb=60000 bigstitcher_spark_fusion:mem_mb=100000`
Note: if you run the workflow on a system with large memory, you will need to set the heap size for the stitching and fusion rules. This can be done with e.g.: `--set-resources bigstitcher_stitching:mem_mb=60000 bigstitcher_fusion:mem_mb=100000`

7. If you want to run the workflow using a batch job submission server, please see the executor plugins here: https://snakemake.github.io/snakemake-plugin-catalog/


Alternate usage of this workflow (making use of conda) is described in the [Snakemake Workflow Catalog](https://snakemake.github.io/snakemake-workflow-catalog?repo=khanlab/SPIMprep).
<!--intro-end-->
8 changes: 3 additions & 5 deletions config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,10 @@ bigstitcher:
downsample_in_x: 4
downsample_in_y: 4
downsample_in_z: 1
method: "phase_corr" #unused
methods: #unused
methods: #unused, only for reference
phase_corr: "Phase Correlation"
optical_flow: "Lucas-Kanade"
filter_pairwise_shifts:
enabled: 1 #unused
min_r: 0.7
max_shift_total: 50
global_optimization:
Expand All @@ -64,7 +62,7 @@ bigstitcher:
block_size_factor_z: 32

ome_zarr:
desc: sparkstitchedflatcorr
desc: stitchedflatcorr
max_downsampling_layers: 5 # e.g. 4 levels: { 0: orig, 1: ds2, 2: ds4, 3: ds8, 4: ds16}
rechunk_size: #z, y, x
- 1
Expand Down Expand Up @@ -155,5 +153,5 @@ report:


containers:
spimprep: 'docker://khanlab/spimprep-deps:main'
spimprep: 'docker://khanlab/spimprep-deps:v0.1.0'

56 changes: 0 additions & 56 deletions workflow/macros/AutostitchMacro.ijm

This file was deleted.

47 changes: 0 additions & 47 deletions workflow/macros/FuseImageMacroZarr.ijm

This file was deleted.

168 changes: 4 additions & 164 deletions workflow/rules/bigstitcher.smk
Original file line number Diff line number Diff line change
Expand Up @@ -94,74 +94,7 @@ rule zarr_to_bdv:
"../scripts/zarr_to_n5_bdv.py"


rule bigstitcher:
input:
dataset_n5=rules.zarr_to_bdv.output.bdv_n5,
dataset_xml=rules.zarr_to_bdv.output.bdv_xml,
ijm=Path(workflow.basedir) / "macros" / "AutostitchMacro.ijm",
params:
fiji_launcher_cmd=get_fiji_launcher_cmd,
macro_args=get_macro_args_bigstitcher,
rm_old_xml=lambda wildcards, output: f"rm -f {output.dataset_xml}~?",
output:
launcher=temp(
bids(
root=work,
subject="{subject}",
datatype="micr",
sample="{sample}",
acq="{acq}",
desc="{desc}",
suffix="bigstitcherfiji.sh",
)
),
dataset_xml=temp(
bids(
root=work,
subject="{subject}",
datatype="micr",
sample="{sample}",
acq="{acq}",
desc="{desc}",
suffix="bigstitcherfiji.xml",
)
),
benchmark:
bids(
root="benchmarks",
datatype="bigstitcherfiji",
subject="{subject}",
sample="{sample}",
acq="{acq}",
desc="{desc}",
suffix="benchmark.tsv",
)
log:
bids(
root="logs",
datatype="bigstitcherfiji",
subject="{subject}",
sample="{sample}",
acq="{acq}",
desc="{desc}",
suffix="log.txt",
),
container:
config["containers"]["spimprep"]
resources:
runtime=30,
mem_mb=10000,
threads: config["cores_per_rule"]
group:
"preproc"
shell:
"cp {input.dataset_xml} {output.dataset_xml} && "
" {params.fiji_launcher_cmd} && "
" echo ' -macro {input.ijm} \"{params.macro_args}\"' >> {output.launcher} "
" && {output.launcher} |& tee {log} && {params.rm_old_xml}"


rule bigstitcher_spark_stitching:
rule bigstitcher_stitching:
input:
dataset_n5=rules.zarr_to_bdv.output.bdv_n5,
dataset_xml=rules.zarr_to_bdv.output.bdv_xml,
Expand Down Expand Up @@ -230,10 +163,10 @@ rule bigstitcher_spark_stitching:
"{params.rm_old_xml}"


rule bigstitcher_spark_solver:
rule bigstitcher_solver:
input:
dataset_n5=rules.zarr_to_bdv.output.bdv_n5,
dataset_xml=rules.bigstitcher_spark_stitching.output.dataset_xml,
dataset_xml=rules.bigstitcher_stitching.output.dataset_xml,
params:
downsampling="--downsampling={dsx},{dsy},{dsz}".format(
dsx=config["bigstitcher"]["calc_pairwise_shifts"]["downsample_in_x"],
Expand Down Expand Up @@ -295,7 +228,6 @@ rule bigstitcher_spark_solver:
"{params.rm_old_xml}"
#lambda 0.1 is default (can expose this if needed)


rule bigstitcher_fusion:
input:
dataset_n5=bids(
Expand All @@ -320,98 +252,6 @@ rule bigstitcher_fusion:
else "stitching"
),
),
ijm=Path(workflow.basedir) / "macros" / "FuseImageMacroZarr.ijm",
params:
fiji_launcher_cmd=get_fiji_launcher_cmd,
macro_args=get_macro_args_zarr_fusion,
output:
launcher=temp(
bids(
root=work,
subject="{subject}",
datatype="micr",
sample="{sample}",
acq="{acq}",
desc="stitched{desc}",
stain="{stain}",
suffix="fuseimagen5.sh",
)
),
zarr=temp(
directory(
bids(
root=work,
subject="{subject}",
datatype="micr",
sample="{sample}",
acq="{acq}",
desc="stitched{desc}",
stain="{stain}",
suffix="SPIM.zarr",
)
)
),
benchmark:
bids(
root="benchmarks",
datatype="fuse_dataset",
subject="{subject}",
sample="{sample}",
acq="{acq}",
desc="stitched{desc}",
stain="{stain}",
suffix="benchmark.tsv",
)
log:
bids(
root="logs",
datatype="fuse_dataset",
subject="{subject}",
sample="{sample}",
acq="{acq}",
desc="stitched{desc}",
stain="{stain}",
suffix="log.txt",
),
container:
config["containers"]["spimprep"]
resources:
runtime=30,
mem_mb=40000,
threads: config["cores_per_rule"]
group:
"preproc"
shell:
" {params.fiji_launcher_cmd} && "
" echo ' -macro {input.ijm} \"{params.macro_args}\"' >> {output.launcher} "
" && {output.launcher} |& tee {log}"


rule bigstitcher_spark_fusion:
input:
dataset_n5=bids(
root=work,
subject="{subject}",
datatype="micr",
sample="{sample}",
acq="{acq}",
desc="{desc}",
suffix="bdv.n5",
),
dataset_xml=bids(
root=work,
subject="{subject}",
datatype="micr",
sample="{sample}",
acq="{acq}",
desc="{desc}",
suffix="bigstitcher{}.xml".format(
"solver"
if config["bigstitcher"]["global_optimization"]["enabled"]
else "stitching"
),
),
ijm=Path(workflow.basedir) / "macros" / "FuseImageMacroZarr.ijm",
params:
channel=lambda wildcards: "--channelId={channel}".format(
channel=get_stains(wildcards).index(wildcards.stain)
Expand All @@ -438,7 +278,7 @@ rule bigstitcher_spark_fusion:
datatype="micr",
sample="{sample}",
acq="{acq}",
desc="sparkstitched{desc}",
desc="stitched{desc}",
stain="{stain}",
suffix="SPIM.zarr",
)
Expand Down
Loading

0 comments on commit 1ff3be8

Please sign in to comment.