STIR
6.2.0
|
Base class for classes that create output files. More...
#include "stir/IO/OutputFileFormat.h"
Public Member Functions | |
OutputFileFormat (const NumericType &=NumericType::FLOAT, const ByteOrder &=ByteOrder::native) | |
Succeeded | write_to_file (std::string &filename, const DataT &data) const |
Write a single image to file. More... | |
Succeeded | write_to_file (const std::string &filename, const DataT &density) const |
write a single image to file More... | |
NumericType | get_type_of_numbers () const |
get type used for outputting numbers | |
ByteOrder | get_byte_order () |
get byte order used for output | |
float | get_scale_to_write_data () const |
get scale to write the data More... | |
virtual NumericType | set_type_of_numbers (const NumericType &, const bool warn=false) |
set type used for outputting numbers More... | |
virtual ByteOrder | set_byte_order (const ByteOrder &, const bool warn=false) |
set byte order used for output More... | |
virtual void | set_byte_order_and_type_of_numbers (ByteOrder &, NumericType &, const bool warn=false) |
set byte order and data type used for output More... | |
virtual float | set_scale_to_write_data (const float new_scale_to_write_data, const bool warn=false) |
set scale outputting numbers More... | |
Public Member Functions inherited from stir::RegisteredObjectBase | |
virtual std::string | get_registered_name () const =0 |
Returns the name of the type of the object. More... | |
Public Member Functions inherited from stir::ParsingObject | |
ParsingObject (const ParsingObject &) | |
ParsingObject & | operator= (const ParsingObject &) |
void | ask_parameters () |
virtual std::string | parameter_info () |
bool | parse (std::istream &f) |
bool | parse (const char *const filename) |
Static Public Member Functions | |
static shared_ptr< OutputFileFormat< DataT > > | default_sptr () |
A function to return a default output file format. | |
Static Public Member Functions inherited from stir::RegisteredObject< OutputFileFormat< DataT > > | |
static OutputFileFormat< DataT > * | read_registered_object (std::istream *in, const std::string ®istered_name) |
Construct a new object (of a type derived from Root, its actual type determined by the registered_name parameter) by parsing the istream. More... | |
static OutputFileFormat< DataT > * | ask_type_and_parameters () |
ask the user for the type, and then calls read_registered_object(0, type) More... | |
static void | list_registered_names (std::ostream &stream) |
List all possible registered names to the stream. More... | |
Protected Member Functions | |
virtual Succeeded | actual_write_to_file (std::string &filename, const DataT &density) const =0 |
virtual function called by write_to_file() More... | |
void | set_defaults () override |
sets value for output data type More... | |
void | initialise_keymap () override |
sets keys for output data type for parsing More... | |
bool | post_processing () override |
Checks if parameters have sensible values after parsing. More... | |
void | set_key_values () override |
overloaded member for ParsingObject::set_key_values() More... | |
Protected Attributes | |
NumericType | type_of_numbers |
type used for outputting numbers | |
ByteOrder | file_byte_order |
byte order used for output | |
float | scale_to_write_data |
scale to write the data More... | |
Protected Attributes inherited from stir::ParsingObject | |
KeyParser | parser |
Additional Inherited Members | |
Protected Types inherited from stir::RegisteredObject< OutputFileFormat< DataT > > | |
typedef OutputFileFormat< DataT > *(* | RootFactory) (std::istream *) |
The type of a root factory is a function, taking an istream* as argument, and returning a Root*. | |
typedef FactoryRegistry< std::string, RootFactory, interfile_less > | RegistryType |
The type of the registry. | |
Static Protected Member Functions inherited from stir::RegisteredObject< OutputFileFormat< DataT > > | |
static RegistryType & | registry () |
Static function returning the registry. More... | |
Base class for classes that create output files.
; byte order defaults to native order byte order := littleendian ; type specification as in Interfile number format:=float number of bytes per pixel:=4 scale_to_write_data:=0
Support projection data
Provide functions that enable the user to inquire about capabilities. For instance, supports_multi_time_frames(), supports_different_xy_pixel_size() etc.
Succeeded stir::OutputFileFormat< DataT >::write_to_file | ( | std::string & | filename, |
const DataT & | data | ||
) | const |
Write a single image to file.
filename | desired output filename. If it does not have an extension, a default extension will/should be added by the derived class. If there is an extension, the derived class should try to honour it. On return, the parameter will be overwritten with the actual filename used, such that the file can be read back using this string. |
data | the data to write to file. |
Referenced by stir::LogcoshPrior< elemT >::compute_gradient(), stir::ScatterEstimation::process_data(), and stir::TestBSplineTransformation::run_transformation().
Succeeded stir::OutputFileFormat< DataT >::write_to_file | ( | const std::string & | filename, |
const DataT & | density | ||
) | const |
write a single image to file
See the version with non-const filename. This version does not return the filename used.
float stir::OutputFileFormat< DataT >::get_scale_to_write_data | ( | ) | const |
get scale to write the data
|
virtual |
set type used for outputting numbers
Returns type actually used. Calls warning() with some text if the requested type is not supported.
Default implementation accepts any type.
Reimplemented in stir::ecat::ecat7::ECAT7ParametricDensityOutputFileFormat< DiscretisedDensityT >, stir::ecat::ecat6::ECAT6OutputFileFormat, stir::ecat::ecat7::ECAT7DynamicDiscretisedDensityOutputFileFormat, and stir::ecat::ecat7::ECAT7OutputFileFormat.
|
virtual |
set byte order used for output
Returns type actually used. Calls warning() with some text if the requested type is not supported.
Default implementation accepts any byte order.
Reimplemented in stir::ITKOutputFileFormat, stir::InterfileParametricDiscretisedDensityOutputFileFormat< DiscDensityT >, stir::ecat::ecat7::ECAT7ParametricDensityOutputFileFormat< DiscretisedDensityT >, stir::ecat::ecat6::ECAT6OutputFileFormat, stir::ecat::ecat7::ECAT7DynamicDiscretisedDensityOutputFileFormat, stir::ecat::ecat7::ECAT7OutputFileFormat, stir::MultiDynamicDiscretisedDensityOutputFileFormat, stir::InterfileDynamicDiscretisedDensityOutputFileFormat, stir::MultiParametricDiscretisedDensityOutputFileFormat< DiscDensityT >, and stir::InterfileOutputFileFormat.
|
virtual |
set byte order and data type used for output
Changes parameters to the types actually used. Calls warning() with some text if the requested type is not supported.
This function is necessary in case a byte order for a particular data type is not supported.
Default implementation calls set_byte_order() and set_type_of_numbers().
|
virtual |
set scale outputting numbers
Returns scale actually used. Calls warning() with some text if the requested scale is not supported.
If scale_to_write_data is 0 (which is the default), the output will be rescaled such that the maximum range of the output type of numbers is used, except for floats and doubles in which case no rescaling occurs.
Default implementation accepts any scale.
|
protectedpure virtual |
virtual function called by write_to_file()
This function has to be overloaded by the derived class.
The reason we do not simply make write_to_file() virtual is that we have 2 versions of write_to_file. C++ rules are such that overloading the virtual function in a derived class means that the other version gets hidden. Having the non-virtual write_to_file() call the virtual actual_write_to_file() solves this problem.
Implemented in stir::ecat::ecat7::ECAT7ParametricDensityOutputFileFormat< DiscretisedDensityT >, stir::ITKOutputFileFormat, stir::InterfileParametricDiscretisedDensityOutputFileFormat< DiscDensityT >, stir::ecat::ecat6::ECAT6OutputFileFormat, stir::ecat::ecat7::ECAT7DynamicDiscretisedDensityOutputFileFormat, stir::ecat::ecat7::ECAT7OutputFileFormat, stir::MultiDynamicDiscretisedDensityOutputFileFormat, stir::InterfileDynamicDiscretisedDensityOutputFileFormat, stir::MultiParametricDiscretisedDensityOutputFileFormat< DiscDensityT >, and stir::InterfileOutputFileFormat.
|
overrideprotectedvirtual |
sets value for output data type
Has to be called by set_defaults() in the leaf-class
Reimplemented from stir::ParsingObject.
|
overrideprotectedvirtual |
sets keys for output data type for parsing
Has to be called by initialise_keymap() in the leaf-class
Reimplemented from stir::ParsingObject.
|
overrideprotectedvirtual |
Checks if parameters have sensible values after parsing.
Has to be called by post_processing() in the leaf-class
Reimplemented from stir::ParsingObject.
|
overrideprotectedvirtual |
overloaded member for ParsingObject::set_key_values()
Has to be called by set_key_values() in the leaf-class (if it redefines it)
Reimplemented from stir::ParsingObject.
|
protected |
scale to write the data