NPL
Neurological Programs and Libraries
|
Constant iterator for NDArray. This is slightly different from order iterator in that the ROI may be broken down into chunks. When the end of a chunk is reached, no more iteration can be performed until nextChunk() is called. isEnd() will return false until nextChunk() is called while the current chunk is at the last available. Note that if setBreaks uses an array that is smaller than input dimension, then the whole of the dimension will be used. More...
#include <iterators.h>
Inherits npl::ChunkSlicer.
Public Member Functions | |
ChunkConstIter () | |
Default constructor. Note, this will segfault if you don't use setArray to set the target NDArray/Image. More... | |
ChunkConstIter (std::shared_ptr< const NDArray > in) | |
void | setArray (ptr< const NDArray > in) |
ChunkConstIter & | operator++ () |
Prefix increment operator. More... | |
ChunkConstIter & | operator-- () |
Prefix decrement operator. More... | |
ChunkConstIter & | nextChunk () |
Prefix increment operator. More... | |
ChunkConstIter & | prevChunk () |
Prefix decrement operator. More... | |
T | operator* () const |
Dereference operator. More... | |
T | get () const |
Dereference operator. More... | |
void | goBegin () |
Go to beginning of iteration. More... | |
void | goEnd () |
Go to end of iteration. More... | |
bool | isEnd () const |
Are we one past the last element? More... | |
bool | eof () const |
Are we one past the last element? More... | |
bool | isBegin () const |
Are we at the first element. More... | |
bool | operator== (const ChunkConstIter &other) const |
Whether the position and parent are the same as another. More... | |
bool | operator!= (const ChunkConstIter &other) const |
Whether the position and parent are different from another. More... | |
bool | operator< (const ChunkConstIter &other) const |
If the parents are different then false, if they are the same, returns whether this iterator is before the other. More... | |
bool | operator> (const ChunkConstIter &other) const |
If the parents are different then false, if they are the same, returns whether this iterator is after the other. More... | |
bool | operator<= (const ChunkConstIter &other) const |
If the parents are different then false, if they are the same, returns whether this iterator is the same or before the other. More... | |
bool | operator>= (const ChunkConstIter &other) const |
If the parents are different then false, if they are the same, returns whether this iterator is the same or after the other. More... | |
void | setDim (size_t ndim, const size_t *dim) |
Sets the dimensionality of iteration, and the dimensions of the image. More... | |
bool | isChunkBegin () const |
Returns true when we have reached the end of the chunk. More... | |
bool | isChunkEnd () const |
Returns true when we have reached the end of the chunk. More... | |
bool | eoc () const |
Returns true when we have reached the end of the chunk. More... | |
void | goChunkBegin () |
Go to the beginning for the current chunk. More... | |
void | goChunkEnd () |
Jump to the end of current chunk. More... | |
void | goIndex (size_t len, int64_t *newpos) |
Jump to the given position, additional values in newpos beyond dim will be ignored. Any values missing due to ndim > len will be treated as zeros. More... | |
void | goIndex (std::vector< int64_t > newpos) |
Jump to the given position. More... | |
void | index (size_t len, int64_t *index) const |
Places the first len dimension in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ. More... | |
void | index (size_t len, int *index) const |
Places the first len dimension in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ. More... | |
void | index (size_t len, double *index) const |
Places the first len dimension in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ. More... | |
void | index (std::vector< int64_t > &ind) const |
Places the first len dimension in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ. More... | |
void | index (std::vector< int > &ind) const |
Places the first len dimension in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ. More... | |
void | index (std::vector< double > &ind) const |
Places the first len dimension in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ. More... | |
int64_t | index (size_t dd) const |
Returns the index in the specified dimension. More... | |
size_t | linIndex () const |
get linear position of current point More... | |
int64_t | getStride (size_t dd) |
get stride in specified dimension More... | |
void | setROI (size_t len, const size_t *roisize, const int64_t *roistart=NULL) |
Sets the region of interest, with lower bound of 0. During iteration or any motion the position will not move outside the specified range. Invalidates position. More... | |
void | setROI (const std::vector< std::pair< int64_t, int64_t >> &roi) |
Sets the region of interest. During iteration or any motion the position will not move outside the specified range. Extra elements in roi beyond the number of dimensions, are ignored. More... | |
void | setChunkSize (size_t len, const int64_t *sizes, bool defunity=false) |
Set the sizes of chunks for each dimension. Chunks will end every N steps in each of the provided dimension, with the caveout that 0 indicates no breaks in the given dimension. So size = {0, 2, 2} will cause chunks to after . (the default) indicate * that the entire image will be iterated and only one chunk will be used. Defunity will cause the default to be 1 for non-specified dimensions. More... | |
void | setChunkSize (size_t len, const size_t *sizes, bool defunity=false) |
Set the sizes of chunks for each dimension. Chunks will end every N steps in each of the provided dimension, with the caveout that 0 indicates no breaks in the given dimension. So size = {0, 2, 2} will cause chunks to after . (the default) indicate * that the entire image will be iterated and only one chunk will be used. Defunity will cause the default to be 1 for non-specified dimensions. More... | |
void | setLineChunk (size_t dir) |
Sets the chunk sizes so that each chunk is a line in the given dimension. This would be analogous to itk's linear iterator. Usage: More... | |
void | setOrder (const std::vector< size_t > &order, bool revorder=false) |
Sets the order of iteration from ++/– operators. More... | |
void | setOrder (std::initializer_list< size_t > order, bool revorder=false) |
Sets the order of iteration from ++/– operators. More... | |
const std::vector< size_t > & | getOrder () const |
Returns the array giving the order of dimension being traversed. So 3,2,1,0 would mean that the next point in dimension 3 will be next, when wrapping the next point in 2 is visited, when that wraps the next in one and so on. More... | |
Protected Attributes | |
size_t | m_linfirst |
size_t | m_chunkfirst |
bool | m_end |
bool | m_chunkend |
size_t | m_linpos |
std::vector< int64_t > | m_pos |
std::vector< std::pair< int64_t, int64_t > > | m_chunk |
std::vector< size_t > | m_order |
std::vector< std::pair< int64_t, int64_t > > | m_roi |
std::vector< int64_t > | m_chunksizes |
size_t | m_ndim |
std::vector< size_t > | m_dim |
std::vector< size_t > | m_strides |
Constant iterator for NDArray. This is slightly different from order iterator in that the ROI may be broken down into chunks. When the end of a chunk is reached, no more iteration can be performed until nextChunk() is called. isEnd() will return false until nextChunk() is called while the current chunk is at the last available. Note that if setBreaks uses an array that is smaller than input dimension, then the whole of the dimension will be used.
Usage:
ChunkConstIter it(imag); it.setBreaks({0,0,10}); // stop every 10 values of z it.setBreaks({0,0,0,1}); // stop at the end of each volume it.setBreaks({1,1,1,0}); // stop at the end of each time-series it.setBreaks({1,1,1}); // same as above (default = 0) it.setLineChunk(0); // iterates along lines in dimension 0
for(it.goBegin(); !it.isEnd(); it.nextChunk()) { for(it.goBegin(); !it.isChunkEnd(); ++it) { it.get(); ... } }
T |
Definition at line 1206 of file iterators.h.
|
inline |
Default constructor. Note, this will segfault if you don't use setArray to set the target NDArray/Image.
Definition at line 1214 of file iterators.h.
|
inline |
Definition at line 1216 of file iterators.h.
|
inlineinherited |
|
inline |
Are we one past the last element?
Definition at line 1370 of file iterators.h.
|
inline |
|
inlineinherited |
|
inlineinherited |
|
inline |
Go to beginning of iteration.
Definition at line 1355 of file iterators.h.
|
inherited |
Go to the beginning for the current chunk.
|
inherited |
Jump to the end of current chunk.
|
inline |
Go to end of iteration.
Definition at line 1360 of file iterators.h.
|
inherited |
Jump to the given position, additional values in newpos beyond dim will be ignored. Any values missing due to ndim > len will be treated as zeros.
len | length of newpos array |
newpos | Position to move to |
|
inherited |
Jump to the given position.
newpos | location to move to |
|
inherited |
Places the first len dimension in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ.
len | size of index array |
index | output index variable |
|
inherited |
Places the first len dimension in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ.
len | size of index |
index | output index variable |
|
inherited |
Places the first len dimension in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ.
len | size of index |
index | output index variable |
|
inlineinherited |
Places the first len dimension in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ.
ind | output index variable |
|
inlineinherited |
Places the first len dimension in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ.
ind | output index variable |
|
inlineinherited |
Places the first len dimension in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ.
ind | output index variable |
|
inlineinherited |
|
inline |
Are we at the first element.
Definition at line 1375 of file iterators.h.
|
inlineinherited |
|
inlineinherited |
|
inline |
Are we one past the last element?
Definition at line 1365 of file iterators.h.
|
inlineinherited |
|
inline |
|
inline |
Whether the position and parent are different from another.
other |
Definition at line 1396 of file iterators.h.
|
inline |
|
inline |
|
inline |
|
inline |
If the parents are different then false, if they are the same, returns whether this iterator is before the other.
other |
Definition at line 1409 of file iterators.h.
|
inline |
If the parents are different then false, if they are the same, returns whether this iterator is the same or before the other.
other |
Definition at line 1451 of file iterators.h.
|
inline |
Whether the position and parent are the same as another.
other |
Definition at line 1384 of file iterators.h.
|
inline |
If the parents are different then false, if they are the same, returns whether this iterator is after the other.
other |
Definition at line 1430 of file iterators.h.
|
inline |
If the parents are different then false, if they are the same, returns whether this iterator is the same or after the other.
other |
Definition at line 1470 of file iterators.h.
|
inline |
|
inline |
Definition at line 1221 of file iterators.h.
|
inherited |
Set the sizes of chunks for each dimension. Chunks will end every N steps in each of the provided dimension, with the caveout that 0 indicates no breaks in the given dimension. So size = {0, 2, 2} will cause chunks to after . (the default) indicate * that the entire image will be iterated and only one chunk will be used. Defunity will cause the default to be 1 for non-specified dimensions.
len | Length of sizes array |
sizes | Size of chunk in each dimension. If you multiply together the elements of sizes that is the MAXIMUM number of iterations between chunks. Note however that there could be less if we are at the edge. |
defunity | Sets the default to unity rather than 0. Thus unreferenced dimensions will be broken up at each step; so {0,1} for a 4D image will be effectively {0,1,1,1} instead of {0,1,0,0}. This is convenient, for instance, if you want to split up based on volumes, {0,0,0} would stop at the end of each volume, whereas the default would be to treat the entire ND-image as a chunk. |
|
inherited |
Set the sizes of chunks for each dimension. Chunks will end every N steps in each of the provided dimension, with the caveout that 0 indicates no breaks in the given dimension. So size = {0, 2, 2} will cause chunks to after . (the default) indicate * that the entire image will be iterated and only one chunk will be used. Defunity will cause the default to be 1 for non-specified dimensions.
len | Length of sizes array |
sizes | Size of chunk in each dimension. If you multiply together the elements of sizes that is the MAXIMUM number of iterations between chunks. Note however that there could be less if we are at the edge. |
defunity | Sets the default to unity rather than 0. Thus unreferenced dimensions will be broken up at each step; so {0,1} for a 4D image will be effectively {0,1,1,1} instead of {0,1,0,0}. This is convenient, for instance, if you want to split up based on volumes, {0,0,0} would stop at the end of each volume, whereas the default would be to treat the entire ND-image as a chunk. |
|
inherited |
Sets the dimensionality of iteration, and the dimensions of the image.
Invalidates position and ROI.
ndim | Number of dimension |
dim | Dimensions (size) |
|
inherited |
Sets the chunk sizes so that each chunk is a line in the given dimension. This would be analogous to itk's linear iterator. Usage:
it.setLineChunk(0); while(!it.isEnd()) { while(!it.isChunkEnd()) {
++it; } it.nextChunk(); }
dir | Dimension to travel linearly along |
|
inherited |
Sets the order of iteration from ++/– operators.
order | vector of priorities, with first element being the fastest iteration and last the slowest. All other dimensions not used will be slower than the last |
revorder | Reverse order, in which case the first element of order will have the slowest iteration, and dimensions not specified in order will be faster than those included. |
|
inherited |
Sets the order of iteration from ++/– operators.
order | vector of priorities, with first element being the fastest iteration and last the slowest. All other dimensions not used will be slower than the last |
revorder | Reverse order, in which case the first element of order will have the slowest iteration, and dimensions not specified in order will be faster than those included. |
|
inherited |
Sets the region of interest, with lower bound of 0. During iteration or any motion the position will not move outside the specified range. Invalidates position.
Invalidates position
len | length of roi array |
roistart | lower bound of ROI |
roisize | Size of ROI (which runs in the block from: [0 to roisize[0]-1,0. to roisize[1]-1, etc] |
|
inherited |
Sets the region of interest. During iteration or any motion the position will not move outside the specified range. Extra elements in roi beyond the number of dimensions, are ignored.
roi | pair of [min,max] values in the desired hypercube |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |