Skip to main content

A converter for Zeiss txrm and xrm files, created from B24 of Diamond Light Source

Project description

txrm2tiff

Converts txrm/xrm files to OME tif/tiff files.

txrm2tiff was created for users of beamline B24 of Diamond Light Source by Thomas Fish. This has been adapted from B24's the automatic processing pipeline. Parts of this code were originally written by Kevin Savage, with further additions and amendments by Peter Chang, Victoria Beilsten-Edmands, and Thomas Fish.

Installation

Available on PyPI and conda-forge as txrm2tiff. To install:

  • PyPI: python -m pip install txrm2tiff
  • conda-forge: conda install -c conda-forge txrm2tiff

Instructions

txrm2tiff {--input input file path (required)} {--reference reference file path (optional, default=None)} {--output path (optional, default=None)} {--annotate (optional)} {--datetype output data type (optional, choices=[uint16, float32, float64], default=None)} {--ignore-ref (optional)} {--set-logging (optional, default="info"}

txrm2tiff -h or txrm2tiff --help will give more info.  

Setup options:

txrm2tiff setup {--windows-shortcut (WINDOWS ONLY: optional, creates shortcut to .bat file on the desktop for drag'n'drop processing )}

txrm2tiff setup -h or txrm2tiff setup --help will give more info.  

Inspector options:

txrm2tiff inspect {--input input file path (required)} {--extra (optional, default=False)} {--list-streams (optional, default=False)} {--inspect-streams space separated streams (optional)}

txrm2tiff inspect --input or txrm2tiff inspect -i followed by the path of a txrm/xrm file will output some basic information about the images contained.

  • Adding --extra or -e will add further information to this output.
  • Adding --list-streams or -l will list all of the streams* in addition to the any previous output. This will be a lot so it may be useful to save this to a file using > file.txt.
  • Adding --inspect-streams or -s followed by a 1 or more space separated stream names will read each stream using a variety of formats. As txrm and xrm files do not save the streams with information on what data type is being used**, the output will take some interpreting.

txrm2tiff inspect -h or txrm2tiff inspect --help will give more info.

*xrm and txrm files are 'OLE' type files. These files to separate and store information in streams.

** with the exception of images, which do get the image data type saved separately.

NOTE: any commands beginning with txrm2tiff are essentially equivalent to usng python -m txrm2tiff (arguments will be parsed by the same parser via either method). This may be useful if there were any installation issues.


If no output path is supplied, the output file will be placed at the input path with the extension ".ome.tif"/".ome.tiff" as appropriate. The ".ome" signifies the OME XML metadata header.

dragndrop.bat has been supplied allowing windows users to drag and drop individual files or entire directories for processing (note: you cannot set output path this way). This may require some setup depending on your Python installation, so please see the file.

Logging options are:
  • debug OR 1
  • info OR 2
  • warning OR 3
  • error OR 4
  • critical OR 5

Examples:

txrm2tiff -h and txrm2tiff setup --h will give more info

txrm2tiff -i input.txrm Saves "input.ome.tiff" with reference applied, if available.

txrm2tiff -i input.txrm -r ref_stack.txrm Saves "input.ome.tiff" with a reference image applied from running Despeckle & Average on the the txrm stack. This Despeckle & Average algorithm is near-identical to the Zeiss algorithm, based on their logic.

txrm2tiff --input input.txrm --reference ref_single.xrm --ignore-ref Saves "input.ome.tiff" with custom reference applied from a single image (e.g. a Despeckled_Ave.xrm file). If a custom reference is supplied, the ignore reference argument will be ignored.

txrm2tiff -i input.xrm -o custom-output.ome.tif Saves "custom-output.ome.tif" with reference applied, if available.

txrm2tiff -i input.xrm --annotate Saves "input.ome.tiff", as well as a separate file "input_Annotated.tif", which has annotations overlaid (if annotations are found) and scale bar.

txrm2tiff --input input.xrm --ignore-ref --set-logging debug Saves "input.ome.tiff" and ignores any reference, shows debug and above level log messages.

txrm2tiff -i input.xrm --output custom-output.ome.tif --set-logging error Saves "custom-output.ome.tiff", shows error and above level log messages.

To batch convert: txrm2tiff --input path/to/inputDirectory/ Converts all xrm/txrm files within input_directory with reference applied, if available.

txrm2tiff --input path/to/inputDirectory/ --ignore-ref Converts all xrm/txrm files within input_directory, ignoring all references.

txrm2tiff --input path/to/inputDirectory/ --output path/to/outputDirectory/ --ignore-ref Converts all xrm/txrm files within "inputDirectory", saving to the automatic name within the specified output directory, ignoring all references.

Batch conversion notes:

  • --output must be a directory or it will be ignored and files placed in the same directory as the xrm/txrms
  • Sub directories containing any xrm/txrm files found within "inputDirectory" will be copied to "outputDirectory" (directories will be created if they don't already exist)
  • --reference inputs will be ignored for batch conversion

Features

  • xrm/txrm files will be converted to tif/tiff
  • If a reference has been applied within XMController, it will automatically apply the reference (image * 100.0 / reference, as done by XMController)
  • Any annotations from the latest version xrm/txrm files can be exported and saved (along with a scale bar)
  • The data type of the saved image can be specified (warnings will be given if the data type limits off the dynamic range of the image, also values are rounded before casting float -> integer)
  • Internally stored reference images can be ignored
  • A separate file containing reference images can be specified (can be a txrm stack, single xrm image, tiff stack, or tif image) - this overrides any internally stored reference and the ignore reference option
  • If it is a mosaic, this is recognised and the reference will be applied to each individual image within the mosaic
  • Additional metadata will be added in OME XML format to the header
  • Batch convert options
  • Within Python, xrm/txrm files can be inspected using from txrm2tiff import txrm_wrapper and using the contained functions
  • Within Python, xrm/txrm files can be converted and saved using the following functions: convert_and_save, convert, convert_with_annotations, save (from txrm2tiff import convert_and_save, convert, convert_with_annotations, save). For more control, use the TxrmToImage class functions (from txrm2tiff.txrm_to_image import TxrmToImage)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

txrm2tiff-1.2.1.tar.gz (53.4 kB view details)

Uploaded Source

Built Distribution

txrm2tiff-1.2.1-py3-none-any.whl (53.0 kB view details)

Uploaded Python 3

File details

Details for the file txrm2tiff-1.2.1.tar.gz.

File metadata

  • Download URL: txrm2tiff-1.2.1.tar.gz
  • Upload date:
  • Size: 53.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

File hashes

Hashes for txrm2tiff-1.2.1.tar.gz
Algorithm Hash digest
SHA256 8ed111136e3d7d9b584619b4093773a558bdd8d53db4d04e02fc2d4dfadc60cb
MD5 b99a6dd2a467b4b4904b090f560fb88a
BLAKE2b-256 0f88c5af7b46c5c220e57f66f2e4f06f5e9854e60bd6d1a863e860dfc1ca414c

See more details on using hashes here.

File details

Details for the file txrm2tiff-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: txrm2tiff-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 53.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

File hashes

Hashes for txrm2tiff-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c2db2c3a5340c955dbf9d9e7c51e9fd5dd7f7f9067693672d40e6e2318e07640
MD5 5703dca9eed23218e20f24b0d3f06101
BLAKE2b-256 81d8e7549f0ba0586c7e341859169d08f173ce1372dbb7b30d185fbc79668fde

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page