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 YAML files, converted from parameter txt files #14

Closed
wants to merge 2 commits into from

Conversation

N-Dekker
Copy link
Member

@lassoan @mstaring @stefanklein The aim of this PR is to show what a YAML parameter file for elastix might look like. Does it look good to you?

Please have a look at the second commit, Convert all *.yml files to valid YAML. It shows the diff between the old txt format and the proposed new YAML format.

Specifically:

Double slashes are replaced by hashtags, to denote comment (following the YAML specification):

+ // Description: elastixpaper, affine
+ # Description: elastixpaper, affine

When a parameter has multiple values, they are enclosed by square brackets, and comma-separated:

- (GridSpacingSchedule 8.0 4.0 2.0 1.0)
+ GridSpacingSchedule: [8.0, 4.0, 2.0, 1.0]

YAML also supports to have a new line for each value, but that seems a bit too verbose.

When a parameter has just a single value, it is not enclosed by square brackets! (This is just a choice, of course. We could also choose to always use square brackets for parameter values.)

Double-quotes are removed from "true" and "false" (following the YAML specification):

- (WriteResultImage "false")
+ WriteResultImage: false

Other double-quotes are preserved. YAML supports double-quoted string values. A double-quoted string like "unsigned short" represents one single value.

- (ResultImagePixelType "unsigned short")
+ ResultImagePixelType: "unsigned short"

For this PR, I just wrote a little program to convert those txt files to yml: elastix_txt2yml.cxx

Note: This is still work in progress, so it should not yet be merged! elastix does not yet support YAML.

Note: elastix does not yet support YAML for parameter files!
Note: elastix does not yet support YAML for parameter files!
@N-Dekker
Copy link
Member Author

For the record: YAML representations of floating point numbers (including .inf and .NaN) are described at https://yaml.org/type/float.html

@stefanklein
Copy link
Member

stefanklein commented Jan 23, 2025 via email

@N-Dekker
Copy link
Member Author

Very nice! It looks pretty good to me.

Thanks @stefanklein 👍

Does it also support parameters with mixed value types?

Good question... My little converter elastix_txt2yml.cxx does support parameters with mixed value types:

- (FullSearchSpace0 "t_z" 5 -10.0 30.0 0.1)
+ FullSearchSpace0: ["t_z", 5, -10.0, 30.0, 0.1]

And as far as I can see, the YAML specification does allow such mixed lists as well. (I tried https://www.yamllint.com and it says: "Valid YAML!") So the short answer is: yes, it does! 😃

Comment on lines +26 to +28
NewSamplesEveryIteration: [true, true, true, true]
NumberOfSpatialSamples: [5000, 5000, 5000, 5000]
NewSamplesEveryIteration: [true, true]
Copy link
Member Author

Choose a reason for hiding this comment

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

@stefanklein
Copy link
Member

stefanklein commented Jan 23, 2025 via email

@mstaring
Copy link
Member

beautiful!

@N-Dekker
Copy link
Member Author

@N-Dekker N-Dekker closed this Jan 30, 2025
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.

3 participants