STIR  6.2.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
stir::OutputFileFormat< DataT > Class Template Referenceabstract

Base class for classes that create output files. More...

#include "stir/IO/OutputFileFormat.h"

Inheritance diagram for stir::OutputFileFormat< DataT >:
Inheritance graph
[legend]

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 &)
 
ParsingObjectoperator= (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 &registered_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_lessRegistryType
 The type of the registry.
 
- Static Protected Member Functions inherited from stir::RegisteredObject< OutputFileFormat< DataT > >
static RegistryTyperegistry ()
 Static function returning the registry. More...
 

Detailed Description

template<typename DataT>
class stir::OutputFileFormat< DataT >

Base class for classes that create output files.

Parsing
The following keywords can be parsed (defaults indicated).
 ; 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
Todo:

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.

Member Function Documentation

◆ write_to_file() [1/2]

template<typename DataT>
Succeeded stir::OutputFileFormat< DataT >::write_to_file ( std::string &  filename,
const DataT &  data 
) const

Write a single image to file.

Parameters
filenamedesired 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.
datathe data to write to file.
Returns
Succeeded::yes if the file was successfully written.
Warning
In the case of file formats that use a separate header file, the filename argument at input is/should be used as a filename for the file with the actual data. At output however, the name of the header file will/should be returned. This is all a bit messy, so it's recommended to not use an extension for the output filename.

Referenced by stir::LogcoshPrior< elemT >::compute_gradient(), stir::ScatterEstimation::process_data(), and stir::TestBSplineTransformation::run_transformation().

◆ write_to_file() [2/2]

template<typename DataT>
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.

◆ get_scale_to_write_data()

template<typename DataT>
float stir::OutputFileFormat< DataT >::get_scale_to_write_data ( ) const

get scale to write the data

See also
set_scale_to_write_data

◆ set_type_of_numbers()

template<typename DataT>
virtual NumericType stir::OutputFileFormat< DataT >::set_type_of_numbers ( const NumericType ,
const bool  warn = false 
)
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.

◆ set_byte_order()

template<typename DataT>
virtual ByteOrder stir::OutputFileFormat< DataT >::set_byte_order ( const ByteOrder ,
const bool  warn = false 
)
virtual

◆ set_byte_order_and_type_of_numbers()

template<typename DataT>
virtual void stir::OutputFileFormat< DataT >::set_byte_order_and_type_of_numbers ( ByteOrder ,
NumericType ,
const bool  warn = false 
)
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().

◆ set_scale_to_write_data()

template<typename DataT>
virtual float stir::OutputFileFormat< DataT >::set_scale_to_write_data ( const float  new_scale_to_write_data,
const bool  warn = false 
)
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.

◆ actual_write_to_file()

template<typename DataT>
virtual Succeeded stir::OutputFileFormat< DataT >::actual_write_to_file ( std::string &  filename,
const DataT &  density 
) const
protectedpure virtual

◆ set_defaults()

template<typename DataT>
void stir::OutputFileFormat< DataT >::set_defaults ( )
overrideprotectedvirtual

sets value for output data type

Has to be called by set_defaults() in the leaf-class

Reimplemented from stir::ParsingObject.

◆ initialise_keymap()

template<typename DataT>
void stir::OutputFileFormat< DataT >::initialise_keymap ( )
overrideprotectedvirtual

sets keys for output data type for parsing

Has to be called by initialise_keymap() in the leaf-class

Reimplemented from stir::ParsingObject.

◆ post_processing()

template<typename DataT>
bool stir::OutputFileFormat< DataT >::post_processing ( )
overrideprotectedvirtual

Checks if parameters have sensible values after parsing.

Has to be called by post_processing() in the leaf-class

Reimplemented from stir::ParsingObject.

◆ set_key_values()

template<typename DataT>
void stir::OutputFileFormat< DataT >::set_key_values ( )
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.

Member Data Documentation

◆ scale_to_write_data

template<typename DataT>
float stir::OutputFileFormat< DataT >::scale_to_write_data
protected

scale to write the data

See also
set_scale_to_write_data

The documentation for this class was generated from the following file: