ITK  4.3.0
Insight Segmentation and Registration Toolkit
itkNeuralNetworkFileWriter.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  *=========================================================================*/
18 #ifndef __itkNeuralNetworkFileWriter_h
19 #define __itkNeuralNetworkFileWriter_h
20 
21 #include <metaTypes.h>
22 #include <metaUtils.h>
23 #include <typeinfo>
24 
27 
29 
30 
32 
33 namespace itk
34 {
54 template< class TNetwork >
56 {
57 public:
58 
61  typedef Object Superclass;
64 
66  itkTypeMacro(NeuralNetworkFileWriter, Object);
67 
69  itkNewMacro(Self);
70 
71  typedef typename TNetwork::MeasurementVectorType MeasurementVectorType;
72  typedef typename TNetwork::TargetVectorType TargetVectorType;
73 
77 
78 // typedef typename TNetwork::Pointer NetworkPointer;
79 // typedef typename TNetwork::ConstPointer
80 // NetworkConstPointer;
81 
82 // typedef typename TNetwork::LayerType LayerType;
83 // typedef typename LayerType::Pointer LayerPointer;
84 // typedef typename LayerType::ConstPointer LayerConstPointer;
85 // typedef typename LayerType::TransferFunctionType::Pointer
86 // TransferFunctionPointer;
87 // typedef typename LayerType::TransferFunctionType::ConstPointer
88 // TransferFunctionConstPointer;
89 
90 // typedef typename LayerType::InputFunctionType::Pointer
91 // InputFunctionPointer;
92 // typedef typename LayerType::InputFunctionType::ConstPointer
93 // InputFunctionConstPointer;
94 
95 // typedef typename LayerType::WeightSetType WeightSetType;
96 // typedef typename LayerType::WeightSetPointer WeightSetPointer;
97 // typedef typename LayerType::WeightSetConstPointer
98 // WeightSetConstPointer;
99 // typedef typename LayerType::ValueType ValueType;
100 
102  itkSetStringMacro(FileName);
103 
105  itkGetStringMacro(FileName);
106 
108  //Avoiding VS6 compiler error void SetInput( const TNetwork* network );
109  void SetInput(TNetwork *network);
111 
112  const TNetwork * GetInput() const;
113 
115  void Update(void);
116 
117 #ifdef IGNORE
118 #undef IGNORE
119 #endif
120  //ASCII only works for very small networks (i.e. less than 256 weights),
121  //and the MetaIO mechanism is not desigend for the way that this is used
122  //to write these files out.
123  // Comment this code out until it can be robustly written.
124  typedef enum { IGNORE = 0, ASCII = 1, BINARY = 2 } NetworkWriteWeightsType;
125  itkSetEnumMacro(WriteWeightValuesType, NetworkWriteWeightsType);
126  itkGetEnumMacro(WriteWeightValuesType, NetworkWriteWeightsType);
127 
128 protected:
131  virtual void PrintSelf(std::ostream & os, Indent indent) const;
132 
133 private:
134  void ClearFields();
135 
136  typedef std::vector< MET_FieldRecordType * > FieldsContainerType;
137 
138  //Attempting to avoid VS 6 compiler error typename TNetwork::ConstPointer
139  // m_Network;
140  typename TNetwork::Pointer m_Network;
141 
143 
144  std::string m_FileName;
146 
147  std::ofstream m_OutputFile;
148 };
149 } // namespace itk
150 
151 #ifndef ITK_MANUAL_INSTANTIATION
152 #include "itkNeuralNetworkFileWriter.hxx"
153 #endif
154 
155 #endif
156