Repository navigation
Add metadata builder API for writing CZI metadata - #23
Merged
Merged
Conversation
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.
Contributor
There was a problem hiding this comment.
🟡 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.
| 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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_GetPreparedMetadataWriter_WriteMetadataMetadataBuilder_ModifyMetadataBuilder_GetXmlMetadataBuilder_SetXmlMetadataBuilder_ReleaseMetadataBuilder_Modifycurrently supports scaling values in metres andoptional 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