elsa io

General

template<typename data_t>
void elsa::io::write(DataContainer<data_t> x, std::string_view filename)

Write DataContainer to a file with given filename. Filename is expected to have a valid (i.e. supported) extension, else this function will throw.

Parameters
  • x: DataContainer to write to file

  • filename: filename to write data to

template<typename data_t>
DataContainer<data_t> elsa::io::read(std::string_view filename)

Read from filename and create a DataContainer. Filename is expected to have a valid (i.e. supported) extension, else this function will throw.

Parameters
  • filename: filename to read data from

EDF

class elsa::EDF

class to read and write EDF files.

Class to handle reading EDF files into DataContainers and writing of DataContainers to EDF files.

EDF files are non-standard files that include a 1024 Byte header containing textual meta data about the following raw data. It allows storing images of arbitrary dimensions in a low-overhead manner.

Please note: we assume little endian byte order.

Author

  • Matthias Wieczorek - initial code

  • Maximilian Hornung - modularization

  • Tobias Lasser - modernization

  • David Frank - istream overloads, improved testability

Public Static Functions

template<typename data_t = real_t>
DataContainer<data_t> read(std::string filename)

read from filename into a DataContainer

template<typename data_t = real_t>
DataContainer<data_t> read(std::istream &input)

read from stream into a DataContainer

template<typename data_t = real_t>
void write(const DataContainer<data_t> &data, std::string filename)

write the DataContainer to the file named filename

template<typename data_t = real_t>
void write(const DataContainer<data_t> &data, std::ostream &output)

write the DataContainer to the file named filename

Private Static Functions

std::map<std::string, std::string> readHeader(std::istream &file)

read the EDF header into a property map

std::pair<std::unique_ptr<DataDescriptor>, DataUtils::DataType> parseHeader(const std::map<std::string, std::string> &properties)

parse the EDF header property map into a DataDescriptor and DataType

template<typename data_t>
void writeHeader(std::ostream &file, const DataContainer<data_t> &data)

write the EDF header to file

template<typename data_t>
std::string getDataTypeName(const DataContainer<data_t> &data)

return the EDF string for data type of DataContainer

MHD

class elsa::MHD

class to read and write MHD files. MHD files are compatible with ITK/VTK based applications.

Class to handle reading

MHD files into DataContainers and writing of DataContainers to MHD files.
Author

Matthias Wieczorek - initial code

Author

Maximilian Hornung - modularization

Author

Tobias Lasser - modernization

MHD files consist of two parts, a text file (ending in .mhd) containing meta data, and a raw file containing the image data (filename is referenced in meta data). It allows storing images of arbitrary dimensions in a low-overhead manner.

Please note: we assume little endian byte order.

Public Static Functions

template<typename data_t = real_t>
DataContainer<data_t> read(std::string filename)

read from filename into a DataContainer

template<typename data_t = real_t>
void write(const DataContainer<data_t> &data, std::string metaFilename, std::string rawFilename)

write the DataContainer to the file named filename

Private Static Functions

std::map<std::string, std::string> readHeader(std::ifstream &metaFile)

read the MHD header into a property map

std::tuple<std::unique_ptr<DataDescriptor>, std::string, DataUtils::DataType> parseHeader(const std::map<std::string, std::string> &properties)

parse the MHD header property map into a DataDescriptor and DataType

template<typename data_t>
void writeHeader(std::ofstream &metaFile, const DataContainer<data_t> &data, std::string rawFilename)

write the MHD header to file

template<typename data_t>
std::string getDataTypeName(const DataContainer<data_t> &data)

return the MHD string for data type of DataContainer

PGM

class elsa::PGM

Class to handle writing PGM image files from DataContainers.

The “portable gray map” (PGM) fileformat is split into the header and the body (with image data). The header starts with a magic number, then width and height (in ASCII) are specified and the last part of the header is the maximum value of the colour component. The Magic number in our case is “P2” as we want to write a grey scale image. The width and height are taken from the DataContainer and the maximum value is 255 (values are scaled accordingly)

An example of a header would be:

P2
100 50 # width height
255    # Max value, 1 byte

Then the body prints one value in each line

Note: This class currently only handles 2D DataContainers.

Reference: http://paulbourke.net/dataformats/ppm/

Author

David Frank - initial code

Public Static Functions

template<typename data_t = real_t>
void write(const DataContainer<data_t> &data, const std::string &filename)

write the DataContainer to the file named filename. Currently we only handle 2D images

template<typename data_t = real_t>
void write(const DataContainer<data_t> &data, std::ostream &stream)

write the DataContainer to ostream with the specified format. Only 2D buffers are supported

IO Utilities

StringUtils

struct elsa::StringUtils

class providing string handling utility functions.

Author

Maximilian Hornung - initial code

Author

Tobias Lasser - rewrite

Public Static Functions

void trim(std::string &str)

trim whitespace from beginning/end of string

void toLower(std::string &str)

convert string to lower case

void toUpper(std::string &str)

convert string to upper case

DataUtils

struct elsa::DataUtils

class providing utility functions for reading/writing data

Author

Matthias Wieczorek - first version of code

Author

Maximilian Hornung - modularization

Author

Tobias Lasser - rewrite

Public Types

enum ByteOrder

byte order

Values:

enumerator LOW_BYTE_FIRST
enumerator HIGH_BYTE_FIRST
enum DataType

data types

Values:

enumerator INT8
enumerator UINT8
enumerator INT16
enumerator UINT16
enumerator INT32
enumerator UINT32
enumerator FLOAT32
enumerator FLOAT64

Public Static Functions

index_t getSizeOfDataType(DataType type)

return the size in bytes for the respective DataType

template<typename data_t>
data_t parse(const std::string &str)

parse a data_t value from a string

template<typename data_t>
std::vector<data_t> parseVector(const std::string &str)

parse a vector of data_t values from a string

template<typename raw_data_t, typename data_t>
void parseRawData(std::istream &file, DataContainer<data_t> &data)

read in raw data (of type raw_data_t) into a data container (of type data_t)

Public Static Attributes

const ByteOrder DEFAULT_BYTE_ORDER = ByteOrder::LOW_BYTE_FIRST

our default byte order is little endian (low byte first)

FileSystemUtils

struct elsa::FileSystemUtils

class providing utility functions for the filesystem

Author

Maximilian Hornung - initial code

Author

Tobias Lasser - rewrite

Public Static Functions

std::string getAbsolutePath(std::string path, std::string base)

return the absolute path of path with respect to base