Skip to main content

Read Leica image files (LIF, LOF, and XLIF)

Project description

Liffile is a Python library to read image and metadata from Leica image file formats: LIF (Leica Image File), LOF (Leica Object File), and XLIF (XML Leica Image File).

These files are written by LAS X software to store collections of images and metadata from microscopy experiments.

Author:

Christoph Gohlke

License:

BSD 3-Clause

Version:

2025.2.5

DOI:

10.5281/zenodo.14740657

Quickstart

Install the liffile package and all dependencies from the Python Package Index:

python -m pip install -U liffile[all]

See Examples for using the programming interface.

Source code and support are available on GitHub.

Requirements

This revision was tested with the following requirements and dependencies (other versions may work):

Revisions

2025.2.5

  • Support XLIF files.

  • Revise LifMemoryBlock (breaking).

  • Replace LifImage.is_lof property with format (breaking).

  • Require imagecodecs for decoding TIF, JPEG, PNG, and BMP frames.

2025.2.2

  • Add LifFlimImage class.

  • Derive LifImage and LifFlimImage from LifImageABC.

  • Rename LifImage.guid property to uuid (breaking).

  • Add LifFile.uuid property.

2025.1.31

  • Support LOF files.

  • Make LifFile.xml_header a function (breaking).

2025.1.30

  • Remove LifFile.flim_rawdata (breaking).

  • Add index, guid, and xml_element_smd properties to LifImage.

2025.1.26

  • Fix image coordinate values.

  • Prompt for file name if main is called without arguments.

2025.1.25

  • Initial alpha release.

Notes

Leica Microsystems GmbH is a manufacturer of microscopes and scientific instruments for the analysis of micro and nanostructures.

This library is in its early stages of development. It is not feature-complete. Large, backwards-incompatible changes may occur between revisions.

Specifically, the following features are currently not supported: related Leica file formats (XLEF, XLLF, LIFEXT), image mosaics and pyramids, partial image reads, reading non-image data like FLIM/TCSPC, heterogeneous channel data types, discontiguous storage, and bit increments.

The library has been tested with a limited number of version 2 files only.

The Leica Image File format is documented at:

  • Leica Image File Formats - LIF, XLEF, XLLF, LOF. Version 3.2. Leica Microsystems GmbH. 21 September 2016.

  • Annotations to Leica Image File Formats for LAS X Version 3.x. Version 1.4. Leica Microsystems GmbH. 24 August 2016.

  • TSC SP8 FALCON File Format Description. LAS X Version 3.5.0.

Other implementations for reading Leica LIF files are readlif and Bio-Formats .

Examples

Read a FLIM lifetime image and metadata from a LIF file:

>>> with LifFile('tests/data/FLIM.lif') as lif:
...     for image in lif.series:
...         name = image.name
...     image = lif.series['Fast Flim']
...     assert image.shape == (1024, 1024)
...     assert image.dims == ('Y', 'X')
...     lifetimes = image.asxarray()
...
>>> lifetimes
<xarray.DataArray 'Fast Flim' (Y: 1024, X: 1024)> Size: 2MB
array([[...]],
      shape=(1024, 1024), dtype=float16)
    Coordinates:
      * Y        (Y) float64... 0.0005564
      * X        (X) float64... 0.0005564
Attributes...
    path:           FLIM_testdata.lif/sample1_slice1/FLIM Compressed/Fast Flim
    F16:            {'Name': 'F16',...
    TileScanInfo:   {'Tile': {'FieldX': 0,...
    ViewerScaling:  {'ChannelScalingInfo': {...

View the image and metadata in a LIF file from the console:

$ python -m liffile tests/data/FLIM.lif

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

liffile-2025.2.5.tar.gz (31.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

liffile-2025.2.5-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file liffile-2025.2.5.tar.gz.

File metadata

  • Download URL: liffile-2025.2.5.tar.gz
  • Upload date:
  • Size: 31.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for liffile-2025.2.5.tar.gz
Algorithm Hash digest
SHA256 ec2c879aa0d9877fa95fbba29b29a390d897a2ff5fec0f1285b87e39fe4387d9
MD5 71dc9781709b7da01b70d5635de80d72
BLAKE2b-256 2d2b096d514b3e13748fe4863ab99e8f0404d902bc7aae7c90cbcc8d5e2dfb27

See more details on using hashes here.

File details

Details for the file liffile-2025.2.5-py3-none-any.whl.

File metadata

  • Download URL: liffile-2025.2.5-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for liffile-2025.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f5295a6d6c90df7cae6e87584940f6de1cf9832a8eb582cdec10b3e361ef9714
MD5 9790fad69c7017e3bac66ac5ed7803b0
BLAKE2b-256 0a6d65c51b38ab1eecff950df9f3d2705386099676702439c145069af0492c9d

See more details on using hashes here.

Supported by

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