8000 Add metadata builder API for writing CZI metadata by ptahmose · Pull Request #23 · ptahmose/MEXlibCZI · GitHub
[go: up one dir, main page]

Skip to content

Add metadata builder API for writing CZI metadata - #23

Merged
ptahmose merged 4 commits into
masterfrom
jbl/metadata-builder
Oct 29, 2026
Merged

ptahmose merged 4 commits into
masterfrom
jbl/metadata-builder

Conversation

@ptahmose
@ptahmose ptahmose commented Oct 29, 2026 •
Copy link
Copy Markdown
Owner

Closes #22.

Adds an explicit prepare → edit → write workflow for document metadata.
Users can set pixel sizes through a scaling convenience operation and
edit arbitrary metadata through XML.

New commands

  • Writer_GetPreparedMetadata
  • Writer_WriteMetadata
  • MetadataBuilder_Modify
  • MetadataBuilder_GetXml
  • MetadataBuilder_SetXml
  • MetadataBuilder_Release

MetadataBuilder_Modify currently supports scaling values in metres and
optional display-unit formats through MetadataUtils::WriteScalingInfoEx.
The dispatcher provides an extension point for further convenience operations.

Existing workflows retain automatic metadata generation on close.
After an explicit metadata write succeeds, closing preserves that metadata.

Validation

  • Release build succeeded.
  • All 5 MATLAB metadata and writer tests passed.
  • Added an Octave scaling round-trip test
  • Documented command syntax, parameters, and lifecycle behavior.

Expose writer metadata preparation and writing, plus mutable builder
handles with XML access and a convenience-operation dispatcher.
Support scaling values and display units through MetadataUtils.

Preserve automatic metadata generation on close unless explicit metadata
writing succeeds. Document the API and add MATLAB and Octave tests.
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Complex scales can trigger host API errors or silently lose imaginary data, while fractional builder handles are rounded and can release or mutate unintended live objects.

2 open issues
What changed in this PR

Adds an extensible prepare → edit → write metadata workflow for MATLAB and Octave, addressing #22’s pixel-size requirement while retaining automatic metadata generation for existing callers.

Changes:

  • Adds six commands for preparing, editing, serializing, writing, and releasing metadata builders.
  • Supports scaling in metres, optional display units, and arbitrary XML edits; preserves explicitly written metadata on close.
  • Documents the workflow, adds MATLAB and Octave tests, and bumps the minor version to 0.6.
8000
File Description
tests/​octave/​test_write.m Adds a scaling round-trip test.
tests/​MATLAB/​TestMEXlib_MetadataBuilder.m Tests metadata round trips, validation, and lifecycle behavior.
lib/​src/​mexFunctions.cpp Registers the six metadata commands.
lib/​src/​implementation/​MetadataFunctionUtils.h Shares handle and argument validation.
lib/​src/​implementation/​MetadataBuilderManager.h Manages independent builder handles and ownership.
lib/​src/​implementation/​CziWriter.h Declares metadata preparation and writing methods.
lib/​src/​implementation/​CziWriter.cpp Writes explicit metadata and preserves it on close.
lib/​src/​functions/​func_writer_writemetadata.h Declares the metadata-writing command.
lib/​src/​functions/​func_writer_writemetadata.cpp Parses XML before writing metadata.
lib/​src/​functions/​func_writer_getpreparedmetadata.h Declares the metadata-preparation command.
lib/​src/​functions/​func_writer_getpreparedmetadata.cpp Exposes prepared metadata through a builder handle.
lib/​src/​functions/​func_metadatabuilder_setxml.h Declares the XML-replacement command.
lib/​src/​functions/​func_metadatabuilder_setxml.cpp Replaces builder XML after successful parsing.
lib/​src/​functions/​func_metadatabuilder_release.h Declares the builder-release command.
lib/​src/​functions/​func_metadatabuilder_release.cpp Releases builders and invalidates their handles.
lib/​src/​functions/​func_metadatabuilder_modify.h Declares the convenience-edit command.
lib/​src/​functions/​func_metadatabuilder_modify.cpp Validates and applies scaling and display units.
lib/​src/​functions/​func_metadatabuilder_getxml.h Declares the XML-serialization command.
lib/​src/​functions/​func_metadatabuilder_getxml.cpp Returns formatted builder XML.
lib/​src/​function.cpp Clears builders during extension shutdown.
lib/​CMakeLists.txt Includes the new metadata sources.
doc/​commands.markdown Documents commands, units, lifecycle, and usage.
CMakeLists.txt Bumps the minor version to 0.6.

Review effort: Balanced

Expand CZI metadata command documentation, clarify scaling units, and describe explicit metadata writing and lifecycle behavior.
Require scalar Int32 handles before conversion in `GetHandle`, rejecting invalid MATLAB argument types consistently.
Add validated document information fields and ratings to
MetadataBuilder_Modify, with accompanying documentation and examples.
@ptahmose
ptahmose marked this pull request as ready for review October 29, 2026 12:51
@ptahmose
ptahmose merged commit 10a3b75 into master Oct 29, 2026
4 checks passed
@ptahmose
ptahmose deleted the jbl/metadata-builder branch October 30, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support setting metadata when writing CZI files, including pixel size

2 participants

0