Skip to content

Python MATLAB Feature Parity for IFCB v4 Features

John Walsh edited this page May 29, 2026 · 3 revisions

Python/MATLAB Feature Parity for IFCB v4 Features

Status

As of May 2026, the Python ifcb-features v4 pipeline has near-complete parity with the MATLAB v4 feature pipeline.

The blob generation pipeline is identical. Feature differences are now limited to a very small number of floating-point-level differences, primary in Biovolume, SurfaceArea, and their summed equivalents.

Scope

This page describes parity between:

  • Python: ifcb-features
  • MATLAB: ifcb-analysis, branch match-python
  • Output version: v4
  • Python output:
    • *_features_v4.csv
    • *_blobs_v4.zip
  • MATLAB outputs:
    • *_fea_v4.csv
    • *_blobs_v4.zip

Note that this is parity with the MATLAB v4 feature pipeline, not the older MATLAB v2 feature pipeline.

Changes

The main sources of Python/MATLAB mismatch were removed by making ambiguous operations explicit and deterministic.

Blob Segmentation

The k-means segmentation path was updated to avoid implementation-dependent floating-point behavior.

Key changes:

  • Use deterministic 1D k-means behavior.
  • Match MATLAB/Python cluster initialization and empty-cluster behavior.
  • Use explicit single-precision accumulation semantics.

Result: blob masks now match exactly.

Orientation and Rotation

Small differences in regionprops orientation caused nearest-neighbor rotation to choose different pixels at half-pixel boundaries.

The fix was to make orientation and crop rotation explicit:

  • Compute orientation from image moments directly in both languages.
  • Use deterministic nearest-neighbor crop rotation.
  • Avoid relying on MATLAB imrotate black-box edge behavior.

Result: blob rotation behavior now matches between Python and MATLAB.

Biovolume / Surface Area

Biovolume and surface area are computed by two paths: - Solid of revolution, for simpler compact blobs.

  • Distance-map volume, for more complex blobs.

The distance-map path was aligned by making distance transform and summation behavior more explicit. Remaining feature differences are now small and isolated.

Large Sample Validation

TODO

Clone this wiki locally