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

Read a series of files that have a common naming convention. More...

#include <vtkvmtkITKArchetypeImageSeriesReader.h>

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

Public Types

typedef vtkImageAlgorithm Superclass
typedef itk::SpatialOrientation::ValidCoordinateOrientationFlags CoordinateOrientationCode

Public Member Functions

virtual int IsA (const char *type)
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 vtkvmtkITKArchetypeImageSeriesReader * New ()
static int IsTypeOf (const char *type)
static vtkvmtkITKArchetypeImageSeriesReader * SafeDownCast (vtkObjectBase *o)

Public Attributes

std::vector< std::string > Tags
std::vector< std::string > TagValues

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkITKArchetypeImageSeriesReader ()
 ~vtkvmtkITKArchetypeImageSeriesReader ()
virtual int RequestInformation (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override

Protected Attributes

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 that have a common naming convention.

ArchetypeImageSeriesReader creates a volume from a series of images stored in files. The series are represented by one filename. This filename, the archetype, is any one of the files in the series.

Note
This work is part of the National Alliance for Medical Image Computing (NAMIC), funded by the National Institutes of Health through the NIH Roadmap for Medical Research, Grant U54 EB005149.

Definition at line 43 of file vtkvmtkITKArchetypeImageSeriesReader.h.

Member Typedef Documentation

◆ Superclass

◆ CoordinateOrientationCode

typedef itk::SpatialOrientation::ValidCoordinateOrientationFlags vtkvmtkITKArchetypeImageSeriesReader::CoordinateOrientationCode

Definition at line 53 of file vtkvmtkITKArchetypeImageSeriesReader.h.

Constructor & Destructor Documentation

◆ vtkvmtkITKArchetypeImageSeriesReader()

vtkvmtkITKArchetypeImageSeriesReader::vtkvmtkITKArchetypeImageSeriesReader ( )
protected

Definition at line 45 of file vtkvmtkITKArchetypeImageSeriesReader.cxx.

46{
47 this->Archetype = NULL;
48 this->IndexArchetype = 0;
49 this->SingleFile = 1;
50 this->UseOrientationFromFile = 1;
51 this->RasToIjkMatrix = NULL;
52 this->MeasurementFrameMatrix = vtkMatrix4x4::New();
53 this->MeasurementFrameMatrix->Identity();
56 this->FileNameSliceOffset = 0;
57 this->FileNameSliceSpacing = 1;
58 this->FileNameSliceCount = 0;
59 this->UseNativeOrigin = true;
60 this->OutputScalarType = VTK_FLOAT;
61 this->NumberOfComponents = 0;
62 this->UseNativeScalarType = 0;
63 for (int i = 0; i < 3; i++)
64 {
65 this->DefaultDataSpacing[i] = 1.0;
66 this->DefaultDataOrigin[i] = 0.0;
67 }
68
69 this->SeriesInstanceUIDs.resize( 0 );
70 this->ContentTime.resize( 0 );
71 this->TriggerTime.resize( 0 );
72 this->EchoNumbers.resize( 0 );
73 this->DiffusionGradientOrientation.resize( 0 );
74 this->SliceLocation.resize( 0 );
75 this->ImageOrientationPatient.resize( 0 );
76
77 this->AnalyzeHeader = true;
78
79 this->GroupingByTags = false;
80 this->IsOnlyFile = false;
81
82 this->SelectedUID = -1;
83 this->SelectedContentTime = -1;
84 this->SelectedTriggerTime = -1;
85 this->SelectedEchoNumbers = -1;
86 this->SelectedDiffusion = -1;
87 this->SelectedSlice = -1;
88 this->SelectedOrientation = -1;
89
90 this->SetNumberOfInputPorts(0);
91 this->SetNumberOfOutputPorts(1);
92}
void SetDesiredCoordinateOrientationToAxial()
Set the orientation of the output image.
std::vector< std::vector< float > > DiffusionGradientOrientation
std::vector< std::vector< float > > ImageOrientationPatient

◆ ~vtkvmtkITKArchetypeImageSeriesReader()

vtkvmtkITKArchetypeImageSeriesReader::~vtkvmtkITKArchetypeImageSeriesReader ( )
protected

Definition at line 95 of file vtkvmtkITKArchetypeImageSeriesReader.cxx.

96{
97 if (this->Archetype)
98 {
99 delete [] this->Archetype;
100 this->Archetype = NULL;
101 }
102 if (RasToIjkMatrix)
103 {
104 RasToIjkMatrix->Delete();
105 RasToIjkMatrix = NULL;
106 }
108 {
109 MeasurementFrameMatrix->Delete();
111 }
112
113}

Member Function Documentation

◆ New()

vtkvmtkITKArchetypeImageSeriesReader * vtkvmtkITKArchetypeImageSeriesReader::New ( )
static

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkITKArchetypeImageSeriesReader::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkITKArchetypeImageSeriesReader * vtkvmtkITKArchetypeImageSeriesReader::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 128 of file vtkvmtkITKArchetypeImageSeriesReader.cxx.

129{
130 int idx;
131
132 this->Superclass::PrintSelf(os,indent);
133
134 os << indent << "Archetype: " <<
135 (this->Archetype ? this->Archetype : "(none)") << "\n";
136
137 os << indent << "FileNameSliceOffset: "
138 << this->FileNameSliceOffset << "\n";
139 os << indent << "FileNameSliceSpacing: "
140 << this->FileNameSliceSpacing << "\n";
141 os << indent << "FileNameSliceCount: "
142 << this->FileNameSliceCount << "\n";
143
144 os << indent << "OutputScalarType: "
145 << vtkImageScalarTypeNameMacro(this->OutputScalarType)
146 << std::endl;
147 os << indent << "DefaultDataSpacing: (" << this->DefaultDataSpacing[0];
148 for (idx = 1; idx < 3; ++idx)
149 {
150 os << ", " << this->DefaultDataSpacing[idx];
151 }
152 os << ")\n";
153
154 os << indent << "DefaultDataOrigin: (" << this->DefaultDataOrigin[0];
155 for (idx = 1; idx < 3; ++idx)
156 {
157 os << ", " << this->DefaultDataOrigin[idx];
158 }
159 os << ")\n";
160
161}

◆ SetArchetype()

virtual void vtkvmtkITKArchetypeImageSeriesReader::SetArchetype ( const char * )
virtual

Specify the archetype filename for the series.

◆ GetArchetype()

virtual char * vtkvmtkITKArchetypeImageSeriesReader::GetArchetype ( )
virtual

◆ GetNumberOfFileNames()

unsigned int vtkvmtkITKArchetypeImageSeriesReader::GetNumberOfFileNames ( )

See how many file names were generated during ExecuteInformation.

Definition at line 931 of file vtkvmtkITKArchetypeImageSeriesReader.cxx.

932{
933 return this->FileNames.size();
934}

◆ GetFileNames()

const std::vector< std::string > & vtkvmtkITKArchetypeImageSeriesReader::GetFileNames ( )

Return all the file names.

Definition at line 937 of file vtkvmtkITKArchetypeImageSeriesReader.cxx.

938{
939 return this->FileNames;
940}

◆ AddFileName()

unsigned int vtkvmtkITKArchetypeImageSeriesReader::AddFileName ( const char * filename)

Specify the file names to be used when looking for extra files that match the archetype in defining the volume to load (e.g. other canidate dicom files to look in for matching tags)

Definition at line 1332 of file vtkvmtkITKArchetypeImageSeriesReader.cxx.

1333{
1334 std::string filenamestr (filename);
1335 this->FileNames.push_back( filenamestr );
1336 return this->FileNames.size();
1337}

◆ GetFileName()

const char * vtkvmtkITKArchetypeImageSeriesReader::GetFileName ( unsigned int n)

Definition at line 1320 of file vtkvmtkITKArchetypeImageSeriesReader.cxx.

1321{
1322 if ( n >= this->GetNumberOfFileNames() )
1323 {
1324 return NULL;
1325 }
1326
1327 return this->FileNames[n].c_str();
1328
1329}
unsigned int GetNumberOfFileNames()
See how many file names were generated during ExecuteInformation.

◆ ResetFileNames()

void vtkvmtkITKArchetypeImageSeriesReader::ResetFileNames ( )

Definition at line 1340 of file vtkvmtkITKArchetypeImageSeriesReader.cxx.

1341{
1342 this->FileNames.resize( 0 );
1343 this->AllFileNames.resize( 0 );
1344 this->SeriesInstanceUIDs.resize( 0 );
1345 this->ContentTime.resize( 0 );
1346 this->TriggerTime.resize( 0 );
1347 this->EchoNumbers.resize( 0 );
1348 this->DiffusionGradientOrientation.resize( 0 );
1349 this->SliceLocation.resize( 0 );
1350 this->ImageOrientationPatient.resize( 0 );
1351}

◆ SetDefaultDataSpacing() [1/2]

virtual void vtkvmtkITKArchetypeImageSeriesReader::SetDefaultDataSpacing ( double ,
double ,
double  )
virtual

Set/Get the default spacing of the data in the file. This will be used if the reader provided spacing is 1.0. (Default is 1.0)

◆ SetDefaultDataSpacing() [2/2]

virtual void vtkvmtkITKArchetypeImageSeriesReader::SetDefaultDataSpacing ( double [3])
virtual

◆ GetDefaultDataSpacing() [1/3]

virtual double * vtkvmtkITKArchetypeImageSeriesReader::GetDefaultDataSpacing ( )
virtual

◆ GetDefaultDataSpacing() [2/3]

virtual void vtkvmtkITKArchetypeImageSeriesReader::GetDefaultDataSpacing ( double & ,
double & ,
double &  )
virtual

◆ GetDefaultDataSpacing() [3/3]

virtual void vtkvmtkITKArchetypeImageSeriesReader::GetDefaultDataSpacing ( double [3])
virtual

◆ SetDefaultDataOrigin() [1/2]

virtual void vtkvmtkITKArchetypeImageSeriesReader::SetDefaultDataOrigin ( double ,
double ,
double  )
virtual

Set/Get the default origin of the data (location of first pixel in the file). This will be used if the reader provided origin is 0.0. (Default is 0.0)

◆ SetDefaultDataOrigin() [2/2]

virtual void vtkvmtkITKArchetypeImageSeriesReader::SetDefaultDataOrigin ( double [3])
virtual

◆ GetDefaultDataOrigin() [1/3]

virtual double * vtkvmtkITKArchetypeImageSeriesReader::GetDefaultDataOrigin ( )
virtual

◆ GetDefaultDataOrigin() [2/3]

virtual void vtkvmtkITKArchetypeImageSeriesReader::GetDefaultDataOrigin ( double & ,
double & ,
double &  )
virtual

◆ GetDefaultDataOrigin() [3/3]

virtual void vtkvmtkITKArchetypeImageSeriesReader::GetDefaultDataOrigin ( double [3])
virtual

◆ SetFileNameSliceOffset()

virtual void vtkvmtkITKArchetypeImageSeriesReader::SetFileNameSliceOffset ( int )
virtual

When reading files which start at an unusual index, this can be added to the slice number when generating the file name (default = 0)

◆ GetFileNameSliceOffset()

virtual int vtkvmtkITKArchetypeImageSeriesReader::GetFileNameSliceOffset ( )
virtual

◆ SetFileNameSliceSpacing()

virtual void vtkvmtkITKArchetypeImageSeriesReader::SetFileNameSliceSpacing ( int )
virtual

When reading files which have regular, but non contiguous slices (eg filename.1,filename.3,filename.5) a spacing can be specified to skip missing files (default = 1)

◆ GetFileNameSliceSpacing()

virtual int vtkvmtkITKArchetypeImageSeriesReader::GetFileNameSliceSpacing ( )
virtual

◆ SetFileNameSliceCount()

virtual void vtkvmtkITKArchetypeImageSeriesReader::SetFileNameSliceCount ( int )
virtual

The maximum number of files to include in the series. If this is zero, then all files will be included. (Default is 0)

◆ GetFileNameSliceCount()

virtual int vtkvmtkITKArchetypeImageSeriesReader::GetFileNameSliceCount ( )
virtual

◆ CanReadFile()

int vtkvmtkITKArchetypeImageSeriesReader::CanReadFile ( const char * filename)
virtual

is the given file name a NRRD file?

Definition at line 164 of file vtkvmtkITKArchetypeImageSeriesReader.cxx.

165{
166 if (this->Archetype == NULL)
167 {
168 return false;
169 }
170
171 std::string fileNameCollapsed = itksys::SystemTools::CollapseFullPath( this->Archetype);
172
173 // First see if the archetype exists
174 if (!itksys::SystemTools::FileExists (fileNameCollapsed.c_str()))
175 {
176 vtkDebugMacro(<<"The filename does not exist.");
177 return false;
178 }
179 return true;
180}

◆ SetDesiredCoordinateOrientationToAxial()

void vtkvmtkITKArchetypeImageSeriesReader::SetDesiredCoordinateOrientationToAxial ( )
inline

Set the orientation of the output image.

itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RPS;

Definition at line 113 of file vtkvmtkITKArchetypeImageSeriesReader.h.

114 {
115#if (ITK_VERSION_MAJOR >= 5)
117 itk::SpatialOrientationEnums::ValidCoordinateOrientations::ITK_COORDINATE_ORIENTATION_RAI;
118#else
120 itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RAI;
121#endif
124 this->Modified();
125 }

◆ SetDesiredCoordinateOrientationToCoronal()

void vtkvmtkITKArchetypeImageSeriesReader::SetDesiredCoordinateOrientationToCoronal ( )
inline

itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RIP;

Definition at line 126 of file vtkvmtkITKArchetypeImageSeriesReader.h.

127 {
128#if (ITK_VERSION_MAJOR >= 5)
130 itk::SpatialOrientationEnums::ValidCoordinateOrientations::ITK_COORDINATE_ORIENTATION_RSA;
131#else
133 itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RSA;
134#endif
137 this->Modified();
138 }

◆ SetDesiredCoordinateOrientationToSagittal()

void vtkvmtkITKArchetypeImageSeriesReader::SetDesiredCoordinateOrientationToSagittal ( )
inline

itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_AIR;

Definition at line 139 of file vtkvmtkITKArchetypeImageSeriesReader.h.

140 {
142#if (ITK_VERSION_MAJOR >= 5)
143 itk::SpatialOrientationEnums::ValidCoordinateOrientations::ITK_COORDINATE_ORIENTATION_ASL;
144#else
145 itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_ASL;
146#endif
149 this->Modified();
150 }

◆ SetDesiredCoordinateOrientationToNative()

void vtkvmtkITKArchetypeImageSeriesReader::SetDesiredCoordinateOrientationToNative ( )
inline

Definition at line 151 of file vtkvmtkITKArchetypeImageSeriesReader.h.

152 {
154 this->Modified();
155 }

◆ GetDesiredCoordinateOrientation()

virtual CoordinateOrientationCode vtkvmtkITKArchetypeImageSeriesReader::GetDesiredCoordinateOrientation ( )
virtual

◆ GetUseNativeCoordinateOrientation()

virtual char vtkvmtkITKArchetypeImageSeriesReader::GetUseNativeCoordinateOrientation ( )
virtual

◆ SetOutputScalarTypeToDouble()

virtual void vtkvmtkITKArchetypeImageSeriesReader::SetOutputScalarTypeToDouble ( )
inlinevirtual

Set the data type of pixels in the file. If you want the output scalar type to have a different value, set it after this method is called.

Definition at line 163 of file vtkvmtkITKArchetypeImageSeriesReader.h.

164 {
166 this->SetOutputScalarType(VTK_DOUBLE);
167 }
virtual void SetOutputScalarType(int)
Get the file format. Pixels are this type in the file.

◆ SetOutputScalarTypeToFloat()

virtual void vtkvmtkITKArchetypeImageSeriesReader::SetOutputScalarTypeToFloat ( )
inlinevirtual

Definition at line 168 of file vtkvmtkITKArchetypeImageSeriesReader.h.

169 {
171 this->SetOutputScalarType(VTK_FLOAT);
172 }

◆ SetOutputScalarTypeToLong()

virtual void vtkvmtkITKArchetypeImageSeriesReader::SetOutputScalarTypeToLong ( )
inlinevirtual

Definition at line 173 of file vtkvmtkITKArchetypeImageSeriesReader.h.

174 {
176 this->SetOutputScalarType(VTK_LONG);
177 }

◆ SetOutputScalarTypeToUnsignedLong()

virtual void vtkvmtkITKArchetypeImageSeriesReader::SetOutputScalarTypeToUnsignedLong ( )
inlinevirtual

Definition at line 178 of file vtkvmtkITKArchetypeImageSeriesReader.h.

179 {
181 this->SetOutputScalarType(VTK_UNSIGNED_LONG);
182 }

◆ SetOutputScalarTypeToInt()

virtual void vtkvmtkITKArchetypeImageSeriesReader::SetOutputScalarTypeToInt ( )
inlinevirtual

Definition at line 183 of file vtkvmtkITKArchetypeImageSeriesReader.h.

184 {
186 this->SetOutputScalarType(VTK_INT);
187 }

◆ SetOutputScalarTypeToUnsignedInt()

virtual void vtkvmtkITKArchetypeImageSeriesReader::SetOutputScalarTypeToUnsignedInt ( )
inlinevirtual

Definition at line 188 of file vtkvmtkITKArchetypeImageSeriesReader.h.

189 {
191 this->SetOutputScalarType(VTK_UNSIGNED_INT);
192 }

◆ SetOutputScalarTypeToShort()

virtual void vtkvmtkITKArchetypeImageSeriesReader::SetOutputScalarTypeToShort ( )
inlinevirtual

Definition at line 193 of file vtkvmtkITKArchetypeImageSeriesReader.h.

194 {
196 this->SetOutputScalarType(VTK_SHORT);
197 }

◆ SetOutputScalarTypeToUnsignedShort()

virtual void vtkvmtkITKArchetypeImageSeriesReader::SetOutputScalarTypeToUnsignedShort ( )
inlinevirtual

Definition at line 198 of file vtkvmtkITKArchetypeImageSeriesReader.h.

199 {
201 this->SetOutputScalarType(VTK_UNSIGNED_SHORT);
202 }

◆ SetOutputScalarTypeToChar()

virtual void vtkvmtkITKArchetypeImageSeriesReader::SetOutputScalarTypeToChar ( )
inlinevirtual

Definition at line 203 of file vtkvmtkITKArchetypeImageSeriesReader.h.

204 {
206 this->SetOutputScalarType(VTK_CHAR);
207 }

◆ SetOutputScalarTypeToUnsignedChar()

virtual void vtkvmtkITKArchetypeImageSeriesReader::SetOutputScalarTypeToUnsignedChar ( )
inlinevirtual

Definition at line 208 of file vtkvmtkITKArchetypeImageSeriesReader.h.

209 {
211 this->SetOutputScalarType(VTK_UNSIGNED_CHAR);
212 }

◆ SetOutputScalarTypeToNative()

virtual void vtkvmtkITKArchetypeImageSeriesReader::SetOutputScalarTypeToNative ( )
inlinevirtual

Definition at line 213 of file vtkvmtkITKArchetypeImageSeriesReader.h.

214 {
216 this->Modified();
217 }

◆ SetUseNativeOriginOn()

void vtkvmtkITKArchetypeImageSeriesReader::SetUseNativeOriginOn ( )
inline

Use image origin from the file.

Definition at line 221 of file vtkvmtkITKArchetypeImageSeriesReader.h.

222 {
223 UseNativeOrigin = true;
224 }

◆ SetUseNativeOriginOff()

void vtkvmtkITKArchetypeImageSeriesReader::SetUseNativeOriginOff ( )
inline

Use image center as origin.

Definition at line 228 of file vtkvmtkITKArchetypeImageSeriesReader.h.

229 {
230 UseNativeOrigin = false;
231 }

◆ SetOutputScalarType()

virtual void vtkvmtkITKArchetypeImageSeriesReader::SetOutputScalarType ( int )
virtual

Get the file format. Pixels are this type in the file.

◆ GetOutputScalarType()

virtual int vtkvmtkITKArchetypeImageSeriesReader::GetOutputScalarType ( )
virtual

◆ SetNumberOfComponents()

virtual void vtkvmtkITKArchetypeImageSeriesReader::SetNumberOfComponents ( unsigned int )
virtual

Get number of scalars.

◆ GetNumberOfComponents()

virtual unsigned int vtkvmtkITKArchetypeImageSeriesReader::GetNumberOfComponents ( )
virtual

◆ SetSingleFile()

virtual void vtkvmtkITKArchetypeImageSeriesReader::SetSingleFile ( int )
virtual

Whether load in a single file or a series.

◆ GetSingleFile()

virtual int vtkvmtkITKArchetypeImageSeriesReader::GetSingleFile ( )
virtual

◆ SetUseOrientationFromFile()

virtual void vtkvmtkITKArchetypeImageSeriesReader::SetUseOrientationFromFile ( int )
virtual

Whether to use orientation from file.

◆ GetUseOrientationFromFile()

virtual int vtkvmtkITKArchetypeImageSeriesReader::GetUseOrientationFromFile ( )
virtual

◆ GetRasToIjkMatrix()

vtkMatrix4x4 * vtkvmtkITKArchetypeImageSeriesReader::GetRasToIjkMatrix ( )

Returns an IJK to RAS transformation matrix.

Definition at line 115 of file vtkvmtkITKArchetypeImageSeriesReader.cxx.

116{
117 this->UpdateInformation();
118 return RasToIjkMatrix;
119}

◆ GetMeasurementFrameMatrix()

vtkMatrix4x4 * vtkvmtkITKArchetypeImageSeriesReader::GetMeasurementFrameMatrix ( )

Returns the Measurement frame matrix.

Definition at line 121 of file vtkvmtkITKArchetypeImageSeriesReader.cxx.

122{
123 this->UpdateInformation();
125}

◆ GetMetaDataDictionary()

const itk::MetaDataDictionary & vtkvmtkITKArchetypeImageSeriesReader::GetMetaDataDictionary ( ) const

Return the MetaDataDictionary from the ITK layer.

Definition at line 1245 of file vtkvmtkITKArchetypeImageSeriesReader.cxx.

1247{
1248 return this->Dictionary;
1249}

◆ ParseDictionary()

void vtkvmtkITKArchetypeImageSeriesReader::ParseDictionary ( )

Definition at line 1252 of file vtkvmtkITKArchetypeImageSeriesReader.cxx.

1253{
1254 int nItems = this->Dictionary.GetKeys().size();
1255 this->Tags.resize(0);
1256 this->TagValues.resize(0);
1257
1258 if (nItems == 0)
1259 {
1260 return;
1261 }
1262
1263 std::vector<std::string> keys = this->Dictionary.GetKeys();
1264 for (int k = 0; k < nItems; k++)
1265 {
1266 this->Tags.push_back( keys[k] );
1267 std::string tagvalue;
1268 itk::ExposeMetaData<std::string>(this->Dictionary, keys[k], tagvalue);
1269 this->TagValues.push_back( tagvalue );
1270 }
1271}

◆ GetNumberOfItemsInDictionary()

unsigned int vtkvmtkITKArchetypeImageSeriesReader::GetNumberOfItemsInDictionary ( )

Definition at line 1274 of file vtkvmtkITKArchetypeImageSeriesReader.cxx.

1275{
1276 return this->Tags.size();
1277}

◆ HasKey()

bool vtkvmtkITKArchetypeImageSeriesReader::HasKey ( char * tag)

Definition at line 1280 of file vtkvmtkITKArchetypeImageSeriesReader.cxx.

1281{
1282 return this->Dictionary.HasKey( tag );
1283}

◆ GetNthKey()

const char * vtkvmtkITKArchetypeImageSeriesReader::GetNthKey ( unsigned int n)

Definition at line 1286 of file vtkvmtkITKArchetypeImageSeriesReader.cxx.

1287{
1288 if (n >= this->Tags.size())
1289 {
1290 return NULL;
1291 }
1292 return this->Tags[n].c_str();
1293}

◆ GetNthValue()

const char * vtkvmtkITKArchetypeImageSeriesReader::GetNthValue ( unsigned int n)

Definition at line 1296 of file vtkvmtkITKArchetypeImageSeriesReader.cxx.

1297{
1298 if (n >= this->TagValues.size())
1299 {
1300 return NULL;
1301 }
1302 return this->TagValues[n].c_str();
1303}

◆ GetTagValue()

const char * vtkvmtkITKArchetypeImageSeriesReader::GetTagValue ( char * tag)

Definition at line 1306 of file vtkvmtkITKArchetypeImageSeriesReader.cxx.

1307{
1308 std::string tagstr (tag);
1309 for (unsigned int k = 0; k < this->Tags.size(); k++)
1310 {
1311 if (this->Tags[k] == tagstr)
1312 {
1313 return this->TagValues[k].c_str();
1314 }
1315 }
1316 return NULL;
1317}

◆ GetGroupingByTags()

bool vtkvmtkITKArchetypeImageSeriesReader::GetGroupingByTags ( )
inline

set/get functions for grouping by tags

Definition at line 275 of file vtkvmtkITKArchetypeImageSeriesReader.h.

276 {
277 return GroupingByTags;
278 }

◆ SetGroupingByTagsOn()

void vtkvmtkITKArchetypeImageSeriesReader::SetGroupingByTagsOn ( )
inline

Definition at line 280 of file vtkvmtkITKArchetypeImageSeriesReader.h.

281 {
282 GroupingByTags = true;
283 }

◆ SetGroupingByTagsOff()

void vtkvmtkITKArchetypeImageSeriesReader::SetGroupingByTagsOff ( )
inline

Definition at line 285 of file vtkvmtkITKArchetypeImageSeriesReader.h.

286 {
287 GroupingByTags = false;
288 }

◆ GetSelectedUID()

int vtkvmtkITKArchetypeImageSeriesReader::GetSelectedUID ( )
inline

Definition at line 291 of file vtkvmtkITKArchetypeImageSeriesReader.h.

292 {
293 return SelectedUID;
294 }

◆ SetSelectedUID()

void vtkvmtkITKArchetypeImageSeriesReader::SetSelectedUID ( int v)
inline

◆ GetSelectedContentTime()

int vtkvmtkITKArchetypeImageSeriesReader::GetSelectedContentTime ( )
inline

Definition at line 303 of file vtkvmtkITKArchetypeImageSeriesReader.h.

304 {
305 return SelectedContentTime;
306 }

◆ SetSelectedContentTime()

void vtkvmtkITKArchetypeImageSeriesReader::SetSelectedContentTime ( int v)
inline

Definition at line 308 of file vtkvmtkITKArchetypeImageSeriesReader.h.

309 {
312 }

◆ GetSelectedTriggerTime()

int vtkvmtkITKArchetypeImageSeriesReader::GetSelectedTriggerTime ( )
inline

Definition at line 315 of file vtkvmtkITKArchetypeImageSeriesReader.h.

316 {
317 return SelectedTriggerTime;
318 }

◆ SetSelectedTriggerTime()

void vtkvmtkITKArchetypeImageSeriesReader::SetSelectedTriggerTime ( int v)
inline

Definition at line 320 of file vtkvmtkITKArchetypeImageSeriesReader.h.

321 {
324 }

◆ GetSelectedEchoNumbers()

int vtkvmtkITKArchetypeImageSeriesReader::GetSelectedEchoNumbers ( )
inline

Definition at line 327 of file vtkvmtkITKArchetypeImageSeriesReader.h.

328 {
329 return SelectedEchoNumbers;
330 }

◆ SetSelectedEchoNumbers()

void vtkvmtkITKArchetypeImageSeriesReader::SetSelectedEchoNumbers ( int v)
inline

Definition at line 332 of file vtkvmtkITKArchetypeImageSeriesReader.h.

333 {
336 }

◆ GetSelectedDiffusion()

int vtkvmtkITKArchetypeImageSeriesReader::GetSelectedDiffusion ( )
inline

Definition at line 340 of file vtkvmtkITKArchetypeImageSeriesReader.h.

341 {
342 return SelectedDiffusion;
343 }

◆ SetSelectedDiffusion()

void vtkvmtkITKArchetypeImageSeriesReader::SetSelectedDiffusion ( int v)
inline

Definition at line 345 of file vtkvmtkITKArchetypeImageSeriesReader.h.

346 {
349 }

◆ GetSelectedSlice()

int vtkvmtkITKArchetypeImageSeriesReader::GetSelectedSlice ( )
inline

Definition at line 352 of file vtkvmtkITKArchetypeImageSeriesReader.h.

353 {
354 return SelectedSlice;
355 }

◆ SetSelectedSlice()

void vtkvmtkITKArchetypeImageSeriesReader::SetSelectedSlice ( int v)
inline

Definition at line 357 of file vtkvmtkITKArchetypeImageSeriesReader.h.

358 {
359 SelectedSlice = v;
361 }

◆ GetSelectedOrientation()

int vtkvmtkITKArchetypeImageSeriesReader::GetSelectedOrientation ( )
inline

Definition at line 364 of file vtkvmtkITKArchetypeImageSeriesReader.h.

365 {
366 return SelectedOrientation;
367 }

◆ SetSelectedOrientation()

void vtkvmtkITKArchetypeImageSeriesReader::SetSelectedOrientation ( int v)
inline

Definition at line 369 of file vtkvmtkITKArchetypeImageSeriesReader.h.

370 {
373 }

◆ GetNumberOfSeriesInstanceUIDs()

unsigned int vtkvmtkITKArchetypeImageSeriesReader::GetNumberOfSeriesInstanceUIDs ( )
inline

get number of certain discriminators in the directory

Definition at line 376 of file vtkvmtkITKArchetypeImageSeriesReader.h.

377 {
378 return this->SeriesInstanceUIDs.size();
379 }

◆ GetNumberOfContentTime()

unsigned int vtkvmtkITKArchetypeImageSeriesReader::GetNumberOfContentTime ( )
inline

Definition at line 381 of file vtkvmtkITKArchetypeImageSeriesReader.h.

382 {
383 return this->ContentTime.size();
384 }

◆ GetNumberOfTriggerTime()

unsigned int vtkvmtkITKArchetypeImageSeriesReader::GetNumberOfTriggerTime ( )
inline

Definition at line 386 of file vtkvmtkITKArchetypeImageSeriesReader.h.

387 {
388 return this->TriggerTime.size();
389 }

◆ GetNumberOfEchoNumbers()

unsigned int vtkvmtkITKArchetypeImageSeriesReader::GetNumberOfEchoNumbers ( )
inline

Definition at line 391 of file vtkvmtkITKArchetypeImageSeriesReader.h.

392 {
393 return this->EchoNumbers.size();
394 }

◆ GetNumberOfSliceLocation()

unsigned int vtkvmtkITKArchetypeImageSeriesReader::GetNumberOfSliceLocation ( )
inline

Definition at line 396 of file vtkvmtkITKArchetypeImageSeriesReader.h.

397 {
398 return this->SliceLocation.size();
399 }

◆ GetNumberOfDiffusionGradientOrientation()

unsigned int vtkvmtkITKArchetypeImageSeriesReader::GetNumberOfDiffusionGradientOrientation ( )
inline

Definition at line 401 of file vtkvmtkITKArchetypeImageSeriesReader.h.

402 {
403 return this->DiffusionGradientOrientation.size();
404 };

◆ GetNumberOfImageOrientationPatient()

unsigned int vtkvmtkITKArchetypeImageSeriesReader::GetNumberOfImageOrientationPatient ( )
inline

Definition at line 406 of file vtkvmtkITKArchetypeImageSeriesReader.h.

407 {
408 return this->ImageOrientationPatient.size();
409 };

◆ GetNumberOfImagePositionPatient()

unsigned int vtkvmtkITKArchetypeImageSeriesReader::GetNumberOfImagePositionPatient ( )
inline

Definition at line 411 of file vtkvmtkITKArchetypeImageSeriesReader.h.

412 {
413 return this->ImagePositionPatient.size();
414 }
std::vector< std::vector< float > > ImagePositionPatient

◆ ExistSeriesInstanceUID()

int vtkvmtkITKArchetypeImageSeriesReader::ExistSeriesInstanceUID ( const char * SeriesInstanceUID)
inline

check the existance of given discriminator

Definition at line 417 of file vtkvmtkITKArchetypeImageSeriesReader.h.

418 {
419 for (unsigned int k = 0; k < GetNumberOfSeriesInstanceUIDs(); k++)
420 {
421 if ( this->SeriesInstanceUIDs[k].find(SeriesInstanceUID) != std::string::npos )
422 {
423 return k;
424 }
425 }
426 return -1;
427 }
unsigned int GetNumberOfSeriesInstanceUIDs()
get number of certain discriminators in the directory

◆ ExistContentTime()

int vtkvmtkITKArchetypeImageSeriesReader::ExistContentTime ( const char * contentTime)
inline

Definition at line 429 of file vtkvmtkITKArchetypeImageSeriesReader.h.

430 {
431 for (unsigned int k = 0; k < GetNumberOfContentTime(); k++)
432 {
433 if ( this->ContentTime[k].find(contentTime) != std::string::npos )
434 {
435 return k;
436 }
437 }
438 return -1;
439 }

◆ ExistTriggerTime()

int vtkvmtkITKArchetypeImageSeriesReader::ExistTriggerTime ( const char * triggerTime)
inline

Definition at line 441 of file vtkvmtkITKArchetypeImageSeriesReader.h.

442 {
443 for (unsigned int k = 0; k < GetNumberOfTriggerTime(); k++)
444 {
445 if ( this->TriggerTime[k].find(triggerTime) != std::string::npos )
446 {
447 return k;
448 }
449 }
450 return -1;
451 }

◆ ExistEchoNumbers()

int vtkvmtkITKArchetypeImageSeriesReader::ExistEchoNumbers ( const char * echoNumbers)
inline

Definition at line 453 of file vtkvmtkITKArchetypeImageSeriesReader.h.

454 {
455 for (unsigned int k = 0; k < GetNumberOfEchoNumbers(); k++)
456 {
457 if ( this->EchoNumbers[k].find(echoNumbers) != std::string::npos )
458 {
459 return k;
460 }
461 }
462 return -1;
463 }

◆ ExistDiffusionGradientOrientation()

int vtkvmtkITKArchetypeImageSeriesReader::ExistDiffusionGradientOrientation ( float * dgo)
inline

Definition at line 465 of file vtkvmtkITKArchetypeImageSeriesReader.h.

466 {
467 float a = 0;
468 for (int n = 0; n < 3; n++)
469 {
470 a += dgo[n]*dgo[n];
471 }
472
473 for (unsigned int k = 0; k < GetNumberOfDiffusionGradientOrientation(); k++)
474 {
475 float b = 0;
476 float c = 0;
477 for (int n = 0; n < 3; n++)
478 {
479 b += this->DiffusionGradientOrientation[k][n] * this->DiffusionGradientOrientation[k][n];
480 c += this->DiffusionGradientOrientation[k][n] * dgo[n];
481 }
482 c = std::fabs(c)/std::sqrt(a*b);
483
484 if ( c > 0.99999 )
485 {
486 return k;
487 }
488 }
489 return -1;
490 }

◆ ExistSliceLocation()

int vtkvmtkITKArchetypeImageSeriesReader::ExistSliceLocation ( float sliceLocation)
inline

Definition at line 492 of file vtkvmtkITKArchetypeImageSeriesReader.h.

493 {
494 std::vector<float>::iterator iter =
495 std::find(this->SliceLocation.begin(), this->SliceLocation.end(), sliceLocation);
496 return iter != this->SliceLocation.end() ?
497 std::distance(this->SliceLocation.begin(), iter) : -1;
498 }

◆ ExistImageOrientationPatient()

int vtkvmtkITKArchetypeImageSeriesReader::ExistImageOrientationPatient ( float * directionCosine)
inline

input has to have six elements

Definition at line 500 of file vtkvmtkITKArchetypeImageSeriesReader.h.

501 {
503 float a = std::sqrt( directionCosine[0]*directionCosine[0] + directionCosine[1]*directionCosine[1] + directionCosine[2]*directionCosine[2] );
504 for (int k = 0; k < 3; k++)
505 {
506 directionCosine[k] /= a;
507 }
508 a = std::sqrt( directionCosine[3]*directionCosine[3] + directionCosine[4]*directionCosine[4] + directionCosine[5]*directionCosine[5] );
509 for (int k = 3; k < 6; k++)
510 {
511 directionCosine[k] /= a;
512 }
513
514 for (unsigned int k = 0; k < GetNumberOfImageOrientationPatient(); k++)
515 {
516 std::vector<float> aVec = ImageOrientationPatient[k];
517 a = std::sqrt( aVec[0]*aVec[0] + aVec[1]*aVec[1] + aVec[2]*aVec[2] );
518 float b = (directionCosine[0]*aVec[0] + directionCosine[1]*aVec[1] + directionCosine[2]*aVec[2])/a;
519 if ( b < 0.99999 )
520 {
521 continue;
522 }
523
524 a = std::sqrt( aVec[3]*aVec[3] + aVec[4]*aVec[4] + aVec[5]*aVec[5] );
525 b = (directionCosine[3]*aVec[3] + directionCosine[4]*aVec[4] + directionCosine[5]*aVec[5])/a;
526 if ( b > 0.99999 )
527 {
528 return k;
529 }
530 }
531 return -1;
532 }

◆ ExistImagePositionPatient()

int vtkvmtkITKArchetypeImageSeriesReader::ExistImagePositionPatient ( float * ipp)
inline

Definition at line 534 of file vtkvmtkITKArchetypeImageSeriesReader.h.

535 {
536 float a = 0;
537 for (int n = 0; n < 3; n++)
538 {
539 a += ipp[n]*ipp[n];
540 }
541
542 for (unsigned int k = 0; k < GetNumberOfImagePositionPatient(); k++)
543 {
544 float b = 0;
545 float c = 0;
546 for (int n = 0; n < 3; n++)
547 {
548 b += this->ImagePositionPatient[k][n] * this->ImagePositionPatient[k][n];
549 c += this->ImagePositionPatient[k][n] * ipp[n];
550 }
551 c = std::fabs(c)/std::sqrt(a*b);
552 if ( c > 0.99999 )
553 {
554 return k;
555 }
556 }
557 return -1;
558 }

◆ GetNthSeriesInstanceUID()

const char * vtkvmtkITKArchetypeImageSeriesReader::GetNthSeriesInstanceUID ( unsigned int n)
inline

methods to get N-th discriminator

Definition at line 561 of file vtkvmtkITKArchetypeImageSeriesReader.h.

562 {
563 if ( n >= this->GetNumberOfSeriesInstanceUIDs() )
564 {
565 return NULL;
566 }
567 return this->SeriesInstanceUIDs[n].c_str();
568 }

◆ GetNthContentTime()

const char * vtkvmtkITKArchetypeImageSeriesReader::GetNthContentTime ( unsigned int n)
inline

Definition at line 570 of file vtkvmtkITKArchetypeImageSeriesReader.h.

571 {
572 if ( n >= this->GetNumberOfContentTime() )
573 {
574 return NULL;
575 }
576 return this->ContentTime[n].c_str();
577 }

◆ GetNthTriggerTime()

const char * vtkvmtkITKArchetypeImageSeriesReader::GetNthTriggerTime ( unsigned int n)
inline

Definition at line 579 of file vtkvmtkITKArchetypeImageSeriesReader.h.

580 {
581 if ( n >= this->GetNumberOfTriggerTime() )
582 {
583 return NULL;
584 }
585 return this->TriggerTime[n].c_str();
586 }

◆ GetNthEchoNumbers()

const char * vtkvmtkITKArchetypeImageSeriesReader::GetNthEchoNumbers ( unsigned int n)
inline

Definition at line 588 of file vtkvmtkITKArchetypeImageSeriesReader.h.

589 {
590 if ( n >= this->GetNumberOfEchoNumbers() )
591 {
592 return NULL;
593 }
594 return this->EchoNumbers[n].c_str();
595 }

◆ GetNthDiffusionGradientOrientation()

float * vtkvmtkITKArchetypeImageSeriesReader::GetNthDiffusionGradientOrientation ( unsigned int n)
inline

Definition at line 597 of file vtkvmtkITKArchetypeImageSeriesReader.h.

598 {
600 {
601 return NULL;
602 }
603 float *dgo = new float [3];
604 for (int k = 0; k <3; k++)
605 {
606 dgo[k] = this->DiffusionGradientOrientation[n][k];
607 }
608 return dgo;
609 }

◆ GetNthSliceLocation()

float vtkvmtkITKArchetypeImageSeriesReader::GetNthSliceLocation ( unsigned int n)
inline

Definition at line 611 of file vtkvmtkITKArchetypeImageSeriesReader.h.

612 {
613 if ( n >= this->GetNumberOfSliceLocation() )
614 {
615 return this->SliceLocation[0];
616 }
617 return this->SliceLocation[0];
618 }

◆ GetNthImageOrientationPatient()

float * vtkvmtkITKArchetypeImageSeriesReader::GetNthImageOrientationPatient ( unsigned int n)
inline

Definition at line 620 of file vtkvmtkITKArchetypeImageSeriesReader.h.

621 {
622 if ( n >= this->GetNumberOfImageOrientationPatient() )
623 {
624 return NULL;
625 }
626 float *dgo = new float [6];
627 for (int k = 0; k <6; k++)
628 {
629 dgo[k] = this->ImageOrientationPatient[n][k];
630 }
631 return dgo;
632 }

◆ GetNthImagePositionPatient()

float * vtkvmtkITKArchetypeImageSeriesReader::GetNthImagePositionPatient ( unsigned int n)
inline

Definition at line 634 of file vtkvmtkITKArchetypeImageSeriesReader.h.

635 {
636 if (n >= this->GetNumberOfImagePositionPatient() )
637 {
638 return NULL;
639 }
640 float *ipp = new float [3];
641 for (int k = 0; k <3; k++)
642 {
643 ipp[k] = this->ImagePositionPatient[n][k];
644 }
645 return ipp;
646 }

◆ InsertSeriesInstanceUIDs()

int vtkvmtkITKArchetypeImageSeriesReader::InsertSeriesInstanceUIDs ( const char * aUID)
inline

insert unique item into array. Duplicate code for TCL wrapping. TODO: need to clean up

Definition at line 650 of file vtkvmtkITKArchetypeImageSeriesReader.h.

651 {
652 int k = ExistSeriesInstanceUID( aUID );
653 if ( k >= 0 )
654 {
655 return k;
656 }
657
658 std::string aVector(aUID);
659 this->SeriesInstanceUIDs.push_back( aVector );
660 return (this->SeriesInstanceUIDs.size()-1);
661 }
int ExistSeriesInstanceUID(const char *SeriesInstanceUID)
check the existance of given discriminator

◆ InsertContentTime()

int vtkvmtkITKArchetypeImageSeriesReader::InsertContentTime ( const char * aTime)
inline

Definition at line 663 of file vtkvmtkITKArchetypeImageSeriesReader.h.

664 {
665 int k = ExistContentTime( aTime );
666 if ( k >= 0 )
667 {
668 return k;
669 }
670
671 std::string aVector(aTime);
672 this->ContentTime.push_back( aVector );
673 return (this->ContentTime.size()-1);
674 }

◆ InsertTriggerTime()

int vtkvmtkITKArchetypeImageSeriesReader::InsertTriggerTime ( const char * aTime)
inline

Definition at line 676 of file vtkvmtkITKArchetypeImageSeriesReader.h.

677 {
678 int k = ExistTriggerTime( aTime );
679 if ( k >= 0 )
680 {
681 return k;
682 }
683
684 std::string aVector(aTime);
685 this->TriggerTime.push_back( aVector );
686 return (this->TriggerTime.size()-1);
687 }

◆ InsertEchoNumbers()

int vtkvmtkITKArchetypeImageSeriesReader::InsertEchoNumbers ( const char * aEcho)
inline

Definition at line 689 of file vtkvmtkITKArchetypeImageSeriesReader.h.

690 {
691 int k = ExistEchoNumbers( aEcho );
692 if ( k >= 0 )
693 {
694 return k;
695 }
696
697 std::string aVector(aEcho);
698 this->EchoNumbers.push_back( aVector );
699 return (this->EchoNumbers.size()-1);
700 }

◆ InsertDiffusionGradientOrientation()

int vtkvmtkITKArchetypeImageSeriesReader::InsertDiffusionGradientOrientation ( float * a)
inline

Definition at line 702 of file vtkvmtkITKArchetypeImageSeriesReader.h.

703 {
705 if ( k >= 0 )
706 {
707 return k;
708 }
709 std::vector< float > aVector(3);
710 float aMag = std::sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);
711 for (k = 0; k < 3; k++)
712 {
713 aVector[k] = a[k]/aMag;
714 }
715
716 this->DiffusionGradientOrientation.push_back( aVector );
717 return (this->DiffusionGradientOrientation.size()-1);
718 }

◆ InsertSliceLocation()

int vtkvmtkITKArchetypeImageSeriesReader::InsertSliceLocation ( float a)
inline

Append the slice location a. Do nothing if the slice location has already been added.

See also
InsertNextSliceLocation()

Definition at line 723 of file vtkvmtkITKArchetypeImageSeriesReader.h.

724 {
725 int k = ExistSliceLocation( a );
726 if ( k >= 0 )
727 {
728 return k;
729 }
730
731 this->SliceLocation.push_back( a );
732 return (this->SliceLocation.size()-1);
733 }

◆ InsertNextSliceLocation()

int vtkvmtkITKArchetypeImageSeriesReader::InsertNextSliceLocation ( )
inline

Linearly insert the next slicer. This prevents a n*log(n) insertion

See also
InsertSliceLocation()

Definition at line 736 of file vtkvmtkITKArchetypeImageSeriesReader.h.

737 {
738 int size = this->SliceLocation.size();
739 this->SliceLocation.push_back(
740 size > 0 ? this->SliceLocation.back() + 1 : 0.f);
741 return size;
742 }

◆ InsertImageOrientationPatient()

int vtkvmtkITKArchetypeImageSeriesReader::InsertImageOrientationPatient ( float * a)
inline

Definition at line 744 of file vtkvmtkITKArchetypeImageSeriesReader.h.

745 {
746 int k = ExistImageOrientationPatient( a );
747 if ( k >= 0 )
748 {
749 return k;
750 }
751 std::vector< float > aVector(6);
752 float aMag = std::sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);
753 float bMag = std::sqrt(a[3]*a[3]+a[4]*a[4]+a[5]*a[5]);
754 for (k = 0; k < 3; k++)
755 {
756 aVector[k] = a[k]/aMag;
757 aVector[k+3] = a[k+3]/bMag;
758 }
759
760 this->ImageOrientationPatient.push_back( aVector );
761 return (this->ImageOrientationPatient.size()-1);
762 }

◆ InsertImagePositionPatient()

int vtkvmtkITKArchetypeImageSeriesReader::InsertImagePositionPatient ( float * a)
inline

Definition at line 764 of file vtkvmtkITKArchetypeImageSeriesReader.h.

765 {
766 int k = ExistImagePositionPatient( a );
767 if ( k >= 0 )
768 {
769 return k;
770 }
771
772 std::vector< float > aVector(3);
773 for ( unsigned int i = 0; i < 3; i++ ) aVector[i] = a[i];
774 this->ImagePositionPatient.push_back( aVector );
775 return (this->ImagePositionPatient.size()-1);
776 }

◆ AnalyzeDicomHeaders()

void vtkvmtkITKArchetypeImageSeriesReader::AnalyzeDicomHeaders ( )

Definition at line 1019 of file vtkvmtkITKArchetypeImageSeriesReader.cxx.

1020{
1021 itk::TimeProbe AnalyzeTime;
1022 AnalyzeTime.Start();
1023
1024 int nFiles = this->AllFileNames.size();
1025 typedef itk::Image<float,3> ImageType;
1026
1027 this->IndexSeriesInstanceUIDs.resize( nFiles );
1028 this->IndexContentTime.resize( nFiles );
1029 this->IndexTriggerTime.resize( nFiles );
1030 this->IndexEchoNumbers.resize( nFiles );
1031 this->IndexDiffusionGradientOrientation.resize( nFiles );
1032 this->IndexSliceLocation.resize( nFiles );
1033 this->IndexImageOrientationPatient.resize( nFiles );
1034 this->IndexImagePositionPatient.resize( nFiles );
1035
1036 this->SeriesInstanceUIDs.resize( 0 );
1037 this->ContentTime.resize( 0 );
1038 this->TriggerTime.resize( 0 );
1039 this->EchoNumbers.resize( 0 );
1040 this->DiffusionGradientOrientation.resize( 0 );
1041 this->SliceLocation.resize( 0 );
1042 this->ImageOrientationPatient.resize( 0 );
1043 this->ImagePositionPatient.resize( 0 );
1044
1045
1046 itk::GDCMImageIO::Pointer gdcmIO = itk::GDCMImageIO::New();
1047 if ( !gdcmIO->CanReadFile(this->Archetype) )
1048 {
1049 itk::ImageIOBase::Pointer lastImageIO;
1050 for (int f = 0; f < nFiles; f++)
1051 {
1052 itk::ImageFileReader<ImageType>::Pointer imageReader =
1053 itk::ImageFileReader<ImageType>::New();
1054 const std::string& fileName = this->AllFileNames[f];
1055 imageReader->SetFileName( fileName );
1056 // Try first to reuse the same imageIO for each file. If it fails, then use
1057 // the default imageIO
1058 if (lastImageIO && (lastImageIO->CanReadFile(fileName.c_str())))
1059 {
1060 imageReader->SetImageIO(lastImageIO);
1061 }
1062 else
1063 {
1064 imageReader->UpdateOutputInformation();
1065 lastImageIO = imageReader->GetImageIO();
1066 }
1067
1068 // Don't read the image header if it is a 2D file type.
1069 std::string IOType = imageReader->GetImageIO()->GetNameOfClass();
1070 bool ioHas3DInformation =
1071 IOType.find("BPMImageIO") != std::string::npos &&
1072 IOType.find("JPEGImageIO") != std::string::npos &&
1073 IOType.find("PNGImageIO") != std::string::npos &&
1074 IOType.find("TIFFImageIO") != std::string::npos &&
1075 IOType.find("RawImageIO") != std::string::npos;
1076 if (ioHas3DInformation)
1077 {
1078 imageReader->UpdateOutputInformation();
1079 lastImageIO = imageReader->GetImageIO();
1080 }
1081
1082 // insert series
1083 int idx = this->InsertSeriesInstanceUIDs( "Non-Dicom Series" );
1084 this->IndexSeriesInstanceUIDs[f] = idx;
1085
1086 // for now, assume ContentTime, TriggerTime, and DiffusionGradientOrientation do not exist
1087 this->IndexContentTime[f] = -1;
1088 this->IndexTriggerTime[f] = -1;
1089 this->IndexEchoNumbers[f] = -1;
1091
1092 // Slice Location
1093 if (ioHas3DInformation)
1094 {
1095 ImageType::PointType origin = imageReader->GetOutput()->GetOrigin();
1096 idx = this->InsertSliceLocation( origin[2] );
1097 }
1098 else
1099 {
1100 idx = this->InsertNextSliceLocation();
1101 }
1102 this->IndexSliceLocation[f] = idx;
1103
1104 // Orientation
1105 float sliceOrientation[6] = {1., 0., 0.,
1106 0., 1., 0.};
1107 if (ioHas3DInformation)
1108 {
1109 ImageType::DirectionType orientation =
1110 imageReader->GetOutput()->GetDirection();
1111 for (int k = 0; k < 3; k++)
1112 {
1113 sliceOrientation[k] = orientation[0][k];
1114 sliceOrientation[k+3] = orientation[1][k];
1115 }
1116 }
1117 idx = this->InsertImageOrientationPatient( sliceOrientation );
1118 this->IndexImageOrientationPatient[f] = idx;
1119 }
1120 return;
1121 }
1122
1123 // if Archetype is a Dicom File
1124 gdcmIO->SetFileName( this->Archetype );
1125 for (int f = 0; f < nFiles; f++)
1126 {
1127 gdcmIO->SetFileName( this->AllFileNames[f] );
1128 gdcmIO->ReadImageInformation();
1129 itk::MetaDataDictionary &dict = gdcmIO->GetMetaDataDictionary();
1130 std::string tagValue;
1131
1132 // series instance UID
1133 tagValue.clear(); itk::ExposeMetaData<std::string>( dict, "0020|000e", tagValue );
1134 if ( tagValue.length() > 0 )
1135 {
1136 int idx = InsertSeriesInstanceUIDs( tagValue.c_str() );
1137 this->IndexSeriesInstanceUIDs[f] = idx;
1138 }
1139 else
1140 {
1141 this->IndexSeriesInstanceUIDs[f] = -1;
1142 }
1143
1144 // content time
1145 tagValue.clear(); itk::ExposeMetaData<std::string>( dict, "0008|0033", tagValue );
1146 if ( tagValue.length() > 0 )
1147 {
1148 int idx = InsertContentTime( tagValue.c_str() );
1149 this->IndexContentTime[f] = idx;
1150 }
1151 else
1152 {
1153 this->IndexContentTime[f] = -1;
1154 }
1155
1156 // trigger time
1157 tagValue.clear(); itk::ExposeMetaData<std::string>( dict, "0018|1060", tagValue );
1158 if ( tagValue.length() > 0 )
1159 {
1160 int idx = InsertTriggerTime( tagValue.c_str() );
1161 this->IndexTriggerTime[f] = idx;
1162 }
1163 else
1164 {
1165 this->IndexTriggerTime[f] = -1;
1166 }
1167
1168 // echo numbers
1169 tagValue.clear(); itk::ExposeMetaData<std::string>( dict, "0018|0086", tagValue );
1170 if ( tagValue.length() > 0 )
1171 {
1172 int idx = InsertEchoNumbers( tagValue.c_str() );
1173 this->IndexEchoNumbers[f] = idx;
1174 }
1175 else
1176 {
1177 this->IndexEchoNumbers[f] = -1;
1178 }
1179
1180 // diffision gradient orientation
1181 tagValue.clear(); itk::ExposeMetaData<std::string>( dict, "0010|9089", tagValue );
1182 if ( tagValue.length() > 0 )
1183 {
1184 float a[3];
1185 sscanf( tagValue.c_str(), "%f\\%f\\%f", a, a+1, a+2 );
1187 this->IndexDiffusionGradientOrientation[f] = idx;
1188 }
1189 else
1190 {
1192 }
1193
1194 // slice location
1195 tagValue.clear(); itk::ExposeMetaData<std::string>( dict, "0020|1041", tagValue );
1196 if ( tagValue.length() > 0 )
1197 {
1198 float a;
1199 sscanf( tagValue.c_str(), "%f", &a );
1200 int idx = InsertSliceLocation( a );
1201 this->IndexSliceLocation[f] = idx;
1202 }
1203 else
1204 {
1205 this->IndexSliceLocation[f] = -1;
1206 }
1207
1208 // image orientation patient
1209 tagValue.clear(); itk::ExposeMetaData<std::string>( dict, "0020|0037", tagValue );
1210 if ( tagValue.length() > 0 )
1211 {
1212 float a[6];
1213 sscanf( tagValue.c_str(), "%f\\%f\\%f\\%f\\%f\\%f", a, a+1, a+2, a+3, a+4, a+5 );
1214 int idx = InsertImageOrientationPatient( a );
1215 this->IndexImageOrientationPatient[f] = idx;
1216 }
1217 else
1218 {
1219 this->IndexImageOrientationPatient[f] = -1;
1220 }
1221 // image position patient
1222 tagValue.clear(); itk::ExposeMetaData<std::string>( dict, "0020|0032", tagValue );
1223 if( tagValue.length() > 0 )
1224 {
1225 float a[3];
1226 sscanf( tagValue.c_str(), "%f\\%f\\%f", a, a+1, a+2 );
1227 int idx = InsertImagePositionPatient( a );
1228 this->IndexImagePositionPatient[f] = idx;
1229 }
1230 else
1231 {
1232 this->IndexImagePositionPatient[f] = -1;
1233 }
1234 }
1235
1236 AnalyzeTime.Stop();
1237
1238 // double timeelapsed = AnalyzeTime.GetMean(); UNUSED
1239 AnalyzeHeader = false;
1240 return;
1241}
std::vector< long int > IndexSeriesInstanceUIDs
index of each dicom file into the above arrays

◆ AssembleNthVolume()

void vtkvmtkITKArchetypeImageSeriesReader::AssembleNthVolume ( int n)

Definition at line 910 of file vtkvmtkITKArchetypeImageSeriesReader.cxx.

911{
912 this->FileNames.resize( 0 );
913 // int nFiles = this->AllFileNames.size(); UNUSED
914
915 unsigned int nSlices = this->GetNumberOfSliceLocation();
916
917 for (unsigned int k = 0; k < nSlices; k++)
918 {
919 const char* name = GetNthFileName( 0, -1, -1, -1, 0, k, 0, n );
920 if (name == NULL)
921 {
922 continue;
923 }
924 std::string nameInString (name);
925 this->FileNames.push_back(nameInString);
926 }
927
928}
const char * GetNthFileName(int idxSeriesInstanceUID, int idxContentTime, int idxTriggerTime, int idxEchoNumbers, int idxDiffusionGradientOrientation, int idxSliceLocation, int idxImageOrientationPatient, int n)

◆ AssembleVolumeContainingArchetype()

int vtkvmtkITKArchetypeImageSeriesReader::AssembleVolumeContainingArchetype ( )

Definition at line 1354 of file vtkvmtkITKArchetypeImageSeriesReader.cxx.

1355{
1356 // we will set FileNames to have only volumes that match the archetype
1357 // and we will return the size of the list.
1358 // - if the files have ImagePositionPatient tags, we will sort
1359 // the files based on this information
1360 this->FileNames.resize(0);
1361
1362 // Note: Since IndexArchetype is unsigned int, it's always postive
1363 if (this->IndexArchetype >= this->IndexSeriesInstanceUIDs.size()
1364 || this->IndexArchetype >= this->IndexTriggerTime.size()
1365 || this->IndexArchetype >= this->IndexDiffusionGradientOrientation.size()
1366 || this->IndexArchetype >= this->IndexImageOrientationPatient.size())
1367 {
1368 vtkErrorMacro("AssembleVolumeContainingArchetype: index archetype "
1369 << this->IndexArchetype << " is out of bounds 0-" << this->IndexSeriesInstanceUIDs.size());
1370 return 0;
1371 }
1372
1373
1374 long int iArchetypeSeriesUID = this->IndexSeriesInstanceUIDs[this->IndexArchetype];
1375 long int iArchetypeEchoNumbers = this->IndexEchoNumbers[this->IndexArchetype];
1376 long int iArchetypeDiffusion = this->IndexDiffusionGradientOrientation[this->IndexArchetype];
1377 long int iArchetypeOrientation = this->IndexImageOrientationPatient[this->IndexArchetype];
1378
1379 // keep track of the locations for the selected files
1380 std::vector<std::pair <double, int> > fileNameSortKey;
1381 bool originSet = false;
1382
1383 // Sort good files based on distance from Origin to ImagePositionPatient along ScanAxis
1384 // Follows logic originally in LoadVolume.tcl
1385 for (unsigned int k = 0; k < this->AllFileNames.size(); k++)
1386 {
1387 if ( (this->IndexSeriesInstanceUIDs[k] != iArchetypeSeriesUID &&
1388 this->IndexSeriesInstanceUIDs[k] >= 0 && iArchetypeSeriesUID >= 0)
1389 ||
1390 (this->IndexEchoNumbers[k] != iArchetypeEchoNumbers &&
1391 this->IndexEchoNumbers[k] >= 0 && iArchetypeEchoNumbers >= 0)
1392 ||
1393 (this->IndexDiffusionGradientOrientation[k] != iArchetypeDiffusion &&
1394 this->IndexDiffusionGradientOrientation[k] >= 0 && iArchetypeDiffusion >= 0)
1395 ||
1396 (this->IndexImageOrientationPatient[k] != iArchetypeOrientation &&
1397 this->IndexImageOrientationPatient[k] >= 0 && iArchetypeOrientation >= 0) )
1398 {
1399 // file doesn't match our criteria
1400 continue;
1401 }
1402 else
1403 {
1404 // find the position and orientation corresponding to this
1405 // file - it could be that all files in the set have the same index
1406 // (1) or that there is no position information, in which case the
1407 // position index will be -1
1408 int kth_orientation = -1;
1409 int kth_position = -1;
1410 if ( ImagePositionPatient.size() != 0 )
1411 {
1412 kth_orientation = this->IndexImageOrientationPatient[k];
1413 kth_position = this->IndexImagePositionPatient[k];
1414 }
1415 if (kth_orientation > 0 && kth_position > 0)
1416 {
1417 if (!originSet)
1418 {
1419 std::vector<float> iopv = this->ImageOrientationPatient[kth_orientation];
1420 float iopf1[] = {iopv[0], iopv[1], iopv[2]};
1421 float iopf2[] = {iopv[3], iopv[4], iopv[5]};
1422
1423 vtkMath::Cross( iopf1, iopf2, this->ScanAxis );
1424 this->ScanOrigin[0] = ImagePositionPatient[kth_position][0];
1425 this->ScanOrigin[1] = ImagePositionPatient[kth_position][1];
1426 this->ScanOrigin[2] = ImagePositionPatient[kth_position][2];
1427 originSet = true;
1428 }
1429 float tempiop[3], diff[3];
1430 tempiop[0] = ImagePositionPatient[kth_position][0];
1431 tempiop[1] = ImagePositionPatient[kth_position][1];
1432 tempiop[2] = ImagePositionPatient[kth_position][2];
1433
1434 vtkMath::Subtract( tempiop, this->ScanOrigin, diff );
1435 float dist = vtkMath::Dot( diff, ScanAxis );
1436
1437 fileNameSortKey.push_back( std::make_pair(dist, k) );
1438 }
1439 else
1440 {
1441 // no position info, so use the file index
1442 fileNameSortKey.push_back( std::make_pair(k, k) );
1443 }
1444 }
1445 }
1446
1447 std::sort(fileNameSortKey.begin(), fileNameSortKey.end());
1448 std::vector<std::pair <double, int> >::iterator keyiter;
1449 for (keyiter = fileNameSortKey.begin(); keyiter != fileNameSortKey.end(); ++keyiter)
1450 {
1451 FileNames.push_back(AllFileNames[keyiter->second]);
1452 }
1453
1454 return this->FileNames.size();
1455}

◆ GroupFiles()

void vtkvmtkITKArchetypeImageSeriesReader::GroupFiles ( int idxSeriesInstanceUID,
int idxContentTime,
int idxTriggerTime,
int idxEchoNumbers,
int idxDiffusionGradientOrientation,
int idxSliceLocation,
int idxImageOrientationPatient )

Definition at line 988 of file vtkvmtkITKArchetypeImageSeriesReader.cxx.

995{
996 this->FileNames.resize( 0 );
997 int nFiles = this->AllFileNames.size();
998 for (int k = 0; k < nFiles; k++)
999 {
1000 if ( (this->IndexSeriesInstanceUIDs[k] != idxSeriesInstanceUID && this->IndexSeriesInstanceUIDs[k] >= 0 && idxSeriesInstanceUID >= 0) ||
1001 (this->IndexContentTime[k] != idxContentTime && this->IndexContentTime[k] >= 0 && idxContentTime >= 0) ||
1002 (this->IndexTriggerTime[k] != idxTriggerTime && this->IndexTriggerTime[k] >= 0 && idxTriggerTime >= 0) ||
1003 (this->IndexEchoNumbers[k] != idxEchoNumbers && this->IndexEchoNumbers[k] >= 0 && idxEchoNumbers >= 0) ||
1004 (this->IndexDiffusionGradientOrientation[k] != idxDiffusionGradientOrientation && this->IndexDiffusionGradientOrientation[k] >= 0 && idxDiffusionGradientOrientation >= 0) ||
1005 (this->IndexSliceLocation[k] != idxSliceLocation && this->IndexSliceLocation[k] >= 0 && idxSliceLocation >= 0) ||
1006 (this->IndexImageOrientationPatient[k] != idxImageOrientationPatient && this->IndexImageOrientationPatient[k] >= 0 && idxImageOrientationPatient >= 0) )
1007 {
1008 continue;
1009 }
1010 else
1011 {
1012 this->FileNames.push_back( this->AllFileNames[k] );
1013 }
1014 }
1015 return;
1016}

◆ GetNthFileName()

const char * vtkvmtkITKArchetypeImageSeriesReader::GetNthFileName ( int idxSeriesInstanceUID,
int idxContentTime,
int idxTriggerTime,
int idxEchoNumbers,
int idxDiffusionGradientOrientation,
int idxSliceLocation,
int idxImageOrientationPatient,
int n )

Definition at line 943 of file vtkvmtkITKArchetypeImageSeriesReader.cxx.

951{
952 int nFiles = this->AllFileNames.size();
953 int count = 0;
954 std::string FirstName;
955 for (int k = 0; k < nFiles; k++)
956 {
957 if ( (this->IndexSeriesInstanceUIDs[k] != idxSeriesInstanceUID && this->IndexSeriesInstanceUIDs[k] >= 0 && idxSeriesInstanceUID >= 0) ||
958 (this->IndexContentTime[k] != idxContentTime && this->IndexContentTime[k] >= 0 && idxContentTime >= 0) ||
959 (this->IndexTriggerTime[k] != idxTriggerTime && this->IndexTriggerTime[k] >= 0 && idxTriggerTime >= 0) ||
960 (this->IndexEchoNumbers[k] != idxEchoNumbers && this->IndexEchoNumbers[k] >= 0 && idxEchoNumbers >= 0) ||
961 (this->IndexDiffusionGradientOrientation[k] != idxDiffusionGradientOrientation && this->IndexDiffusionGradientOrientation[k] >= 0 && idxDiffusionGradientOrientation >= 0) ||
962 (this->IndexSliceLocation[k] != idxSliceLocation && this->IndexSliceLocation[k] >= 0 && idxSliceLocation >= 0) ||
963 (this->IndexImageOrientationPatient[k] != idxImageOrientationPatient && this->IndexImageOrientationPatient[k] >= 0 && idxImageOrientationPatient >= 0) )
964 {
965 continue;
966 }
967 else
968 {
969 if (count == n)
970 {
971 return this->AllFileNames[k].c_str();
972 }
973 else if( count == 0 )
974 {
975 FirstName = this->AllFileNames[k];
976 count ++;
977 }
978 else
979 {
980 count ++;
981 }
982 }
983 }
984 return NULL;
985}

◆ RequestInformation()

int vtkvmtkITKArchetypeImageSeriesReader::RequestInformation ( vtkInformation * ,
vtkInformationVector ** ,
vtkInformationVector *  )
overrideprotectedvirtual

Definition at line 184 of file vtkvmtkITKArchetypeImageSeriesReader.cxx.

188{
189 // get the info objects
190 vtkInformation* outInfo = outputVector->GetInformationObject(0);
191
192 std::vector<std::string> candidateFiles;
193 std::vector<std::string> candidateSeries;
194 int extent[6];
195 std::string fileNameCollapsed = itksys::SystemTools::CollapseFullPath( this->Archetype);
196
197 if ( this->SingleFile )
198 {
199 this->AnalyzeHeader = false;
200 }
201
202 // Since we only need origin, spacing and extents, we can use one
203 // image type.
204 typedef itk::Image<float,3> ImageType;
205 itk::ImageRegion<3> region;
206
207 typedef itk::ImageSource<ImageType> FilterType;
208 FilterType::Pointer filter;
209
210 // First see if the archetype exists, if it's not a pointer into memory
211 if (fileNameCollapsed.find("slicer:") != std::string::npos &&
212 fileNameCollapsed.find("#") != std::string::npos)
213 {
214 vtkDebugMacro("File " << fileNameCollapsed.c_str() << " is a pointer to the mrml scene in memory, not checking for it on disk");
215 }
216 else
217 {
218 if (!itksys::SystemTools::FileExists (fileNameCollapsed.c_str()))
219 {
220 vtkErrorMacro( "vtkvmtkITKArchetypeImageSeriesReader::ExecuteInformation: Archetype file " << fileNameCollapsed.c_str() << " does not exist.");
221 return 0;
222 }
223 }
224
225 this->AllFileNames.resize( 0 );
226
227 // Some file types require special processing
228 itk::GDCMImageIO::Pointer dicomIO = itk::GDCMImageIO::New();
229
230 // Test whether the input file is a DICOM file
231 bool isDicomFile = dicomIO->CanReadFile(this->Archetype);
232
233 // if user already set up FileNames, we do not try to find candidate files
234 if ( this->GetNumberOfFileNames() > 0 )
235 {
236 unsigned int nFiles = this->GetNumberOfFileNames();
237 this->AllFileNames.resize( 0 );
238 for (unsigned int k = 0; k < nFiles; k++)
239 {
240 this->AllFileNames.push_back( this->FileNames[k] );
241 }
242 this->FileNames.resize( 0 );
243
244 // if this is the only file set by user
245 if (nFiles == 1)
246 {
247 this->IsOnlyFile = true;
248 }
249
250 // if we need to analyze the header
251 if ( AnalyzeHeader )
252 {
253 this->AnalyzeDicomHeaders();
254 }
255 }
256 else
257 {
258 if ( isDicomFile && !this->GetSingleFile() )
259 {
260 typedef itk::GDCMSeriesFileNames DICOMNameGeneratorType;
261 DICOMNameGeneratorType::Pointer inputImageFileGenerator = DICOMNameGeneratorType::New();
262 std::string fileNamePath = itksys::SystemTools::GetFilenamePath( this->Archetype );
263 if (fileNamePath == "")
264 {
265 fileNamePath = ".";
266 }
267 inputImageFileGenerator->SetDirectory( fileNamePath );
268
269 // determine if the file is diffusion weighted MR file
270
271 // Find the series that contains the archetype
272 candidateSeries = inputImageFileGenerator->GetSeriesUIDs();
273
274 // Find all dicom files in the directory
275 for (unsigned int s = 0; s < candidateSeries.size(); s++)
276 {
277 std::vector<std::string> seriesFileNames;
278 seriesFileNames = inputImageFileGenerator->GetFileNames( candidateSeries[s] );
279 for (unsigned int f = 0; f < seriesFileNames.size(); f++)
280 {
281 this->AllFileNames.push_back( seriesFileNames[f] );
282 }
283 }
284 //int nFiles = this->AllFileNames.size(); UNUSED
285
286 // analysis dicom files and fill the Dicom Tag arrays
287 if ( AnalyzeHeader )
288 {
289 this->AnalyzeDicomHeaders();
290 }
291
292 // the following for loop set up candidate files with same series number
293 // that include the given Archetype;
294 int found = 0;
295 for (unsigned int s = 0; s < candidateSeries.size() && found == 0; s++)
296 {
297 candidateFiles = inputImageFileGenerator->GetFileNames(candidateSeries[s]);
298 for (unsigned int f = 0; f < candidateFiles.size(); f++)
299 {
300 if (itksys::SystemTools::CollapseFullPath(candidateFiles[f].c_str()) ==
301 fileNameCollapsed)
302 {
303 found = 1;
304 break;
305 }
306 }
307 }
308
309 // do we have just one candidate file
310 if ( candidateFiles.size() == 1 )
311 {
312 this->IsOnlyFile = true;
313 }
314 }
315 else if( !this->GetSingleFile() )
316 { // not dicom
317 // check the dimensions of the archetype - if there
318 // is more then one slice, use only the archetype
319 // but if it is a single slice, try to generate a
320 // series of filenames
321 itk::ImageFileReader<ImageType>::Pointer imageReader =
322 itk::ImageFileReader<ImageType>::New();
323 imageReader->SetFileName(this->Archetype);
324 imageReader->UpdateOutputInformation();
325 region = imageReader->GetOutput()->GetLargestPossibleRegion();
326 if ( region.GetSize()[2] > 1 )
327 {
328 candidateFiles.push_back( this->Archetype );
329 this->AllFileNames.push_back( this->Archetype );
330 this->IsOnlyFile = true;
331 }
332 else
333 {
334 // Generate filenames from the Archetype
335 itk::ArchetypeSeriesFileNames::Pointer fit = itk::ArchetypeSeriesFileNames::New();
336 fit->SetArchetype (this->Archetype);
337 candidateFiles = fit->GetFileNames();
338 this->AllFileNames.resize( candidateFiles.size() );
339 for (int f = 0; f < (int)(candidateFiles.size()); f ++)
340 {
341 this->AllFileNames[f] = candidateFiles[f];
342 }
343 if ( candidateFiles.size() == 1 )
344 {
345 this->IsOnlyFile = true;
346 }
347 else if ( AnalyzeHeader )
348 {
349 this->AnalyzeDicomHeaders();
350 }
351 }
352 }
353 else
354 {
355 this->AllFileNames.push_back( this->Archetype );
356 this->IsOnlyFile = true;
357 }
358 }
359
360 // figure out the index of Archetype in AllFileNames
361 for (unsigned int k = 0; k < this->AllFileNames.size(); k++)
362 {
363 if (this->AllFileNames[k] == this->Archetype)
364 {
365 this->IndexArchetype = k;
366 break;
367 }
368 }
369
370 // Reduce the selection of filenames
371 if ( this->IsOnlyFile || this->SingleFile )
372 {
373 this->FileNames.resize( 0 );
374 this->FileNames.push_back( this->Archetype );
375 }
376 else
377 {
378 if ( !GroupingByTags )
379 {
381 }
382 else
383 {
391 }
392 }
393
394 if (RasToIjkMatrix)
395 {
396 RasToIjkMatrix->Delete();
397 }
398 RasToIjkMatrix = vtkMatrix4x4::New();
399
400 vtkMatrix4x4* IjkToLpsMatrix = vtkMatrix4x4::New();
401
402 RasToIjkMatrix->Identity();
403 IjkToLpsMatrix->Identity();
404
405 double spacing[3];
406 double origin[3];
407
408
409 itk::ImageIOBase::Pointer imageIO = nullptr;
410
411 try
412 {
413 // If there is only one file in the series, just use an image file reader
414 if (this->FileNames.size() == 1)
415 {
416 itk::OrientImageFilter<ImageType,ImageType>::Pointer orient =
417 itk::OrientImageFilter<ImageType,ImageType>::New();
418 itk::ImageFileReader<ImageType>::Pointer imageReader =
419 itk::ImageFileReader<ImageType>::New();
420 imageReader->SetFileName(this->FileNames[0].c_str());
421 if (isDicomFile)
422 {
423 imageReader->SetImageIO(dicomIO);
424 }
425
427 {
428 imageReader->UpdateOutputInformation();
429 filter = imageReader;
430 }
431 else
432 {
433 orient->SetInput(imageReader->GetOutput());
434 orient->UseImageDirectionOn();
435 orient->SetDesiredCoordinateOrientation(this->DesiredCoordinateOrientation);
436 orient->UpdateOutputInformation();
437 filter = orient;
438 }
439 for (int i = 0; i < 3; i++)
440 {
441 spacing[i] = filter->GetOutput()->GetSpacing()[i];
442 origin[i] = filter->GetOutput()->GetOrigin()[i];
443
444 // Get IJK to RAS direction vector
445 for ( unsigned int j=0; j < filter->GetOutput()->GetImageDimension (); j++ )
446 {
447 IjkToLpsMatrix->SetElement(j, i, spacing[i]*filter->GetOutput()->GetDirection()[j][i]);
448 }
449 }
450 region = filter->GetOutput()->GetLargestPossibleRegion();
451 extent[0] = region.GetIndex()[0];
452 extent[1] = region.GetIndex()[0] + region.GetSize()[0] - 1;
453 extent[2] = region.GetIndex()[1];
454 extent[3] = region.GetIndex()[1] + region.GetSize()[1] - 1;
455 extent[4] = region.GetIndex()[2];
456 extent[5] = region.GetIndex()[2] + region.GetSize()[2] - 1;
457
458 typedef std::vector<std::vector<double> > DoubleVectorType;
459 typedef itk::MetaDataObject<DoubleVectorType> MetaDataDoubleVectorType;
460 const itk::MetaDataDictionary & dictionary = imageReader->GetMetaDataDictionary();
461 itk::MetaDataDictionary::ConstIterator itr = dictionary.Begin();
462 itk::MetaDataDictionary::ConstIterator end = dictionary.End();
463 while( itr != end )
464 {
465 itk::MetaDataObjectBase::Pointer entry = itr->second;
466 MetaDataDoubleVectorType::Pointer entryvalue1
467 = dynamic_cast<MetaDataDoubleVectorType *>( entry.GetPointer() );
468 if( entryvalue1 )
469 {
470 int pos = itr->first.find( "NRRD_measurement frame" );
471 if( pos != -1 )
472 {
473 DoubleVectorType tagvalue = entryvalue1->GetMetaDataObjectValue();
474 for( int i = 0; i < 3; i++ )
475 {
476 for( int j = 0; j < 3; j++ )
477 {
478 this->MeasurementFrameMatrix->SetElement(i,j, tagvalue.at( j ).at( i ));
479 }
480 }
481 }
482 }
483 ++itr;
484 }
485
486
487 imageIO = imageReader->GetImageIO();
488 if (imageIO.GetPointer() == NULL)
489 {
490 vtkErrorMacro( "vtkvmtkITKArchetypeImageSeriesReader::ExecuteInformation: ImageIO for file " << fileNameCollapsed.c_str() << " does not exist.");
491 return 0;
492 }
493 }
494 else
495 {
496 itk::OrientImageFilter<ImageType,ImageType>::Pointer orient =
497 itk::OrientImageFilter<ImageType,ImageType>::New();
498 itk::ImageSeriesReader<ImageType>::Pointer seriesReader =
499 itk::ImageSeriesReader<ImageType>::New();
500 seriesReader->SetFileNames(this->FileNames);
501 if (isDicomFile)
502 {
503 seriesReader->SetImageIO(dicomIO);
504 }
505 else
506 {
507 itk::ImageFileReader<ImageType>::Pointer imageReader =
508 itk::ImageFileReader<ImageType>::New();
509 imageReader->SetFileName(this->FileNames[0].c_str());
510 imageReader->UpdateOutputInformation();
511 imageIO = imageReader->GetImageIO();
512 seriesReader->SetImageIO(imageIO);
513 }
515 {
516 seriesReader->UpdateOutputInformation();
517 filter = seriesReader;
518 }
519 else
520 {
521 orient->SetInput(seriesReader->GetOutput());
522 orient->UseImageDirectionOn();
523 orient->SetDesiredCoordinateOrientation(this->DesiredCoordinateOrientation);
524 orient->UpdateOutputInformation();
525 filter = orient;
526 }
527 for (int i = 0; i < 3; i++)
528 {
529 spacing[i] = filter->GetOutput()->GetSpacing()[i];
530 origin[i] = filter->GetOutput()->GetOrigin()[i];
531 // Get IJK to RAS direction vector
532 for ( unsigned int j=0; j < filter->GetOutput()->GetImageDimension (); j++ )
533 {
534 IjkToLpsMatrix->SetElement(j, i, spacing[i]*filter->GetOutput()->GetDirection()[j][i]);
535 }
536 }
537
538 region = filter->GetOutput()->GetLargestPossibleRegion();
539 extent[0] = region.GetIndex()[0];
540 extent[1] = region.GetIndex()[0] + region.GetSize()[0] - 1;
541 extent[2] = region.GetIndex()[1];
542 extent[3] = region.GetIndex()[1] + region.GetSize()[1] - 1;
543 extent[4] = region.GetIndex()[2];
544 extent[5] = region.GetIndex()[2] + region.GetSize()[2] - 1;
545 imageIO = seriesReader->GetImageIO();
546
547 }
548 }
549 catch (itk::ExceptionObject& e)
550 {
551 IjkToLpsMatrix->Delete();
552 vtkErrorMacro( "vtkvmtkITKArchetypeImageSeriesReader::ExecuteInformation: Cannot open " << fileNameCollapsed.c_str() << ". "
553 << "ITK exception info: error in " << e.GetLocation() << ": "<< e.GetDescription());
554 return 0;
555 }
556 // Transform from LPS to RAS
557 vtkMatrix4x4* LpsToRasMatrix = vtkMatrix4x4::New();
558 LpsToRasMatrix->Identity();
559 LpsToRasMatrix->SetElement(0,0,-1);
560 LpsToRasMatrix->SetElement(1,1,-1);
561
562 vtkMatrix4x4* LPSMeasurementFrameMatrix = vtkMatrix4x4::New();
563 LPSMeasurementFrameMatrix->DeepCopy(this->MeasurementFrameMatrix);
564
565 vtkMatrix4x4::Multiply4x4(LpsToRasMatrix,IjkToLpsMatrix, RasToIjkMatrix);
566 vtkMatrix4x4::Multiply4x4(LpsToRasMatrix,LPSMeasurementFrameMatrix, this->MeasurementFrameMatrix);
567 LpsToRasMatrix->Delete();
568 LPSMeasurementFrameMatrix->Delete();
569
570 // If it looks like the pipeline did not provide the spacing and
571 // origin, modify the spacing and origin with the defaults
572 for (int j = 0; j < 3; j++)
573 {
574 if (spacing[j] == 1.0)
575 {
576 spacing[j] = this->DefaultDataSpacing[j];
577 }
578 if (origin[j] == 0.0)
579 {
580 origin[j] = this->DefaultDataOrigin[j];
581 }
582 }
583
584 origin[0] *= -1; // L -> R
585 origin[1] *= -1; // P -> A
586
587 if (this->UseNativeOrigin)
588 {
589 for (int j = 0; j < 3; j++)
590 {
591 RasToIjkMatrix->SetElement(j, 3, origin[j]);
592 }
593 RasToIjkMatrix->Invert();
594 }
595 else
596 {
597 RasToIjkMatrix->Invert();
598 for (int j = 0; j < 3; j++)
599 {
600 RasToIjkMatrix->SetElement(j, 3, (extent[2*j+1] - extent[2*j])/2.0);
601 }
602 }
603
604 outInfo->Set(vtkDataObject::SPACING(), spacing, 3);
605 outInfo->Set(vtkDataObject::ORIGIN(), origin, 3);
606 RasToIjkMatrix->SetElement(3,3,1.0);
607 IjkToLpsMatrix->Delete();
608
609 if ( !this->GetUseOrientationFromFile() )
610 {
611 RasToIjkMatrix->Identity();
612 for ( unsigned int j=0; j < 3; j++ )
613 {
614 RasToIjkMatrix->SetElement(j, j, 1.0/spacing[j]);
615 }
616 }
617
618 outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), extent, 6);
619 int scalarType = this->OutputScalarType;
620 if (this->UseNativeScalarType)
621 {
622 // If there is only one file in the series
623 if (this->FileNames.size() == 1)
624 {
625 if (imageIO.GetPointer() == NULL)
626 {
627 scalarType = VTK_SHORT; // TODO - figure out why multi-file series doen't have an imageIO
628 }
629#if (ITK_VERSION_MAJOR >= 5)
630 else if (imageIO->GetComponentType() == itk::IOComponentEnum::UCHAR)
631#else
632 else if (imageIO->GetComponentType() == itk::ImageIOBase::UCHAR)
633#endif
634 {
635 scalarType = VTK_UNSIGNED_CHAR;
636 }
637#if (ITK_VERSION_MAJOR >= 5)
638 else if (imageIO->GetComponentType() == itk::IOComponentEnum::CHAR)
639#else
640 else if (imageIO->GetComponentType() == itk::ImageIOBase::CHAR)
641#endif
642 {
643 scalarType = VTK_CHAR;
644 }
645#if (ITK_VERSION_MAJOR >= 5)
646 else if (imageIO->GetComponentType() == itk::IOComponentEnum::USHORT)
647#else
648 else if (imageIO->GetComponentType() == itk::ImageIOBase::USHORT)
649#endif
650 {
651 scalarType = VTK_UNSIGNED_SHORT;
652 }
653#if (ITK_VERSION_MAJOR >= 5)
654 else if (imageIO->GetComponentType() == itk::IOComponentEnum::SHORT)
655#else
656 else if (imageIO->GetComponentType() == itk::ImageIOBase::SHORT)
657#endif
658 {
659 scalarType = VTK_SHORT;
660 }
661#if (ITK_VERSION_MAJOR >= 5)
662 else if (imageIO->GetComponentType() == itk::IOComponentEnum::UINT)
663#else
664 else if (imageIO->GetComponentType() == itk::ImageIOBase::UINT)
665#endif
666 {
667 scalarType = VTK_UNSIGNED_INT;
668 }
669#if (ITK_VERSION_MAJOR >= 5)
670 else if (imageIO->GetComponentType() == itk::IOComponentEnum::INT)
671#else
672 else if (imageIO->GetComponentType() == itk::ImageIOBase::INT)
673#endif
674 {
675 scalarType = VTK_INT;
676 }
677#if (ITK_VERSION_MAJOR >= 5)
678 else if (imageIO->GetComponentType() == itk::IOComponentEnum::ULONG)
679#else
680 else if (imageIO->GetComponentType() == itk::ImageIOBase::ULONG)
681#endif
682 {
683 scalarType = VTK_UNSIGNED_LONG;
684 }
685#if (ITK_VERSION_MAJOR >= 5)
686 else if (imageIO->GetComponentType() == itk::IOComponentEnum::LONG)
687#else
688 else if (imageIO->GetComponentType() == itk::ImageIOBase::LONG)
689#endif
690 {
691 scalarType = VTK_LONG;
692 }
693#if (ITK_VERSION_MAJOR >= 5)
694 else if (imageIO->GetComponentType() == itk::IOComponentEnum::FLOAT)
695#else
696 else if (imageIO->GetComponentType() == itk::ImageIOBase::FLOAT)
697#endif
698 {
699 scalarType = VTK_FLOAT;
700 }
701#if (ITK_VERSION_MAJOR >= 5)
702 else if (imageIO->GetComponentType() == itk::IOComponentEnum::DOUBLE)
703#else
704 else if (imageIO->GetComponentType() == itk::ImageIOBase::DOUBLE)
705#endif
706 {
707 scalarType = VTK_DOUBLE;
708 }
709 }
710 else
711 {
712 double min = 0, max = 0;
713
714 for( unsigned int f = 0; f < this->FileNames.size(); f++ )
715 {
716 imageIO->SetFileName( this->FileNames[f] );
717 imageIO->ReadImageInformation();
718
719#if (ITK_VERSION_MAJOR >= 5)
720 if ( imageIO->GetComponentType() == itk::IOComponentEnum::UCHAR )
721#else
722 if ( imageIO->GetComponentType() == itk::ImageIOBase::UCHAR )
723#endif
724 {
725 min = std::numeric_limits<uint8_t>::min() < min ? std::numeric_limits<uint8_t>::min() : min;
726 max = std::numeric_limits<uint8_t>::max() > max ? std::numeric_limits<uint8_t>::max() : max;
727 }
728#if (ITK_VERSION_MAJOR >= 5)
729 if ( imageIO->GetComponentType() == itk::IOComponentEnum::CHAR )
730#else
731 if ( imageIO->GetComponentType() == itk::ImageIOBase::CHAR )
732#endif
733 {
734 min = std::numeric_limits<int8_t>::min() < min ? std::numeric_limits<int8_t>::min() : min;
735 max = std::numeric_limits<int8_t>::max() > max ? std::numeric_limits<int8_t>::max() : max;
736 }
737#if (ITK_VERSION_MAJOR >= 5)
738 if ( imageIO->GetComponentType() == itk::IOComponentEnum::USHORT )
739#else
740 if ( imageIO->GetComponentType() == itk::ImageIOBase::USHORT )
741#endif
742 {
743 min = std::numeric_limits<uint16_t>::min() < min ? std::numeric_limits<uint16_t>::min() : min;
744 max = std::numeric_limits<uint16_t>::max() > max ? std::numeric_limits<uint16_t>::max() : max;
745 }
746#if (ITK_VERSION_MAJOR >= 5)
747 if ( imageIO->GetComponentType() == itk::IOComponentEnum::SHORT )
748#else
749 if ( imageIO->GetComponentType() == itk::ImageIOBase::SHORT )
750#endif
751 {
752 min = std::numeric_limits<int16_t>::min() < min ? std::numeric_limits<int16_t>::min() : min;
753 max = std::numeric_limits<int16_t>::max() > max ? std::numeric_limits<int16_t>::max() : max;
754 }
755#if (ITK_VERSION_MAJOR >= 5)
756 if ( imageIO->GetComponentType() == itk::IOComponentEnum::UINT )
757#else
758 if ( imageIO->GetComponentType() == itk::ImageIOBase::UINT )
759#endif
760 {
761 min = std::numeric_limits<uint32_t>::min() < min ? std::numeric_limits<uint32_t>::min() : min;
762 max = std::numeric_limits<uint32_t>::max() > max ? std::numeric_limits<uint32_t>::max() : max;
763 }
764#if (ITK_VERSION_MAJOR >= 5)
765 if ( imageIO->GetComponentType() == itk::IOComponentEnum::INT )
766#else
767 if ( imageIO->GetComponentType() == itk::ImageIOBase::INT )
768#endif
769 {
770 min = std::numeric_limits<int32_t>::min() < min ? std::numeric_limits<int32_t>::min() : min;
771 max = std::numeric_limits<int32_t>::max() > max ? std::numeric_limits<int32_t>::max() : max;
772 }
773#if (ITK_VERSION_MAJOR >= 5)
774 if ( imageIO->GetComponentType() == itk::IOComponentEnum::ULONG )
775#else
776 if ( imageIO->GetComponentType() == itk::ImageIOBase::ULONG )
777#endif
778 { // note that on windows ULONG is only 32 bit
779 min = std::numeric_limits<uint64_t>::min() < min ? std::numeric_limits<uint64_t>::min() : min;
780 max = std::numeric_limits<uint64_t>::max() > max ? std::numeric_limits<uint64_t>::max() : max;
781 }
782#if (ITK_VERSION_MAJOR >= 5)
783 if ( imageIO->GetComponentType() == itk::IOComponentEnum::LONG )
784#else
785 if ( imageIO->GetComponentType() == itk::ImageIOBase::LONG )
786#endif
787 { // note that on windows LONG is only 32 bit
788 min = std::numeric_limits<int64_t>::min() < min ? std::numeric_limits<int64_t>::min() : min;
789 max = std::numeric_limits<int64_t>::max() > max ? std::numeric_limits<int64_t>::max() : max;
790 }
791#if (ITK_VERSION_MAJOR >= 5)
792 if ( imageIO->GetComponentType() == itk::IOComponentEnum::FLOAT )
793#else
794 if ( imageIO->GetComponentType() == itk::ImageIOBase::FLOAT )
795#endif
796 {
797 // use -max() as min() for both float and double as temp workaround
798 // should switch to lowest() function in C++ 11 in the future
799 min = -std::numeric_limits<float>::max() < min ? -std::numeric_limits<float>::max() : min;
800 max = std::numeric_limits<float>::max() > max ? std::numeric_limits<float>::max() : max;
801 }
802#if (ITK_VERSION_MAJOR >= 5)
803 if ( imageIO->GetComponentType() == itk::IOComponentEnum::DOUBLE )
804#else
805 if ( imageIO->GetComponentType() == itk::ImageIOBase::DOUBLE )
806#endif
807 {
808 min = -std::numeric_limits<double>::max() < min ? -std::numeric_limits<double>::max() : min;
809 max = std::numeric_limits<double>::max() > max ? std::numeric_limits<double>::max() : max;
810 }
811 }
812 assert( min <= max );
813 if( min >= 0 ) // unsigned
814 {
815 if( max <= std::numeric_limits<uint8_t>::max() )
816 {
817 scalarType = VTK_UNSIGNED_CHAR;
818 }
819 else if( max <= std::numeric_limits<uint16_t>::max() )
820 {
821 scalarType = VTK_UNSIGNED_SHORT;
822 }
823 else if( max <= std::numeric_limits<uint32_t>::max() )
824 {
825 scalarType = VTK_UNSIGNED_INT;
826 }
827 else if( max <= std::numeric_limits<uint64_t>::max() )
828 {
829 scalarType = VTK_UNSIGNED_LONG;
830 }
831 else if( max <= std::numeric_limits<float>::max() )
832 {
833 scalarType = VTK_FLOAT;
834 }
835 else if( max <= std::numeric_limits<double>::max() )
836 {
837 scalarType = VTK_DOUBLE;
838 }
839 else
840 {
841 assert(0);
842 }
843 }
844 else
845 {
846 if( max <= std::numeric_limits<int8_t>::max()
847 && min >= std::numeric_limits<int8_t>::min() )
848 {
849 scalarType = VTK_CHAR;
850 }
851 else if( max <= std::numeric_limits<int16_t>::max()
852 && min >= std::numeric_limits<int16_t>::min() )
853 {
854 scalarType = VTK_SHORT;
855 }
856 else if( max <= std::numeric_limits<int32_t>::max()
857 && min >= std::numeric_limits<int32_t>::min() )
858 {
859 scalarType = VTK_INT;
860 }
861 else if( max <= std::numeric_limits<int64_t>::max()
862 && min >= std::numeric_limits<int64_t>::min() )
863 {
864 scalarType = VTK_LONG;
865 }
866 else if ( max <= std::numeric_limits<float>::max()
867 && min >= -std::numeric_limits<float>::max() )
868 {
869 scalarType = VTK_FLOAT;
870 }
871 else if( max <= std::numeric_limits<double>::max()
872 && min >= -std::numeric_limits<double>::max() )
873 {
874 scalarType = VTK_DOUBLE;
875 }
876 else
877 {
878 assert(0);
879 }
880 }
881 }
882 }
883
884 int numberOfComponents = 1;
885 if (imageIO.GetPointer() != NULL)
886 {
887 numberOfComponents = imageIO->GetNumberOfComponents();
888 }
889 this->SetNumberOfComponents(numberOfComponents);
890 this->SetOutputScalarType(scalarType);
891
892
893 vtkDataObject::SetPointDataActiveScalarInfo(outInfo,
894 scalarType, numberOfComponents);
895
896 // Copy the MetaDataDictionary from the ITK layer to the VTK layer
897 if (imageIO.GetPointer() != NULL)
898 {
899 this->Dictionary = imageIO->GetMetaDataDictionary();
900 }
901 else
902 {
903 this->Dictionary = itk::MetaDataDictionary();
904 }
906 return 1;
907}
virtual void SetNumberOfComponents(unsigned int)
Get number of scalars.
void GroupFiles(int idxSeriesInstanceUID, int idxContentTime, int idxTriggerTime, int idxEchoNumbers, int idxDiffusionGradientOrientation, int idxSliceLocation, int idxImageOrientationPatient)

Member Data Documentation

◆ Tags

std::vector<std::string> vtkvmtkITKArchetypeImageSeriesReader::Tags

Definition at line 264 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ TagValues

std::vector<std::string> vtkvmtkITKArchetypeImageSeriesReader::TagValues

Definition at line 265 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ Archetype

char* vtkvmtkITKArchetypeImageSeriesReader::Archetype
protected

Definition at line 805 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ SingleFile

int vtkvmtkITKArchetypeImageSeriesReader::SingleFile
protected

Definition at line 806 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ UseOrientationFromFile

int vtkvmtkITKArchetypeImageSeriesReader::UseOrientationFromFile
protected

Definition at line 807 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ DataExtent

int vtkvmtkITKArchetypeImageSeriesReader::DataExtent[6]
protected

Definition at line 808 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ OutputScalarType

int vtkvmtkITKArchetypeImageSeriesReader::OutputScalarType
protected

Definition at line 810 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ NumberOfComponents

unsigned int vtkvmtkITKArchetypeImageSeriesReader::NumberOfComponents
protected

Definition at line 811 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ DefaultDataSpacing

double vtkvmtkITKArchetypeImageSeriesReader::DefaultDataSpacing[3]
protected

Definition at line 813 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ DefaultDataOrigin

double vtkvmtkITKArchetypeImageSeriesReader::DefaultDataOrigin[3]
protected

Definition at line 814 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ ScanAxis

float vtkvmtkITKArchetypeImageSeriesReader::ScanAxis[3]
protected

Definition at line 815 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ ScanOrigin

float vtkvmtkITKArchetypeImageSeriesReader::ScanOrigin[3]
protected

Definition at line 816 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ FileNameSliceOffset

int vtkvmtkITKArchetypeImageSeriesReader::FileNameSliceOffset
protected

Definition at line 818 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ FileNameSliceSpacing

int vtkvmtkITKArchetypeImageSeriesReader::FileNameSliceSpacing
protected

Definition at line 819 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ FileNameSliceCount

int vtkvmtkITKArchetypeImageSeriesReader::FileNameSliceCount
protected

Definition at line 820 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ RasToIjkMatrix

vtkMatrix4x4* vtkvmtkITKArchetypeImageSeriesReader::RasToIjkMatrix
protected

Definition at line 822 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ MeasurementFrameMatrix

vtkMatrix4x4* vtkvmtkITKArchetypeImageSeriesReader::MeasurementFrameMatrix
protected

Definition at line 823 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ UseNativeCoordinateOrientation

char vtkvmtkITKArchetypeImageSeriesReader::UseNativeCoordinateOrientation
protected

Definition at line 825 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ UseNativeScalarType

char vtkvmtkITKArchetypeImageSeriesReader::UseNativeScalarType
protected

Definition at line 826 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ UseNativeOrigin

bool vtkvmtkITKArchetypeImageSeriesReader::UseNativeOrigin
protected

Definition at line 827 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ GroupingByTags

bool vtkvmtkITKArchetypeImageSeriesReader::GroupingByTags
protected

Definition at line 829 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ SelectedUID

int vtkvmtkITKArchetypeImageSeriesReader::SelectedUID
protected

Definition at line 830 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ SelectedContentTime

int vtkvmtkITKArchetypeImageSeriesReader::SelectedContentTime
protected

Definition at line 831 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ SelectedTriggerTime

int vtkvmtkITKArchetypeImageSeriesReader::SelectedTriggerTime
protected

Definition at line 832 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ SelectedEchoNumbers

int vtkvmtkITKArchetypeImageSeriesReader::SelectedEchoNumbers
protected

Definition at line 833 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ SelectedDiffusion

int vtkvmtkITKArchetypeImageSeriesReader::SelectedDiffusion
protected

Definition at line 834 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ SelectedSlice

int vtkvmtkITKArchetypeImageSeriesReader::SelectedSlice
protected

Definition at line 835 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ SelectedOrientation

int vtkvmtkITKArchetypeImageSeriesReader::SelectedOrientation
protected

Definition at line 836 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ IndexArchetype

unsigned int vtkvmtkITKArchetypeImageSeriesReader::IndexArchetype
protected

Definition at line 838 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ FileNames

std::vector<std::string> vtkvmtkITKArchetypeImageSeriesReader::FileNames
protected

Definition at line 840 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ FileNameSliceKey

std::vector<std::pair <double, int> > vtkvmtkITKArchetypeImageSeriesReader::FileNameSliceKey
protected

Definition at line 841 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ DesiredCoordinateOrientation

CoordinateOrientationCode vtkvmtkITKArchetypeImageSeriesReader::DesiredCoordinateOrientation
protected

Definition at line 842 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ Dictionary

itk::MetaDataDictionary vtkvmtkITKArchetypeImageSeriesReader::Dictionary
protected

Definition at line 845 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ AllFileNames

std::vector<std::string> vtkvmtkITKArchetypeImageSeriesReader::AllFileNames
protected

The following variables provide support for reading a directory with multiple series/groups. The current scheme is to check the following and see if multiple values exist:

SeriesInstanceUID 0020,000E ContentTime 0008,0033 TriggerTime 0018,1060 EchoNumbers 0018,0086 DiffusionGradientOrientation 0018,9089 SliceLocation 0020,1041 ImageOrientationPatient 0020,0037 ImagePositionPatient 0020,0032

Definition at line 861 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ AnalyzeHeader

bool vtkvmtkITKArchetypeImageSeriesReader::AnalyzeHeader
protected

Definition at line 862 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ IsOnlyFile

bool vtkvmtkITKArchetypeImageSeriesReader::IsOnlyFile
protected

Definition at line 863 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ SeriesInstanceUIDs

std::vector<std::string> vtkvmtkITKArchetypeImageSeriesReader::SeriesInstanceUIDs
protected

Definition at line 865 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ ContentTime

std::vector<std::string> vtkvmtkITKArchetypeImageSeriesReader::ContentTime
protected

Definition at line 866 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ TriggerTime

std::vector<std::string> vtkvmtkITKArchetypeImageSeriesReader::TriggerTime
protected

Definition at line 867 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ EchoNumbers

std::vector<std::string> vtkvmtkITKArchetypeImageSeriesReader::EchoNumbers
protected

Definition at line 868 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ DiffusionGradientOrientation

std::vector< std::vector<float> > vtkvmtkITKArchetypeImageSeriesReader::DiffusionGradientOrientation
protected

Definition at line 869 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ SliceLocation

std::vector<float> vtkvmtkITKArchetypeImageSeriesReader::SliceLocation
protected

Definition at line 870 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ ImageOrientationPatient

std::vector< std::vector<float> > vtkvmtkITKArchetypeImageSeriesReader::ImageOrientationPatient
protected

Definition at line 871 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ ImagePositionPatient

std::vector< std::vector<float> > vtkvmtkITKArchetypeImageSeriesReader::ImagePositionPatient
protected

Definition at line 872 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ IndexSeriesInstanceUIDs

std::vector<long int> vtkvmtkITKArchetypeImageSeriesReader::IndexSeriesInstanceUIDs
protected

index of each dicom file into the above arrays

Definition at line 875 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ IndexContentTime

std::vector<long int> vtkvmtkITKArchetypeImageSeriesReader::IndexContentTime
protected

Definition at line 876 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ IndexTriggerTime

std::vector<long int> vtkvmtkITKArchetypeImageSeriesReader::IndexTriggerTime
protected

Definition at line 877 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ IndexEchoNumbers

std::vector<long int> vtkvmtkITKArchetypeImageSeriesReader::IndexEchoNumbers
protected

Definition at line 878 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ IndexDiffusionGradientOrientation

std::vector<long int> vtkvmtkITKArchetypeImageSeriesReader::IndexDiffusionGradientOrientation
protected

Definition at line 879 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ IndexSliceLocation

std::vector<long int> vtkvmtkITKArchetypeImageSeriesReader::IndexSliceLocation
protected

Definition at line 880 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ IndexImageOrientationPatient

std::vector<long int> vtkvmtkITKArchetypeImageSeriesReader::IndexImageOrientationPatient
protected

Definition at line 881 of file vtkvmtkITKArchetypeImageSeriesReader.h.

◆ IndexImagePositionPatient

std::vector<long int> vtkvmtkITKArchetypeImageSeriesReader::IndexImagePositionPatient
protected

Definition at line 882 of file vtkvmtkITKArchetypeImageSeriesReader.h.


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