icaanalysisbase.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-2016 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>
31 #include <mia/core/slopevector.hh>
32 
33 
34 namespace mia {
35 
37 {
38 public:
39 
43  enum EApproach {
46  appr_unknown
47  };
48 
49  typedef std::unique_ptr<CICAAnalysis> Pointer;
50 
52  typedef std::set<unsigned int> IndexSet;
53 
54  virtual ~CICAAnalysis();
55 
63  template <class Iterator>
64  BOOST_CONCEPT_REQUIRES(((::boost::ForwardIterator<Iterator>)),
65  (void))
66  set_row(unsigned row, Iterator begin, Iterator end);
67 
68 
69  virtual void initialize(unsigned int series_length, unsigned int slice_size) = 0;
76  virtual bool run(unsigned int nica, std::vector<std::vector<float> > guess) = 0;
77 
79  virtual std::vector<float> get_feature_row(unsigned int row)const = 0;
80 
82  virtual std::vector<float> get_mix_series(unsigned int row)const = 0;
83 
85  virtual std::vector<float> get_mix(unsigned int idx)const = 0;
86 
93  virtual std::vector<float> get_incomplete_mix(unsigned int idx, const IndexSet& skip)const = 0;
94 
101  virtual std::vector<float> get_partial_mix(unsigned int idx, const IndexSet& use)const = 0;
102 
108  virtual std::vector<float> get_delta_feature(const IndexSet& plus, const IndexSet& minus)const = 0;
109 
115  virtual void set_mixing_series(unsigned int index, const std::vector<float>& series) = 0;
116 
118  virtual CSlopeColumns get_mixing_curves() const = 0;
119 
126  virtual void normalize_ICs() = 0;
127 
133  virtual std::vector<float> normalize_Mix() = 0;
134 
135 
137  virtual unsigned int get_ncomponents() const = 0;
138 
143  virtual void set_max_iterations(int n) = 0;
144 
149  virtual void set_approach(EApproach approach) = 0;
150 private:
151  virtual void set_row_internal(unsigned row, const std::vector<double>& buffer, double mean) = 0;
152 
153 };
154 
155 typedef CICAAnalysis::Pointer PICAAnalysis;
156 
157 
159 public:
160  virtual ~CICAAnalysisFactory();
161  virtual PICAAnalysis create() const = 0;
162 };
163 
164 
165 typedef std::shared_ptr<CICAAnalysisFactory> PICAAnalysisFactory;
166 
168 template <class Iterator>
169 BOOST_CONCEPT_REQUIRES(((::boost::ForwardIterator<Iterator>)),
170  (void))
171 CICAAnalysis::set_row(unsigned row, Iterator begin, Iterator end)
172 {
173  const unsigned int length = std::distance(begin, end);
174  std::vector<double> buffer(length);
175  unsigned int idx = 0;
176  double mean = 0.0;
177 
178  while (begin != end)
179  mean += (buffer[idx++] = *begin++);
180  mean /= length;
181  for(unsigned int i = 0; i < length; ++i)
182  buffer[i] -= mean;
183  set_row_internal(row, buffer, mean);
184 }
186 
187 }
188 
189 #endif // CICAANALYSISBASE_HH
Definition: fastica.hh:28
class EXPORT_CORE CMeans private
std::shared_ptr< CICAAnalysisFactory > PICAAnalysisFactory
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
Definition: defines.hh:101
CICAAnalysis::Pointer PICAAnalysis
std::vector< std::vector< float > > CSlopeColumns
class to store the ICA weight matrix
Definition: slopevector.hh:33
std::set< unsigned int > IndexSet
defines a set of indices used for mixing
std::unique_ptr< CICAAnalysis > Pointer