Skip to content

Conversation

@PintoCraig
Copy link
Contributor

Description

add default componentbitcount when writing czi

Fixes #156

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Added unit tests

Checklist:

  • I followed the Contributing Guidelines.
  • I did a self-review.
  • I commented my code, particularly in hard-to-understand areas.
  • I updated the documentation.
  • I updated the version of libCZI following Versioning of libCZI depending on the type of change
    • Bug fix -> PATCH
    • New feature -> MINOR
    • Breaking change -> MAJOR
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

@PintoCraig PintoCraig added the cla Contributor License Agreement sent to Admin label Oct 27, 2025
@codecov
Copy link

codecov bot commented Oct 27, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.34%. Comparing base (da3d7dc) to head (9bd46bb).

Files with missing lines Patch % Lines
Src/libCZI/CziMetadataBuilder.cpp 50.00% 15 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #159      +/-   ##
==========================================
- Coverage   66.38%   66.34%   -0.04%     
==========================================
  Files          96       96              
  Lines       12365    12395      +30     
==========================================
+ Hits         8209     8224      +15     
- Misses       4156     4171      +15     
Flag Coverage Δ
windows-latest 66.34% <50.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@PintoCraig PintoCraig requested a review from ptahmose October 28, 2025 08:30
@ptahmose ptahmose requested a review from Copilot October 28, 2025 08:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug where the ComponentBitCount XML element was missing from CZI metadata when writing CZI files. The fix adds a utility function to automatically infer and populate this field based on the pixel type.

Key changes:

  • Added TryGetComponentBitCountFromPixelType() helper method that maps pixel types to their component bit counts
  • Updated metadata generation to automatically include ComponentBitCount for each channel
  • Incremented library version from 0.67.3 to 0.67.4 (patch version)

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
Src/libCZI/CziMetadataBuilder.h Added declaration for new helper method TryGetComponentBitCountFromPixelType
Src/libCZI/CziMetadataBuilder.cpp Implemented component bit count inference logic and integrated it into metadata generation
Src/libCZI_UnitTests/test_writer.cpp Added comprehensive unit tests verifying ComponentBitCount is correctly written for Gray8, Gray16, and Bgr24 pixel types
CMakeLists.txt Bumped patch version from 0.67.3 to 0.67.4

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +645 to +648
componentBitCount = 32; // Complex float uses 32 bits per real/imaginary component
return true;
case PixelType::Bgr192ComplexFloat:
componentBitCount = 32; // Complex float uses 32 bits per component
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment states 'real/imaginary component' but ComponentBitCount typically represents bits per channel component, not per real/imaginary part of a complex number. For Gray64ComplexFloat (64 bits total for one complex value), this should clarify whether it's 32 bits for the entire component or 64 bits with 32 per real/imaginary part. The comment should be more precise about what 'component' means in this context.

Suggested change
componentBitCount = 32; // Complex float uses 32 bits per real/imaginary component
return true;
case PixelType::Bgr192ComplexFloat:
componentBitCount = 32; // Complex float uses 32 bits per component
componentBitCount = 32; // For complex float, this is 32 bits per channel component (i.e., per real or imaginary part)
return true;
case PixelType::Bgr192ComplexFloat:
componentBitCount = 32; // For complex float, this is 32 bits per channel component (i.e., per real or imaginary part)

Copilot uses AI. Check for mistakes.
componentBitCount = 32; // Complex float uses 32 bits per real/imaginary component
return true;
case PixelType::Bgr192ComplexFloat:
componentBitCount = 32; // Complex float uses 32 bits per component
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Bgr192ComplexFloat (192 bits total = 3 channels × 64 bits per complex channel), returning 32 as ComponentBitCount is ambiguous. The comment should clarify whether this represents bits per real/imaginary part (32), bits per complex channel (64), or bits per RGB component. This needs to be consistent with the CZI specification's definition of ComponentBitCount for complex pixel types.

Suggested change
componentBitCount = 32; // Complex float uses 32 bits per component
componentBitCount = 32; // For Bgr192ComplexFloat: 32 bits per real/imaginary part of each complex channel (each RGB channel is a complex float: 64 bits = 32 bits real + 32 bits imaginary), per CZI specification.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla Contributor License Agreement sent to Admin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CZIs created with "ICziWriter" (in "proper & default way") should pass CZICheck

1 participant