ISIS Core Library 0.7.2 (api 3.0.0)
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends

isis::data::Chunk Class Reference

Main class for four-dimensional random-access data blocks. More...

#include <chunk.hpp>

Inheritance diagram for isis::data::Chunk:
isis::util::_internal::GenericReference< TYPE_TYPE > isis::data::MemChunk< TYPE > isis::data::MemChunkNonDel< TYPE >

Public Types

typedef
ValueArrayBase::const_value_iterator 
const_iterator
typedef const_iterator::reference const_reference
typedef
ValueArrayBase::value_iterator 
iterator
typedef iterator::reference reference

Public Member Functions

template<typename TYPE >
ValueArray< TYPE > & asValueArray ()
ValueArrayBaseasValueArrayBase ()
std::list< ChunkautoSplice (uint32_t acquisitionNumberStride=0) const
 Splices the chunk at the uppermost dimension and automatically sets indexOrigin and acquisitionNumber appropriately.
const_iterator begin () const
iterator begin ()
 Chunk (const isis::data::ValueArrayReference &src, size_t nrOfColumns, size_t nrOfRows=1, size_t nrOfSlices=1, size_t nrOfTimesteps=1, bool fakeValid=false)
Chunk cloneToNew (size_t nrOfColumns, size_t nrOfRows=1, size_t nrOfSlices=1, size_t nrOfTimesteps=1) const
 Creates a new empty Chunk of different size and without properties, but of the same datatype as this.
size_t compare (const Chunk &dst) const
size_t compareRange (const size_t source_start[], const size_t source_end[], const Chunk &dst, const size_t destination[]) const
bool convertToType (short unsigned int ID, scaling_pair scaling=scaling_pair())
 Ensure, the chunk has the type with the requested ID.
Chunk copyByID (unsigned short ID=0, scaling_pair scaling=scaling_pair()) const
 Create a new Chunk of the requested type and copy all voxel data of the chunk into it.
void copyRange (const size_t source_start[], const size_t source_end[], Chunk &dst, const size_t destination[]) const
void copySlice (size_t thirdDimS, size_t fourthDimS, Chunk &dst, size_t thirdDimD, size_t fourthDimD) const
template<typename T >
bool copyToMem (T *dst, size_t len, scaling_pair scaling=scaling_pair()) const
 Copy all voxel data of the chunk into memory.
iterator end ()
const_iterator end () const
template<typename TYPE >
size_t foreachVoxel (VoxelOp< TYPE > &op)
 Run a functor on every Voxel in the chunk.
template<typename TYPE >
size_t foreachVoxel (VoxelOp< TYPE > &op, util::vector4< size_t > offset)
 Run a functor on every Voxel in the chunk.
size_t getBytesPerVoxel () const
std::pair
< util::ValueReference,
util::ValueReference
getMinMax () const
scaling_pair getScalingTo (unsigned short typeID, autoscaleOption scaleopt=autoscale) const
 get the scaling (and offset) which would be used in an conversion to the given type
scaling_pair getScalingTo (unsigned short typeID, const std::pair< util::ValueReference, util::ValueReference > &minmax, autoscaleOption scaleopt=autoscale) const
unsigned short getTypeID () const
std::string getTypeName () const
template<typename TYPE >
const ValueArray< TYPE > getValueArray () const
const ValueArrayBasegetValueArrayBase () const
const util::ValueReference getVoxelValue (size_t nrOfColumns, size_t nrOfRows=0, size_t nrOfSlices=0, size_t nrOfTimesteps=0) const
template<typename T >
bool is () const
Chunkoperator= (const Chunk &ref)
util::PropertyValuepropertyValueAt (const util::PropertyMap::KeyType &key, size_t at)
 Access properties of the next lower dimension (e.g.
const util::PropertyValuepropertyValueAt (const util::PropertyMap::KeyType &key, size_t at) const
void setVoxelValue (const util::ValueReference &val, size_t nrOfColumns, size_t nrOfRows=0, size_t nrOfSlices=0, size_t nrOfTimesteps=0)
std::list< Chunksplice (dimensions atDim) const
 Splices the chunk at the given dimension and all dimensions above.
void swapAlong (const dimensions dim) const
 Swaps the image along a dimension dim in image space.
bool transformCoords (boost::numeric::ublas::matrix< float > transform_matrix, bool transformCenterIsImageCenter=false)
 Transforms the image coordinate system into an other system by multiplying the orientation matrix with a user defined transformation matrix.
size_t useCount () const
template<typename TYPE >
const TYPE & voxel (size_t nrOfColumns, size_t nrOfRows=0, size_t nrOfSlices=0, size_t nrOfTimesteps=0) const
 Gets a const reference of the element at a given index.
template<typename TYPE >
TYPE & voxel (size_t nrOfColumns, size_t nrOfRows=0, size_t nrOfSlices=0, size_t nrOfTimesteps=0)
 Gets a reference to the element at a given index.

Static Public Member Functions

static Chunk createByID (short unsigned int ID, size_t nrOfColumns, size_t nrOfRows=1, size_t nrOfSlices=1, size_t nrOfTimesteps=1, bool fakeValid=false)
 Creates a new empty Chunk without properties but of specified type and specified size.

Protected Member Functions

template<typename TYPE , typename D >
 Chunk (TYPE *src, D d, size_t nrOfColumns, size_t nrOfRows=1, size_t nrOfSlices=1, size_t nrOfTimesteps=1)
 Creates an data-block from existing data.
 Chunk ()

Friends

class Image
class std::vector< Chunk >

Detailed Description

Main class for four-dimensional random-access data blocks.

Like in ValueArray, the copy of a Chunk will reference the same data. (cheap copy) (If you want to make a memory based deep copy of a Chunk create a MemChunk from it)

Definition at line 65 of file chunk.hpp.


Member Typedef Documentation

Definition at line 86 of file chunk.hpp.

typedef const_iterator::reference isis::data::Chunk::const_reference

Definition at line 88 of file chunk.hpp.

Definition at line 82 of file chunk.hpp.

typedef iterator::reference isis::data::Chunk::reference

Definition at line 87 of file chunk.hpp.


Constructor & Destructor Documentation

template<typename TYPE , typename D >
isis::data::Chunk::Chunk ( TYPE *  src,
d,
size_t  nrOfColumns,
size_t  nrOfRows = 1,
size_t  nrOfSlices = 1,
size_t  nrOfTimesteps = 1 
) [inline, protected]

Creates an data-block from existing data.

Parameters:
srcis a pointer to the existing data. This data will automatically be deleted. So don't use this pointer afterwards.
dis the deleter to be used for deletion of src. It must define operator(TYPE *), which than shall free the given pointer.
nrOfColumnssize in the first dimension (usually read-encoded dim)
nrOfRowssize in the second dimension (usually phase-encoded dim)
nrOfSlicessize in the third dimension (usually slice-encoded dim)
nrOfTimestepssize in the fourth dimension

Definition at line 79 of file chunk.hpp.

isis::data::Chunk::Chunk ( ) [inline, protected]

Definition at line 82 of file chunk.hpp.

_internal isis::data::Chunk::Chunk ( const isis::data::ValueArrayReference src,
size_t  nrOfColumns,
size_t  nrOfRows = 1,
size_t  nrOfSlices = 1,
size_t  nrOfTimesteps = 1,
bool  fakeValid = false 
)

Definition at line 44 of file chunk.cpp.


Member Function Documentation

template<typename TYPE >
ValueArray<TYPE>& isis::data::Chunk::asValueArray ( ) [inline]

Definition at line 170 of file chunk.hpp.

ValueArrayBase& isis::data::Chunk::asValueArrayBase ( ) [inline]

Definition at line 167 of file chunk.hpp.

std::list< Chunk > isis::data::Chunk::autoSplice ( uint32_t  acquisitionNumberStride = 0) const

Splices the chunk at the uppermost dimension and automatically sets indexOrigin and acquisitionNumber appropriately.

This automatically selects the upermost dimension of the chunk to be spliced and will compute the correct offsets for indexOrigin and acquisitionNumberOffset which will be applied to the resulting splices.

E.g. autoSplice() on a chunk of the size 512x512x128, with rowVec 1,0,0, columnVec 0,1,0 and indexOrigin 0,0,0 will result in 128 chunks of the size 512x512x1, with constant rowVec's 1,0,0, and columnVec's 0,1,0 while the indexOrigin will be going from 0,0,0 to 0,0,128 (If voxelSize is 1,1,1 and voxelGap is 0,0,0). The acquisitionNumber will be reset to a simple incrementing counter starting at acquisitionNumberOffset.

Definition at line 180 of file chunk.cpp.

Chunk::const_iterator isis::data::Chunk::begin ( ) const

Definition at line 353 of file chunk.cpp.

Chunk::iterator isis::data::Chunk::begin ( )

Definition at line 344 of file chunk.cpp.

Chunk isis::data::Chunk::cloneToNew ( size_t  nrOfColumns,
size_t  nrOfRows = 1,
size_t  nrOfSlices = 1,
size_t  nrOfTimesteps = 1 
) const

Creates a new empty Chunk of different size and without properties, but of the same datatype as this.

Definition at line 60 of file chunk.cpp.

size_t isis::data::Chunk::compare ( const Chunk dst) const

Definition at line 150 of file chunk.cpp.

size_t isis::data::Chunk::compareRange ( const size_t  source_start[],
const size_t  source_end[],
const Chunk dst,
const size_t  destination[] 
) const

Definition at line 131 of file chunk.cpp.

bool isis::data::Chunk::convertToType ( short unsigned int  ID,
scaling_pair  scaling = scaling_pair() 
)

Ensure, the chunk has the type with the requested ID.

If the typeID of the chunk is not equal to the requested ID, the data of the chunk is replaced by an converted version.

Returns:
false if there was an error

Definition at line 73 of file chunk.cpp.

Chunk isis::data::Chunk::copyByID ( unsigned short  ID = 0,
scaling_pair  scaling = scaling_pair() 
) const

Create a new Chunk of the requested type and copy all voxel data of the chunk into it.

If neccessary a conversion into the requested type is done using the given scale.

Parameters:
IDthe ID of the requested type (type of the source is used if not given)
scalingthe scaling to be used when converting the data (will be determined automatically if not given)
Returns:
a new deep copied Chunk of the same size
void isis::data::Chunk::copyRange ( const size_t  source_start[],
const size_t  source_end[],
Chunk dst,
const size_t  destination[] 
) const

Definition at line 114 of file chunk.cpp.

void isis::data::Chunk::copySlice ( size_t  thirdDimS,
size_t  fourthDimS,
Chunk dst,
size_t  thirdDimD,
size_t  fourthDimD 
) const

Definition at line 106 of file chunk.cpp.

template<typename T >
bool isis::data::Chunk::copyToMem ( T *  dst,
size_t  len,
scaling_pair  scaling = scaling_pair() 
) const [inline]

Copy all voxel data of the chunk into memory.

If neccessary a conversion into T is done using min/max of the image.

Parameters:
dstc-pointer for the memory to copy into
lenthe allocated size of that memory in elements
scalingthe scaling to be used when converting the data (will be determined automatically if not given)
Returns:
true if copying was (at least partly) successful

Definition at line 197 of file chunk.hpp.

static Chunk isis::data::Chunk::createByID ( short unsigned int  ID,
size_t  nrOfColumns,
size_t  nrOfRows = 1,
size_t  nrOfSlices = 1,
size_t  nrOfTimesteps = 1,
bool  fakeValid = false 
) [static]

Creates a new empty Chunk without properties but of specified type and specified size.

Chunk::iterator isis::data::Chunk::end ( )

Definition at line 349 of file chunk.cpp.

Chunk::const_iterator isis::data::Chunk::end ( ) const

Definition at line 358 of file chunk.cpp.

template<typename TYPE >
size_t isis::data::Chunk::foreachVoxel ( VoxelOp< TYPE > &  op,
util::vector4< size_t >  offset 
) [inline]

Run a functor on every Voxel in the chunk.

If the data of the chunk are not of type TYPE, behaviour is undefined. (If _DEBUG_LOG is enabled you will get an error message before the progrmm will crash).

Parameters:
opa functor inheriting from VoxelOp
offsetoffset to be added to the voxel position before op is called
Returns:
amount of operations which returned false - so 0 is good!

Definition at line 136 of file chunk.hpp.

template<typename TYPE >
size_t isis::data::Chunk::foreachVoxel ( VoxelOp< TYPE > &  op) [inline]

Run a functor on every Voxel in the chunk.

Parameters:
opa functor inheriting from VoxelOp
Returns:
amount of operations which returned false - so 0 is good!

Definition at line 158 of file chunk.hpp.

size_t isis::data::Chunk::getBytesPerVoxel ( ) const

Definition at line 93 of file chunk.cpp.

std::pair< util::ValueReference, util::ValueReference > isis::data::Chunk::getMinMax ( ) const

Definition at line 159 of file chunk.cpp.

scaling_pair isis::data::Chunk::getScalingTo ( unsigned short  typeID,
autoscaleOption  scaleopt = autoscale 
) const

get the scaling (and offset) which would be used in an conversion to the given type

Definition at line 164 of file chunk.cpp.

scaling_pair isis::data::Chunk::getScalingTo ( unsigned short  typeID,
const std::pair< util::ValueReference, util::ValueReference > &  minmax,
autoscaleOption  scaleopt = autoscale 
) const

Definition at line 168 of file chunk.cpp.

unsigned short isis::data::Chunk::getTypeID ( ) const

Definition at line 101 of file chunk.cpp.

std::string isis::data::Chunk::getTypeName ( ) const

Definition at line 97 of file chunk.cpp.

template<typename TYPE >
const ValueArray<TYPE> isis::data::Chunk::getValueArray ( ) const [inline]

Definition at line 171 of file chunk.hpp.

const ValueArrayBase& isis::data::Chunk::getValueArrayBase ( ) const [inline]

Definition at line 168 of file chunk.hpp.

const util::ValueReference isis::data::Chunk::getVoxelValue ( size_t  nrOfColumns,
size_t  nrOfRows = 0,
size_t  nrOfSlices = 0,
size_t  nrOfTimesteps = 0 
) const

Definition at line 363 of file chunk.cpp.

template<typename T >
bool isis::data::Chunk::is ( ) const [inline]

Definition at line 216 of file chunk.hpp.

Chunk & isis::data::Chunk::operator= ( const Chunk ref)

Reimplemented in isis::data::MemChunk< TYPE >, and isis::data::MemChunkNonDel< TYPE >.

Definition at line 173 of file chunk.cpp.

const util::PropertyValue & isis::data::Chunk::propertyValueAt ( const util::PropertyMap::KeyType key,
size_t  at 
) const

Access properties of the next lower dimension (e.g.

slice-timings in volumes) This is there for effiency on IO only (you don't have to split up chunks just to store some properties). It will be resolved by reindexing anyway. So, in an clean Image Chunks will never have such sub-properties.

Definition at line 336 of file chunk.cpp.

util::PropertyValue & isis::data::Chunk::propertyValueAt ( const util::PropertyMap::KeyType key,
size_t  at 
)

Access properties of the next lower dimension (e.g.

slice-timings in volumes) This is there for effiency on IO only (you don't have to split up chunks just to store some properties). It will be resolved by reindexing anyway. So, in an clean Image Chunks will never have such sub-properties.

Definition at line 324 of file chunk.cpp.

void isis::data::Chunk::setVoxelValue ( const util::ValueReference val,
size_t  nrOfColumns,
size_t  nrOfRows = 0,
size_t  nrOfSlices = 0,
size_t  nrOfTimesteps = 0 
)

Definition at line 375 of file chunk.cpp.

std::list< Chunk > isis::data::Chunk::splice ( dimensions  atDim) const

Splices the chunk at the given dimension and all dimensions above.

As this will not set or use any property

  • they have to be modified afterwards
  • this can be done on chunks without any property (aka invalid Chunks) E.g. splice\(columnDim\) on a chunk of the size 512x512x128 will result in 512*128 chunks of the size 512x1x1

Definition at line 253 of file chunk.cpp.

void isis::data::Chunk::swapAlong ( const dimensions  dim) const

Swaps the image along a dimension dim in image space.

Definition at line 288 of file chunk.cpp.

bool isis::data::Chunk::transformCoords ( boost::numeric::ublas::matrix< float >  transform_matrix,
bool  transformCenterIsImageCenter = false 
) [inline]

Transforms the image coordinate system into an other system by multiplying the orientation matrix with a user defined transformation matrix.

Additionally, the index origin will be transformed into the new coordinate system. This function only changes the

IMPORTANT!: If you call this function with a matrix other than the identidy matrix, it's not guaranteed that the image is still in ISIS space according to the DICOM conventions. Maybe some ISIS algorithms that depend on correct image orientations won't work as expected. Use this method with caution!

Definition at line 259 of file chunk.hpp.

size_t isis::data::Chunk::useCount ( ) const
Returns:
the number of cheap-copy-chunks using the same memory as this

Definition at line 283 of file chunk.cpp.

template<typename TYPE >
const TYPE& isis::data::Chunk::voxel ( size_t  nrOfColumns,
size_t  nrOfRows = 0,
size_t  nrOfSlices = 0,
size_t  nrOfTimesteps = 0 
) const [inline]

Gets a const reference of the element at a given index.

If index is invalid, behaviour is undefined. Most probably it will crash. If _ENABLE_DATA_DEBUG is true an error message will be send (but it will _not_ stop).

Definition at line 112 of file chunk.hpp.

template<typename TYPE >
TYPE& isis::data::Chunk::voxel ( size_t  nrOfColumns,
size_t  nrOfRows = 0,
size_t  nrOfSlices = 0,
size_t  nrOfTimesteps = 0 
) [inline]

Gets a reference to the element at a given index.

If index is invalid, behaviour is undefined. Most probably it will crash. If _ENABLE_DATA_DEBUG is true an error message will be send (but it will _not_ stop).

Definition at line 97 of file chunk.hpp.


Friends And Related Function Documentation

friend class Image [friend]

Definition at line 67 of file chunk.hpp.

friend class std::vector< Chunk > [friend]

Definition at line 68 of file chunk.hpp.


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