Skip to content

Comments

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

Merged
thewtex merged 1 commit intoInsightSoftwareConsortium:mainfrom
N-Dekker:TOML-dict-to-ParameterMap
Apr 4, 2025
Merged

ENH: Show conversion of TOML dict to elastix ParameterMap#332
thewtex merged 1 commit intoInsightSoftwareConsortium:mainfrom
N-Dekker:TOML-dict-to-ParameterMap

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.
@review-notebook-app
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