lfdfiles

Laboratory for Fluorescence Dynamics (LFD) file formats.

Lfdfiles is a Python library and console script for reading, writing, converting, and viewing many of the proprietary file formats used to store experimental data and metadata at the Laboratory for Fluorescence Dynamics. Supported formats include:

  • SimFCS VPL, VPP, JRN, BIN, INT, CYL, REF, BH, BHZ, B64, I64, Z64, R64

  • GLOBALS LIF, ASCII

  • CCP4 MAP

  • Vaa3D RAW

  • Bio-Rad(r) PIC

  • ISS Vista IFLI, IFI, TDFLIM

  • FlimFast FLIF

Author:

Christoph Gohlke

License:

BSD-3-Clause

Version:

2026.6.24

DOI:

10.5281/zenodo.8384166

Quickstart

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

python -m pip install -U "lfdfiles[all]"

Print the console script usage:

python -m lfdfiles --help

The lfdfiles library is type annotated and documented via docstrings.

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

2026.6.24

  • Add VistaTdflim class for reading ISS Vista TDFLIM files.

  • Support Python 3.15.

2026.4.30

  • Remove FlimboxFbd, FlimboxFbf, and FlimboxFbs (breaking; use fbdfile).

  • Remove CziFile, NetpbmFile, OifFile, and TiffFile wrappers (breaking).

  • Add typed __init__ overrides to subclasses with class-specific parameters.

  • Drop support for numpy 2.0 (SPEC0).

2026.3.18

  • Replace LfdFileRegistry metaclass with __init_subclass__.

  • Add LfdFile.open classmethod as typed factory for auto-detection.

  • Add LfdFile._probe classmethod for cheap file pre-screening.

  • Add asarray overrides with typed signatures to select subclasses.

  • Convert _components to classmethod.

  • Drop support for Python 3.11.

2026.1.14

  • Improve code quality.

2025.12.12

  • Derive LfdFileError from ValueError.

  • Improve code quality.

2025.9.17

  • Many breaking changes to FLIMbox functionality (use fbdfile package instead):

  • Discourage use of FlimboxFbd, FlimboxFbf, and FlimboxFbs classes.

  • Use fbdfile package to implement FlimboxFbd, FlimboxFbf, and FlimboxFbs.

  • Remove flimbox_histogram, flimbox_decode, and sflim_decode functions.

  • Remove convert_fbd2b64 function and fbd2b64 command line app.

  • Remove deprecated SimfcsFbf, and SimfcsFbd classes.

  • Remove deprecated simfcsfbd_histogram and simfcsfbd_decode functions.

2025.7.31

  • Read variants of SimFCS REF files.

  • Drop support for Python 3.10.

2025.5.10

  • Mark Cython extension free-threading compatible.

  • Remove doctest command line option.

  • Support Python 3.14.

2025.3.16

  • Replace deprecated tifffile.stripnull function.

  • Fix misspelled VistaIfli.header keys.

  • Drop support for Python 3.9.

2024.10.24

Refer to the CHANGES file for older revisions.

Notes

The API is not stable yet and might change between revisions.

Many of the LFD file formats are not documented and might change arbitrarily. This implementation is mostly based on reverse engineering existing files. No guarantee can be made as to the correctness of code and documentation.

Experimental data are often stored in plain binary files with metadata available in separate, human readable journal files (.jrn).

Unless specified otherwise, data are stored in little-endian, C contiguous order.

The FLIMbox functionality has been moved to the fbdfile package.

The Laboratory for Fluorescence Dynamics (LFD) was a national research resource center for biomedical fluorescence spectroscopy funded by the National Institutes of Health from 1986 to 2022 (grant P41GM103540).

References

The following software is referenced in this module:

  1. SimFCS, a.k.a. Globals for Images, is software for fluorescence image acquisition, analysis, and simulation, developed by Enrico Gratton at UCI.

  2. Globals, a.k.a. Globals for Spectroscopy, is software for the analysis of multiple files from fluorescence spectroscopy, developed by Enrico Gratton at UIUC and UCI.

  3. ImObj is software for image analysis, developed by LFD at UIUC. Implemented on Win16.

  4. FlimFast is software for frequency-domain, full-field, fluorescence lifetime imaging at video rate, developed by Christoph Gohlke at UIUC.

  5. FLImage is software for frequency-domain, full-field, fluorescence lifetime imaging, developed by Christoph Gohlke at UIUC. Implemented in LabVIEW.

  6. FLIez is software for frequency-domain, full-field, fluorescence lifetime imaging, developed by Glen Redford at UIUC.

  7. Flie is software for frequency-domain, full-field, fluorescence lifetime imaging, developed by Peter Schneider at MPIBPC. Implemented on a Sun UltraSPARC.

  8. FLOP97 is software for frequency-domain, cuvette, fluorescence lifetime measurements, developed by Christoph Gohlke at MPIBPC. Implemented in LabVIEW.

  9. VistaVision is commercial software for instrument control, data acquisition and data processing by ISS Inc (Champaign, IL).

  10. Vaa3D is software for multi-dimensional data visualization and analysis, developed by the Hanchuan Peng group at the Allen Institute.

  11. Voxx is a volume rendering program for 3D microscopy, developed by Jeff Clendenon et al. at the Indiana University.

  12. CCP4, the Collaborative Computational Project No. 4, is software for macromolecular X-Ray crystallography.

Examples

Create a Bio-Rad PIC file from a NumPy array:

>>> data = numpy.arange(1000000).reshape((100, 100, 100)).astype('u1')
>>> bioradpic_write(TEMP / '_biorad.pic', data)

Read the volume data from the PIC file as NumPy array, and access metadata:

>>> with BioradPic(TEMP / '_biorad.pic') as f:
...     f.shape
...     f.spacing
...     data = f.asarray()
...
(100, 100, 100)
(1.0, 1.0, 1.0)

Convert the PIC file to a compressed TIFF file:

>>> with BioradPic(TEMP / '_biorad.pic') as f:
...     f.totiff(TEMP / '_biorad.tif', compression='zlib')
...

License

Copyright (c) 2012-2026, Christoph Gohlke
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
   this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
   contributors may be used to endorse or promote products derived from
   this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

lfdfiles module

lfdfiles.__version__

Lfdfiles version string.

class lfdfiles.BioradPic(filename, /, **kwargs)

Bases: LfdFile

Bio-Rad(tm) multi-dimensional data.

Bio-Rad PIC files contain single-channel volume data or multi-channel images.

Image data in uint8 or uint16 format are stored after a 76-byte header. Additional metadata are stored after the image data as 96-byte records (“notes”).

No official file format specification is available. The header structure was obtained from https://forums.ni.com/ni/attachments/ni/200/7567/1/file%20format.pdf. This implementation does not currently handle multi-file data.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • kwargs (Any)

Return type:

Self

Examples

>>> with BioradPic(DATA / 'biorad.pic') as f:
...     data = f.asarray()
...     f.totiff(TEMP / '_biorad.pic.tif')
...     print(f.shape, data[78, 255, 255])
...
(79, 256, 256) 8
static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

asarray(*args, **kwargs)

Return data in file(s) as NumPy array.

Parameters:
  • **kwargs (Any) – Arguments passed to LfdFile._asarray().

  • args (Any)

  • **kwargs

Return type:

NDArray[Any]

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.Ccp4Map(filename, /, **kwargs)

Bases: LfdFile

CCP4 volume data.

CCP4 MAP files contain 3D volume data. It is used by the Electron Microscopy Data Bank to store electron density maps.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • kwargs (Any)

Return type:

Self

Examples

>>> with Ccp4Map(DATA / 'ccp4.map') as f:
...     data = f.asarray()
...     f.totiff(TEMP / '_ccp4.map.tif', compression='zlib')
...     print(f.shape, data[100, 100, 100])
...
(256, 256, 256) 1.0
static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

asarray(*, memmap=False, **kwargs)

Return volume data as NumPy array.

Parameters:
  • memmap (bool) – If True, use numpy.memmap to read array.

  • kwargs (Any)

Return type:

NDArray[Any]

class lfdfiles.FlieOut(filename, /, **kwargs)

Bases: LfdFile

Flie fluorescence lifetime image.

Flie OUT files contain referenced fluorescence lifetime image data from frequency-domain measurements. Three 300x220 big-endian float32 images are stored in separate files: intensity (off_*.out), phase (phi_*.out), and modulation (mod_*.out). Phase values are in degrees, modulation in percent. No metadata are available.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • kwargs (Any)

Return type:

Self

Examples

>>> with FlieOut(DATA / 'off_flie.out') as f:
...     data = f.asarray()
...     f.totiff(TEMP / '_off_flie.out.tif')
...     print(f.shape, data[:, 219, 299])
...
(3, 220, 300) [91.85 28.24 69.03]
static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

asarray(*args, **kwargs)

Return data in file(s) as NumPy array.

Parameters:
  • **kwargs (Any) – Arguments passed to LfdFile._asarray().

  • args (Any)

  • **kwargs

Return type:

NDArray[Any]

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.FliezDb2(filename, /, **kwargs)

Bases: LfdFile

FLIez double image.

FLIez DB2 files contain a sequence of images from fluorescence lifetime measurements. The modality of the data stored in different files varies: phase intensities, average intensities, phase or modulation. A 12-byte header of three int32 values specifies the data shape (x, y, z). The float64 image data follows immediately at byte 12. No other metadata are available.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • kwargs (Any)

Return type:

Self

Examples

>>> with FliezDb2(DATA / 'fliez.db2') as f:
...     data = f.asarray()
...     f.totiff(TEMP / '_fliez.db2.tif')
...     print(f.shape, data[8, 108, 104])
...
(32, 256, 256) 234.0
static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

asarray(*args, **kwargs)

Return data in file(s) as NumPy array.

Parameters:
  • **kwargs (Any) – Arguments passed to LfdFile._asarray().

  • args (Any)

  • **kwargs

Return type:

NDArray[Any]

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.FliezI16(filename, /, **kwargs)

Bases: LfdFile

FLIez integer image.

FLIez I16 files contain camera images, usually for one phase cycle of frequency-domain fluorescence lifetime measurements. Several 256x256 uint16 intensity images is stored consecutively. No metadata are available.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • kwargs (Any)

Return type:

Self

Examples

>>> with FliezI16(DATA / 'fliez.i16') as f:
...     data = f.asarray()
...     f.totiff(TEMP / '_fliez.i16.tif')
...     print(f.shape, data[::8, 108, 104])
...
(32, 256, 256) [401 538 220 297]
static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

asarray(*args, **kwargs)

Return data in file(s) as NumPy array.

Parameters:
  • **kwargs (Any) – Arguments passed to LfdFile._asarray().

  • args (Any)

  • **kwargs

Return type:

NDArray[Any]

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.FlimageBin(filename, /, **kwargs)

Bases: LfdFile

FLImage fluorescence lifetime image.

FLImage BIN files contain referenced fluorescence lifetime image data from frequency-domain measurements. Three 300x220 big-endian float32 images are stored in separate files, in one of two variants: phase images (intensity .int.bin, phase .phi.bin, modulation .mod.bin) or lifetime images (intensity .int.bin, apparent lifetime from phase .tph.bin, apparent lifetime from modulation .tmd.bin). Phase values are in degrees, modulation in percent.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • kwargs (Any)

Return type:

Self

Examples

>>> with FlimageBin(DATA / 'flimage.int.bin') as f:
...     data = f.asarray()
...     f.totiff(TEMP / '_flimage.int.bin.tif')
...     print(f.shape, data[:, 219, 299])
...
(3, 220, 300) [1.23 111.8 36.93]
static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

asarray(*args, **kwargs)

Return data in file(s) as NumPy array.

Parameters:
  • **kwargs (Any) – Arguments passed to LfdFile._asarray().

  • args (Any)

  • **kwargs

Return type:

NDArray[Any]

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.FlimfastFlif(filename, /, **kwargs)

Bases: LfdFile

FlimFast fluorescence lifetime image.

FlimFast FLIF files contain camera images and metadata of frequency-domain fluorescence lifetime measurements. A 640-byte header is followed by a variable number of uint16 images, each preceded by a 64-byte record.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • kwargs (Any)

Return type:

Self

Examples

>>> f = FlimfastFlif(DATA / 'flimfast.flif')
>>> data = f.asarray()
>>> float(f.header.frequency)
80.652...
>>> float(f.records['phase'][31])
348.75
>>> int(data[31, 219, 299])
366
>>> f.totiff(TEMP / '_flimfast.flif.tif')
>>> f.close()
static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

asarray(*args, **kwargs)

Return data in file(s) as NumPy array.

Parameters:
  • **kwargs (Any) – Arguments passed to LfdFile._asarray().

  • args (Any)

  • **kwargs

Return type:

NDArray[Any]

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.GlobalsAscii(filename, /, **kwargs)

Bases: LfdFile

Globals ASCII lifetime data.

Globals ASCII files contain array and meta data of a single frequency domain lifetime measurement, stored as human readable ASCII string. Consecutive measurements are stored in separate files with increasing file extension numbers. The format is also used by ISS and FLOP97 software.

The metadata can be accessed via dictionary getitem interface. Keys are lower case with spaces replaced by underscores.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • kwargs (Any)

Return type:

Self

Examples

>>> with GlobalsAscii(DATA / 'FLOP.001') as f:
...     print(f['experiment'], f.asarray().shape)
...
LIFETIME (5, 20)
__getitem__(key, /)

Return value of key in record.

Parameters:

key (str)

Return type:

Any

static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

asarray(*args, **kwargs)

Return data in file(s) as NumPy array.

Parameters:
  • **kwargs (Any) – Arguments passed to LfdFile._asarray().

  • args (Any)

  • **kwargs

Return type:

NDArray[Any]

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.GlobalsLif(filename, /, **kwargs)

Bases: LfdFile

Globals binary lifetime data.

Globals LIF files contain array and meta data of multiple frequency-domain cuvette lifetime measurement, stored as consecutive 472-byte records. The number of frequencies per record is limited to 25. The format was also used by ISS software.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • kwargs (Any)

Return type:

Self

Examples

>>> with GlobalsLif(DATA / 'globals.lif') as f:
...     print(len(f), f[42]['date'], f[42].asarray().shape)
...
43 1987.8.8 (5, 11)
class Record

Bases: dict[str, object]

Record in GlobalsLif files.

asarray()

Return record array data.

Return type:

NDArray[Any]

asarray(key=0, **kwargs)

Return freq, phi, mod, dp, dm of selected record as NumPy array.

Parameters:
  • key (int)

  • kwargs (Any)

Return type:

NDArray[numpy.float64]

__getitem__(key, /)

Return selected record.

Parameters:

key (int)

Return type:

Record

__len__()

Return number of records.

Return type:

int

__iter__()

Return iterator over records.

Return type:

Iterator[Record]

static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.LfdFile(filename, /, **kwargs)

Bases: object

Base class for reading LFD files.

Open file(s) and read headers and metadata.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • validate – If True, filename must match LfdFile._filepattern.

  • components – If True, open all component files found.

  • _offset – Initial position of file pointer.

  • **kwargs (Any) – Arguments passed to LfdFile._init().

Return type:

Self

Examples

>>> with LfdFile(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

close()

Close file handle.

Call LfdFile._close().

Return type:

None

asarray(*args, **kwargs)

Return data in file(s) as NumPy array.

Parameters:
  • **kwargs (Any) – Arguments passed to LfdFile._asarray().

  • args (Any)

  • **kwargs

Return type:

NDArray[Any]

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property filename: str

Name of file.

property size: int | None

Number of elements in data array.

property ndim: int | None

Number of dimensions in data array.

class lfdfiles.LfdFileError(arg='', /, msg='')

Bases: ValueError

Exception to indicate invalid LFD files.

Parameters:
  • arg (LfdFile | str) – Error message or LfdFile instance where error occurred.

  • msg (str) – Additional error message.

class lfdfiles.LfdFileSequence(files, /, *, imread=None, pattern=None, container=None, sort=None)

Bases: FileSequence

Series of LFD files.

Parameters:
  • files (str | os.PathLike[Any] | Sequence[str | os.PathLike[Any]]) – Glob filename pattern or sequence of file names.

  • imread (Callable[..., NDArray[Any]] | type[LfdFile] | None) – Class or function to read image array from single file.

  • pattern (str | None) – Regular expression pattern matching axes names and chunk indices in file names.

  • container (str | os.PathLike[Any] | None) – Name or open instance of ZIP file in which files are stored.

  • sort (Callable[..., Any] | bool | None) – Function to sort file names if files is a pattern. If False, disable sorting.

Examples

>>> ims = LfdFileSequence(
...     DATA / 'gpint/v*.int',
...     pattern=r'v(?P<Channel>\d)(?P<Image>\d*).int',
...     imread=SimfcsInt,
... )
>>> ims.axes
'CI'
>>> data = ims.asarray()
>>> data.shape
(2, 135, 256, 256)
>>> ims.close()
__iter__()

Return iterator over all file names.

Return type:

Iterator[str]

asarray(*, imreadargs=None, chunkshape=None, chunkdtype=None, axestiled=None, ioworkers=1, out_inplace=None, out=None, **kwargs)

Return images from files as NumPy array.

Parameters:
  • imreadargs (dict[str, Any] | None) – Arguments passed to FileSequence.imread.

  • chunkshape (tuple[int, ...] | None) – Shape of chunk in each file. Must match FileSequence.imread(file, **imreadargs).shape. By default, this is determined by reading the first file.

  • chunkdtype (DTypeLike | None) – Data type of chunk in each file. Must match FileSequence.imread(file, **imreadargs).dtype. By default, this is determined by reading the first file.

  • axestiled (dict[int, int] | Sequence[tuple[int, int]] | None) – Axes to be tiled. Map stacked sequence axis to chunk axis.

  • ioworkers (int | None) – Maximum number of threads to execute FileSequence.imread asynchronously. If 0, use up to _TIFF.MAXIOWORKERS threads. Using threads can significantly improve runtime when reading many small files from a network share. If enabled, internal threading for the imread function should be disabled.

  • out_inplace (bool | None) – Decode directly into output array without intermediate copy. Not all FileSequence.imread functions support this, especially in non-contiguous cases.

  • out (OutputType) – Output array, ‘memmap’, or file for image data. By default, create a new array. If a numpy.ndarray, a writable array to which the images are copied. If ‘memmap’, create a memory-mapped array in a temporary file. If a string or open file, the file used to create a memory-mapped array.

  • **kwargs (Any) – Deprecated: Arguments passed to FileSequence.imread in addition to imreadargs.

Raises:

IndexError, ValueError – Array shapes do not match.

Return type:

NDArray[Any]

aszarr(**kwargs)

Return images from files as Zarr store.

Parameters:

**kwargs (Any) – Arguments passed to ZarrFileSequenceStore.

Return type:

ZarrFileSequenceStore

close()

Close open files.

Return type:

None

commonpath()

Return longest common sub-path of each file in sequence.

Return type:

str

property files_missing: int

Number of missing files in sequence.

class lfdfiles.RawPal(filename, /, **kwargs)

Bases: LfdFile

Raw color palette.

PAL files contain a single RGB or RGBA color palette, stored as 256x3 or 256x4 unsigned bytes in C or Fortran order, without any header.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • kwargs (Any)

Return type:

Self

Examples

>>> with RawPal(DATA / 'rgb.pal') as f:
...     print(f.asarray()[100])
...
[ 16 255 239]
asarray(*, order=None, **kwargs)

Return palette data as uint8 array of shape (256, 3 or 4).

Parameters:
  • order (Literal['C', 'F'] | None) – Determines whether the data is stored in C (row-major) or Fortran (column-major) order. By default the order is determined based on size and sum of differences.

  • kwargs (Any)

Return type:

NDArray[numpy.uint8]

static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.SimfcsB64(filename, /, **kwargs)

Bases: LfdFile

SimFCS integer intensity data.

SimFCS B64 files contain one or more square intensity images, a carpet of lines, or a stream of intensity data. The first 4 bytes store the square image size as int32. The remaining payload stores contiguous int16 values. The measurement extension and ‘carpet’ identifier are usually encoded in the file name. The file contents are not fully self-describing: the same layout may represent one image, multiple square images, a carpet, or a 1D stream of intensity values.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • dtype (DTypeLike | None) – Type of data in file.

  • maxsize (int) – Maximum square image length.

  • _offset (int)

  • kwargs (Any)

Examples

>>> with SimfcsB64(DATA / 'simfcs.b64') as f:
...     data = f.asarray()
...     f.totiff(TEMP / '_simfcs.b64.tif', compression='zlib')
...     print(f.shape, data[101, 255, 255])
...
(102, 256, 256) 0
static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

asarray(*args, **kwargs)

Return data in file(s) as NumPy array.

Parameters:
  • **kwargs (Any) – Arguments passed to LfdFile._asarray().

  • args (Any)

  • **kwargs

Return type:

NDArray[Any]

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.SimfcsBh(filename, /, **kwargs)

Bases: LfdFile

SimFCS Becker and Hickl fluorescence lifetime histogram.

SimFCS B&H files contain time-domain fluorescence lifetime histogram data, acquired from Becker and Hickl(r) TCSPC cards, or converted from other data sources. The data are stored consecutively as 256 bins of 256x256 float32 images. B&H files are occasionally used to store consecutive 256x256 float32 images, for example, volume data.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • kwargs (Any)

Return type:

Self

Examples

>>> with SimfcsBh(DATA / 'simfcs.b&h') as f:
...     data = f.asarray()
...     f.totiff(TEMP / '_simfcs.b&h.tif')
...     print(f.shape, data[59, 1, 84])
...
(256, 256, 256) 12.0
static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

asarray(*args, **kwargs)

Return data in file(s) as NumPy array.

Parameters:
  • **kwargs (Any) – Arguments passed to LfdFile._asarray().

  • args (Any)

  • **kwargs

Return type:

NDArray[Any]

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.SimfcsBhz(filename, /, **kwargs)

Bases: SimfcsBh

SimFCS compressed Becker and Hickl fluorescence lifetime histogram.

SimFCS BHZ files contain time-domain fluorescence lifetime histogram data, acquired from Becker and Hickl(r) TCSPC cards, or converted from other data sources. SimFCS BHZ files are ZIP archives containing a single B&H file. The inner file stores the same sequence of float32 images as described for SimfcsBh.

Examples

>>> with SimfcsBhz(DATA / 'simfcs.bhz') as f:
...     data = f.asarray()
...     f.totiff(TEMP / '_simfcs.bhz.tif')
...     print(f.shape, data[59, 1, 84])
...
(256, 256, 256) 12.0
Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

asarray(*args, **kwargs)

Return data in file(s) as NumPy array.

Parameters:
  • **kwargs (Any) – Arguments passed to LfdFile._asarray().

  • args (Any)

  • **kwargs

Return type:

NDArray[Any]

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.SimfcsBin(filename, /, **kwargs)

Bases: LfdFile

SimFCS raw binary data.

SimFCS BIN and RAW files contain homogeneous array data of any type and shape, stored C-contiguously in little-endian byte order. The files do not store shape, data type, or metadata. External knowledge is required to interpret the payload correctly. A common format is shape=(256, 256), dtype='uint16'.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • shape (tuple[int, ...] | None) – Shape of array to read from file.

  • dtype (DTypeLike | None) – Datatype of array in file.

  • offset (int) – Position in bytes of array data in file. Use to skip file header.

  • validate_size (bool) – If True, file size must exactly match offset, data shape and dtype.

  • _offset (int)

  • kwargs (Any)

Examples

>>> with SimfcsBin(
...     DATA / 'simfcs.bin', shape=(-1, 256, 256), dtype='uint16'
... ) as f:
...     data = f.asarray(memmap=True)
...     f.totiff(TEMP / '_simfcs.bin.tif', compression='zlib')
...     print(f.shape, data[751, 127, 127])
(752, 256, 256) 1
asarray(*, memmap=False, **kwargs)

Return data as array of specified shape and type.

Parameters:
  • memmap (bool) – Return a read-only memory-map to the data array on disk.

  • kwargs (Any)

Return type:

NDArray[Any]

static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.SimfcsCyl(filename, /, **kwargs)

Bases: LfdFile

SimFCS orbital tracking data.

SimFCS CYL files contain intensity data from orbital tracking measurements, stored as a uint16 array of shape (2 channels, number of orbits, 256 points per orbit).

The number of channels and points per orbit can be read from the associated journal file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • shape (tuple[int, int, int]) – Number of channels, orbits, and points per orbit.

  • _offset (int)

  • kwargs (Any)

Examples

>>> with SimfcsCyl(DATA / 'simfcs.cyl') as f:
...     data = f.asarray()
...     f.totiff(TEMP / '_simfcs.cyl.tif')
...     print(f.shape, data[0, -1, :4])
...
(2, 3291, 256) [109 104 105 112]
static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

asarray(*args, **kwargs)

Return data in file(s) as NumPy array.

Parameters:
  • **kwargs (Any) – Arguments passed to LfdFile._asarray().

  • args (Any)

  • **kwargs

Return type:

NDArray[Any]

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.SimfcsFit(filename, /, **kwargs)

Bases: LfdFile

SimFCS fit data.

SimFCS FIT files contain results from image scan analysis. The fit parameters are stored as a 1024x16 float64 array, followed by an 8-byte buffer and the intensity image used for the fit, stored as a 256x256 float32 array. The purpose of the 8-byte buffer is unknown.

The 16 fit parameters are:

W0
Background
Pixel size
Triplet amplitude
G1
D1 (um2/s)
G2
D2 (um2/s)
Exp aplitude  (actual spelling in file format)
Exp time/Ch1 int
Triplet rate/Ch2 int
Fraction vesicle
Radius vesicle
Velocity modulus
Velocity x
Velocity y
Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • kwargs (Any)

Return type:

Self

Examples

>>> with SimfcsFit(DATA / 'simfcs.fit') as f:
...     dc_ref = f.asarray()
...     p_fit = f.p_fit(size=7)
...     f.totiff(TEMP / '_simfcs.fit.tif')
...     print(f'{p_fit[6, 1, 1]:.3f} {dc_ref[128, 128]:.2f}')
...
0.937 20.23
dc_ref()

Return intensity image as NumPy array.

Return type:

NDArray[numpy.float32]

p_fit(size=32)

Return fit parameters as NumPy array.

Parameters:

size (int) – Number of rows and columns of fit parameters array.

Return type:

NDArray[numpy.float64]

static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

asarray(*args, **kwargs)

Return data in file(s) as NumPy array.

Parameters:
  • **kwargs (Any) – Arguments passed to LfdFile._asarray().

  • args (Any)

  • **kwargs

Return type:

NDArray[Any]

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.SimfcsGpSeries(files, /, *, imread=None, pattern=None, container=None, sort=None)

Bases: LfdFileSequence

SimFCS generalized polarization image series.

SimFCS GP series contain intensity images from two channels, stored in separate SimfcsInt files with consecutive names.

Examples

>>> ims = SimfcsGpSeries(DATA / 'gpint/v*.int')
>>> ims.axes
'CI'
>>> ims = ims.asarray()
>>> ims.shape
(2, 135, 256, 256)
Parameters:
  • files (str | os.PathLike[Any] | Sequence[str | os.PathLike[Any]])

  • imread (Callable[..., NDArray[Any]] | type[LfdFile] | None)

  • pattern (str | None)

  • container (str | os.PathLike[Any] | None)

  • sort (Callable[..., Any] | bool | None)

__iter__()

Return iterator over all file names.

Return type:

Iterator[str]

asarray(*, imreadargs=None, chunkshape=None, chunkdtype=None, axestiled=None, ioworkers=1, out_inplace=None, out=None, **kwargs)

Return images from files as NumPy array.

Parameters:
  • imreadargs (dict[str, Any] | None) – Arguments passed to FileSequence.imread.

  • chunkshape (tuple[int, ...] | None) – Shape of chunk in each file. Must match FileSequence.imread(file, **imreadargs).shape. By default, this is determined by reading the first file.

  • chunkdtype (DTypeLike | None) – Data type of chunk in each file. Must match FileSequence.imread(file, **imreadargs).dtype. By default, this is determined by reading the first file.

  • axestiled (dict[int, int] | Sequence[tuple[int, int]] | None) – Axes to be tiled. Map stacked sequence axis to chunk axis.

  • ioworkers (int | None) – Maximum number of threads to execute FileSequence.imread asynchronously. If 0, use up to _TIFF.MAXIOWORKERS threads. Using threads can significantly improve runtime when reading many small files from a network share. If enabled, internal threading for the imread function should be disabled.

  • out_inplace (bool | None) – Decode directly into output array without intermediate copy. Not all FileSequence.imread functions support this, especially in non-contiguous cases.

  • out (OutputType) – Output array, ‘memmap’, or file for image data. By default, create a new array. If a numpy.ndarray, a writable array to which the images are copied. If ‘memmap’, create a memory-mapped array in a temporary file. If a string or open file, the file used to create a memory-mapped array.

  • **kwargs (Any) – Deprecated: Arguments passed to FileSequence.imread in addition to imreadargs.

Raises:

IndexError, ValueError – Array shapes do not match.

Return type:

NDArray[Any]

aszarr(**kwargs)

Return images from files as Zarr store.

Parameters:

**kwargs (Any) – Arguments passed to ZarrFileSequenceStore.

Return type:

ZarrFileSequenceStore

close()

Close open files.

Return type:

None

commonpath()

Return longest common sub-path of each file in sequence.

Return type:

str

property files_missing: int

Number of missing files in sequence.

class lfdfiles.SimfcsI64(filename, /, **kwargs)

Bases: LfdFile

SimFCS compressed intensity image.

SimFCS I64 files contain a single square intensity image, stored as a Zlib deflate compressed stream of one int32 (defining the image size in x and y dimensions) and the float32 image data. The measurement extension is usually encoded in the file name. Some files with an .i64 extension contain multiple images instead of a single image.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • dtype (DTypeLike | None) – Type of data in file.

  • maxsize (int) – Maximum square image length.

  • _offset (int)

  • kwargs (Any)

Examples

>>> with SimfcsI64(DATA / 'simfcs1000.i64') as f:
...     data = f.asarray()
...     f.totiff(TEMP / '_simfcs1000.i64.tif')
...     print(f.shape, data[128, 128])
...
(256, 256) 12.3125
static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

asarray(*args, **kwargs)

Return data in file(s) as NumPy array.

Parameters:
  • **kwargs (Any) – Arguments passed to LfdFile._asarray().

  • args (Any)

  • **kwargs

Return type:

NDArray[Any]

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.SimfcsInt(filename, /, **kwargs)

Bases: LfdFile

SimFCS intensity image.

SimFCS INT files contain a single intensity image stored as 256x256 values without any header. The data type is determined by file size: 262144-byte files contain float32 data; 131072-byte files contain uint16 data (older format). The measurement extension is usually encoded in the file name.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • kwargs (Any)

Return type:

Self

Examples

>>> with SimfcsInt(DATA / 'simfcs2036.int') as f:
...     print(f.asarray()[255, 255])
...
3.0
static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

asarray(*args, **kwargs)

Return data in file(s) as NumPy array.

Parameters:
  • **kwargs (Any) – Arguments passed to LfdFile._asarray().

  • args (Any)

  • **kwargs

Return type:

NDArray[Any]

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.SimfcsIntPhsMod(filename, /, **kwargs)

Bases: LfdFile

SimFCS lifetime component images.

SimFCS INT, PHS and MOD files contain fluorescence lifetime image data from frequency-domain measurements. Three 256x256 float32 images are stored in separate files: intensity (.int), phase (.phs) and modulation (.mod). Phase values are in degrees, modulation in percent. The measurement extension and channel are often encoded in the file name.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • kwargs (Any)

Return type:

Self

Examples

>>> with SimfcsIntPhsMod(DATA / 'simfcs_1000.phs') as f:
...     print(f.asarray().mean((1, 2)))
...
[5.717 0 0.04645]
static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

asarray(*args, **kwargs)

Return data in file(s) as NumPy array.

Parameters:
  • **kwargs (Any) – Arguments passed to LfdFile._asarray().

  • args (Any)

  • **kwargs

Return type:

NDArray[Any]

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.SimfcsJrn(filename, /, **kwargs)

Bases: LfdFile

SimFCS journal.

SimFCS JRN files contain metadata for several measurements, stored as key, value pairs in an unstructured ASCII format. Records usually start with lines of 80 ‘*’ characters. The files do not contain array data.

The metadata can be accessed as a list of dictionaries.

Parameters:
  • lower (bool) – Convert keys to lower case.

  • filename (os.PathLike[Any] | str)

  • _offset (int)

  • kwargs (Any)

Examples

>>> with SimfcsJrn(DATA / 'simfcs.jrn', lower=True) as f:
...     f[1]['paramters for tracking']['samplimg frequency']  # typo
...
15625
__getitem__(key, /)

Return selected record.

Parameters:

key (int)

Return type:

dict[str, str]

__len__()

Return number of records.

Return type:

int

__iter__()

Return iterator over records.

Return type:

Iterator[dict[str, str]]

static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

asarray(*args, **kwargs)

Return data in file(s) as NumPy array.

Parameters:
  • **kwargs (Any) – Arguments passed to LfdFile._asarray().

  • args (Any)

  • **kwargs

Return type:

NDArray[Any]

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.SimfcsR64(filename, /, **kwargs)

Bases: SimfcsRef

SimFCS compressed referenced fluorescence lifetime images.

SimFCS R64 files contain referenced fluorescence lifetime images. The data are stored as a Zlib deflate compressed stream of one int32 (defining the image size in x and y dimensions) and five (or more) square float32 images:

  1. dc - intensity

  2. ph1 - phase of 1st harmonic

  3. md1 - modulation of 1st harmonic

  4. ph2 - phase of 2nd harmonic

  5. md2 - modulation of 2nd harmonic

Phase values are in degrees, the modulation values are normalized. Phase and modulation values may be NaN.

Parameters:
  • dtype (DTypeLike | None) – Data type of image array.

  • maxsize (int) – Maximum square length of image array.

  • filename (os.PathLike[Any] | str)

  • _offset (int)

  • kwargs (Any)

Examples

>>> with SimfcsR64(DATA / 'simfcs.r64') as f:
...     data = f.asarray()
...     f.totiff(TEMP / '_simfcs.r64.tif')
...     print(f.shape, data[:, 100, 200])
...
(5, 256, 256) [0.25 23.22 0.642 104.3 2.117]
static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

asarray(*args, **kwargs)

Return data in file(s) as NumPy array.

Parameters:
  • **kwargs (Any) – Arguments passed to LfdFile._asarray().

  • args (Any)

  • **kwargs

Return type:

NDArray[Any]

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

lfdfiles.SimfcsRaw

alias of SimfcsBin

class lfdfiles.SimfcsRef(filename, /, **kwargs)

Bases: LfdFile

SimFCS referenced fluorescence lifetime images.

SimFCS REF files contain referenced fluorescence lifetime image data. Five square float32 images are stored consecutively. The image size is not stored explicitly and must be inferred from the total file size. Common files contain 256x256 images:

  1. dc - intensity

  2. ph1 - phase of 1st harmonic

  3. md1 - modulation of 1st harmonic

  4. ph2 - phase of 2nd harmonic

  5. md2 - modulation of 2nd harmonic

Phase values are in degrees, the modulation values are normalized. Phase and modulation values may be NaN.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • kwargs (Any)

Return type:

Self

Examples

>>> with SimfcsRef(DATA / 'simfcs.ref') as f:
...     data = f.asarray()
...     f.totiff(TEMP / '_simfcs.ref.tif')
...     print(f.shape, data[:, 255, 255])
...
(5, 256, 256) [301.3 44.71 0.6185 68.13 0.3174]
static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

asarray(*args, **kwargs)

Return data in file(s) as NumPy array.

Parameters:
  • **kwargs (Any) – Arguments passed to LfdFile._asarray().

  • args (Any)

  • **kwargs

Return type:

NDArray[Any]

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.SimfcsVpl(filename, /, **kwargs)

Bases: LfdFile

SimFCS or ImObj color palette.

SimFCS VPL files contain a single RGB color palette, stored as 256x3 unsigned bytes, preceded by a header. Files with a 22-byte header begin with the magic bytes b'vimage' and store the palette in Fortran order (3x256); files with a 24-byte header have no magic bytes and store the palette in C order (256x3).

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • kwargs (Any)

Return type:

Self

Examples

>>> with SimfcsVpl(DATA / 'simfcs.vpl') as f:
...     data = f.asarray()
...     f.totiff(TEMP / '_simfcs.vpl.tif')
...     print(f.shape, data[100])
...
(256, 3) [189 210 246]
static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

asarray(*args, **kwargs)

Return data in file(s) as NumPy array.

Parameters:
  • **kwargs (Any) – Arguments passed to LfdFile._asarray().

  • args (Any)

  • **kwargs

Return type:

NDArray[Any]

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.SimfcsVpp(filename, /, **kwargs)

Bases: LfdFile

SimFCS color palettes.

SimFCS VPP files contain multiple BGRA color palettes, each stored as 256x4 values of unsigned bytes preceded by a 24-byte Pascal string.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • kwargs (Any)

Return type:

Self

Examples

>>> with SimfcsVpp(DATA / 'simfcs.vpp') as f:
...     data = f.asarray('nice.vpl')
...     f.totiff(TEMP / '_simfcs.vpp.tif')
...     print(f.shape, data[100])
...
(256, 4) [ 16 255 239 255]
asarray(key=0, *, rgba=True, **kwargs)

Return palette data uint8 array of shape (256, 4).

Parameters:
  • key (str | int) – The index or name of the palette to return.

  • rgba (bool) – If True, return RGBA palette, else BGRA.

  • kwargs (Any)

Return type:

NDArray[numpy.uint8]

static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.SimfcsZ64(filename, /, **kwargs)

Bases: LfdFile

SimFCS compressed image stack.

SimFCS Z64 files contain stacks of square images such as intensity volumes or time-domain fluorescence lifetime histograms acquired from Becker and Hickl(r) TCSPC cards. The data are stored as a Zlib deflate compressed stream of two int32 values, defining the image size and number of images, followed by float32 image data. Some legacy files, especially names containing ‘allDC’, contain a duplicated header or report an incorrect image count.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • dtype (DTypeLike | None) – Data type of image array.

  • maxsize (tuple[int, int]) – Maximum square image length and number of images.

  • doubleheader (bool) – File contains two copies of header.

  • _offset (int)

  • kwargs (Any)

Examples

>>> with SimfcsZ64(DATA / 'simfcs.z64') as f:
...     data = f.asarray()
...     f.totiff(TEMP / '_simfcs.z64.tif')
...     print(f.shape, data[142, 128, 128])
...
(256, 256, 256) 2.0
static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

asarray(*args, **kwargs)

Return data in file(s) as NumPy array.

Parameters:
  • **kwargs (Any) – Arguments passed to LfdFile._asarray().

  • args (Any)

  • **kwargs

Return type:

NDArray[Any]

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.Vaa3dRaw(filename, /, **kwargs)

Bases: LfdFile

Vaa3D multi-channel volume data.

Vaa3D RAW files contain 4D CZYX multi-channel volume data.

The data is stored C-contiguously as uint8, uint16 or float32 in little or big-endian byte order, after a header defining data type, endianness, and shape.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • kwargs (Any)

Return type:

Self

Examples

>>> with Vaa3dRaw(DATA / 'vaa3d.v3draw') as f:
...     data = f.asarray()
...     f.totiff(TEMP / '_vaa3d.v3draw.tif')
...     print(f.shape, data[2, 100, 100, 100])
...
(3, 181, 217, 181) 138
static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

asarray(*args, **kwargs)

Return data in file(s) as NumPy array.

Parameters:
  • **kwargs (Any) – Arguments passed to LfdFile._asarray().

  • args (Any)

  • **kwargs

Return type:

NDArray[Any]

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.VistaIfi(filename, /, **kwargs)

Bases: LfdFile

VistaVision fluorescence intensity image.

VistaVision IFI files contain multi-dimensional confocal intensity images.

After a header of 256 bytes, the images are stored as float32 in CZYX order.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • kwargs (Any)

Return type:

Self

Examples

>>> f = VistaIfi(DATA / 'vista.ifi')
>>> data = f.asarray()
>>> f.axes
'CYX'
>>> print(f.header.dwelltime)
0.1
>>> data.shape
(2, 128, 128)
>>> f.totiff(TEMP / '_vista.ifi.tif')
>>> f.close()
__getitem__(key, /)

Return header attribute.

Parameters:

key (str)

Return type:

Any

property channel_indices: tuple[int, ...]

Indices of valid channels.

static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

asarray(*args, **kwargs)

Return data in file(s) as NumPy array.

Parameters:
  • **kwargs (Any) – Arguments passed to LfdFile._asarray().

  • args (Any)

  • **kwargs

Return type:

NDArray[Any]

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.VistaIfli(filename, /, **kwargs)

Bases: LfdFile

VistaVision fluorescence lifetime image.

VistaVision IFLI files contain phasor images for several positions, wavelengths, time points, channels, slices, and frequencies from analog or digital frequency domain fluorescence lifetime measurements. After a version dependent header of 1024 bytes, the image is stored as a 9-dimensional arrays of float32 and shape (position, wavelength, time, channel, Z, Y, X, frequency, sample). The phasor array has three samples: the average intensity (DC) and the real (g) and imaginary (s) parts of the phasor. Additional metadata may be stored in an associated XML file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • kwargs (Any)

Return type:

Self

Examples

>>> f = VistaIfli(DATA / 'vista.ifli')
>>> data = f.asarray(memmap=True)
>>> f.header['ModFrequency']
(48000000.0, 96000000.0)
>>> data.shape
(1, 1, 1, 2, 1, 128, 128, 2, 3)
>>> f.totiff(TEMP / '_vista.ifli.tif')
>>> f.close()
property channel_indices: tuple[int, ...]

Indices of valid channels.

asarray(*, memmap=False, **kwargs)

Return average intensity and phasor coordinates from file.

The returned array is of shape (position, wavelength, time, channel, Z, Y, X, frequency, sample) and type float32. The three samples are the average intensity (DC) and the real (g) and imaginary (s) parts of the phasor.

Parameters:
  • memmap (bool) – If True, use numpy.memmap to read array.

  • kwargs (Any)

Return type:

NDArray[Any]

static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.VistaTdflim(filename, /, **kwargs)

Bases: LfdFile

ISS Vista time-domain fluorescence lifetime image.

VistaTdflim files are ZIP archives containing acquisition metadata in dataProps/Core.xml and raw photon histogram data in data/PrimaryDecayData.bin.

Two binary format variants exist, identified by the <FileVersion> element in the XML:

  • Version 1 (<FileVersion> absent): uint16, dimension order TCYXH.

  • Version 2 (<iVersionNumber>2</iVersionNumber>): uint32, dimension order TCYX(H+2). The last dimension contains two trailing uint32 words per pixel (reserved zero word and a pre-computed float32 lifetime preview).

The returned array has shape (T, C, Y, X, H), where T is the number of time series points, C is the channel count, Y and X are spatial dimensions, and H is the photon histogram bin count.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • kwargs (Any)

Return type:

Self

Examples

>>> with VistaTdflim(DATA / 'version1.iss-tdflim') as f:
...     data = f.asarray()
...     f.axes
...
'TCYXH'
>>> data.shape
(1, 2, 128, 128, 1024)
>>> with VistaTdflim(DATA / 'version2.iss-tdflim') as f:
...     data = f.asarray()
...     data.shape
...
(1, 1, 128, 128, 4096)
lifetime()

Return lifetime image from version 2 file as NumPy array.

The returned array has shape (T, C, Y, X) and type float32. The lifetime values are pre-computed by the ISS Vista acquisition software.

Return type:

NDArray[numpy.float32]

static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

asarray(*args, **kwargs)

Return data in file(s) as NumPy array.

Parameters:
  • **kwargs (Any) – Arguments passed to LfdFile._asarray().

  • args (Any)

  • **kwargs

Return type:

NDArray[Any]

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

class lfdfiles.VoxxMap(filename, /, **kwargs)

Bases: LfdFile

Voxx color palette.

Voxx map files contain a single RGBA color palette, stored as 256x4 whitespace separated integers (0..255) in an ASCII file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • kwargs (Any)

Return type:

Self

Examples

>>> with VoxxMap(DATA / 'voxx.map') as f:
...     data = f.asarray()
...     f.totiff(TEMP / '_voxx.map.tif')
...     print(f.shape, data[100])
...
(256, 4) [255 227 155 237]
static __new__(cls, filename, /, **kwargs)

Return LfdFile subclass instance that can open filename.

Parameters:
  • filename (os.PathLike[Any] | str)

  • kwargs (Any)

Return type:

Self

asarray(*args, **kwargs)

Return data in file(s) as NumPy array.

Parameters:
  • **kwargs (Any) – Arguments passed to LfdFile._asarray().

  • args (Any)

  • **kwargs

Return type:

NDArray[Any]

close()

Close file handle.

Call LfdFile._close().

Return type:

None

property filename: str

Name of file.

property ndim: int | None

Number of dimensions in data array.

classmethod open(filename, /, *, registry=None, skip=None, validate=True, **kwargs)

Return LfdFile subclass instance that can read filename.

Iterate registered LfdFile subclasses and return an instance of the first class that can successfully open the file.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to open.

  • registry (Sequence[type[LfdFile]] | None) – Sequence of LfdFile subclasses to try. If None, use all registered subclasses.

  • skip (set[type[LfdFile]] | None) – Set of LfdFile subclasses to skip when probing. If None and validate is False, skip overly generic formats.

  • validate (bool) – If True, filename must match the class’s file pattern.

  • **kwargs (Any) – Arguments passed to the subclass constructor.

Raises:

LfdFileError – If no registered class can open filename.

Return type:

LfdFile

Examples

>>> with LfdFile.open(DATA / 'flimfast.flif') as f:
...     type(f)
...
<class '...FlimfastFlif'>
show(**kwargs)

Display data in matplotlib figure.

Parameters:

**kwargs (Any) – Arguments passed to LfdFile._plot().

Return type:

None

property size: int | None

Number of elements in data array.

totiff(filename=None, /, **kwargs)

Write image(s) and metadata to TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str | None) – Name of TIFF file to write.

  • **kwargs (Any) – Arguments passed to LfdFile._totiff().

Return type:

None

lfdfiles.bioradpic_write(filename, data, /, *, axis='Z', spacing=None, origin=None, name=None, lens=1, mag_factor=1.0, image_number=0, merged=0, edited=0, ramp1_min=0, ramp1_max=0, color1=0, ramp2_min=0, ramp2_max=0, color2=0)

Write volume or multi-channel data to Bio-Rad(tm) PIC formatted file.

This implementation does not currently allow writing multi-file datasets, advanced metadata, or color palettes.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to write.

  • data (ArrayLike) – Data to write. Must be two or three-dimensional of type uint8 or uint16.

  • spacing (Sequence[float] | None) – Position and spacing of pixel or voxel in micrometer.

  • origin (Sequence[float] | None) – Position and spacing of pixel or voxel in micrometer.

  • name (str | None) – Refer to the Biorad PIC header documentation.

  • lens (int) – Refer to the Biorad PIC header documentation.

  • mag_factor (float) – Refer to the Biorad PIC header documentation.

  • image_number (int) – Refer to the Biorad PIC header documentation.

  • merged (int) – Refer to the Biorad PIC header documentation.

  • edited (int) – Refer to the Biorad PIC header documentation.

  • ramp1_min (int) – Refer to the Biorad PIC header documentation.

  • ramp1_max (int) – Refer to the Biorad PIC header documentation.

  • color1 (int) – Refer to the Biorad PIC header documentation.

  • ramp2_min (int) – Refer to the Biorad PIC header documentation.

  • ramp2_max (int) – Refer to the Biorad PIC header documentation.

  • color2 (int) – Refer to the Biorad PIC header documentation.

  • axis (str)

Return type:

None

Examples

>>> data = numpy.arange(1000000).reshape((100, 100, 100)).astype('u1')
>>> bioradpic_write(TEMP / '_test.pic', data)
>>> with BioradPic(TEMP / '_test.pic') as f:
...     assert numpy.array_equal(f.asarray(), data)
...
lfdfiles.ccp4map_write(filename, data, /, *, start=(0, 0, 0), cell_interval=None, cell_length=None, cell_angle=(90, 90, 90), map_src=(3, 2, 1), density=None, density_rms=0, spacegroup=1, skew_matrix=None, skew_translation=None, symboltable=b'', labels=(b'Created by lfdfiles.py',))

Write 3D volume data to CCP4 MAP formatted file.

Parameters:
Return type:

None

Examples

>>> data = numpy.arange(1000000).reshape((100, 100, 100)).astype('f4')
>>> ccp4map_write(TEMP / '_test.ccp4', data)
>>> with Ccp4Map(TEMP / '_test.ccp4') as f:
...     assert numpy.array_equal(f.asarray(), data)
...
lfdfiles.convert2tiff(files, /, *, verbose=True, skip=None, **kwargs)

Convert image data from LfdFile(s) to TIFF files.

Parameters:
  • files (str | os.PathLike[Any] | Sequence[str | os.PathLike[Any]]) – Files to convert to TIFF.

  • verbose (bool) – Print conversion status.

  • skip (Sequence[type[LfdFile]] | None) – File types not to use for conversion. The default is SimfcsBin, SimfcsRaw, SimfcsCyl, FliezI16.

  • kwargs (Any)

Return type:

None

Examples

>>> convert2tiff(DATA / 'flimfast.flif', verbose=False)
lfdfiles.simfcsb64_write(filename, data, /)

Write array of square int16 images to B64 file.

Refer to SimfcsB64 for the B64 file format.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to write.

  • data (ArrayLike) – Data to write to file. Must be of shape (-1, size, size) and type int16.

Return type:

None

Examples

>>> data = (
...     numpy.arange(5 * 256 * 256)
...     .reshape((5, 256, 256))
...     .astype('int16')
... )
>>> simfcsb64_write(TEMP / '_test.b64', data)
>>> with SimfcsB64(TEMP / '_test.b64') as f:
...     assert numpy.array_equal(f.asarray(), data)
...
lfdfiles.simfcsi64_write(filename, data, /)

Write a single float32 image to I64 file.

Refer to SimfcsI64 for the I64 file format.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to write.

  • data (ArrayLike) – Data to write. Must be of shape (size, size) and type float32.

Return type:

None

Examples

>>> data = numpy.arange(256 * 256).reshape((256, 256)).astype('f4')
>>> simfcsi64_write(TEMP / '_test.i64', data)
>>> with SimfcsI64(TEMP / '_test.i64') as f:
...     assert numpy.array_equal(f.asarray(), data)
...
lfdfiles.simfcsr64_write(filename, data, /)

Write referenced data to R64 file.

Refer to SimfcsR64 for the format of referenced data.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to write.

  • data (ArrayLike) – Referenced data to write. Must be of shape (5, size, size) and type float32.

Return type:

None

Examples

>>> data = (
...     numpy.arange(5 * 256 * 256).reshape((5, 256, 256)).astype('f4')
... )
>>> simfcsr64_write(TEMP / '_test.r64', data)
>>> with SimfcsR64(TEMP / '_test.r64') as f:
...     assert numpy.array_equal(f.asarray(), data)
...
lfdfiles.simfcsz64_write(filename, data, /)

Write stack of float32 images to Z64 file.

Refer to SimfcsZ64 for the Z64 file format.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to write.

  • data (ArrayLike) – Data to write. Must be of shape (-1, size, size) and type float32.

Return type:

None

Examples

>>> data = (
...     numpy.arange(5 * 256 * 256).reshape((5, 256, 256)).astype('f4')
... )
>>> simfcsz64_write(TEMP / '_test.z64', data)
>>> with SimfcsZ64(TEMP / '_test.z64') as f:
...     assert numpy.array_equal(f.asarray(), data)
...
lfdfiles.vaa3draw_write(filename, data, /, *, byteorder=None, twobytes=False)

Write data to Vaa3D RAW binary file(s).

Refer to Vaa3dRaw for the v3draw file format.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to write.

  • data (ArrayLike) – Data to write. Must be of type uint8, uint16, or float32 with up to 5 dimensions ordered ‘TCZYX’. Time points are stored in separate files.

  • byteorder (Literal['>', '<'] | None) – Byte order of data in file.

  • twobytes (bool) – If True, store data shape as int16, else uint32 (default).

Return type:

None

Examples

>>> data = (
...     numpy.arange(1000000)
...     .reshape((10, 10, 100, 100))
...     .astype('uint16')
... )
>>> vaa3draw_write(TEMP / '_test.v3draw', data, byteorder='<')
>>> with Vaa3dRaw(TEMP / '_test.v3draw') as f:
...     assert numpy.array_equal(f.asarray(), data)
...
lfdfiles.voxxmap_write(filename, data, /)

Write data to Voxx map file(s).

Refer to VoxxMap for the Voxx map format.

Parameters:
  • filename (os.PathLike[Any] | str) – Name of file to write.

  • data (ArrayLike) – Data to write. Must be of shape (256, 4) and type uint8.

Return type:

None

Examples

>>> data = numpy.repeat(numpy.arange(256, dtype='uint8'), 4).reshape(
...     (-1, 4)
... )
>>> voxxmap_write(TEMP / '_test_vox.map', data)
>>> with VoxxMap(TEMP / '_test_vox.map') as f:
...     assert numpy.array_equal(f.asarray(), data)
...
lfdfiles.FILE_EXTENSIONS

Supported LFD file extensions.