..
  This file is generated by setup.py

Read Olympus image files (OIF and OIB)
======================================

Oiffile is a Python library to read image and metadata from Olympus Image
Format files. OIF is the native file format of the Olympus FluoView(tm)
software for confocal microscopy.

There are two variants of the format:

- OIF (Olympus Image File) is a multi-file format that includes a main setting
  file (.oif) and an associated directory with data and setting files (.tif,
  .bmp, .txt, .pty, .roi, and .lut).

- OIB (Olympus Image Binary) is a compound document file, storing OIF and
  associated files within a single file.

:Author: `Christoph Gohlke <https://www.cgohlke.com>`_
:License: BSD-3-Clause
:Version: 2025.5.10

Quickstart
----------

Install the oiffile package and all dependencies from the
`Python Package Index <https://pypi.org/project/oiffile/>`_::

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

View image and metadata stored in an OIF or OIB file::

    python -m oiffile file.oif

See `Examples`_ for using the programming interface.

Source code and support are available on
`GitHub <https://github.com/cgohlke/oiffile>`_.

Requirements
------------

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

- `CPython <https://www.python.org>`_ 3.10.11, 3.11.9, 3.12.10, 3.13.3 64-bit
- `NumPy <https://pypi.org/project/numpy/>`_ 2.2.5
- `Tifffile <https://pypi.org/project/tifffile/>`_ 2025.5.10

Revisions
---------

2025.5.10

- Remove doctest command line option.
- Support Python 3.14.

2025.1.1

- Improve type hints.
- Drop support for Python 3.9, support Python 3.13.

2024.5.24

- Support NumPy 2.
- Fix docstring examples not correctly rendered on GitHub.

2023.8.30

- Fix linting issues.
- Add py.typed marker.
- Drop support for Python 3.8 and numpy < 1.22 (NEP29).

2022.9.29

- Switch to Google style docstrings.

2022.2.2

- Add type hints.
- Add main function.
- Add FileSystemAbc abstract base class.
- Remove OifFile.tiffs (breaking).
- Drop support for Python 3.7 and numpy < 1.19 (NEP29).

2021.6.6

- Fix unclosed file warnings.

2020.9.18

- Remove support for Python 3.6 (NEP 29).
- Support os.PathLike file names.
- Fix unclosed files.

2020.1.18

- Fix indentation error.

2020.1.1

- Support multiple image series.
- Parse shape and dtype from settings file.
- Remove support for Python 2.7 and 3.5.
- Update copyright.

Notes
-----

No specification document is available.

Tested only with files produced on Olympus FV1000 hardware.

Examples
--------

Read the image from an OIB file as numpy array:

.. code-block:: python

    >>> image = imread('test.oib')
    >>> image.shape
    (3, 256, 256)
    >>> image[:, 95, 216]
    array([820,  50, 436], dtype=uint16)

Read the image from a single TIFF file in an OIB file:

.. code-block:: python

    >>> from tifffile import natural_sorted
    >>> with OifFile('test.oib') as oib:
    ...     filename = natural_sorted(oib.glob('*.tif'))[0]
    ...     image = oib.asarray(filename)
    ...
    >>> filename
    'Storage00001/s_C001.tif'
    >>> print(image[95, 216])
    820

Access metadata and the OIB main file:

.. code-block:: python

    >>> with OifFile('test.oib') as oib:
    ...     oib.axes
    ...     oib.shape
    ...     oib.dtype
    ...     dataname = oib.mainfile['File Info']['DataName']
    ...
    'CYX'
    (3, 256, 256)
    dtype('uint16')
    >>> dataname
    'Cell 1 mitoEGFP.oib'

Extract the OIB file content to an OIF file and associated data directory:

.. code-block:: python

    >>> import tempfile
    >>> tempdir = tempfile.mkdtemp()
    >>> oib2oif('test.oib', location=tempdir)
    Saving ... done.

Read the image from the extracted OIF file:

.. code-block:: python

    >>> image = imread(f'{tempdir}/{dataname[:-4]}.oif')
    >>> image[:, 95, 216]
    array([820,  50, 436], dtype=uint16)

Read OLE compound file and access the 'OibInfo.txt' settings file:

.. code-block:: python

    >>> with CompoundFile('test.oib') as com:
    ...     info = com.open_file('OibInfo.txt')
    ...     len(com.files())
    ...
    14
    >>> info = SettingsFile(info, 'OibInfo.txt')
    >>> info['OibSaveInfo']['Version']
    '2.0.0.0'