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
94 vtkImageData* GetCachedImage(unsigned int index);
96
97protected:
100
101 // void ExecuteInformation() override;
102 void ExecuteDataWithInformation(vtkDataObject* output, vtkInformation* outInfo) override;
103
104protected:
106 unsigned int CurrentFrameIndex{ 0 };
107
109 unsigned int NumberOfFrames{ 0 };
110
112 vtkMatrix4x4* RasToIjkMatrix{ nullptr };
113
115
117 std::map<std::string, std::string> HeaderKeyValueMap;
118
119 // Axis labels read from the header.
120 std::map<unsigned int, std::string> AxisLabels;
121 // Axis units read from the header.
122 std::map<unsigned int, std::string> AxisUnits;
123 // Sequence axis label read from the header.
124 std::string SequenceAxisLabel;
125 // Sequence axis unit read from the header.
126 std::string SequenceAxisUnit;
127
128 std::vector<vtkSmartPointer<vtkImageData>> CachedImages;
129
130private:
132 void operator=(const vtkITKImageSequenceReader&) = delete;
133
134 class vtkInternal;
135 vtkInternal* Internal{ nullptr };
136};
137
138#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()