43 #ifndef SVK_DCM_HEADER_H
44 #define SVK_DCM_HEADER_H
47 #include <vtkObjectFactory.h>
48 #include <vtkObject.h>
102 UNKNOWN_ORIENTATION = -1,
109 SLICE_ORDER_UNDEFINED = -1,
110 INCREMENT_ALONG_POS_NORMAL = 0,
111 INCREMENT_ALONG_NEG_NORMAL = 1
112 } DcmDataOrderingDirection;
129 } DimensionIndexLabel;
137 #ifdef SVK_ADAPT_DCMTK
138 static const int adapter_type = DCMTK_API;
148 virtual void CreateIOD(
DcmIodType iodType) = 0;
149 virtual void SetSOPClassUID(
DcmIodType iodType) = 0;
150 virtual void PrintDcmHeader() = 0;
151 virtual void PrintDcmHeader(ostream& os) = 0;
157 virtual void InsertEmptyElement(
const char* name) = 0;
164 virtual void InsertUniqueUID(
const char* name) = 0;
169 virtual string GenerateUniqueUID() = 0;
175 virtual void SetValue(
const char *name,
int value) = 0;
181 virtual void SetValue(
const char *name,
float value) = 0;
187 virtual void SetValue(
const char *name,
double value) = 0;
194 virtual void SetValue(
const char *name,
string value,
bool setMetaInfo =
false) = 0;
205 virtual void SetValue(
const char* name,
unsigned char* values,
int numValues) = 0;
216 virtual void SetValue(
const char* name,
unsigned short* values,
int numValues) = 0;
227 virtual void SetValue(
const char* name,
signed short* values,
int numValues) = 0;
238 virtual void SetValue(
const char* name,
float* values,
int numValues) = 0;
243 virtual void ModifyValueRecursive(
const char* name,
string value) = 0;
249 virtual void GetByteValue(
const char* name,
char* values,
long unsigned int numValues) = 0;
255 virtual void GetShortValue(
const char* name,
short* values,
long unsigned int numValues) = 0;
261 virtual unsigned short GetShortValue(
const char* name,
long unsigned int position) = 0;
267 virtual unsigned short GetPixelValue(
long unsigned int position) = 0;
273 virtual int GetIntValue(
const char *name) = 0;
279 virtual float GetFloatValue(
const char *name) = 0;
285 virtual void GetFloatValue(
const char* name,
float* values,
long unsigned int numValues) = 0;
292 virtual double GetDoubleValue(
const char *name) = 0;
298 virtual string GetStringValue(
const char *name) = 0;
304 virtual string GetStringValue(
const char *name,
int pos) = 0;
310 virtual void AddSequenceItemElement(
311 const char* parentSeqName,
312 int parentSeqItemPosition,
313 const char* elementName
321 virtual void AddSequenceItemElement(
324 const char* elementName,
326 const char* parentSeqName = NULL,
327 int parentSeqItemPosition = 0
336 virtual void AddSequenceItemElement(
339 const char* elementName,
342 const char* parentSeqName = NULL,
343 int parentSeqItemPosition = 0
352 virtual void AddSequenceItemElement(
355 const char* elementName,
356 unsigned short* values,
358 const char* parentSeqName = NULL,
359 int parentSeqItemPosition = 0
367 virtual void AddSequenceItemElement(
370 const char* elementName,
371 unsigned int* values,
373 const char* parentSeqName = NULL,
374 int parentSeqItemPosition = 0
382 virtual void AddSequenceItemElement(
385 const char* elementName,
387 unsigned long int numValues,
388 const char* parentSeqName = NULL,
389 int parentSeqItemPosition = 0
397 virtual void AddSequenceItemElement(
400 const char* elementName,
402 const char* parentSeqName = NULL,
403 int parentSeqItemPosition = 0
411 virtual void AddSequenceItemElement(
414 const char* elementName,
416 const char* parentSeqName = NULL,
417 int parentSeqItemPosition = 0
425 virtual void AddSequenceItemElement(
428 const char* elementName,
430 const char* parentSeqName = NULL,
431 int parentSeqItemPosition = 0
439 virtual void AddSequenceItemElement(
442 const char* elementName,
444 const char* parentSeqName = NULL,
445 int parentSeqItemPosition = 0
453 virtual void CopySequence(
svkDcmHeader* target,
const char* seqName ) = 0;
459 virtual void ClearSequence(
const char* parentSeqName ) = 0;
465 virtual void ClearElement(
const char* elementName ) = 0;
470 virtual void RemoveElement(
const char* elementName ) = 0;
482 virtual int GetIntSequenceItemElement(
485 const char* elementName,
486 const char* parentSeqName = NULL,
487 int parentSeqItemPosition = 0,
501 virtual long int GetLongIntSequenceItemElement(
504 const char* elementName,
505 const char* parentSeqName = NULL,
506 int parentSeqItemPosition = 0,
514 virtual float GetFloatSequenceItemElement(
517 const char* elementName,
518 const char* parentSeqName = NULL,
519 int parentSeqItemPosition = 0,
528 virtual void GetFloatSequenceItemElement(
531 const char* elementName,
534 const char* parentSeqName = NULL,
535 int parentSeqItemPosition = 0
543 virtual double GetDoubleSequenceItemElement(
546 const char* elementName,
547 const char* parentSeqName = NULL,
548 int parentSeqItemPosition = 0
556 virtual string GetStringSequenceItemElement(
559 const char* elementName,
560 const char* parentSeqName = NULL,
561 int parentSeqItemPosition = 0
569 virtual string GetStringSequenceItemElement(
572 const char* elementName,
574 const char* parentSeqName = NULL,
575 int parentSeqItemPosition = 0
582 virtual int GetNumberOfElements(
const char* elementName ) = 0;
588 virtual int GetNumberOfItemsInSequence(
const char* seqName ) = 0;
594 virtual int GetNumberOfItemsInSequence(
596 const char* parentSeqName,
597 int parentSeqItemPosition
605 virtual void WriteDcmFile(
string fileName) = 0;
614 virtual void WriteDcmFileCompressed(
string fileName) = 0;
624 virtual int ReadDcmFile(
string fileName,
unsigned int max_length = 0) = 0;
633 virtual int ReadDcmFileHeaderOnly(
string fileName) = 0;
642 virtual int GetOriginalXFerSyntax() = 0;
651 virtual void CopyDcmHeader(
svkDcmHeader* headerCopy) = 0;
662 void MakeDerivedDcmHeader(
svkDcmHeader* headerCopy,
string seriesDescription);
667 void MakeDerivedDcmHeader(
string seriesDescription =
"");
673 virtual bool ElementExists(
const char* elementName,
const char* parentSeqName = NULL) = 0;
679 virtual void ReplaceOldElements(
bool replaceElements ) = 0;
682 string GetDcmPatientName(
string PatientName );
683 void SetDcmPatientName(
string PatientName );
687 int GetOrigin(
double origin[3],
int frameNumber = 0 );
688 void GetPixelSpacing(
double spacing[3]);
689 void GetPixelSize(
double size[3]);
690 void GetOrientation(
double orientation[2][3]);
693 void GetNormalVector(
double normal[3]);
699 int GetNumberOfCoils();
700 int GetNumberOfSlices();
701 static int GetNumberOfDimensionIndices(
int numTimePts,
int numCoils);
702 static void SetDimensionIndices(
703 unsigned int* indexValues,
711 int GetNumberOfTimePoints();
712 int GetSliceForFrame(
int frame );
713 void UpdateNumTimePoints();
714 void UpdateNumCoils();
716 int GetDimensionIndexPosition(
string indexLabel);
717 string GetDimensionIndexLabel(
int dimensionIndexNumber );
721 void SetDimensionIndexSize(
723 virtual int GetSequenceItemElementLength(
726 const char* elementName,
727 const char* parentSeqName,
728 int parentSeqItemPosition) = 0;
732 static void SwapDimensionIndexLabels(
739 StringToDimensionIndexLabel(
string dimensionIndexLabelString );
742 GetDimensionLabelFromIndex(
767 int GetNumberOfFramesInDimension(
int dimensionIndex );
770 static long int GetPixelDataOffset(
string fileName );
771 static short GetPixelValueAsShort(
772 long int offsetToPixelData,
780 void InitPatientModule(
783 string PatientBirthDate,
787 void InitGeneralStudyModule(
790 string referringPhysiciansName,
792 string accessionNumber,
793 string studyInstanceUID
795 void InitGeneralSeriesModule(
797 string seriesDescription,
798 string patientPosition
801 void InitImagePlaneModule(
802 string imagePositionPatient,
803 string pixelSpacing =
"",
804 string imageOrientationPatient =
"",
805 string sliceThickness =
""
807 void InitMRImageModule(
string repetitionTime,
string echoTime);
808 void InitPlaneOrientationMacro(
double dcos[3][3] );
809 void InitPlaneOrientationMacro(
string orientationString );
810 void InitPixelMeasuresMacro(
string pixelSizes,
string sliceThickness );
812 void InitPerFrameFunctionalGroupSequence(
814 double voxelSpacing[3],
819 void InitVOILUTModule(
float center,
float width);
820 void InitPixelValueTransformationMacro(
double slope = 1.00000,
double intercept = 0.00000);
821 void InitMRImagingModifierMacro(
823 float pixelBandwidth,
824 string magTransfer =
"NONE",
825 string bloodNulling =
"NO"
827 void InitVolumeLocalizationSeq(
float size[3],
float center[3],
float dcos[3][3]);
828 void InitMRTimingAndRelatedParametersMacro(
float tr = UNKNOWN_TIME,
float flipAngle= -999,
int numEchoes = 1);
829 void InitMREchoMacro(
float TE = UNKNOWN_TIME );
830 void InitMRModifierMacro(
float inversionTime = UNKNOWN_TIME);
831 void InitMRTransmitCoilMacro(
832 string coilMfg =
"UNKNOWN",
833 string coilName =
"UNKNOWN",
834 string coilType =
"UNKNOWN"
836 void InitMRAveragesMacro(
int numAverages = 1);
837 void InitRawDataModule(
843 int InitDerivedMRIHeader(
svkDcmHeader* mri, vtkIdType dataType,
string seriesDescription);
844 int ConvertEnhancedMriToMriHeader(
svkDcmHeader* mri, vtkIdType dataType );
845 virtual string GetDcmNameFromTag(
string groupElementString ) = 0;
852 void Deidentify(
PHIType phiType );
853 void Deidentify(
PHIType phiType,
string id );
854 void Deidentify(
PHIType phyType,
string patientId,
string studyId );
856 static bool IsFileDICOM(
string fname);
862 static void GetCenterFromOrigin(
865 double voxelSpacing[3],
869 static void GetCenterFromOrigin(
svkDcmHeader* hdr,
double center[3] );
870 static void GetOriginFromCenter(
873 double voxelSpacing[3],
877 static void GetSpatialDimensions(
894 double pixelSpacing[3];
896 double orientation[2][3];
899 unsigned long lastUpdateTime;
903 void UpdateSpatialParams();
904 void UpdateOrientation();
905 void UpdatePixelSpacing();
906 void UpdatePixelSize();
907 void UpdateOrigin0();
908 void UpdateDimensionIndexVector();
909 void InitPlanePositionMacro(
910 double toplc[3],
double voxelSpacing[3],
915 int GetNumberOfFrames();
916 void InsertDimensionIndexLabels( );
917 void GetDimensionIndexPointer(
919 unsigned short* dimensionIndexPointer,
920 unsigned short* functionalGroupPointer
930 #endif //SVK_DCM_HEADER_H