/usr/include/IGSTK/igstkDICOMImageReader.h is in libigstk4-dev 4.4.0-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | /*=========================================================================
Program: Image Guided Surgery Software Toolkit
Module: $RCSfile: igstkDICOMImageReader.h,v $
Language: C++
Date: $Date: 2009-06-15 19:54:58 $
Version: $Revision: 1.18 $
Copyright (c) ISC Insight Software Consortium. All rights reserved.
See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __igstkDICOMImageReader_h
#define __igstkDICOMImageReader_h
#include "igstkImageReader.h"
#include "igstkEvents.h"
#include "itkImageSeriesReader.h"
#include "itkEventObject.h"
#include "itkGDCMImageIO.h"
#include "itkGDCMSeriesFileNames.h"
namespace igstk
{
#define igstkUnsafeGetMacro(name,type) \
virtual const type & Get##name () const \
{ \
igstkLogMacro( CRITICAL, \
"igstk::DICOMImageReader::Get" #name " unsafe method called...\n"); \
return this->m_##name; \
}
igstkEventMacro( DICOMModalityEvent, StringEvent);
igstkEventMacro( DICOMPatientNameEvent, StringEvent);
igstkEventMacro( DICOMImageReaderEvent, StringEvent);
// Invalid request error event
igstkEventMacro( DICOMImageReaderErrorEvent, IGSTKErrorWithStringEvent );
igstkEventMacro( DICOMInvalidRequestErrorEvent,
DICOMImageReaderErrorEvent );
// Events to handle errors with the ImageDirectory name
igstkEventMacro(DICOMImageDirectoryEmptyErrorEvent,
DICOMImageReaderErrorEvent );
igstkEventMacro(DICOMImageDirectoryDoesNotExistErrorEvent,
DICOMImageReaderErrorEvent );
igstkEventMacro(DICOMImageDirectoryIsNotDirectoryErrorEvent,
DICOMImageReaderErrorEvent );
igstkEventMacro(DICOMImageDirectoryDoesNotHaveEnoughFilesErrorEvent,
DICOMImageReaderErrorEvent );
// Image series filename generation error event
igstkEventMacro(DICOMImageSeriesFileNamesGeneratingErrorEvent,
DICOMImageReaderErrorEvent );
//Image reading error
igstkEventMacro(DICOMImageReadingErrorEvent,
DICOMImageReaderErrorEvent );
/** \class DICOMImageReader
*
* \brief This class reads DICOM files.
*
* This class should not be instantiated directly, instead the derived
* classes that are specific to particular image modalities should be used.
*
* \image html igstkDICOMImageReader.png
* "DICOM Image Reader State Machine Diagram"
*
* \image latex igstkDICOMImageReader.eps
* "DICOM Image Reader State Machine Diagram"
* \ingroup Readers
*/
template <class TImageSpatialObject>
class DICOMImageReader : public ImageReader< TImageSpatialObject >
{
public:
/** Macro with standard traits declarations. */
igstkStandardTemplatedAbstractClassTraitsMacro( DICOMImageReader, \
ImageReader< TImageSpatialObject> )
public:
/** Type for representing the string of the directory
* from which the DICOM files will be read. */
typedef std::string DirectoryNameType;
/** Method to pass the directory name containing the DICOM image data */
void RequestSetDirectory( const DirectoryNameType & directory );
void RequestSetProgressCallback(itk::Command *progressCallback)
{
m_ImageSeriesReader->AddObserver(itk::ProgressEvent(),progressCallback);
}
void RequestSetAbortCallback(itk::Command *abortCallback)
{
m_ImageSeriesReader->AddObserver(itk::AbortEvent(),abortCallback);
}
/** This method request image read */
void RequestReadImage();
/** This function should be used to request modality info */
void RequestGetModalityInformation();
/** This function will be used to request patient name info */
void RequestGetPatientNameInformation();
/** Type used for returning string values from the DICOM header */
typedef std::string DICOMInformationType;
/** Precondition that should be invoked and verified before attempting to
* use the values of the methods GetPatientName(), GetPatientID() and
* GetModality().
*/
bool FileSuccessfullyRead() const { return m_FileSuccessfullyRead; }
/** Unsafe Get Macro for having access to the Patient Name. This method is
* considered unsafe because it is not subject to the control of the internal
* state machine. The method GetPatientName() should only be invoked if the
* precondition method FileSuccessfullyRead() has already been called and it
* has returned true. Calling GetPatientName() in any other situation will
* lead to unpredictable behavior. */
igstkUnsafeGetMacro( PatientName, DICOMInformationType );
/** Unsafe Get Macro for having access to the Patient unique Identifier.
* This method is considered unsafe because it is not subject to the control
* of the internal state machine. The method GetPatientID() should only be
* invoked if the precondition method FileSuccessfullyRead() has already been
* called and it has returned true. Calling GetPatientID() in any other
* situation will lead to unpredictable behavior. */
igstkUnsafeGetMacro( PatientID, DICOMInformationType );
/** Unsafe Get Macro for having access to the image Modality. This method is
* considered unsafe because it is not subject to the control of the internal
* state machine. The method GetModality() should only be invoked if the
* precondition method FileSuccessfullyRead() has already been called and it
* has returned true. Calling GetModality() in any other situation will lead
* to unpredictable behavior. */
igstkUnsafeGetMacro( Modality, DICOMInformationType );
/** Request to get the output image as an event */
void RequestGetImage();
/** Event type */
igstkLoadedTemplatedObjectEventMacro( ImageModifiedEvent, IGSTKEvent,
TImageSpatialObject);
/** Declarations needed for the Logger */
igstkLoggerMacro();
protected:
DICOMImageReader( void );
~DICOMImageReader( void );
/** Helper classes for the image series reader */
itk::GDCMSeriesFileNames::Pointer m_FileNames;
itk::GDCMImageIO::Pointer m_ImageIO;
typedef typename Superclass::ImageType ImageType;
typedef itk::ImageSeriesReader< ImageType > ImageSeriesReaderType;
typedef itk::ImageFileReader< ImageType > ImageReaderType;
/** Internal itkImageSeriesReader */
typename ImageSeriesReaderType::Pointer m_ImageSeriesReader;
typename ImageReaderType::Pointer m_ImageFileReader;
/** Print the object information in a stream. */
void PrintSelf( std::ostream& os, itk::Indent indent ) const;
/** This method MUST be protected n order to prevent
* unsafe access to the ITK image level */
virtual const ImageType * GetITKImage() const;
private:
/** These two methods must be declared and note be implemented
* in order to enforce the protocol of smart pointers. */
DICOMImageReader(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
DirectoryNameType m_ImageDirectoryName;
DirectoryNameType m_ImageDirectoryNameToBeSet;
/** List of States */
igstkDeclareStateMacro( Idle );
igstkDeclareStateMacro( ImageDirectoryNameRead );
igstkDeclareStateMacro( AttemptingToReadImage );
igstkDeclareStateMacro( ImageSeriesFileNamesGenerated );
igstkDeclareStateMacro( ImageRead );
/** List of State Inputs */
igstkDeclareInputMacro( ReadImage );
igstkDeclareInputMacro( ImageDirectoryNameValid );
igstkDeclareInputMacro( ImageReadingSuccess );
igstkDeclareInputMacro( ImageSeriesFileNamesGeneratingSuccess );
igstkDeclareInputMacro( ResetReader );
igstkDeclareInputMacro( GetImage );
/** Error related state inputs */
igstkDeclareInputMacro( ImageReadingError );
igstkDeclareInputMacro( ImageDirectoryNameIsEmpty );
igstkDeclareInputMacro( ImageDirectoryNameDoesNotExist );
igstkDeclareInputMacro( ImageDirectoryNameIsNotDirectory );
igstkDeclareInputMacro( ImageDirectoryNameDoesNotHaveEnoughFiles );
igstkDeclareInputMacro( ImageSeriesFileNamesGeneratingError );
/** Check modality type
* This method is implemented in the derived classes to
* check if the dicom data is read by the correct
* Dicom image reader. For example, CT DICOM image
* should be read by CT image reader not by MRI image reader */
virtual bool CheckModalityType( DICOMInformationType modality );
/** DICOM tags request inputs */
igstkDeclareInputMacro( GetModalityInformation );
igstkDeclareInputMacro( GetPatientNameInformation );
/** Set the name of the directory. To be invoked ONLY by the StateMachine */
void SetDirectoryNameProcessing();
/** Invokes a FileNameGenerator in order to get the names of all the DICOM
* files in a directory. To be invoked ONLY by the StateMachine */
void ReadDirectoryFileNamesProcessing();
/** This method request image read. To be invoked ONLY by the StateMachine. */
void AttemptReadImageProcessing();
/** The "ReportInvalidRequest" method throws InvalidRequestErrorEvent
when invalid requests are made */
void ReportInvalidRequestProcessing();
/** This function reports an when the image directory is empty */
void ReportImageDirectoryEmptyErrorProcessing();
/** This function reports an error when image directory is non-existing */
void ReportImageDirectoryDoesNotExistErrorProcessing();
/** This function reports an error if the image directory doesn't have enough
* files */
void ReportImageDirectoryDoesNotHaveEnoughFilesErrorProcessing();
/** This function reports an error in dicom image series file name
* generation */
void ReportImageSeriesFileNamesGeneratingErrorProcessing();
/** This function reports success in dicom image series file name
* generation */
void ReportImageSeriesFileNamesGeneratingSuccessProcessing();
/** This function reports an error while image reading */
void ReportImageReadingErrorProcessing();
/** This function reports success in image reading */
void ReportImageReadingSuccessProcessing();
/** This function reports the image */
void ReportImageProcessing();
/** This function resets the reader */
void ResetReaderProcessing();
/** This function reports an error when the image directory name
* provided is not a directory containing DICOM series */
void ReportImageDirectoryIsNotDirectoryErrorProcessing();
/** This function throws a string loaded event. The string is loaded
* with DICOM modality */
void GetModalityInformationProcessing();
/** This function throws a string loaded event. The string is loaded
* with patient name */
void GetPatientNameInformationProcessing();
/** Flag that indicates whether the file has been read successfully */
bool m_FileSuccessfullyRead;
/** Internal variables for holding patient and image specific information. */
DICOMInformationType m_PatientID;
DICOMInformationType m_PatientName;
DICOMInformationType m_Modality;
DICOMInformationType m_GantryTilt;
/** Variable to hold image reading error information */
std::string m_ImageReadingErrorInformation;
};
} // end namespace igstk
#ifndef IGSTK_MANUAL_INSTANTIATION
#include "igstkDICOMImageReader.txx"
#endif
#endif // __igstkDICOMImageReader_h
|