ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkMINC2ImageIO.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 __itkMINC2ImageIO_h
26 #define __itkMINC2ImageIO_h
27 
28 
29 #include "itkImageIOBase.h"
30 
31 #include "itkMatrix.h"
32 
33 extern "C" {
34 #include <minc2.h>
35 }
36 
37 namespace itk
38 {
61 class ITK_EXPORT MINC2ImageIO:public ImageIOBase
62 {
63 public:
65  typedef MINC2ImageIO Self;
69 
71  itkNewMacro(Self);
72 
74  itkTypeMacro(MINC2ImageIO, ImageIOBase);
75 
76  /*-------- This part of the interface deals with reading data. ------ */
77 
80  virtual bool CanReadFile(const char *);
81 
83  virtual void ReadImageInformation();
84 
86  virtual void Read(void *buffer);
87 
88  /*-------- This part of the interfaces deals with writing data. ----- */
89 
92  virtual bool CanWriteFile(const char *);
93 
96  virtual void WriteImageInformation();
97 
100  virtual void Write(const void *buffer);
101 
102  char * GetDimensionOrder() { return m_DimensionOrder; }
103  void SetDimensionOrder(char *dimorder) { m_DimensionOrder = dimorder; }
104 
105  void XYZFromDirectionCosines(midimhandle_t *hdims, int *dim_indices, unsigned int *number_of_components);
106 
107 protected:
108  MINC2ImageIO();
109  ~MINC2ImageIO();
110  void PrintSelf(std::ostream & os, Indent indent) const;
111 
112  void WriteSlice(std::string & fileName, const void *buffer);
113 
114  // Num. dimensions in base class (c.f. GetNumberOfDimensions); why keep a
115  // second copy here?
116  unsigned int m_NDims;
117 
119  virtual void SetDimensionName(unsigned int i, char *name);
120 
121  virtual char * GetDimensionName(unsigned int i){ return m_DimensionName[i]; }
122 
124 
125  // shift and scale parameter (god help me with slice scaling!!)
126  double m_Shift;
127  double m_Scale;
128 
129  // dimension size and start and step
130  unsigned int *m_DimensionSize;
133 
135 
137 
138  // Description:
139  // Check the DimensionOrder and adjust according to what
140  // dimensions the user has actually specified via
141  // SetDimensionOrder()
142  int CheckDimensionOrder(char *userdimorder);
143 
144  double m_OriginalStart[3];
145  // complex type images, composed of complex numbers
147 private:
148  MINC2ImageIO(const Self &); //purposely not implemented
149  void operator=(const Self &); //purposely not implemented
150 
151  // Description
152  // Get slice scaling from local slice scaling
153  void SetSliceScalingFromLocalScaling(mihandle_t volume);
154 
155  // Description
156  // Get slice scaling from global slice scaling
157  void SetSliceScalingFromGlobalScaling(mihandle_t volume);
158 };
159 } // end namespace itk
160 
161 #endif // __itkMINC2ImageIO_h
162