libfs
Header-only C++11 library for accessing FreeSurfer neuroimaging data
Public Member Functions | Public Attributes | List of all members
fs::Array4D< T > Struct Template Reference

A simple 4D array datastructure, useful for representing volume data. More...

#include <libfs.h>

Public Member Functions

 Array4D (unsigned int d1, unsigned int d2, unsigned int d3, unsigned int d4)
 
 Array4D (MghHeader *mgh_header)
 
 Array4D (Mgh *mgh)
 
const T & at (const unsigned int i1, const unsigned int i2, const unsigned int i3, const unsigned int i4) const
 Get the value at the given 4D position.
 
unsigned int get_index (const unsigned int i1, const unsigned int i2, const unsigned int i3, const unsigned int i4) const
 Get the index in the vector for the given 4D position.
 
unsigned int num_values () const
 Get number of values/voxels.
 

Public Attributes

unsigned int d1
 size of data along 1st dimension
 
unsigned int d2
 size of data along 2nd dimension
 
unsigned int d3
 size of data along 3rd dimension
 
unsigned int d4
 size of data along 4th dimension
 
std::vector< T > data
 the data, as a 1D vector. Use fs::Array4D::at for easy access in 4D.
 

Detailed Description

template<class T>
struct fs::Array4D< T >

A simple 4D array datastructure, useful for representing volume data.

By convention, for FreeSurfer data, the order of the 4 dimensions is: time, x, y, z.

Constructor & Destructor Documentation

◆ Array4D() [1/3]

template<class T >
fs::Array4D< T >::Array4D ( unsigned int  d1,
unsigned int  d2,
unsigned int  d3,
unsigned int  d4 
)
inline

Constructor for creating an empty 4D array of the given dimensions.

Exceptions
std::domain_errorif any dimension is zero.
std::overflow_errorif the product of dimensions overflows size_t.
std::runtime_errorif the allocation exceeds the configured limit.

◆ Array4D() [2/3]

template<class T >
fs::Array4D< T >::Array4D ( MghHeader mgh_header)
inline

Constructor for creating an empty 4D array based on dimensions specified in an fs::MghHeader.

Exceptions
std::domain_errorif any dimension is not positive (including the case where the int32_t header field was negative and wrapped to a huge unsigned int).
std::overflow_errorif the product of dimensions overflows size_t.
std::runtime_errorif the allocation exceeds the configured limit.

◆ Array4D() [3/3]

template<class T >
fs::Array4D< T >::Array4D ( Mgh mgh)
inline

Constructor for creating an empty 4D array based on dimensions specified in the header of an fs::Mgh. Does not init the data.

Exceptions
std::domain_errorif any dimension is not positive.
std::overflow_errorif the product of dimensions overflows size_t.
std::runtime_errorif the allocation exceeds the configured limit.

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