ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00025 #ifndef __itkNiftiImageIO_h 00026 #define __itkNiftiImageIO_h 00027 00028 00029 #include <fstream> 00030 #include "itkImageIOBase.h" 00031 #include <nifti1_io.h> 00032 00033 namespace itk 00034 { 00044 class ITK_EXPORT NiftiImageIO:public ImageIOBase 00045 { 00046 public: 00048 typedef NiftiImageIO Self; 00049 typedef ImageIOBase Superclass; 00050 typedef SmartPointer< Self > Pointer; 00051 00053 itkNewMacro(Self); 00054 00056 itkTypeMacro(NiftiImageIO, Superclass); 00057 00058 /*-------- This part of the interfaces deals with reading data. ----- */ 00059 00066 virtual bool CanReadFile(const char *FileNameToRead); 00067 00069 virtual void ReadImageInformation(); 00070 00072 virtual void Read(void *buffer); 00073 00074 /*-------- This part of the interfaces deals with writing data. ----- */ 00075 00082 virtual bool CanWriteFile(const char *FileNameToWrite); 00083 00085 virtual void WriteImageInformation(); 00086 00089 virtual void Write(const void *buffer); 00090 00093 virtual ImageIORegion 00094 GenerateStreamableReadRegionFromRequestedRegion(const ImageIORegion & requestedRegion) const; 00095 00101 itkSetMacro(LegacyAnalyze75Mode, bool); 00102 itkGetConstMacro(LegacyAnalyze75Mode, bool); 00103 protected: 00104 NiftiImageIO(); 00105 ~NiftiImageIO(); 00106 void PrintSelf(std::ostream & os, Indent indent) const; 00108 00109 virtual bool GetUseLegacyModeForTwoFileWriting(void) const { return false; } 00110 private: 00111 bool MustRescale(); 00112 00113 void DefineHeaderObjectDataType(); 00114 00115 void SetNIfTIOrientationFromImageIO(unsigned short int origdims, unsigned short int dims); 00116 00117 void SetImageIOOrientationFromNIfTI(unsigned short int dims); 00118 00119 void SetImageIOMetadataFromNIfTI(); 00120 00121 nifti_image *m_NiftiImage; 00122 00123 double m_RescaleSlope; 00124 double m_RescaleIntercept; 00125 00126 IOComponentType m_OnDiskComponentType; 00127 00128 bool m_LegacyAnalyze75Mode; 00129 00130 NiftiImageIO(const Self &); //purposely not implemented 00131 void operator=(const Self &); //purposely not implemented 00132 }; 00133 } // end namespace itk 00134 00135 #endif // __itkNiftiImageIO_h 00136