ITK  4.3.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);
104 
105 protected:
106  NiftiImageIO();
107  ~NiftiImageIO();
108  void PrintSelf(std::ostream & os, Indent indent) const;
109 
110  virtual bool GetUseLegacyModeForTwoFileWriting(void) const { return false; }
111 
112 private:
113  bool MustRescale();
114 
115  void DefineHeaderObjectDataType();
116 
117  void SetNIfTIOrientationFromImageIO(unsigned short int origdims, unsigned short int dims);
118 
119  void SetImageIOOrientationFromNIfTI(unsigned short int dims);
120 
121  void SetImageIOMetadataFromNIfTI();
122 
123  nifti_image *m_NiftiImage;
124 
127 
129 
131 
132  NiftiImageIO(const Self &); //purposely not implemented
133  void operator=(const Self &); //purposely not implemented
134 };
135 } // end namespace itk
136 
137 #endif // __itkNiftiImageIO_h
138