Skip to content

ENH: Show conversion of TOML dict to elastix ParameterMap #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

N-Dekker
Copy link
Collaborator

@N-Dekker N-Dekker commented Apr 3, 2025

Extended the TOML notebook, showing how to convert a Python dict from TOML to the elastix ParameterMap format.

Extended the TOML notebook, showing how to convert a Python `dict` from TOML to
the elastix ParameterMap format.
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@N-Dekker N-Dekker marked this pull request as ready for review April 3, 2025 14:42
@N-Dekker
Copy link
Collaborator Author

N-Dekker commented Apr 4, 2025

@thewtex The example presents a convert_to_parameter_map(toml_dict) function, so that one can initialize a ParameterObject by a converted TOM dict, as follows:

toml_dict = tomllib.loads(
    """
# Example transformation
NumberOfParameters = 2
Transform = "TranslationTransform"
TransformParameters = [ 1.2345, -1048 ]
"""
)

parameter_object = itk.ParameterObject.New(
    parameter_map=convert_to_parameter_map(toml_dict)
)

As an example, this may be nice, but I think it would be even nicer if one could directly initialize a ParameterObject by a TOM dict, without having to call convert_to_parameter_map(toml_dict) explicitly. As in itk.ParameterObject.New(parameter_map=toml_dict). Do you have an idea how to achieve that? Something with %extend swig_name, extending ParameterObject with TOML dict support?

Copy link
Member

@thewtex thewtex left a comment

Choose a reason for hiding this comment

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

🎇 @N-Dekker very nice!

Yes, we could look into making the conversion happen directly. I will take a look. Tracking issue #332 created.

@thewtex thewtex merged commit 4464e05 into InsightSoftwareConsortium:main Apr 4, 2025
19 of 20 checks passed
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.

2 participants