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
FlimFast FLIF
- Author:
- License:
BSD-3-Clause
- Version:
2026.4.30
- DOI:
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):
CPython 3.12.10, 3.13.13, 3.14.4 64-bit
NumPy 2.4.4
Tifffile 2026.4.11
Matplotlib 3.10.9 (optional, for plotting)
Click 8.3.3 (optional, for command line apps)
Revisions¶
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:
SimFCS, a.k.a. Globals for Images, is software for fluorescence image acquisition, analysis, and simulation, developed by Enrico Gratton at UCI.
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.
ImObj is software for image analysis, developed by LFD at UIUC. Implemented on Win16.
FlimFast is software for frequency-domain, full-field, fluorescence lifetime imaging at video rate, developed by Christoph Gohlke at UIUC.
FLImage is software for frequency-domain, full-field, fluorescence lifetime imaging, developed by Christoph Gohlke at UIUC. Implemented in LabVIEW.
FLIez is software for frequency-domain, full-field, fluorescence lifetime imaging, developed by Glen Redford at UIUC.
Flie is software for frequency-domain, full-field, fluorescence lifetime imaging, developed by Peter Schneider at MPIBPC. Implemented on a Sun UltraSPARC.
FLOP97 is software for frequency-domain, cuvette, fluorescence lifetime measurements, developed by Christoph Gohlke at MPIBPC. Implemented in LabVIEW.
VistaVision is commercial software for instrument control, data acquisition and data processing by ISS Inc (Champaign, IL).
Vaa3D is software for multi-dimensional data visualization and analysis, developed by the Hanchuan Peng group at the Allen Institute.
Voxx is a volume rendering program for 3D microscopy, developed by Jeff Clendenon et al. at the Indiana University.
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__ = '2026.4.30'¶
Lfdfiles version string.
- class lfdfiles.BioradPic(filename, /, **kwargs)¶
Bases:
LfdFileBio-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
- _filepattern = '.*\\.pic$'¶
Regular expression pattern matching valid file names.
- _filesizemin = 76¶
Minimum file size.
- _figureargs: ClassVar[dict[str, Any]] = {'figsize': (8, 6)}¶
Arguments passed to
pyplot.figure.
- header: dict[str, Any]¶
Select values of header structure.
- notes: list[tuple[str, int, int, int, int]]¶
Additional information about images.
- origin: tuple[float, ...]¶
Position of first pixel or voxel in micrometer.
- spacing: tuple[float, ...]¶
Spacing of pixels or voxels in micrometer.
- class lfdfiles.Ccp4Map(filename, /, **kwargs)¶
Bases:
LfdFileCCP4 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
- _filepattern = '.*\\.(map|ccp4)$'¶
Regular expression pattern matching valid file names.
- _filesizemin = 1104¶
Minimum file size.
- start: tuple[int, int, int]¶
Position of first section, row, and column (voxel grid units).
- cell_interval: tuple[int, int, int]¶
Intervals per unit cell repeat along Z, Y, X.
- cell_length: tuple[float, float, float]¶
Unit Cell repeats along Z, Y, X in Angstroms.
- cell_angle: tuple[float, float, float]¶
Unit Cell angles (alpha, beta, gamma) in degrees.
- map_src: tuple[int, int, int]¶
Relationship of Z, Y, X axes to sections, rows, columns.
- skew_translation: NDArray[numpy.float64] | None¶
Translation vector.
- skew_matrix: NDArray[numpy.float64] | None¶
Skew matrix.
- symboltable: list[bytes]¶
Symmetry records as defined in International Tables.
- labels: list[bytes]¶
Column labels.
- density_min: float¶
Minimum density.
- density_max: float¶
Maximum density.
- density_mean: float¶
Average density.
- density_rms: float¶
RMS deviation of map from mean density.
- spacegoup: int¶
IUCr space group number (1-230).
- asarray(*, memmap=False, **kwargs)¶
Return volume data as NumPy array.
- Parameters:
memmap (bool) – If True, use
numpy.memmapto read array.kwargs (Any)
- Return type:
NDArray[Any]
- class lfdfiles.FlieOut(filename, /, **kwargs)¶
Bases:
LfdFileFlie 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]
- _filepattern = '(off|phi|mod)_.*\\.out$'¶
Regular expression pattern matching valid file names.
- _figureargs: ClassVar[dict[str, Any]] = {'figsize': (6, 7)}¶
Arguments passed to
pyplot.figure.
- class lfdfiles.FliezDb2(filename, /, **kwargs)¶
Bases:
LfdFileFLIez 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
- _filepattern = '.*\\.db2$'¶
Regular expression pattern matching valid file names.
- class lfdfiles.FliezI16(filename, /, **kwargs)¶
Bases:
LfdFileFLIez 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]
- _filepattern = '.*\\.i16$'¶
Regular expression pattern matching valid file names.
- class lfdfiles.FlimageBin(filename, /, **kwargs)¶
Bases:
LfdFileFLImage 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]
- _filepattern = '.*\\.(int|mod|phi|tmd|tph)\\.bin$'¶
Regular expression pattern matching valid file names.
- _figureargs: ClassVar[dict[str, Any]] = {'figsize': (6, 7)}¶
Arguments passed to
pyplot.figure.
- class lfdfiles.FlimfastFlif(filename, /, **kwargs)¶
Bases:
LfdFileFlimFast 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()
- _filepattern = '.*\\.flif$'¶
Regular expression pattern matching valid file names.
- _figureargs: ClassVar[dict[str, Any]] = {'figsize': (6, 7)}¶
Arguments passed to
pyplot.figure.
- header: numpy.recarray[Any, Any]¶
File header.
- records: numpy.recarray[Any, Any]¶
Frame header.
- class lfdfiles.GlobalsAscii(filename, /, **kwargs)¶
Bases:
LfdFileGlobals 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
getiteminterface. 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)
- _filemode = 'r'¶
File open mode.
- _fileencoding = 'cp1252'¶
Text file encoding.
- _filepattern = '.*\\.(\\d){3}$'¶
Regular expression pattern matching valid file names.
- _figureargs: ClassVar[dict[str, Any]] = {'figsize': (6, 5)}¶
Arguments passed to
pyplot.figure.
- __getitem__(key, /)¶
Return value of key in record.
- Parameters:
key (str)
- Return type:
Any
- class lfdfiles.GlobalsLif(filename, /, **kwargs)¶
Bases:
LfdFileGlobals 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)
- _filepattern = '.*\\.lif$'¶
Regular expression pattern matching valid file names.
- class Record¶
Bases:
dict[str,object]Record in GlobalsLif files.
- asarray()¶
Return record array data.
- Return type:
NDArray[Any]
- __str__()¶
Return str(self).
- Return type:
str
- __weakref__¶
list of weak references to the object
- 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]
- __len__()¶
Return number of records.
- Return type:
int
- class lfdfiles.LfdFile(filename, /, **kwargs)¶
Bases:
objectBase 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 __init_subclass__(**kwargs)¶
This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
- Parameters:
kwargs (Any)
- Return type:
None
- _filemode: ClassVar[str] = 'rb'¶
File open mode.
- _fileencoding: ClassVar[str | None] = None¶
Text file encoding.
- _filepattern: ClassVar[str] = '.*'¶
Regular expression pattern matching valid file names.
- _filesizemin: ClassVar[int] = 16¶
Minimum file size.
- _noplot: ClassVar[bool] = False¶
Plotting disabled.
- _figureargs: ClassVar[dict[str, Any]] = {'figsize': (6, 8.5)}¶
Arguments passed to
pyplot.figure.
- 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
Noneand 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:
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
- __init__(filename, /, *, _offset=0, **kwargs)¶
- Parameters:
filename (os.PathLike[Any] | str)
_offset (int)
kwargs (Any)
- Return type:
None
- shape: tuple[int, ...] | None¶
Shape of data array contained in file.
- dtype: numpy.dtype[Any] | None¶
Type of array data contained in file.
- axes: str | None¶
Character codes of array axes.
- __repr__()¶
Return repr(self).
- Return type:
str
- __str__()¶
Return str(self).
- Return type:
str
- 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.
- _init(**kwargs)¶
Validate file and read metadata.
- Parameters:
kwargs (Any)
- Return type:
None
- _close()¶
Free any allocated resources.
- Return type:
None
- classmethod _components(filename, /)¶
Return possible names of component files.
- Parameters:
filename (str)
- Return type:
list[tuple[str, str]]
- _asarray(**kwargs)¶
Read data from file and return as NumPy array.
- Parameters:
kwargs (Any)
- Return type:
NDArray[Any]
- _totiff(tif, /, **kwargs)¶
Write image and metadata to TIFF file.
- Parameters:
tif (TiffWriter)
kwargs (Any)
- Return type:
None
- _plot(figure, /, **kwargs)¶
Display data in matplotlib figure.
- Parameters:
figure (Figure)
kwargs (Any)
- Return type:
None
- _str()¶
Return extra information about file.
- Return type:
str | None
- __weakref__¶
list of weak references to the object
- class lfdfiles.LfdFileError(arg='', /, msg='')¶
Bases:
ValueErrorException to indicate invalid LFD files.
- Parameters:
arg (LfdFile | str) – Error message or LfdFile instance where error occurred.
msg (str) – Additional error message.
- __weakref__¶
list of weak references to the object
- class lfdfiles.LfdFileSequence(files, /, *, imread=None, pattern=None, container=None, sort=None)¶
Bases:
FileSequenceSeries 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
filesis 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()
- _readfunction: ClassVar[type[LfdFile] | Callable[..., NDArray[Any]] | None] = None¶
Function or class to read image array from single file.
- _indexpattern: ClassVar[str | None] = None¶
Regex pattern for axes names and chunk indices in filenames.
- __init__(files, /, *, imread=None, pattern=None, container=None, sort=None)¶
- class lfdfiles.RawPal(filename, /, **kwargs)¶
Bases:
LfdFileRaw 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]
- _filepattern = '.*\\.(pal|raw|bin|lut)$'¶
Regular expression pattern matching valid file names.
- _figureargs: ClassVar[dict[str, Any]] = {'figsize': (6, 1)}¶
Arguments passed to
pyplot.figure.
- 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]
- class lfdfiles.SimfcsB64(filename, /, **kwargs)¶
Bases:
LfdFileSimFCS 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
- _filepattern = '.*\\.b64$'¶
Regular expression pattern matching valid file names.
- __init__(filename, /, *, dtype='<i2', maxsize=4096, _offset=0, **kwargs)¶
- Parameters:
filename (os.PathLike[Any] | str)
dtype (DTypeLike | None)
maxsize (int)
_offset (int)
kwargs (Any)
- Return type:
None
- class lfdfiles.SimfcsBh(filename, /, **kwargs)¶
Bases:
LfdFileSimFCS 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
- _filepattern = '.*\\.(b&h)$'¶
Regular expression pattern matching valid file names.
- class lfdfiles.SimfcsBhz(filename, /, **kwargs)¶
Bases:
SimfcsBhSimFCS 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
- _filepattern = '.*\\.(bhz)$'¶
Regular expression pattern matching valid file names.
- class lfdfiles.SimfcsBin(filename, /, **kwargs)¶
Bases:
LfdFileSimFCS 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
- _filepattern = '.*\\.(bin|raw)$'¶
Regular expression pattern matching valid file names.
- __init__(filename, /, *, shape=None, dtype=None, offset=0, validate_size=True, _offset=0, **kwargs)¶
- Parameters:
filename (os.PathLike[Any] | str)
shape (tuple[int, ...] | None)
dtype (DTypeLike | None)
offset (int)
validate_size (bool)
_offset (int)
kwargs (Any)
- Return type:
None
- 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]
- class lfdfiles.SimfcsCyl(filename, /, **kwargs)¶
Bases:
LfdFileSimFCS 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]
- _filepattern = '.*\\.cyl$'¶
Regular expression pattern matching valid file names.
- _figureargs: ClassVar[dict[str, Any]] = {'figsize': (6, 3)}¶
Arguments passed to
pyplot.figure.
- __init__(filename, /, *, shape=(2, -1, 256), _offset=0, **kwargs)¶
- Parameters:
filename (os.PathLike[Any] | str)
shape (tuple[int, int, int])
_offset (int)
kwargs (Any)
- Return type:
None
- class lfdfiles.SimfcsFit(filename, /, **kwargs)¶
Bases:
LfdFileSimFCS 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
- _filepattern = '.*\\.fit$'¶
Regular expression pattern matching valid file names.
- 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]
- class lfdfiles.SimfcsGpSeries(files, /, *, imread=None, pattern=None, container=None, sort=None)¶
Bases:
LfdFileSequenceSimFCS generalized polarization image series.
SimFCS GP series contain intensity images from two channels, stored in separate
SimfcsIntfiles with consecutive names.Examples
>>> ims = SimfcsGpSeries(DATA / 'gpint/v*.int') >>> ims.axes 'CI' >>> ims = ims.asarray() >>> ims.shape (2, 135, 256, 256)
- Parameters:
- _indexpattern = '(?P<C>\\d)(?P<I>\\d+)\\.int'¶
Regex pattern for axes names and chunk indices in filenames.
- class lfdfiles.SimfcsI64(filename, /, **kwargs)¶
Bases:
LfdFileSimFCS 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
.i64extension 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
- _filepattern = '.*\\.i64$'¶
Regular expression pattern matching valid file names.
- __init__(filename, /, *, dtype='<f4', maxsize=1024, _offset=0, **kwargs)¶
- Parameters:
filename (os.PathLike[Any] | str)
dtype (DTypeLike | None)
maxsize (int)
_offset (int)
kwargs (Any)
- Return type:
None
- class lfdfiles.SimfcsInt(filename, /, **kwargs)¶
Bases:
LfdFileSimFCS 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
- _filepattern = '.*\\.(int|ac)$'¶
Regular expression pattern matching valid file names.
- class lfdfiles.SimfcsIntPhsMod(filename, /, **kwargs)¶
Bases:
LfdFileSimFCS 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]
- _filepattern = '.*\\.(int|phs|mod)$'¶
Regular expression pattern matching valid file names.
- _figureargs: ClassVar[dict[str, Any]] = {'figsize': (6, 8)}¶
Arguments passed to
pyplot.figure.
- class lfdfiles.SimfcsJrn(filename, /, **kwargs)¶
Bases:
LfdFileSimFCS 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
- _filemode = 'r'¶
File open mode.
- _fileencoding = 'cp1252'¶
Text file encoding.
- _filepattern = '.*\\.jrn$'¶
Regular expression pattern matching valid file names.
- _noplot = True¶
Plotting disabled.
- __init__(filename, /, *, lower=False, _offset=0, **kwargs)¶
- Parameters:
filename (os.PathLike[Any] | str)
lower (bool)
_offset (int)
kwargs (Any)
- Return type:
None
- __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]]
- class lfdfiles.SimfcsR64(filename, /, **kwargs)¶
Bases:
SimfcsRefSimFCS 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:
dc - intensity
ph1 - phase of 1st harmonic
md1 - modulation of 1st harmonic
ph2 - phase of 2nd harmonic
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]
- _filepattern = '.*\\.r64$'¶
Regular expression pattern matching valid file names.
- __init__(filename, /, *, dtype='<f4', maxsize=1024, _offset=0, **kwargs)¶
- Parameters:
filename (os.PathLike[Any] | str)
dtype (DTypeLike | None)
maxsize (int)
_offset (int)
kwargs (Any)
- Return type:
None
- class lfdfiles.SimfcsRef(filename, /, **kwargs)¶
Bases:
LfdFileSimFCS 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:
dc - intensity
ph1 - phase of 1st harmonic
md1 - modulation of 1st harmonic
ph2 - phase of 2nd harmonic
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]
- _filepattern = '.*\\.ref$'¶
Regular expression pattern matching valid file names.
- _figureargs: ClassVar[dict[str, Any]] = {'figsize': (6, 11)}¶
Arguments passed to
pyplot.figure.
- class lfdfiles.SimfcsVpl(filename, /, **kwargs)¶
Bases:
LfdFileSimFCS 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]
- _filepattern = '.*\\.vpl$'¶
Regular expression pattern matching valid file names.
- _figureargs: ClassVar[dict[str, Any]] = {'figsize': (6, 1)}¶
Arguments passed to
pyplot.figure.
- name: str | None¶
Name of palette.
- class lfdfiles.SimfcsVpp(filename, /, **kwargs)¶
Bases:
LfdFileSimFCS 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]
- _filepattern = '.*\\.vpp$'¶
Regular expression pattern matching valid file names.
- _filesizemin = 24¶
Minimum file size.
- names: list[str]¶
Names of palettes in file.
- 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]
- class lfdfiles.SimfcsZ64(filename, /, **kwargs)¶
Bases:
LfdFileSimFCS 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
- _filepattern = '.*\\.(z64|i64)$'¶
Regular expression pattern matching valid file names.
- _filesizemin = 32¶
Minimum file size.
- __init__(filename, /, *, dtype='<f4', maxsize=(256, 1024), doubleheader=False, _offset=0, **kwargs)¶
- Parameters:
filename (os.PathLike[Any] | str)
dtype (DTypeLike | None)
maxsize (tuple[int, int])
doubleheader (bool)
_offset (int)
kwargs (Any)
- Return type:
None
- class lfdfiles.Vaa3dRaw(filename, /, **kwargs)¶
Bases:
LfdFileVaa3D 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
- _filepattern = '.*\\.(v3draw|raw)$'¶
Regular expression pattern matching valid file names.
- _filesizemin = 35¶
Minimum file size.
- _figureargs: ClassVar[dict[str, Any]] = {'figsize': (8, 8)}¶
Arguments passed to
pyplot.figure.
- class lfdfiles.VistaIfi(filename, /, **kwargs)¶
Bases:
LfdFileVistaVision 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()
- _filepattern = '.*\\.ifi$'¶
Regular expression pattern matching valid file names.
- header: numpy.recarray[Any, Any]¶
File header.
- __getitem__(key, /)¶
Return header attribute.
- Parameters:
key (str)
- Return type:
Any
- property channel_indices: tuple[int, ...]¶
Indices of valid channels.
- class lfdfiles.VistaIfli(filename, /, **kwargs)¶
Bases:
LfdFileVistaVision 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()
- _filepattern = '.*\\.ifli$'¶
Regular expression pattern matching valid file names.
- _figureargs: ClassVar[dict[str, Any]] = {'figsize': (8, 7.5)}¶
Arguments passed to
pyplot.figure.
- header: dict[str, Any]¶
Metadata from file header.
- offsets: dict[str, Any]¶
Data offsets from file header.
- 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.memmapto read array.kwargs (Any)
- Return type:
NDArray[Any]
- class lfdfiles.VoxxMap(filename, /, **kwargs)¶
Bases:
LfdFileVoxx 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]
- _filemode = 'r'¶
File open mode.
- _fileencoding = 'latin-1'¶
Text file encoding.
- _filepattern = '.*\\.map$'¶
Regular expression pattern matching valid file names.
- _figureargs: ClassVar[dict[str, Any]] = {'figsize': (6, 1)}¶
Arguments passed to
pyplot.figure.
- 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:
filename (os.PathLike[Any] | str) – Name of file to write.
data (ArrayLike) – Volume data to write.
start (Sequence[int]) – See
Ccp4Map.cell_interval (Sequence[int] | None) – See
Ccp4Map.cell_length (Sequence[float] | None) – See
Ccp4Map.cell_angle (Sequence[int]) – See
Ccp4Map.map_src (Sequence[int]) – See
Ccp4Map.density (Sequence[float] | None) – See
Ccp4Map.density_rms (int) – See
Ccp4Map.spacegroup (int) – See
Ccp4Map.skew_matrix (ArrayLike | None) – See
Ccp4Map.skew_translation (ArrayLike | None) – See
Ccp4Map.symboltable (bytes) – See
Ccp4Map.labels (Sequence[bytes]) – See
Ccp4Map.
- 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:
- 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
SimfcsB64for 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
SimfcsI64for 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
SimfcsR64for 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
SimfcsZ64for 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
Vaa3dRawfor 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
VoxxMapfor 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¶