00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00025 #ifndef __itkMINC2ImageIO_h
00026 #define __itkMINC2ImageIO_h
00027
00028 #ifdef _MSC_VER
00029 #pragma warning ( disable : 4786 )
00030 #endif
00031
00032 #include "itkImageIOBase.h"
00033
00034 #include "itkMatrix.h"
00035
00036 extern "C" {
00037 #include <netcdf.h>
00038 #include <hdf5.h>
00039 #include <minc2.h>
00040
00041 }
00042 namespace itk
00043 {
00044
00059 class ITK_EXPORT MINC2ImageIO : public ImageIOBase
00060 {
00061 public:
00063 typedef MINC2ImageIO Self;
00064 typedef ImageIOBase Superclass;
00065 typedef SmartPointer<Self> Pointer;
00066 typedef Matrix<float,3,3> MatrixType;
00067
00069 itkNewMacro(Self);
00070
00072 itkTypeMacro(MINC2ImageIO, ImageIOBase);
00073
00074
00075
00078 virtual bool CanReadFile(const char*);
00079
00081 virtual void ReadImageInformation();
00082
00084 virtual void Read(void* buffer);
00085
00087 virtual void ReadVolume(void* buffer);
00088
00089
00090
00093 virtual bool CanWriteFile(const char*);
00094
00097 virtual void WriteImageInformation();
00098
00101 virtual void Write(const void* buffer);
00102
00103 char *GetDimensionOrder() { return m_DimensionOrder; }
00104 void SetDimensionOrder(char *dimorder) { m_DimensionOrder = dimorder; }
00105
00106 void XYZFromDirectionCosines(midimhandle_t *hdims, int *dim_indices, int *number_of_components);
00107
00108 protected:
00109 MINC2ImageIO();
00110 ~MINC2ImageIO();
00111 void PrintSelf(std::ostream& os, Indent indent) const;
00112
00113 void WriteSlice(std::string& fileName, const void* buffer);
00114
00115 int m_NDims;
00116
00117 char **m_DimensionName;
00118 virtual void SetDimensionName(unsigned int i, char *name);
00119 virtual char * GetDimensionName(unsigned int i){ return m_DimensionName[i]; }
00120
00121 char *m_DimensionOrder;
00122
00123
00124 double m_Shift;
00125 double m_Scale;
00126
00127
00128 int * m_DimensionSize;
00129 double * m_DimensionStart;
00130 double * m_DimensionStep;
00131 MatrixType m_DirectionCosines;
00132
00133 int * m_DimensionIndices;
00134
00135
00136
00137
00138
00139 int CheckDimensionOrder(char *userdimorder);
00140
00141 double m_OriginalStart[3];
00142
00143 int m_Complex;
00144 private:
00145 MINC2ImageIO(const Self&);
00146 void operator=(const Self&);
00147
00148
00149 void SetSliceScalingFromLocalScaling(mihandle_t volume);
00150
00151
00152
00153 void SetSliceScalingFromGlobalScaling(mihandle_t volume);
00154
00155 };
00156
00157 }
00158
00159 #endif // __itkMINC2ImageIO_h
00160