NPL
Neurological Programs and Libraries
|
Basic storage unity for ND array. Creates a big chunk of memory. More...
#include <ndarray.h>
Inherits npl::NDArray.
Inherited by npl::MRImageStore< D, T > [virtual]
.
Public Member Functions | |
NDArrayStore () | |
Constructor with initializer list. Orientation will be default (direction = identity, spacing = 1, origin = 0). More... | |
NDArrayStore (const std::initializer_list< size_t > &dim) | |
Constructor with initializer list. Orientation will be default (direction = identity, spacing = 1, origin = 0). More... | |
NDArrayStore (const std::vector< size_t > &dim) | |
Constructor with vector. Orientation will be default (direction = identity, spacing = 1, origin = 0). More... | |
NDArrayStore (size_t len, const size_t *dim) | |
Constructor with array of length len, Orientation will be default (direction = identity, spacing = 1, origin = 0). More... | |
NDArrayStore (size_t len, const size_t *dim, T *ptr, const std::function< void(void *)> &deleter) | |
Constructor which uses a preexsting array, to graft into the array. No new allocation will be performed, however ownership of the array will be taken, meaning it could be deleted anytime after this constructor completes. More... | |
~NDArrayStore () | |
T & | operator[] (const int64_t *index) |
T & | operator[] (const std::vector< int64_t > &index) |
T & | operator[] (std::initializer_list< int64_t > index) |
T & | operator[] (int64_t pixel) |
const T & | operator[] (const int64_t *index) const |
const T & | operator[] (const std::vector< int64_t > &index) const |
const T & | operator[] (std::initializer_list< int64_t > index) const |
const T & | operator[] (int64_t pixel) const |
size_t | ndim () const |
size_t | bytes () const |
size_t | bytesper () const |
size_t | elements () const |
size_t | dim (size_t dir) const |
const size_t * | dim () const |
void | resize (const size_t dim[D]) |
Changes the dimensions (size) of the image. This does not affect rank/dimensionality. More... | |
void | resize (std::initializer_list< size_t > dim) |
Changes the dimensions (size) of the image. This does not affect rank/dimensionality. More... | |
PixelT | type () const |
Return enum PixelT type of pixels. More... | |
void * | data () |
Returns a pointer to the data array. Be careful. More... | |
const void * | data () const |
Returns a pointer to the data array. Be careful. More... | |
void | graft (const size_t dim[D], T *ptr, const std::function< void(void *)> &deleter) |
Grafts data of the given dimensions into the image, effectively changing the image size. More... | |
virtual int | write (std::string filename, double version=1) const |
Write the image to a nifti file. More... | |
virtual ptr< NDArray > | copy () const |
Performs a deep copy of the entire array. More... | |
virtual ptr< NDArray > | createAnother () const |
Creates an identical array, but does not initialize pixel values. More... | |
virtual ptr< NDArray > | createAnother (size_t newdims, const size_t *newsize, PixelT newtype) const |
Create a new array that is the same underlying type as this. If this is an image then it will also copy the metdata, but NOT the pixels. More... | |
virtual ptr< NDArray > | createAnother (PixelT newtype) const |
Create a new array that is the same underlying type as this, but with a different pixel type. More... | |
virtual ptr< NDArray > | createAnother (size_t newdims, const size_t *newsize) const |
Create a new array that is the same underlying type as this, and same pixel type and orientation as this, but with a different size. More... | |
virtual ptr< NDArray > | copyCast (size_t newdims, const size_t *newsize, PixelT newtype) const |
Create a new array that is a copy of the input, possibly with new dimensions and pixeltype. The new array will have all overlapping pixels copied from the old array. More... | |
virtual ptr< NDArray > | copyCast (PixelT newtype) const |
Create a new array that is a copy of the input, with same dimensions but pxiels cast to newtype. The new array will have all overlapping pixels copied from the old array. More... | |
virtual ptr< NDArray > | copyCast (size_t newdims, const size_t *newsize) const |
Create a new array that is a copy of the input, possibly with new dimensions or size. The new array will have all overlapping pixels copied from the old array. The new array will have the same pixel type as the input array. More... | |
virtual ptr< NDArray > | extractCast (size_t len, const int64_t *index, const size_t *size) const |
Create a new array that is a copy of the input, possibly with new dimensions or size. The new array will have all overlapping pixels copied from the old array. The new array will have the same pixel type as the input array. More... | |
virtual ptr< NDArray > | extractCast (size_t len, const size_t *size) const |
Create a new array that is a copy of the input, possibly with new dimensions or size. The new array will have all overlapping pixels copied from the old array. The new array will have the same pixel type as the input array. Index assumed to be [0,0,...], so the output image will start at the origin of this image. More... | |
virtual ptr< NDArray > | extractCast (size_t len, const int64_t *index, const size_t *size, PixelT newtype) const |
Create a new array that is a copy of the input, possibly with new dimensions or size. The new array will have all overlapping pixels copied from the old array. The new array will have the same pixel type as the input array. More... | |
virtual ptr< NDArray > | extractCast (size_t len, const size_t *size, PixelT newtype) const |
Create a new array that is a copy of the input, possibly with new dimensions or size. The new array will have all overlapping pixels copied from the old array. The new array will have the same pixel type as the input array. Index assumed to be [0,0,...], so the output image will start at the origin of this image. More... | |
void | zero () |
Sets all elements to zero. More... | |
virtual void * | __getAddr (std::initializer_list< int64_t > index) const |
virtual void * | __getAddr (size_t len, const int64_t *index) const |
virtual void * | __getAddr (const std::vector< int64_t > &index) const |
virtual void * | __getAddr (int64_t i) const |
virtual void * | __getAddr (int64_t x, int64_t y, int64_t z, int64_t t) const |
virtual int64_t | getLinIndex (std::initializer_list< int64_t > index) const |
virtual int64_t | getLinIndex (size_t len, const int64_t *index) const |
virtual int64_t | getLinIndex (const std::vector< int64_t > &index) const |
virtual int64_t | getLinIndex (int64_t x, int64_t y, int64_t z, int64_t t) const |
virtual int64_t | tlen () const |
This function just returns the number of elements in a theoretical fourth dimension (ignoring orgnaization of higher dimensions) More... | |
bool | floatType () const |
Returns true if the stored type is FLOAT32, FLOAT64, or FLOAT128, ie is a pure float type. More... | |
bool | complexType () const |
Returns true if the stored type is COMPLEX256, COMPLEX128, or COMPLEX64, ie is a complex floating point type. More... | |
bool | signedType () const |
Returns true if the stored type is a variant of signed integer . More... | |
bool | unsignedType () const |
Returns true if the stored type is a variant of unsigned signed integer. More... | |
ptr< NDArray > | getPtr () |
ptr< const NDArray > | getConstPtr () const |
Public Attributes | |
T * | _m_data |
size_t | _m_stride [D] |
size_t | _m_dim [D] |
Protected Member Functions | |
void | updateStrides () |
virtual int | writeNifti1Image (gzFile file) const |
virtual int | writeNifti2Image (gzFile file) const |
virtual int | writeNifti1Header (gzFile file) const |
virtual int | writeNifti2Header (gzFile file) const |
virtual int | writePixels (gzFile file) const |
virtual int | writeJSON (gzFile file) const |
virtual int | writeCSV (gzFile file) const |
Protected Attributes | |
std::function< void(void *)> | m_freefunc |
The function which should be called when deleting data. By default this will just be delete[], but if data is grafted or if. More... | |
Basic storage unity for ND array. Creates a big chunk of memory.
D | dimension of array |
T | type of sample |
npl::NDArrayStore< D, T >::NDArrayStore | ( | ) |
Constructor with initializer list. Orientation will be default (direction = identity, spacing = 1, origin = 0).
npl::NDArrayStore< D, T >::NDArrayStore | ( | const std::initializer_list< size_t > & | dim | ) |
Constructor with initializer list. Orientation will be default (direction = identity, spacing = 1, origin = 0).
dim | dimensions of input, the length of this initializer list may not be fully used if a_args is longer than D. If it is shorter then D then additional dimensions are left as size 1. |
npl::NDArrayStore< D, T >::NDArrayStore | ( | const std::vector< size_t > & | dim | ) |
Constructor with vector. Orientation will be default (direction = identity, spacing = 1, origin = 0).
dim | dimensions of input, the length of this initializer list may not be fully used if a_args is longer than D. If it is shorter then D then additional dimensions are left as size 1. |
npl::NDArrayStore< D, T >::NDArrayStore | ( | size_t | len, |
const size_t * | dim | ||
) |
Constructor with array of length len, Orientation will be default (direction = identity, spacing = 1, origin = 0).
len | Length of array 'size' |
dim | dimensions of input, the length of this initializer list may not be fully used if a_args is longer than D. If it is shorter then D then additional dimensions are left as size 1. |
npl::NDArrayStore< D, T >::NDArrayStore | ( | size_t | len, |
const size_t * | dim, | ||
T * | ptr, | ||
const std::function< void(void *)> & | deleter | ||
) |
Constructor which uses a preexsting array, to graft into the array. No new allocation will be performed, however ownership of the array will be taken, meaning it could be deleted anytime after this constructor completes.
len | Length of array 'size' |
dim | dimensions of input, the length of this initializer list may not be fully used if a_args is longer than D. If it is shorter then D then additional dimensions are left as size 1. |
ptr | Pointer to data array, should be allocated with new, and size should be exactly sizeof(T)*size[0]*size[1]*...*size[len-1] |
deleter | Function which should be used to delete ptr |
|
inline |
|
inlinevirtual |
Implements npl::NDArray.
|
inlinevirtual |
Implements npl::NDArray.
|
inlinevirtual |
Implements npl::NDArray.
|
inlinevirtual |
Implements npl::NDArray.
|
inlinevirtual |
Implements npl::NDArray.
|
virtual |
Implements npl::NDArray.
|
virtual |
Implements npl::NDArray.
|
inlineinherited |
|
virtual |
Performs a deep copy of the entire array.
Implements npl::NDArray.
Reimplemented in npl::MRImageStore< D, T >, npl::MRImageStore< 3, double >, npl::MRImageStore< 4, double >, and npl::MRImageStore< 5, double >.
|
virtual |
Create a new array that is a copy of the input, possibly with new dimensions and pixeltype. The new array will have all overlapping pixels copied from the old array.
newdims | Number of dimensions in output array |
newsize | Input array sized 'newdims', indicating size of output array |
newtype | Type of pixels in output array |
Implements npl::NDArray.
Reimplemented in npl::MRImageStore< D, T >, npl::MRImageStore< 3, double >, npl::MRImageStore< 4, double >, and npl::MRImageStore< 5, double >.
|
virtual |
Create a new array that is a copy of the input, with same dimensions but pxiels cast to newtype. The new array will have all overlapping pixels copied from the old array.
newtype | Type of pixels in output array |
Implements npl::NDArray.
Reimplemented in npl::MRImageStore< D, T >, npl::MRImageStore< 3, double >, npl::MRImageStore< 4, double >, and npl::MRImageStore< 5, double >.
|
virtual |
Create a new array that is a copy of the input, possibly with new dimensions or size. The new array will have all overlapping pixels copied from the old array. The new array will have the same pixel type as the input array.
newdims | Number of dimensions in output array |
newsize | Size of output array |
Implements npl::NDArray.
Reimplemented in npl::MRImageStore< D, T >, npl::MRImageStore< 3, double >, npl::MRImageStore< 4, double >, and npl::MRImageStore< 5, double >.
|
virtual |
Creates an identical array, but does not initialize pixel values.
Implements npl::NDArray.
Reimplemented in npl::MRImageStore< D, T >, npl::MRImageStore< 3, double >, npl::MRImageStore< 4, double >, and npl::MRImageStore< 5, double >.
|
virtual |
Create a new array that is the same underlying type as this. If this is an image then it will also copy the metdata, but NOT the pixels.
newdims | Number of dimensions in copied output |
newsize | Size of output, this array should be of size newdims |
newtype | Type of pixels in output array |
Implements npl::NDArray.
Reimplemented in npl::MRImageStore< D, T >, npl::MRImageStore< 3, double >, npl::MRImageStore< 4, double >, and npl::MRImageStore< 5, double >.
|
virtual |
Create a new array that is the same underlying type as this, but with a different pixel type.
newtype | Type of pixels in output array |
Implements npl::NDArray.
Reimplemented in npl::MRImageStore< D, T >, npl::MRImageStore< 3, double >, npl::MRImageStore< 4, double >, and npl::MRImageStore< 5, double >.
|
virtual |
Create a new array that is the same underlying type as this, and same pixel type and orientation as this, but with a different size.
newdims | Number of dimensions in output array |
newsize | Input array of length newdims that gives the size of output array, |
Implements npl::NDArray.
Reimplemented in npl::MRImageStore< D, T >, npl::MRImageStore< 3, double >, npl::MRImageStore< 4, double >, and npl::MRImageStore< 5, double >.
|
inlinevirtual |
|
inlinevirtual |
|
virtual |
Implements npl::NDArray.
|
virtual |
Implements npl::NDArray.
|
virtual |
Implements npl::NDArray.
|
virtual |
Create a new array that is a copy of the input, possibly with new dimensions or size. The new array will have all overlapping pixels copied from the old array. The new array will have the same pixel type as the input array.
len | Length of index/newsize arrays |
index | Index to start copying from. |
size | Size of output image. Note length 0 dimensions will be removed, while length 1 dimensions will be left. |
Implements npl::NDArray.
Reimplemented in npl::MRImageStore< D, T >, npl::MRImageStore< 3, double >, npl::MRImageStore< 4, double >, and npl::MRImageStore< 5, double >.
|
virtual |
Create a new array that is a copy of the input, possibly with new dimensions or size. The new array will have all overlapping pixels copied from the old array. The new array will have the same pixel type as the input array. Index assumed to be [0,0,...], so the output image will start at the origin of this image.
len | Length of index/size arrays |
size | Size of output image. Note length 0 dimensions will be removed, while length 1 dimensions will be left. |
Implements npl::NDArray.
Reimplemented in npl::MRImageStore< D, T >, npl::MRImageStore< 3, double >, npl::MRImageStore< 4, double >, and npl::MRImageStore< 5, double >.
|
virtual |
Create a new array that is a copy of the input, possibly with new dimensions or size. The new array will have all overlapping pixels copied from the old array. The new array will have the same pixel type as the input array.
len | Length of index/size arrays |
index | Index to start copying from. |
size | Size of output image. Note length 0 dimensions will be removed, while length 1 dimensions will be left. |
newtype | Pixel type of output image. |
Implements npl::NDArray.
Reimplemented in npl::MRImageStore< D, T >, npl::MRImageStore< 3, double >, npl::MRImageStore< 4, double >, and npl::MRImageStore< 5, double >.
|
virtual |
Create a new array that is a copy of the input, possibly with new dimensions or size. The new array will have all overlapping pixels copied from the old array. The new array will have the same pixel type as the input array. Index assumed to be [0,0,...], so the output image will start at the origin of this image.
len | Length of index/size arrays |
size | Size of output image. Note length 0 dimensions will be removed, while length 1 dimensions will be left. |
newtype | Pixel type of output image. |
Implements npl::NDArray.
Reimplemented in npl::MRImageStore< D, T >, npl::MRImageStore< 3, double >, npl::MRImageStore< 4, double >, and npl::MRImageStore< 5, double >.
|
inlineinherited |
|
virtual |
Implements npl::NDArray.
|
virtual |
Implements npl::NDArray.
|
virtual |
Implements npl::NDArray.
|
virtual |
Implements npl::NDArray.
void npl::NDArrayStore< D, T >::graft | ( | const size_t | dim[D], |
T * | ptr, | ||
const std::function< void(void *)> & | deleter | ||
) |
Grafts data of the given dimensions into the image, effectively changing the image size.
dim | Dimensions of image |
ptr | Pointer to data which we will take control of |
deleter | Function which can be called on ptr to delete it. |
|
virtual |
Implements npl::NDArray.
T& npl::NDArrayStore< D, T >::operator[] | ( | const int64_t * | index | ) |
T& npl::NDArrayStore< D, T >::operator[] | ( | const std::vector< int64_t > & | index | ) |
T& npl::NDArrayStore< D, T >::operator[] | ( | std::initializer_list< int64_t > | index | ) |
T& npl::NDArrayStore< D, T >::operator[] | ( | int64_t | pixel | ) |
const T& npl::NDArrayStore< D, T >::operator[] | ( | const int64_t * | index | ) | const |
const T& npl::NDArrayStore< D, T >::operator[] | ( | const std::vector< int64_t > & | index | ) | const |
const T& npl::NDArrayStore< D, T >::operator[] | ( | std::initializer_list< int64_t > | index | ) | const |
const T& npl::NDArrayStore< D, T >::operator[] | ( | int64_t | pixel | ) | const |
void npl::NDArrayStore< D, T >::resize | ( | const size_t | dim[D] | ) |
Changes the dimensions (size) of the image. This does not affect rank/dimensionality.
dim | New size |
void npl::NDArrayStore< D, T >::resize | ( | std::initializer_list< size_t > | dim | ) |
Changes the dimensions (size) of the image. This does not affect rank/dimensionality.
dim | New size |
|
inlineinherited |
|
inlinevirtual |
This function just returns the number of elements in a theoretical fourth dimension (ignoring orgnaization of higher dimensions)
Implements npl::NDArray.
|
virtual |
|
inlineinherited |
|
protected |
|
virtual |
Write the image to a nifti file.
filename | Filename |
version | Version of nifti to use |
Implements npl::NDArray.
Reimplemented in npl::MRImageStore< D, T >, npl::MRImageStore< 3, double >, npl::MRImageStore< 4, double >, and npl::MRImageStore< 5, double >.
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
virtual |
Sets all elements to zero.
Implements npl::NDArray.
T* npl::NDArrayStore< D, T >::_m_data |
size_t npl::NDArrayStore< D, T >::_m_dim[D] |
size_t npl::NDArrayStore< D, T >::_m_stride[D] |
|
protectedinherited |