Skip to main content

Converter from the Lif files (Leica Microscope) to OME-Zarr format.

Project description

Lif to OME-Zarr Converters

Fractal lif converter logo

CI (build and test) codecov

This repository contains the code to convert Lif files to OME-Zarr format.

Installation

To install the package, run the following command:

pip install fractal-lif-converters

Plate Conversion

The lif converters package provides a simple interface to convert lif files to OME-Zarr Plate format. The package provides a high-level function convert_lif_plate_to_omezarr that takes a list of LifInputModel objects as input and converts the lif files to OME-Zarr format.

Example Usage

  • Simple Plate Conversion: convert a single lif scene to a OME-Zarr Plate

    from pathlib import Path
    
    from lif_converters.wrappers import 
    convert_lif_plate_to_omezarr
    
    from lif_converters import LifInputModel
    
    conversion_list = [
        LifInputModel(
            lif_file_path="path/to/your.lif",
            plate_name="plate_name",
            tile_scan_name="tile_scan_name",
        )
    ]
    
    convert_lif_plate_to_omezarr(
        zarr_dir="path/to/exports/", # Directory path where the OME-Zarr file will be saved
        conversion_list=conversion_list,
        num_levels=5, # Number of levels to be created in the OME-Zarr file
        coarsening_xy=2, # Coarsening factor for the xy dimensions
        overwrite=True,
        verbose=True,
    )
    
  • Multiplexing Plate Conversion: Convert multiple lif scenes to a single OME-Zarr plate with multiple acquisitions

    from pathlib import Path
    
    from lif_converters.wrappers import 
    convert_lif_plate_to_omezarr
    
    from lif_converters import LifInputModel
    
    conversion_list = [
        LifInputModel(
            lif_file_path="path/to/your.lif",
            plate_name="plate_name",
            tile_scan_name="tile_scan_name",
            acquisition_id=0,
        ),
        LifInputModel(
            lif_file_path="path/to/your.lif", # Can be the same lif file or a different one
            plate_name="plate_name", # MUST BE THE SAME AS THE FIRST ONE
            tile_scan_name="tile_scan_name",
            acquisition_id=1, # MUST BE DIFFERENT FROM THE FIRST ONE
        )
    ]
    
    convert_lif_plate_to_omezarr(
        zarr_dir="path/to/exports/", # Directory path where the OME-Zarr file will be saved
        conversion_list=conversion_list,
        num_levels=5, # Number of levels to be created in the OME-Zarr file
        coarsening_xy=2, # Coarsening factor for the xy dimensions
        overwrite=True,
        verbose=True,
    )
    
  • Wildcard Plate Conversion: if no tile_scan_name is provided, the converter will convert all tile scans in the lif file. In this case, no acquisition_id or plate_name can be provided.

    from pathlib import Path
    
    from lif_converters.wrappers import 
    convert_lif_plate_to_omezarr
    
    from lif_converters import LifInputModel
    
    conversion_list = [
        LifInputModel(
            lif_file_path="path/to/your.lif",
        )
    ]
    
    convert_lif_plate_to_omezarr(
        zarr_dir="path/to/exports/", # Directory path where the OME-Zarr file will be saved
        conversion_list=conversion_list,
        num_levels=5, # Number of levels to be created in the OME-Zarr file
        coarsening_xy=2, # Coarsening factor for the xy dimensions
        overwrite=True,
        verbose=True,
    )
    

Supported Lif File Plate Layouts

The following plate layout are supported:

  • Single Position Plates

    /{Project.lif}
    ----/{Tilescan 1}/
    --------/A
    ------------/1 (Simple Image)
    
    /{Project.lif}
    ----/{Tilescan 1}/
    --------/A1 (Simple Image)
    --------/...
    
  • Multi Position Plates

    /{Project.lif}
    ----/{Tilescan 1}/
    --------/A
    ------------/1
    ----------------/R1 (Simple Image)
    ----------------/R2 (Simple Image)
    ----------------/...
    
    /{Project.lif}
    ----/{Tilescan 1}/
    --------/A1
    ------------/R1 (Simple Image)
    ------------/R2 (Simple Image)
    ------------/...
    
  • Mosaique Plates

    /{Project.lif}
    ----/{Tilescan 1}/
    --------/A
    ------------/1 (Mosaic Image)
    ------------/...
    
    /{Project.lif}
    ----/{Tilescan 1}/
    --------/A1 (Mosaic Image)
    --------/...
    

The names in curly braces {} can be freely chosen by the user.

While the othe names must follow the following format:

  • The well name must be a singe or duble letter followed by a positive integer. Valid examples are A1, A2, B1, AA1, AA12 etc.

  • Alternatively, the well can be hierarchically structured, for example A/1, A/2, B/1, AA/1, AA/12 etc.

  • If the well is a multi-position well, the positions must be named R followed by a positive integer. Valid examples are R1, R2, R3, R12 etc.

  • In case of more complex plate formats, for example FLIM data, the converter will ignore the data that does not follow the above formats. For example:

    /{Project.lif}
    ----/{Tilescan 1}/
    --------/A/1/R1 (Converted)
    --------/A/1/R1/FLIM/Intensity (Ignored)
    --------------------/Fast Flim (Ignored)
    --------------------/Standard Deviation (Ignored)
    

OME-Zarr Image Conversion

The lif converters package provides a simple interface to convert lif files to OME-Zarr Image format. The package provides a high-level function convert_lif_image_to_omezarr that takes a list of LifInputModel objects as input and converts each element in a OME-Zarr Image.

Example Image Conversion

  • Simple Image Conversion: convert a single lif scene to a OME-Zarr Image

    from pathlib import Path
    
    from lif_converters.wrappers import 
    convert_lif_image_to_omezarr
    
    from lif_converters import LifInputModel
    
    conversion_list = [
        LifInputModel(
            lif_file_path="path/to/your.lif",
            zarr_name="output",
            tile_scan_name="tile_scan_name", # Optional
        ),
        LifInputModel(
            lif_file_path="path/to/your.lif", # Can be the same lif file or a different one
            zarr_name="output2", # MUST BE DIFFERENT FROM THE FIRST ONE
            tile_scan_name="tile_scan_name_2", # If given, the converter will only convert the given tile scan
        )
    ]
    
    convert_lif_image_to_omezarr(
        zarr_dir="path/to/exports/", # Directory path where the OME-Zarr file will be saved
        conversion_list=conversion_list,
        num_levels=5, # Number of levels to be created in the OME-Zarr file
        coarsening_xy=2, # Coarsening factor for the xy dimensions
        overwrite=True,
        verbose=True,
    )
    
  • Wildcard Image Conversion: if no tile_scan_name is provided, the converter will convert all tile scans in the lif file. In this case, no zarr_name can be provided.

    from pathlib import Path
    
    from lif_converters.wrappers import 
    convert_lif_image_to_omezarr
    
    from lif_converters import LifInputModel
    
    conversion_list = [
        LifInputModel(
            lif_file_path="path/to/your.lif",
        ),
    ]
    
    convert_lif_image_to_omezarr(
        zarr_dir="path/to/exports/", # Directory path where the OME-Zarr file will be saved
        conversion_list=conversion_list,
        num_levels=5, # Number of levels to be created in the OME-Zarr file
        coarsening_xy=2, # Coarsening factor for the xy dimensions
        overwrite=True,
        verbose=True,
    )
    

Supported Lif File Images Layouts

The following image layout are supported:

  • Single Position Image

    /{Project.lif}
    ----/{Tilescan 1} (Simple Image)
    
  • Multi Position Image

    /{Project.lif}
    ----/{Tilescan 1}/
    --------/Position 1 (Simple Image)
    --------/Position 2 (Simple Image)
    --------/...
    
  • Mosaique Image

    /{Project.lif}
    ----/{Tilescan 1} (Mosaic Image)
    

The names in curly braces {} can be freely chosen by the user. While the othe names must follow the following format:

If the scene is a multi-position image, the positions must be named Position followed by a space and a positive integer. Valid examples are Position 1, Position 2, Position 3, Position 12 etc.

Moreover, if the lif file contains scans that do not follow the above formats, the converter will ignore them.

Project details


Download files

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

Source Distribution

fractal_lif_converters-0.5.0.tar.gz (4.0 MB view details)

Uploaded Source

Built Distribution

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

fractal_lif_converters-0.5.0-py3-none-any.whl (35.7 kB view details)

Uploaded Python 3

File details

Details for the file fractal_lif_converters-0.5.0.tar.gz.

File metadata

  • Download URL: fractal_lif_converters-0.5.0.tar.gz
  • Upload date:
  • Size: 4.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for fractal_lif_converters-0.5.0.tar.gz
Algorithm Hash digest
SHA256 b3c62f735dda110c7bc91723b456944c8440cae8616b8b3a6c277d85f16385a3
MD5 e32ede1dd6d813ada38e468340c5ed51
BLAKE2b-256 5d31dbb99a6d9eef2e970e2660dfe9bd22036b4871fc47faf34643dca52f1c48

See more details on using hashes here.

Provenance

The following attestation bundles were made for fractal_lif_converters-0.5.0.tar.gz:

Publisher: build_and_test.yml on fractal-analytics-platform/fractal-lif-converters

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fractal_lif_converters-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fractal_lif_converters-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f16faee871882b3c62db618259582133b00983eccae2e2abdf332187468c3953
MD5 783c323bedd214ac9b41b3ff15569246
BLAKE2b-256 ce35797c6c6ae7327a2bd47fdfad3c0b0ceb313ad137ed1a9af6df233fd4895a

See more details on using hashes here.

Provenance

The following attestation bundles were made for fractal_lif_converters-0.5.0-py3-none-any.whl:

Publisher: build_and_test.yml on fractal-analytics-platform/fractal-lif-converters

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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