ITK  4.2.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 protected:
119  virtual void PrintSelf(std::ostream & os, Indent indent) const;
120 
121 private:
122 
123  void ClearFields();
124 
125  typedef std::vector< MET_FieldRecordType * > FieldsContainerType;
126  typedef std::vector< typename TNetwork::LayerInterfaceType::Pointer > LayersContainer;
127  typedef std::vector< typename TNetwork::LayerInterfaceType::WeightSetInterfaceType::Pointer > WeightsContainer;
128 
129  typedef struct {
130  std::string name;
131  std::string value;
132  } LineType;
133 
134  typedef std::list< LineType > LinesContainer;
135 
136  typename TNetwork::Pointer m_Network;
137 
142  std::string m_FileName;
144  std::ifstream m_InputFile;
146 };
147 } // namespace itk
148 
149 #ifndef ITK_MANUAL_INSTANTIATION
150 #include "itkNeuralNetworkFileReader.hxx"
151 #endif
152 
153 #endif
154