Skip to content

Commit

Permalink
Merge pull request #1197 from KrisThielemans/STIRoutputfileformatFix
Browse files Browse the repository at this point in the history
Allow STIR output file format par files with/out spaces
  • Loading branch information
KrisThielemans authored Jun 7, 2023
2 parents 7db8add + 6c861d8 commit a31f2d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/xSTIR/cSTIR/include/sirf/STIR/stir_data_containers.h
Original file line number Diff line number Diff line change
Expand Up @@ -1032,17 +1032,18 @@ namespace sirf {
If "" is passed as argument for format_file, the default format will be used.
An example is given below for writing the image in the nifti format. STIR uses
An example is given below for writing the image in the nifti format (when using the
`.nii` extension or when not specifying an extension). STIR uses
ITK to do this, so ensure that STIR is built with ITK if you wish to use it.
\verbatim
OutputFileFormat Parameters:=
Output File Format Parameters:=
output file format type := ITK
ITK Output File Format Parameters:=
number format := float
number_of_bytes_per_pixel:=4
default extension:=.nii
End ITK Output File Format Parameters:=
End:=
End:=
\endverbatim
*/
virtual void write(const std::string& filename, const std::string& format_file) const;
Expand Down
6 changes: 5 additions & 1 deletion src/xSTIR/cSTIR/stir_data_containers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,12 +432,16 @@ STIRImageData::write(const std::string &filename, const std::string &format_file

if (!format_file.empty()) {
KeyParser parser;
// STIR format
parser.add_start_key("Output File Format Parameters");
// old SIRF format, still accepted
parser.add_start_key("OutputFileFormat Parameters");
parser.add_parsing_key("output file format type", &format_sptr);
parser.add_stop_key("END");
parser.parse(format_file.c_str());
if(is_null_ptr(format_sptr))
throw std::runtime_error("STIRImageData::write: Parsing of output format file (" + format_file + ") failed "
throw std::runtime_error("STIRImageData::write: Parsing of output format file (" + format_file + ") failed.\n"
"STIR should have written a warning message why (if you don't see it, redirect warnings to a file using MessageRedirector)\n"
"(see examples/parameter_files/STIR_output_file_format_xxx.par for help).");
}
if(is_null_ptr(format_sptr))
Expand Down

0 comments on commit a31f2d2

Please sign in to comment.