Skip to content

Commit

Permalink
require 'blaze' or 'prestitched' as part of the acq wildcard
Browse files Browse the repository at this point in the history
now uses this to determine how to load data and metadata

e.g. previously acq-4x now could be acq-blaze4x
  • Loading branch information
akhanf committed Apr 9, 2024
1 parent 1c30c3d commit bf6eae9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
6 changes: 5 additions & 1 deletion config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ import:
raw_tif_pattern: "{prefix}_Blaze[{tilex} x {tiley}]_C{channel}_xyz-Table Z{zslice}.ome.tif"
intensity_rescaling: 0.5 #raw images seem to be at the upper end of uint16 (over-saturated) -- causes wrapping issues when adjusting with flatfield correction etc. this rescales the raw data as it imports it..

import_stitched:
import_prestitched:
stitched_tif_glob: "*nm_{stain}/*.tif"
physical_size_x_um: 1.8
physical_size_y_um: 1.8
physical_size_z_um: 4


basic_flatfield_corr:
max_n_images: 500
Expand Down
4 changes: 2 additions & 2 deletions config/datasets.tsv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
subject sample acq stain_0 stain_1 dataset_path
mouse1 brain 1x abeta autof .test/dryrun/data
onuska21 brain lifecanvas PI BetaAmyloid /cifs/prado/Kate/AK_Pipeline_LSM/Onuska_21_PI-BetaAmyloid
mouse1 brain blaze1x abeta autof .test/dryrun/data
onuska21 brain prestitched PI BetaAmyloid /cifs/prado/Kate/AK_Pipeline_LSM/Onuska_21_PI-BetaAmyloid
6 changes: 3 additions & 3 deletions workflow/rules/ome_zarr.smk
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ rule zarr_to_ome_zarr:
subject="{subject}",
datatype="micr",
sample="{sample}",
acq="{acq,^(?!.*lifecanvas)}", #anything but lifecanvas
acq="{acq,blaze[a-zA-Z0-9]*}",
suffix="SPIM.ome.zarr",
)
)
Expand Down Expand Up @@ -60,7 +60,7 @@ rule tif_stacks_to_ome_zarr:
params:
in_tif_glob=lambda wildcards, input: os.path.join(
input.tif_dir,
config["import_stitched"]["stitched_tif_glob"],
config["import_prestitched"]["stitched_tif_glob"],
),
max_downsampling_layers=config["ome_zarr"]["max_downsampling_layers"],
rechunk_size=config["ome_zarr"]["rechunk_size"],
Expand All @@ -75,7 +75,7 @@ rule tif_stacks_to_ome_zarr:
subject="{subject}",
datatype="micr",
sample="{sample}",
acq="{acq,lifecanvas}",
acq="{acq,prestitched[a-zA-Z0-9]*}",
suffix="SPIM.ome.zarr",
)
)
Expand Down
18 changes: 8 additions & 10 deletions workflow/scripts/raw_to_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,19 @@
from itertools import product
from snakemake.io import glob_wildcards

if snakemake.wildcards.acq == 'lifecanvas':
physical_size_x=1.8
physical_size_y=1.8
physical_size_z=4

if 'prestitched' in snakemake.wildcards.acq:
metadata={}
metadata['physical_size_x'] = physical_size_x
metadata['physical_size_y'] = physical_size_y
metadata['physical_size_z'] = physical_size_z
metadata['PixelSize'] = [ float(physical_size_z/1000.0), float(physical_size_y/1000.0), float(physical_size_x/1000.0) ] #zyx since OME-Zarr is ZYX
metadata['physical_size_x'] = config['import_prestitched']['physical_size_x_um']
metadata['physical_size_y'] = config['import_prestitched']['physical_size_y_um']
metadata['physical_size_z'] = config['import_prestitched']['physical_size_z_um']
metadata['PixelSize'] = [ float(metadata['physical_size_z']/1000.0), float(metadata['physical_size_y']/1000.0), float(metadata['physical_size_x']/1000.0) ] #zyx since OME-Zarr is ZYX
metadata['PixelSizeUnits'] = 'mm'

#write metadata to json
with open(snakemake.output.metadata_json, 'w') as fp:
json.dump(metadata, fp,indent=4)

else:
elif 'blaze' in snakemake.wildcards.acq:

in_tif_pattern = snakemake.params.in_tif_pattern

Expand Down Expand Up @@ -111,3 +107,5 @@
#write metadata to json
with open(snakemake.output.metadata_json, 'w') as fp:
json.dump(metadata, fp,indent=4)
else:
print('ERROR: unsupported input acquisition')

0 comments on commit bf6eae9

Please sign in to comment.