My Project
core/ica.hh
Go to the documentation of this file.
1/* -*- mia-c++ -*-
2 *
3 * This file is part of MIA - a toolbox for medical image analysis
4 * Copyright (c) Leipzig, Madrid 1999-2017 Gert Wollny
5 *
6 * MIA is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with MIA; if not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21
22#ifndef mia_core_ICAANALYSISBASE_HH
23#define mia_core_ICAANALYSISBASE_HH
24
25#include <memory>
26#include <set>
27#include <boost/concept/requires.hpp>
28#include <boost/concept_check.hpp>
29
30#include <mia/core/defines.hh>
32#include <mia/core/factory.hh>
33
34namespace mia
35{
36
38{
39public:
40
44 enum EApproach {
47 appr_unknown
48 };
49
50 typedef std::unique_ptr<CIndepCompAnalysis> Pointer;
51
53 typedef std::set<unsigned int> IndexSet;
54
56
64 template <class Iterator>
65 BOOST_CONCEPT_REQUIRES(((::boost::ForwardIterator<Iterator>)),
66 (void))
67 set_row(unsigned row, Iterator begin, Iterator end);
68
69
70 virtual void initialize(unsigned int series_length, unsigned int slice_size) = 0;
77 virtual bool run(unsigned int nica, std::vector<std::vector<float>> guess) = 0;
78
80 virtual std::vector<float> get_feature_row(unsigned int row)const = 0;
81
83 virtual std::vector<float> get_mix_series(unsigned int row)const = 0;
84
86 virtual std::vector<float> get_mix(unsigned int idx)const = 0;
87
94 virtual std::vector<float> get_incomplete_mix(unsigned int idx, const IndexSet& skip)const = 0;
95
102 virtual std::vector<float> get_partial_mix(unsigned int idx, const IndexSet& use)const = 0;
103
109 virtual std::vector<float> get_delta_feature(const IndexSet& plus, const IndexSet& minus)const = 0;
110
116 virtual void set_mixing_series(unsigned int index, const std::vector<float>& series) = 0;
117
119 virtual CSlopeColumns get_mixing_curves() const = 0;
120
127 virtual void normalize_ICs() = 0;
128
134 virtual std::vector<float> normalize_Mix() = 0;
135
136
138 virtual unsigned int get_ncomponents() const = 0;
139
144 virtual void set_max_iterations(int n) = 0;
145
150 virtual void set_approach(EApproach approach) = 0;
151
152 virtual void set_deterministic_seed(int seed) = 0;
153private:
154 virtual void set_row_internal(unsigned row, const std::vector<double>& buffer, double mean) = 0;
155
156};
157
159
160
162{
163public:
164 static const char *data_descr;
165 static const char *type_descr;
166
169
173 CIndepCompAnalysis *create() const __attribute__((warn_unused_result));
174private:
175 virtual CIndepCompAnalysis *do_create() const __attribute__((warn_unused_result)) = 0;
176 int m_deterministic_seed;
177};
178
179
181
183
187
188
189template<> const char *const
191
193
197
198
199
200inline PIndepCompAnalysisFactory produce_ica_factory(const std::string& descr)
201{
202 return CIndepCompAnalysisFactoryPluginHandler::instance().produce(descr);
203}
204
205
206
208template <class Iterator>
209BOOST_CONCEPT_REQUIRES(((::boost::ForwardIterator<Iterator>)),
210 (void))
211CIndepCompAnalysis::set_row(unsigned row, Iterator begin, Iterator end)
212{
213 const unsigned int length = std::distance(begin, end);
214 std::vector<double> buffer(length);
215 unsigned int idx = 0;
216 double mean = 0.0;
217
218 while (begin != end)
219 mean += (buffer[idx++] = *begin++);
220
221 mean /= length;
222
223 for (unsigned int i = 0; i < length; ++i)
224 buffer[i] -= mean;
225
226 set_row_internal(row, buffer, mean);
227}
229
230}
231
232#endif // CICAANALYSISBASE_HH
The base class for all plug-in created object.
the Base class for all plugn handlers that deal with factory plugins.
Definition factory.hh:95
This is tha base of all plugins that create "things", like filters, cost functions time step operator...
Definition factory.hh:51
the singleton that a plug-in handler really is
Definition handler.hh:159
The basic template of all plugin handlers.
Definition handler.hh:57
static const char * data_descr
Definition core/ica.hh:164
CIndepCompAnalysisFactory plugin_data
Definition core/ica.hh:168
void set_deterministic_seed(int seed)
CIndepCompAnalysis * create() const __attribute__((warn_unused_result))
CIndepCompAnalysisFactory plugin_type
Definition core/ica.hh:167
static const char * type_descr
Definition core/ica.hh:165
std::set< unsigned int > IndexSet
defines a set of indices used for mixing
Definition core/ica.hh:53
std::unique_ptr< CIndepCompAnalysis > Pointer
Definition core/ica.hh:50
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
Definition defines.hh:101
std::vector< std::vector< float > > CSlopeColumns
class to store the ICA weight matrix
#define FACTORY_TRAIT(F)
CIndepCompAnalysis::Pointer PIndepCompAnalysis
Definition core/ica.hh:158
std::shared_ptr< CIndepCompAnalysisFactory > PIndepCompAnalysisFactory
Definition core/ica.hh:182