fmi-faim / faim-ipa

A collection of Image Processing and Analysis (IPA) functions used at the Facility for Advanced Imaging and Microscopy (FAIM)
BSD 3-Clause "New" or "Revised" License
9 stars 6 forks source link

Missing planes after stitching #137

Closed tibuch closed 6 months ago

tibuch commented 6 months ago

In some cases planes are missing after stitching.

plate = ZAdjustedStackAcquisition(
    acquisition_dir=config.acquisition_dir,
    trace_log_files=config.trace_log_files,
    alignment=TileAlignmentOptions.STAGE_POSITION,
    n_planes_in_stacked_tile=16,
)

converter = ConvertToNGFFPlate(
    ngff_plate=NGFFPlate(
        root_dir=config.output_dir,
        name=basename(config.acquisition_dir),
        layout=PlateLayout.I384,
        order_name=config.order_name,
        barcode=config.barcode,
    ),
    yx_binning=1,
    warp_func=stitching_utils.translate_tiles_2d,
    fuse_func=stitching_utils.fuse_linear,
    client=client,
)
tibuch commented 6 months ago

The planes are not missing, but some planes get assigned the same ZIndex after the auto-focus correction. The issue can be tracked down to a rounding error in ZAdjustedStackAcquisition._parse_files().

Currently, we compute the updated ZIndex for each acquired plane. Which, in combination with the rounding error, can lead to a situation where the same ZIndex is used by multiple planes and some ZIndices are skipped.

After discussing the issue with @imagejan we concluded that we should compute the Z-Index offset for each field-stack once and shift all Z-indices belonging to one field and well together. Like this the acquired stack stays together.