Skip to content
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

WIP: Add TOML files, converted from parameter txt files #16

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

N-Dekker
Copy link
Member

@N-Dekker N-Dekker commented Jan 28, 2025

TOML's concept of a table of key-value pairs appears to match the elastix concept of a map of parameters. Just like elastix, TOML requires each key (parameter name) to be unique: https://github.com/toml-lang/toml/blob/1.0.0/toml.md#keys TOML also supports arrays of mixed types.

Like YAML, TOML supports comments, starting with #: https://github.com/toml-lang/toml/blob/1.0.0/toml.md#user-content-comment

TOML has built-in Python support, from Python 3.11: https://docs.python.org/3/library/tomllib.html For example:

import tomllib

file_path = "path/to/ElastixModelZoo/models/Par0001/Par0001bspline04.toml"
with open(file_path, "rb") as file_object:
    parameter_dict = tomllib.load(file_object)

The Python dict returned by tomllib.load is quite similar to an elastix ParameterMap, although we might need to write some extra code to ease conversions between such a dict and a ParameterMap.

There are various open source TOML parsers available in C++.

TOML was suggested by both Matt McCormick (@thewtex) and Denis (@dpshamonin)

@mstaring @stefanklein Please have a look! Specifically look at the second commit, "WIP: Convert all *.toml files to the TOML file format

@lassoan Andras, would TOML file support also be useful to you?

Note: elastix does not yet support TOML for parameter files!
Note: elastix does not yet support TOML for parameter files!
@dpshamonin
Copy link

👍

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