Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkITKImageSequenceReader.h
Go to the documentation of this file.
1/*==========================================================================
2
3 Copyright (c) Ebatinca S.L., Las Palmas de Gran Canaria, Spain
4
5 See COPYRIGHT.txt
6 or http://www.slicer.org/copyright/copyright.txt for details.
7
8 Unless required by applicable law or agreed to in writing, software
9 distributed under the License is distributed on an "AS IS" BASIS,
10 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 See the License for the specific language governing permissions and
12 limitations under the License.
13
14 This file was originally developed by Csaba Pinter, Ebatinca, funded
15 by the grant GRT-00000485 of Children's Hospital of Philadelphia, USA.
16
17==========================================================================*/
18
19#ifndef __vtkITKImageSequenceReader_h
20#define __vtkITKImageSequenceReader_h
21
22#include "vtkMedicalImageReader2.h"
23
24#include "vtkMatrix4x4.h"
25
26#include "vtkITK.h"
27#include "vtkITKImageWriter.h"
28
29class VTK_ITK_EXPORT vtkITKImageSequenceReader : public vtkMedicalImageReader2
30{
31public:
33 vtkTypeMacro(vtkITKImageSequenceReader, vtkMedicalImageReader2);
34 void PrintSelf(ostream& os, vtkIndent indent) override;
35
37 vtkSetMacro(CurrentFrameIndex, unsigned int);
39 vtkGetMacro(CurrentFrameIndex, unsigned int);
40
42 vtkSetMacro(NumberOfFrames, unsigned int);
44 vtkGetMacro(NumberOfFrames, unsigned int);
45
47 vtkSetObjectMacro(RasToIjkMatrix, vtkMatrix4x4);
48 vtkGetObjectMacro(RasToIjkMatrix, vtkMatrix4x4);
49
51 vtkSetMacro(VoxelVectorType, int);
52 vtkGetMacro(VoxelVectorType, int);
53
55 const std::vector<std::string> GetHeaderKeysVector();
57 const std::map<std::string, std::string> GetHeaderKeysMap();
59 const char* GetHeaderValue(const char* key);
60
62 const char* GetAxisLabel(unsigned int axis);
63
65 const char* GetAxisUnit(unsigned int axis);
66
70 static bool ParseSequenceItemMetadataKey(const std::string& key, unsigned int& axisIndex, unsigned int& frameIndex, std::string& attributeName);
71
72 // Format axis and frame index values and attribute name into metadata key.
73 // For example: "axis 3 item 0025 SomeAttributeName"
74 static std::string FormatSequenceItemMetadataKey(unsigned int axisIndex, unsigned int frameIndex, const std::string& attributeName);
75
79 static bool ParseAndStoreSequenceItemMetadata(const std::string& key,
80 const char* attributeValue,
81 std::vector<std::string>& attributeNames,
82 std::vector<std::vector<std::string>>& frameAttributeValues);
83
84 vtkGetMacro(SequenceAxisLabel, std::string);
85 vtkGetMacro(SequenceAxisUnit, std::string);
86
88 vtkImageData* GetCachedImage(unsigned int index);
90
91protected:
94
95 // void ExecuteInformation() override;
96 void ExecuteDataWithInformation(vtkDataObject* output, vtkInformation* outInfo) override;
97
98protected:
100 unsigned int CurrentFrameIndex{ 0 };
101
103 unsigned int NumberOfFrames{ 0 };
104
106 vtkMatrix4x4* RasToIjkMatrix{ nullptr };
107
109
111 std::map<std::string, std::string> HeaderKeyValueMap;
112
113 // Axis labels read from the header.
114 std::map<unsigned int, std::string> AxisLabels;
115 // Axis units read from the header.
116 std::map<unsigned int, std::string> AxisUnits;
117 // Sequence axis label read from the header.
118 std::string SequenceAxisLabel;
119 // Sequence axis unit read from the header.
120 std::string SequenceAxisUnit;
121
122 std::vector<vtkSmartPointer<vtkImageData>> CachedImages;
123
124private:
126 void operator=(const vtkITKImageSequenceReader&) = delete;
127};
128
129#endif
vtkMatrix4x4 * RasToIjkMatrix
RAS to IJK matrix.
const char * GetAxisUnit(unsigned int axis)
Get unit for specified axis.
std::map< unsigned int, std::string > AxisUnits
void ExecuteDataWithInformation(vtkDataObject *output, vtkInformation *outInfo) override
static bool ParseAndStoreSequenceItemMetadata(const std::string &key, const char *attributeValue, std::vector< std::string > &attributeNames, std::vector< std::vector< std::string > > &frameAttributeValues)
vtkImageData * GetCachedImage(unsigned int index)
std::map< unsigned int, std::string > AxisLabels
std::map< std::string, std::string > HeaderKeyValueMap
Key/value pairs read from the header.
void PrintSelf(ostream &os, vtkIndent indent) override
const std::map< std::string, std::string > GetHeaderKeysMap()
Get the map of keys in the header.
unsigned int CurrentFrameIndex
Current frame index that is extracted from the sequence image to the output port.
static std::string FormatSequenceItemMetadataKey(unsigned int axisIndex, unsigned int frameIndex, const std::string &attributeName)
unsigned int NumberOfFrames
Number of frames in recently read image. Set in first Update. Read only.
const char * GetAxisLabel(unsigned int axis)
Get label for specified axis.
static bool ParseSequenceItemMetadataKey(const std::string &key, unsigned int &axisIndex, unsigned int &frameIndex, std::string &attributeName)
~vtkITKImageSequenceReader() override
static vtkITKImageSequenceReader * New()
const std::vector< std::string > GetHeaderKeysVector()
Get the list of keys in the header.
const char * GetHeaderValue(const char *key)
Get a value given a key in the header.
std::vector< vtkSmartPointer< vtkImageData > > CachedImages
unsigned int GetNumberOfCachedImages()