ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkNiftiImageIO.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
25 #ifndef __itkNiftiImageIO_h
26 #define __itkNiftiImageIO_h
27 
28 
29 #include <fstream>
30 #include "itkImageIOBase.h"
31 #include <nifti1_io.h>
32 
33 namespace itk
34 {
44 class ITK_EXPORT NiftiImageIO:public ImageIOBase
45 {
46 public:
48  typedef NiftiImageIO Self;
51 
53  itkNewMacro(Self);
54 
56  itkTypeMacro(NiftiImageIO, Superclass);
57 
58  /*-------- This part of the interfaces deals with reading data. ----- */
59 
66  virtual bool CanReadFile(const char *FileNameToRead);
67 
69  virtual void ReadImageInformation();
70 
72  virtual void Read(void *buffer);
73 
74  /*-------- This part of the interfaces deals with writing data. ----- */
75 
82  virtual bool CanWriteFile(const char *FileNameToWrite);
83 
85  virtual void WriteImageInformation();
86 
89  virtual void Write(const void *buffer);
90 
93  virtual ImageIORegion
94  GenerateStreamableReadRegionFromRequestedRegion(const ImageIORegion & requestedRegion) const;
95 
101  itkSetMacro(LegacyAnalyze75Mode, bool);
102  itkGetConstMacro(LegacyAnalyze75Mode, bool);
103 protected:
104  NiftiImageIO();
105  ~NiftiImageIO();
106  void PrintSelf(std::ostream & os, Indent indent) const;
108 
109  virtual bool GetUseLegacyModeForTwoFileWriting(void) const { return false; }
110 private:
111  bool MustRescale();
112 
113  void DefineHeaderObjectDataType();
114 
115  void SetNIfTIOrientationFromImageIO(unsigned short int origdims, unsigned short int dims);
116 
117  void SetImageIOOrientationFromNIfTI(unsigned short int dims);
118 
119  void SetImageIOMetadataFromNIfTI();
120 
121  nifti_image *m_NiftiImage;
122 
125 
127 
129 
130  NiftiImageIO(const Self &); //purposely not implemented
131  void operator=(const Self &); //purposely not implemented
132 };
133 } // end namespace itk
134 
135 #endif // __itkNiftiImageIO_h
136