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

Feature request: specify output name for file in transformix/elastix #672

Closed
Svdvoort opened this issue Jun 27, 2022 · 4 comments · Fixed by #776
Closed

Feature request: specify output name for file in transformix/elastix #672

Svdvoort opened this issue Jun 27, 2022 · 4 comments · Fixed by #776
Milestone

Comments

@Svdvoort
Copy link

Currently, when running elastix/transformix it is only possible to specify the output directory, and not specifically the output name.
For example, from elastix the output files will always be named TransformParameters.0.txt and from transformix result.nii.gz.

Especially for transformix it would be nice to be able to specify the output file name.
I often have the situation where I need to apply the same transformation to multiple images (for example different MR modalities). In this case, I either have to create a new directory per image just to save the transformed image or have to write a wrapper around transformix to rename the output file before a new run.

Could a flag be added to elastix/transformix to specify the output filename directly?

For example:

transformix -tp TransformParameters.0.txt -out /home/user/ -filename T1 original_scan.nii.gz

If the filename flag is not provided, elastix/transformix can use the current default behavior (in this case, writing the file as result.nii.gz), not breaking any existing functionality.

@N-Dekker N-Dekker added this to the IssueSprint milestone Jul 4, 2022
@N-Dekker
Copy link
Member

N-Dekker commented Jul 4, 2022

Interesting suggestion, thanks!

Note that in Python you can already achieve this, when using ITKElastix https://github.com/InsightSoftwareConsortium/ITKElastix

@N-Dekker
Copy link
Member

As far as I can see, the default is "output-directory/result.mhd", looking at:

/** Create a name for the final result. */
std::string resultImageFormat = "mhd";
this->GetConfiguration()->ReadParameter(resultImageFormat, "ResultImageFormat", 0, false);
std::ostringstream makeFileName;
makeFileName << this->GetConfiguration()->GetCommandLineArgument("-out") << "result." << resultImageFormat;

I guess the proposal is to allow specifying a path relative to the output directory, right? Or would it be relative to the current working directory?

Of course, it should then also allow specifying an absolute path, either starting with a (back) slash, or a drive letter, followed by colon and (back) slash. Right?

But then, would it entirely ignore the "ResultImageFormat" parameter from the parameter file?

If the directory of the specified file path would be non-existing, would it be OK for transformix to just fail? Or should it try to create the directory?

@Svdvoort
Copy link
Author

In my opinion it can be much simpler than this. Although specifying additional paths would be nice, in principle I think it's fine to store everything just in the output directory.
However, the file will always be called result. , and it would be nice to change the "result" part since the image format can already be changed. It could be a flag, but also just a parameter in the parameter file, just like the ResultImageFormat is.

That way instead of always saving a file as result. it can be something like .

This allows for a bit more flexibility and clarity when saving transformed images.

N-Dekker added a commit that referenced this issue Dec 20, 2022
Addressing issue #672 "Feature request: specify output name for file in transformix/elastix" by Sebastian van der Voort.
N-Dekker added a commit that referenced this issue Dec 22, 2022
… elastix.exe

Addressing issue #672 "Feature request: specify output name for file in transformix/elastix" by Sebastian van der Voort.
N-Dekker added a commit that referenced this issue Dec 22, 2022
Allows the user to specify the name of the result file, that would otherwise just be named something like "result.mhd".

This improvement applies mainly to the elastix and transformix *executables*. Moreover, for the elastix library, it also applies to the result image files generated with "WriteResultImageAfterEachResolution" and "WriteResultImageAfterEachIteration".

Addressing issue #672 "Feature request: specify output name for file in transformix/elastix" by Sebastian van der Voort.
N-Dekker added a commit that referenced this issue Dec 22, 2022
Allows the user to specify the name of the result file, that would otherwise just be named something like "result.mhd".

This improvement applies mainly to the elastix and transformix *executables*. But moreover, for the elastix library, it also applies to the result image files generated with "WriteResultImageAfterEachResolution" and "WriteResultImageAfterEachIteration".

Addressing issue #672 "Feature request: specify output name for file in transformix/elastix" by Sebastian van der Voort.
@N-Dekker N-Dekker linked a pull request Dec 22, 2022 that will close this issue
N-Dekker added a commit that referenced this issue Dec 22, 2022
Allows the user to specify the name of the result file, that would otherwise just be named something like "result.mhd".

This improvement applies mainly to the elastix and transformix *executables*. But moreover, for the elastix library, it also applies to the result image files generated with "WriteResultImageAfterEachResolution" and "WriteResultImageAfterEachIteration".

Addressing issue #672 "Feature request: specify output name for file in transformix/elastix" by Sebastian van der Voort.
@N-Dekker
Copy link
Member

@Svdvoort Can you please check if the "ResultImageName" parameter implemented with pull request #776 commit b581b92 works the way you had in mind?

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 a pull request may close this issue.

2 participants