VMTK
Loading...
Searching...
No Matches
vtkvmtkITKArchetypeImageSeriesScalarReader Class Reference

Read a series of files into a single-component (scalar) volume. More...

#include <vtkvmtkITKArchetypeImageSeriesScalarReader.h>

Inheritance diagram for vtkvmtkITKArchetypeImageSeriesScalarReader:
[legend]
Collaboration diagram for vtkvmtkITKArchetypeImageSeriesScalarReader:
[legend]

Public Types

typedef vtkvmtkITKArchetypeImageSeriesReader Superclass
Public Types inherited from vtkvmtkITKArchetypeImageSeriesReader
typedef vtkImageAlgorithm Superclass
typedef itk::SpatialOrientation::ValidCoordinateOrientationFlags CoordinateOrientationCode

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkITKArchetypeImageSeriesScalarReader * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
Public Member Functions inherited from vtkvmtkITKArchetypeImageSeriesReader
vtkvmtkITKArchetypeImageSeriesReader * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual void SetArchetype (const char *)
 Specify the archetype filename for the series.
virtual char * GetArchetype ()
unsigned int GetNumberOfFileNames ()
 See how many file names were generated during ExecuteInformation.
const std::vector< std::string > & GetFileNames ()
 Return all the file names.
unsigned int AddFileName (const char *filename)
const char * GetFileName (unsigned int n)
void ResetFileNames ()
virtual void SetDefaultDataSpacing (double, double, double)
virtual void SetDefaultDataSpacing (double[3])
virtual double * GetDefaultDataSpacing ()
virtual void GetDefaultDataSpacing (double &, double &, double &)
virtual void GetDefaultDataSpacing (double[3])
virtual void SetDefaultDataOrigin (double, double, double)
virtual void SetDefaultDataOrigin (double[3])
virtual double * GetDefaultDataOrigin ()
virtual void GetDefaultDataOrigin (double &, double &, double &)
virtual void GetDefaultDataOrigin (double[3])
virtual void SetFileNameSliceOffset (int)
virtual int GetFileNameSliceOffset ()
virtual void SetFileNameSliceSpacing (int)
virtual int GetFileNameSliceSpacing ()
virtual void SetFileNameSliceCount (int)
virtual int GetFileNameSliceCount ()
virtual int CanReadFile (const char *filename)
 is the given file name a NRRD file?
void SetDesiredCoordinateOrientationToAxial ()
 Set the orientation of the output image.
void SetDesiredCoordinateOrientationToCoronal ()
void SetDesiredCoordinateOrientationToSagittal ()
void SetDesiredCoordinateOrientationToNative ()
virtual CoordinateOrientationCode GetDesiredCoordinateOrientation ()
virtual char GetUseNativeCoordinateOrientation ()
virtual void SetOutputScalarTypeToDouble ()
virtual void SetOutputScalarTypeToFloat ()
virtual void SetOutputScalarTypeToLong ()
virtual void SetOutputScalarTypeToUnsignedLong ()
virtual void SetOutputScalarTypeToInt ()
virtual void SetOutputScalarTypeToUnsignedInt ()
virtual void SetOutputScalarTypeToShort ()
virtual void SetOutputScalarTypeToUnsignedShort ()
virtual void SetOutputScalarTypeToChar ()
virtual void SetOutputScalarTypeToUnsignedChar ()
virtual void SetOutputScalarTypeToNative ()
void SetUseNativeOriginOn ()
 Use image origin from the file.
void SetUseNativeOriginOff ()
 Use image center as origin.
virtual void SetOutputScalarType (int)
 Get the file format. Pixels are this type in the file.
virtual int GetOutputScalarType ()
virtual void SetNumberOfComponents (unsigned int)
 Get number of scalars.
virtual unsigned int GetNumberOfComponents ()
virtual void SetSingleFile (int)
 Whether load in a single file or a series.
virtual int GetSingleFile ()
virtual void SetUseOrientationFromFile (int)
 Whether to use orientation from file.
virtual int GetUseOrientationFromFile ()
vtkMatrix4x4 * GetRasToIjkMatrix ()
 Returns an IJK to RAS transformation matrix.
vtkMatrix4x4 * GetMeasurementFrameMatrix ()
 Returns the Measurement frame matrix.
const itk::MetaDataDictionary & GetMetaDataDictionary () const
 Return the MetaDataDictionary from the ITK layer.
void ParseDictionary ()
unsigned int GetNumberOfItemsInDictionary ()
bool HasKey (char *tag)
const char * GetNthKey (unsigned int n)
const char * GetNthValue (unsigned int n)
const char * GetTagValue (char *tag)
bool GetGroupingByTags ()
 set/get functions for grouping by tags
void SetGroupingByTagsOn ()
void SetGroupingByTagsOff ()
int GetSelectedUID ()
void SetSelectedUID (int v)
int GetSelectedContentTime ()
void SetSelectedContentTime (int v)
int GetSelectedTriggerTime ()
void SetSelectedTriggerTime (int v)
int GetSelectedEchoNumbers ()
void SetSelectedEchoNumbers (int v)
int GetSelectedDiffusion ()
void SetSelectedDiffusion (int v)
int GetSelectedSlice ()
void SetSelectedSlice (int v)
int GetSelectedOrientation ()
void SetSelectedOrientation (int v)
unsigned int GetNumberOfSeriesInstanceUIDs ()
 get number of certain discriminators in the directory
unsigned int GetNumberOfContentTime ()
unsigned int GetNumberOfTriggerTime ()
unsigned int GetNumberOfEchoNumbers ()
unsigned int GetNumberOfSliceLocation ()
unsigned int GetNumberOfDiffusionGradientOrientation ()
unsigned int GetNumberOfImageOrientationPatient ()
unsigned int GetNumberOfImagePositionPatient ()
int ExistSeriesInstanceUID (const char *SeriesInstanceUID)
 check the existance of given discriminator
int ExistContentTime (const char *contentTime)
int ExistTriggerTime (const char *triggerTime)
int ExistEchoNumbers (const char *echoNumbers)
int ExistDiffusionGradientOrientation (float *dgo)
int ExistSliceLocation (float sliceLocation)
int ExistImageOrientationPatient (float *directionCosine)
int ExistImagePositionPatient (float *ipp)
const char * GetNthSeriesInstanceUID (unsigned int n)
 methods to get N-th discriminator
const char * GetNthContentTime (unsigned int n)
const char * GetNthTriggerTime (unsigned int n)
const char * GetNthEchoNumbers (unsigned int n)
float * GetNthDiffusionGradientOrientation (unsigned int n)
float GetNthSliceLocation (unsigned int n)
float * GetNthImageOrientationPatient (unsigned int n)
float * GetNthImagePositionPatient (unsigned int n)
int InsertSeriesInstanceUIDs (const char *aUID)
int InsertContentTime (const char *aTime)
int InsertTriggerTime (const char *aTime)
int InsertEchoNumbers (const char *aEcho)
int InsertDiffusionGradientOrientation (float *a)
int InsertSliceLocation (float a)
int InsertNextSliceLocation ()
int InsertImageOrientationPatient (float *a)
int InsertImagePositionPatient (float *a)
void AnalyzeDicomHeaders ()
void AssembleNthVolume (int n)
int AssembleVolumeContainingArchetype ()
void GroupFiles (int idxSeriesInstanceUID, int idxContentTime, int idxTriggerTime, int idxEchoNumbers, int idxDiffusionGradientOrientation, int idxSliceLocation, int idxImageOrientationPatient)
const char * GetNthFileName (int idxSeriesInstanceUID, int idxContentTime, int idxTriggerTime, int idxEchoNumbers, int idxDiffusionGradientOrientation, int idxSliceLocation, int idxImageOrientationPatient, int n)

Static Public Member Functions

static vtkvmtkITKArchetypeImageSeriesScalarReader * New ()
static int IsTypeOf (const char *type)
static vtkvmtkITKArchetypeImageSeriesScalarReader * SafeDownCast (vtkObjectBase *o)
Static Public Member Functions inherited from vtkvmtkITKArchetypeImageSeriesReader
static vtkvmtkITKArchetypeImageSeriesReader * New ()
static int IsTypeOf (const char *type)
static vtkvmtkITKArchetypeImageSeriesReader * SafeDownCast (vtkObjectBase *o)

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkITKArchetypeImageSeriesScalarReader ()
 ~vtkvmtkITKArchetypeImageSeriesScalarReader ()
int RequestData (vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Protected Member Functions inherited from vtkvmtkITKArchetypeImageSeriesReader
 vtkvmtkITKArchetypeImageSeriesReader ()
 ~vtkvmtkITKArchetypeImageSeriesReader ()
virtual int RequestInformation (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override

Static Protected Member Functions

static void ReadProgressCallback (itk::ProcessObject *obj, const itk::ProgressEvent &, void *data)

Additional Inherited Members

Public Attributes inherited from vtkvmtkITKArchetypeImageSeriesReader
std::vector< std::string > Tags
std::vector< std::string > TagValues
Protected Attributes inherited from vtkvmtkITKArchetypeImageSeriesReader
char * Archetype
int SingleFile
int UseOrientationFromFile
int DataExtent [6]
int OutputScalarType
unsigned int NumberOfComponents
double DefaultDataSpacing [3]
double DefaultDataOrigin [3]
float ScanAxis [3]
float ScanOrigin [3]
int FileNameSliceOffset
int FileNameSliceSpacing
int FileNameSliceCount
vtkMatrix4x4 * RasToIjkMatrix
vtkMatrix4x4 * MeasurementFrameMatrix
char UseNativeCoordinateOrientation
char UseNativeScalarType
bool UseNativeOrigin
bool GroupingByTags
int SelectedUID
int SelectedContentTime
int SelectedTriggerTime
int SelectedEchoNumbers
int SelectedDiffusion
int SelectedSlice
int SelectedOrientation
unsigned int IndexArchetype
std::vector< std::string > FileNames
std::vector< std::pair< double, int > > FileNameSliceKey
CoordinateOrientationCode DesiredCoordinateOrientation
itk::MetaDataDictionary Dictionary
std::vector< std::string > AllFileNames
bool AnalyzeHeader
bool IsOnlyFile
std::vector< std::string > SeriesInstanceUIDs
std::vector< std::string > ContentTime
std::vector< std::string > TriggerTime
std::vector< std::string > EchoNumbers
std::vector< std::vector< float > > DiffusionGradientOrientation
std::vector< float > SliceLocation
std::vector< std::vector< float > > ImageOrientationPatient
std::vector< std::vector< float > > ImagePositionPatient
std::vector< long int > IndexSeriesInstanceUIDs
 index of each dicom file into the above arrays
std::vector< long int > IndexContentTime
std::vector< long int > IndexTriggerTime
std::vector< long int > IndexEchoNumbers
std::vector< long int > IndexDiffusionGradientOrientation
std::vector< long int > IndexSliceLocation
std::vector< long int > IndexImageOrientationPatient
std::vector< long int > IndexImagePositionPatient

Detailed Description

Read a series of files into a single-component (scalar) volume.

Specializes vtkvmtkITKArchetypeImageSeriesReader for single-component pixel types, reading the series through ITK's itk::ImageSeriesReader / itk::ImageFileReader and exporting the result as a scalar vtkImageData.

See also
vtkvmtkITKArchetypeImageSeriesReader

Definition at line 30 of file vtkvmtkITKArchetypeImageSeriesScalarReader.h.

Member Typedef Documentation

◆ Superclass

Constructor & Destructor Documentation

◆ vtkvmtkITKArchetypeImageSeriesScalarReader()

vtkvmtkITKArchetypeImageSeriesScalarReader::vtkvmtkITKArchetypeImageSeriesScalarReader ( )
protected

Definition at line 44 of file vtkvmtkITKArchetypeImageSeriesScalarReader.cxx.

45{
46}

◆ ~vtkvmtkITKArchetypeImageSeriesScalarReader()

vtkvmtkITKArchetypeImageSeriesScalarReader::~vtkvmtkITKArchetypeImageSeriesScalarReader ( )
protected

Definition at line 49 of file vtkvmtkITKArchetypeImageSeriesScalarReader.cxx.

50{
51}

Member Function Documentation

◆ New()

vtkvmtkITKArchetypeImageSeriesScalarReader * vtkvmtkITKArchetypeImageSeriesScalarReader::New ( )
static

◆ IsTypeOf()

int vtkvmtkITKArchetypeImageSeriesScalarReader::IsTypeOf ( const char * type)
static

◆ IsA()

virtual int vtkvmtkITKArchetypeImageSeriesScalarReader::IsA ( const char * type)
virtual

◆ SafeDownCast()

vtkvmtkITKArchetypeImageSeriesScalarReader * vtkvmtkITKArchetypeImageSeriesScalarReader::SafeDownCast ( vtkObjectBase * o)
static

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkITKArchetypeImageSeriesScalarReader::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkITKArchetypeImageSeriesScalarReader * vtkvmtkITKArchetypeImageSeriesScalarReader::NewInstance ( ) const

◆ PrintSelf()

void vtkvmtkITKArchetypeImageSeriesScalarReader::PrintSelf ( std::ostream & os,
vtkIndent indent )
override

Definition at line 54 of file vtkvmtkITKArchetypeImageSeriesScalarReader.cxx.

55{
56 this->Superclass::PrintSelf(os,indent);
57 os << indent << "vtk ITK Archetype Image Series Scalar Reader\n";
58}
void PrintSelf(std::ostream &os, vtkIndent indent) override

◆ RequestData()

int vtkvmtkITKArchetypeImageSeriesScalarReader::RequestData ( vtkInformation * request,
vtkInformationVector ** inputVector,
vtkInformationVector * outputVector )
overrideprotected

SCALAR MACRO

END SCALAR MACRO

Definition at line 63 of file vtkvmtkITKArchetypeImageSeriesScalarReader.cxx.

67{
68 if (!this->Superclass::Archetype)
69 {
70 vtkErrorMacro("An Archetype must be specified.");
71 return 0;
72 }
73
74 vtkInformation *outInfo = outputVector->GetInformationObject(0);
75
76 vtkDataObject * output = outInfo->Get(vtkDataObject::DATA_OBJECT());
77 vtkImageData *data = vtkImageData::SafeDownCast(output);
78 // removed UpdateInformation: generates an error message
79 // from VTK and doesn't appear to be needed...
80 //data->UpdateInformation();
81 data->SetExtent(0,0,0,0,0,0);
82 data->AllocateScalars(outInfo);
83 data->SetExtent(outInfo->Get(
84 vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()));
85
87#define vtkITKExecuteDataFromSeries(typeN, type) \
88 case typeN: \
89 {\
90 typedef itk::Image<type,3> image##typeN;\
91 typedef itk::ImageSource<image##typeN> FilterType; \
92 FilterType::Pointer filter; \
93 itk::ImageSeriesReader<image##typeN>::Pointer reader##typeN = \
94 itk::ImageSeriesReader<image##typeN>::New(); \
95 itk::CStyleCommand::Pointer pcl=itk::CStyleCommand::New(); \
96 pcl->SetCallback((itk::CStyleCommand::FunctionPointer)&ReadProgressCallback); \
97 pcl->SetClientData(this); \
98 reader##typeN->AddObserver(itk::ProgressEvent(),pcl); \
99 reader##typeN->SetFileNames(this->FileNames); \
100 reader##typeN->ReleaseDataFlagOn(); \
101 if (this->UseNativeCoordinateOrientation) \
102 { \
103 filter = reader##typeN; \
104 } \
105 else \
106 { \
107 itk::OrientImageFilter<image##typeN,image##typeN>::Pointer orient##typeN = \
108 itk::OrientImageFilter<image##typeN,image##typeN>::New(); \
109 if (this->Debug) {orient##typeN->DebugOn();} \
110 orient##typeN->SetInput(reader##typeN->GetOutput()); \
111 orient##typeN->UseImageDirectionOn(); \
112 orient##typeN->SetDesiredCoordinateOrientation(this->DesiredCoordinateOrientation); \
113 filter = orient##typeN; \
114 }\
115 filter->UpdateLargestPossibleRegion(); \
116 itk::ImportImageContainer<itk::SizeValueType, type>::Pointer PixelContainer##typeN;\
117 PixelContainer##typeN = filter->GetOutput()->GetPixelContainer();\
118 void *ptr = static_cast<void *> (PixelContainer##typeN->GetBufferPointer());\
119 DownCast<type>(data->GetPointData()->GetScalars()) \
120 ->SetVoidArray(ptr, PixelContainer##typeN->Size(), 0,\
121 vtkAOSDataArrayTemplate<type>::VTK_DATA_ARRAY_DELETE);\
122 PixelContainer##typeN->ContainerManageMemoryOff();\
123 }\
124 break
125
126#define vtkITKExecuteDataFromFile(typeN, type) \
127 case typeN: \
128 {\
129 typedef itk::Image<type,3> image2##typeN;\
130 typedef itk::ImageSource<image2##typeN> FilterType; \
131 FilterType::Pointer filter; \
132 itk::ImageFileReader<image2##typeN>::Pointer reader2##typeN = \
133 itk::ImageFileReader<image2##typeN>::New(); \
134 reader2##typeN->SetFileName(this->FileNames[0].c_str()); \
135 if (this->UseNativeCoordinateOrientation) \
136 { \
137 filter = reader2##typeN; \
138 } \
139 else \
140 { \
141 itk::OrientImageFilter<image2##typeN,image2##typeN>::Pointer orient2##typeN = \
142 itk::OrientImageFilter<image2##typeN,image2##typeN>::New(); \
143 if (this->Debug) {orient2##typeN->DebugOn();} \
144 orient2##typeN->SetInput(reader2##typeN->GetOutput()); \
145 orient2##typeN->UseImageDirectionOn(); \
146 orient2##typeN->SetDesiredCoordinateOrientation(this->DesiredCoordinateOrientation); \
147 filter = orient2##typeN; \
148 } \
149 filter->UpdateLargestPossibleRegion();\
150 itk::ImportImageContainer<itk::SizeValueType, type>::Pointer PixelContainer2##typeN;\
151 PixelContainer2##typeN = filter->GetOutput()->GetPixelContainer();\
152 void *ptr = static_cast<void *> (PixelContainer2##typeN->GetBufferPointer());\
153 DownCast<type>(data->GetPointData()->GetScalars()) \
154 ->SetVoidArray(ptr, PixelContainer2##typeN->Size(), 0,\
155 vtkAOSDataArrayTemplate<type>::VTK_DATA_ARRAY_DELETE);\
156 PixelContainer2##typeN->ContainerManageMemoryOff();\
157 }\
158 break
160
161 // If there is only one file in the series, just use an image file reader
162 if (this->FileNames.size() == 1)
163 {
164 if (this->GetNumberOfComponents() == 1)
165 {
166 switch (this->OutputScalarType)
167 {
168 vtkITKExecuteDataFromFile(VTK_DOUBLE, double);
169 vtkITKExecuteDataFromFile(VTK_FLOAT, float);
170 vtkITKExecuteDataFromFile(VTK_LONG, long);
171 vtkITKExecuteDataFromFile(VTK_UNSIGNED_LONG, unsigned long);
172 vtkITKExecuteDataFromFile(VTK_INT, int);
173 vtkITKExecuteDataFromFile(VTK_UNSIGNED_INT, unsigned int);
174 vtkITKExecuteDataFromFile(VTK_SHORT, short);
175 vtkITKExecuteDataFromFile(VTK_UNSIGNED_SHORT, unsigned short);
176 vtkITKExecuteDataFromFile(VTK_CHAR, char);
177 vtkITKExecuteDataFromFile(VTK_UNSIGNED_CHAR, unsigned char);
178 default:
179 vtkErrorMacro(<< "UpdateFromFile: Unknown data type");
180 }
181 }
182 else
183 {
184 vtkErrorMacro(<< "UpdateFromFile: Unsupported number of components (only 1 allowed): " << this->GetNumberOfComponents());
185 }
186 }
187 else
188 {
189 if (this->GetNumberOfComponents() == 1)
190 {
191 switch (this->OutputScalarType)
192 {
193 vtkITKExecuteDataFromSeries(VTK_DOUBLE, double);
194 vtkITKExecuteDataFromSeries(VTK_FLOAT, float);
195 vtkITKExecuteDataFromSeries(VTK_LONG, long);
196 vtkITKExecuteDataFromSeries(VTK_UNSIGNED_LONG, unsigned long);
197 vtkITKExecuteDataFromSeries(VTK_INT, int);
198 vtkITKExecuteDataFromSeries(VTK_UNSIGNED_INT, unsigned int);
199 vtkITKExecuteDataFromSeries(VTK_SHORT, short);
200 vtkITKExecuteDataFromSeries(VTK_UNSIGNED_SHORT, unsigned short);
201 vtkITKExecuteDataFromSeries(VTK_CHAR, char);
202 vtkITKExecuteDataFromSeries(VTK_UNSIGNED_CHAR, unsigned char);
203 default:
204 vtkErrorMacro(<< "UpdateFromFile: Unknown data type");
205 }
206 }
207 else
208 {
209 vtkErrorMacro(<<"UpdateFromSeries: Unsupported number of components: 1 != " << this->GetNumberOfComponents());
210 }
211 }
212 return 1;
213}
virtual unsigned int GetNumberOfComponents()
#define vtkITKExecuteDataFromSeries(typeN, type)
#define vtkITKExecuteDataFromFile(typeN, type)

◆ ReadProgressCallback()

void vtkvmtkITKArchetypeImageSeriesScalarReader::ReadProgressCallback ( itk::ProcessObject * obj,
const itk::ProgressEvent & ,
void * data )
staticprotected

Definition at line 216 of file vtkvmtkITKArchetypeImageSeriesScalarReader.cxx.

217{
219 me->Progress=obj->GetProgress();
220 me->InvokeEvent(vtkCommand::ProgressEvent,&me->Progress);
221}

The documentation for this class was generated from the following files: