Slicer 5.13
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
88 static bool IsImageSequenceFile(const char* fileName);
89
90 vtkGetMacro(SequenceAxisLabel, std::string);
91 vtkGetMacro(SequenceAxisUnit, std::string);
92
95 vtkGetMacro(VoxelValueUnit, std::string);
96
99 vtkGetMacro(VoxelValueLabel, std::string);
100
102 vtkImageData* GetCachedImage(unsigned int index);
104
105protected:
108
109 // void ExecuteInformation() override;
110 void ExecuteDataWithInformation(vtkDataObject* output, vtkInformation* outInfo) override;
111
112protected:
114 unsigned int CurrentFrameIndex{ 0 };
115
117 unsigned int NumberOfFrames{ 0 };
118
120 vtkMatrix4x4* RasToIjkMatrix{ nullptr };
121
123
125 std::map<std::string, std::string> HeaderKeyValueMap;
126
127 // Axis labels read from the header.
128 std::map<unsigned int, std::string> AxisLabels;
129 // Axis units read from the header.
130 std::map<unsigned int, std::string> AxisUnits;
131 // Sequence axis label read from the header.
132 std::string SequenceAxisLabel;
133 // Sequence axis unit read from the header.
134 std::string SequenceAxisUnit;
135 // Unit of the voxel values read from the header (units of the pixel axis).
136 std::string VoxelValueUnit;
137 // Quantity of the voxel values read from the header (labels of the pixel axis).
138 std::string VoxelValueLabel;
139
140 std::vector<vtkSmartPointer<vtkImageData>> CachedImages;
141
142private:
144 void operator=(const vtkITKImageSequenceReader&) = delete;
145
146 class vtkInternal;
147 vtkInternal* Internal{ nullptr };
148};
149
150#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.
static bool IsImageSequenceFile(const char *fileName)
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()