ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkNeuralNetworkFileReader.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 __itkNeuralNetworkFileReader_h
19 #define __itkNeuralNetworkFileReader_h
20 
21 #include "metaTypes.h"
22 #include "metaUtils.h"
23 
25 
27 
28 
29 #include "itkSumInputFunction.h"
31 
37 
38 namespace itk
39 {
56 template< class TNetwork >
58 {
59 public:
60 
63  typedef Object Superclass;
66 
68  itkTypeMacro(NeuralNetworkFileReader, Object);
69 
71  itkNewMacro(Self);
72 
73  typedef typename TNetwork::MeasurementVectorType MeasurementVectorType;
74  typedef typename TNetwork::TargetVectorType TargetVectorType;
78  typedef typename MeasurementVectorType::ValueType MeasurementVectorValueType;
79 
80  typedef typename TNetwork::LayerInterfaceType LayerInterfaceType;
81  typedef typename LayerInterfaceType::WeightSetType WeightSetType;
82  typedef typename WeightSetType::Pointer WeightSetPointer;
83 
84 // typedef typename TNetwork::Pointer NetworkPointer;
85 // typedef typename TNetwork::ConstPointer NetworkConstPointer;
86 
87 // typedef typename LayerInterfaceType::TransferFunctionType::Pointer
88 // TransferFunctionPointer;
89 // typedef typename LayerInterfaceType::TransferFunctionType::ConstPointer
90 // TransferFunctionConstPointer;
91 
92 // typedef typename LayerInterfaceType::InputFunctionType::Pointer
93 // InputFunctionPointer;
94 // typedef typename LayerInterfaceType::InputFunctionType::ConstPointer
95 // InputFunctionConstPointer;
96 
97 // typedef typename LayerInterfaceType::ValueType ValueType;
98 
100  itkSetStringMacro(FileName);
101 
103  itkGetStringMacro(FileName);
104 
106  void Update(void);
107 
108  TNetwork * GetOutput() const;
109 
110 #ifdef IGNORE
111 #undef IGNORE
112 #endif
113  typedef enum { IGNORE = 0, ASCII = 1, BINARY = 2 } NetworkWriteWeightsType;
114  itkSetEnumMacro(ReadWeightValuesType, NetworkWriteWeightsType);
115  itkGetEnumMacro(ReadWeightValuesType, NetworkWriteWeightsType);
116 
117 protected:
120  virtual void PrintSelf(std::ostream & os, Indent indent) const;
121 
122 private:
123 
124  void ClearFields();
125 
126  typedef std::vector< MET_FieldRecordType * > FieldsContainerType;
127  typedef std::vector< typename TNetwork::LayerInterfaceType::Pointer > LayersContainer;
128  typedef std::vector< typename TNetwork::LayerInterfaceType::WeightSetInterfaceType::Pointer > WeightsContainer;
129 
130  typedef struct {
131  std::string name;
132  std::string value;
133  } LineType;
134 
135  typedef std::list< LineType > LinesContainer;
136 
137  typename TNetwork::Pointer m_Network;
138 
143  std::string m_FileName;
145  std::ifstream m_InputFile;
147 };
148 } // namespace itk
149 
150 #ifndef ITK_MANUAL_INSTANTIATION
151 #include "itkNeuralNetworkFileReader.hxx"
152 #endif
153 
154 #endif
155