Helper code for the Leica SCAPE to post process resulting images.
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.
You only need one file and pixi (installed on IMCF machines).
- Download
fix_ome_metadata.pyfrom this repository and save it anywhere, for example in your Downloads folder. It does not have to be next to your data. - Open a terminal in the folder where you saved the file (Windows: right-click inside the folder in Explorer → "Open in Terminal").
- Run it on your LAS X project folder (the folder with the
.xlefand.ome.tiffiles):
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)
| 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" --restoreGood to know:
- The path can be a project folder (all
.ome.tiffiles in it are handled) or a single.ome.tif. - Put quotes around paths, especially if they contain spaces.
- Keep the
.ome-backup.xmlnext to the file; without it--restoreis 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.
Clone the repository and run the tools through pixi tasks from the repo folder:
pixi run fix-metadata path/to/Project001The options are the same as above, for example pixi run fix-metadata path/to/Project001 --apply.