Skip to content

About

Helper code for the Leica SCAPE to post process resulting images.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

scape-post-processing

Helper code for the Leica SCAPE to post process resulting images.

Fix OME-TIFF metadata

Leica SCAPE OME-TIFF exports store voxel sizes in metres and reuse the same IDs for every tile. Imaris then fails to open the image directly as it needs the metadata to be in um. fix_ome_metadata.py fixes the header only; the image data is never touched.

Run without the repo

You only need one file and pixi (installed on IMCF machines).

  1. Download fix_ome_metadata.py from this repository and save it anywhere, for example in your Downloads folder. It does not have to be next to your data.
  2. Open a terminal in the folder where you saved the file (Windows: right-click inside the folder in Explorer → "Open in Terminal").
  3. Run it on your LAS X project folder (the folder with the .xlef and .ome.tif files):
pixi exec --spec tifffile python fix_ome_metadata.py "U:\path\to\Project001"

pixi exec --spec tifffile sets up a temporary Python with tifffile in it. The first run downloads it and takes a minute; later runs start right away.

Without any option, the script only checks the files and changes nothing:

Mosaic001.ome.tif
  - sizes/positions in m (Imaris reads 1 x 1 x 1 µm)
  - IDs used more than once: Pixels:0, Channel:0, Channel:1
  - all 24 tiles have the same stage position (fix with --positions)
  -> run again with --apply (fix in place) or --copy (fix a copy)

Options

Option What it does
(none) Check only, changes nothing.
--apply Fix the file in place. The original header is first saved as <file>.ome-backup.xml next to it.
--copy Write a fixed copy <name>_fixed.ome.tif next to the original and leave the original untouched. Needs as much free disk space as the file.
--positions Also write the real tile positions from the LAS X .xlif files (for BigStitcher). Use together with --apply or --copy.
--restore Undo --apply: puts the original header back from the backup.

Examples, all run from the folder with fix_ome_metadata.py:

pixi exec --spec tifffile python fix_ome_metadata.py "U:\path\to\Project001" --apply
pixi exec --spec tifffile python fix_ome_metadata.py "U:\path\to\Project001" --copy --positions
pixi exec --spec tifffile python fix_ome_metadata.py "U:\path\to\Project001\Mosaic001.ome.tif" --restore

Good to know:

  • The path can be a project folder (all .ome.tif files in it are handled) or a single .ome.tif.
  • Put quotes around paths, especially if they contain spaces.
  • Keep the .ome-backup.xml next to the file; without it --restore is not possible.
  • Files that are already fixed are skipped, so running the script twice is safe.
  • If you keep working on the data in LAS X, prefer --copy: LAS X reads its own project files and the original stays exactly as it was.

Run with the repo

Clone the repository and run the tools through pixi tasks from the repo folder:

pixi run fix-metadata path/to/Project001

The options are the same as above, for example pixi run fix-metadata path/to/Project001 --apply.

About

Helper code for the Leica SCAPE to post process resulting images.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages