core/ica.hh
Go to the documentation of this file.
/* -*- mia-c++ -*-
*
* This file is part of MIA - a toolbox for medical image analysis
* Copyright (c) Leipzig, Madrid 1999-2017 Gert Wollny
*
* MIA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MIA; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef mia_core_ICAANALYSISBASE_HH
#define mia_core_ICAANALYSISBASE_HH
#include <memory>
#include <set>
#include <boost/concept/requires.hpp>
#include <boost/concept_check.hpp>
#include <mia/core/defines.hh>
#include <mia/core/slopevector.hh>
#include <mia/core/factory.hh>
namespace mia
{
class EXPORT_CORE CIndepCompAnalysis
{
public:
enum EApproach {
appr_defl,
appr_symm,
appr_unknown
};
typedef std::unique_ptr<CIndepCompAnalysis> Pointer;
typedef std::set<unsigned int> IndexSet;
virtual ~CIndepCompAnalysis();
template <class Iterator>
BOOST_CONCEPT_REQUIRES(((::boost::ForwardIterator<Iterator>)),
(void))
set_row(unsigned row, Iterator begin, Iterator end);
virtual void initialize(unsigned int series_length, unsigned int slice_size) = 0;
virtual bool run(unsigned int nica, std::vector<std::vector<float>> guess) = 0;
virtual std::vector<float> get_feature_row(unsigned int row)const = 0;
virtual std::vector<float> get_mix_series(unsigned int row)const = 0;
virtual std::vector<float> get_mix(unsigned int idx)const = 0;
virtual std::vector<float> get_incomplete_mix(unsigned int idx, const IndexSet& skip)const = 0;
virtual std::vector<float> get_partial_mix(unsigned int idx, const IndexSet& use)const = 0;
virtual std::vector<float> get_delta_feature(const IndexSet& plus, const IndexSet& minus)const = 0;
virtual void set_mixing_series(unsigned int index, const std::vector<float>& series) = 0;
virtual CSlopeColumns get_mixing_curves() const = 0;
virtual void normalize_ICs() = 0;
virtual std::vector<float> normalize_Mix() = 0;
virtual unsigned int get_ncomponents() const = 0;
virtual void set_max_iterations(int n) = 0;
virtual void set_approach(EApproach approach) = 0;
virtual void set_deterministic_seed(int seed) = 0;
private:
virtual void set_row_internal(unsigned row, const std::vector<double>& buffer, double mean) = 0;
};
typedef CIndepCompAnalysis::Pointer PIndepCompAnalysis;
class EXPORT_CORE CIndepCompAnalysisFactory : public CProductBase
{
public:
static const char *data_descr;
static const char *type_descr;
typedef CIndepCompAnalysisFactory plugin_type;
typedef CIndepCompAnalysisFactory plugin_data;
CIndepCompAnalysisFactory();
virtual ~CIndepCompAnalysisFactory();
void set_deterministic_seed(int seed);
CIndepCompAnalysis *create() const __attribute__((warn_unused_result));
private:
virtual CIndepCompAnalysis *do_create() const __attribute__((warn_unused_result)) = 0;
int m_deterministic_seed;
};
typedef TFactory<CIndepCompAnalysisFactory> CIndepCompAnalysisFactoryPlugin;
typedef std::shared_ptr<CIndepCompAnalysisFactory> PIndepCompAnalysisFactory;
typedef THandlerSingleton<TFactoryPluginHandler<CIndepCompAnalysisFactoryPlugin>>
CIndepCompAnalysisFactoryPluginHandler;
template<> const char *const
TPluginHandler<TFactory<CIndepCompAnalysisFactory>>::m_help;
extern template class EXPORT_CORE TPluginHandler<TFactory<CIndepCompAnalysisFactory>>;
FACTORY_TRAIT(CIndepCompAnalysisFactoryPluginHandler);
inline PIndepCompAnalysisFactory produce_ica_factory(const std::string& descr)
{
return CIndepCompAnalysisFactoryPluginHandler::instance().produce(descr);
}
template <class Iterator>
BOOST_CONCEPT_REQUIRES(((::boost::ForwardIterator<Iterator>)),
(void))
CIndepCompAnalysis::set_row(unsigned row, Iterator begin, Iterator end)
{
const unsigned int length = std::distance(begin, end);
std::vector<double> buffer(length);
unsigned int idx = 0;
double mean = 0.0;
while (begin != end)
mean += (buffer[idx++] = *begin++);
mean /= length;
for (unsigned int i = 0; i < length; ++i)
buffer[i] -= mean;
set_row_internal(row, buffer, mean);
}
}
#endif // CICAANALYSISBASE_HH
CProductBase
The base class for all plug-in created object.
Definition product_base.hh:41
Pointer
TFactoryPluginHandler
the Base class for all plugn handlers that deal with factory plugins.
Definition factory.hh:95
TFactory
This is tha base of all plugins that create "things", like filters, cost functions time step operator...
Definition factory.hh:51
THandlerSingleton
the singleton that a plug-in handler really is
Definition handler.hh:159
THandlerSingleton< TFactoryPluginHandler< CIndepCompAnalysisFactoryPlugin > >::instance
static const TFactoryPluginHandler< CIndepCompAnalysisFactoryPlugin > & instance()
TPluginHandler
The basic template of all plugin handlers.
Definition handler.hh:57
mia::CIndepCompAnalysisFactory
Definition core/ica.hh:162
mia::CIndepCompAnalysisFactory::data_descr
static const char * data_descr
Definition core/ica.hh:164
mia::CIndepCompAnalysisFactory::CIndepCompAnalysisFactory
CIndepCompAnalysisFactory()
mia::CIndepCompAnalysisFactory::plugin_data
CIndepCompAnalysisFactory plugin_data
Definition core/ica.hh:168
mia::CIndepCompAnalysisFactory::set_deterministic_seed
void set_deterministic_seed(int seed)
mia::CIndepCompAnalysisFactory::~CIndepCompAnalysisFactory
virtual ~CIndepCompAnalysisFactory()
mia::CIndepCompAnalysisFactory::create
CIndepCompAnalysis * create() const __attribute__((warn_unused_result))
mia::CIndepCompAnalysisFactory::plugin_type
CIndepCompAnalysisFactory plugin_type
Definition core/ica.hh:167
mia::CIndepCompAnalysisFactory::type_descr
static const char * type_descr
Definition core/ica.hh:165
mia::CIndepCompAnalysis
Definition core/ica.hh:38
mia::CIndepCompAnalysis::normalize_Mix
virtual std::vector< float > normalize_Mix()=0
mia::CIndepCompAnalysis::set_row
void set_row(unsigned row, Iterator begin, Iterator end)
mia::CIndepCompAnalysis::set_approach
virtual void set_approach(EApproach approach)=0
mia::CIndepCompAnalysis::normalize_ICs
virtual void normalize_ICs()=0
mia::CIndepCompAnalysis::set_mixing_series
virtual void set_mixing_series(unsigned int index, const std::vector< float > &series)=0
mia::CIndepCompAnalysis::get_mixing_curves
virtual CSlopeColumns get_mixing_curves() const =0
mia::CIndepCompAnalysis::get_mix
virtual std::vector< float > get_mix(unsigned int idx) const =0
mia::CIndepCompAnalysis::get_delta_feature
virtual std::vector< float > get_delta_feature(const IndexSet &plus, const IndexSet &minus) const =0
mia::CIndepCompAnalysis::run
virtual bool run(unsigned int nica, std::vector< std::vector< float > > guess)=0
mia::CIndepCompAnalysis::set_max_iterations
virtual void set_max_iterations(int n)=0
mia::CIndepCompAnalysis::~CIndepCompAnalysis
virtual ~CIndepCompAnalysis()
mia::CIndepCompAnalysis::get_feature_row
virtual std::vector< float > get_feature_row(unsigned int row) const =0
mia::CIndepCompAnalysis::get_incomplete_mix
virtual std::vector< float > get_incomplete_mix(unsigned int idx, const IndexSet &skip) const =0
mia::CIndepCompAnalysis::IndexSet
std::set< unsigned int > IndexSet
defines a set of indices used for mixing
Definition core/ica.hh:53
mia::CIndepCompAnalysis::get_mix_series
virtual std::vector< float > get_mix_series(unsigned int row) const =0
mia::CIndepCompAnalysis::get_ncomponents
virtual unsigned int get_ncomponents() const =0
mia::CIndepCompAnalysis::get_partial_mix
virtual std::vector< float > get_partial_mix(unsigned int idx, const IndexSet &use) const =0
mia::CIndepCompAnalysis::set_deterministic_seed
virtual void set_deterministic_seed(int seed)=0
mia::CIndepCompAnalysis::Pointer
std::unique_ptr< CIndepCompAnalysis > Pointer
Definition core/ica.hh:50
mia::CIndepCompAnalysis::initialize
virtual void initialize(unsigned int series_length, unsigned int slice_size)=0
mia::CIndepCompAnalysis::EApproach
EApproach
Definition core/ica.hh:44
mia::CIndepCompAnalysis::appr_symm
@ appr_symm
Definition core/ica.hh:46
mia::CIndepCompAnalysis::appr_defl
@ appr_defl
Definition core/ica.hh:45
mia::CIndepCompAnalysis::appr_unknown
@ appr_unknown
Definition core/ica.hh:47
defines.hh
EXPORT_CORE
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
Definition defines.hh:101
factory.hh
CSlopeColumns
std::vector< std::vector< float > > CSlopeColumns
class to store the ICA weight matrix
Definition slopevector.hh:33
FACTORY_TRAIT
#define FACTORY_TRAIT(F)
Definition factory_trait.hh:69
mia
Definition convergence_measure.hh:31
mia::m_help
const char *const TPluginHandler< TFactory< CIndepCompAnalysisFactory > >::m_help
Definition core/ica.hh:190
mia::CIndepCompAnalysisFactoryPluginHandler
THandlerSingleton< TFactoryPluginHandler< CIndepCompAnalysisFactoryPlugin > > CIndepCompAnalysisFactoryPluginHandler
plugin handler for spaciel filter kernels
Definition core/ica.hh:186
mia::CIndepCompAnalysisFactoryPlugin
TFactory< CIndepCompAnalysisFactory > CIndepCompAnalysisFactoryPlugin
Definition core/ica.hh:180
mia::produce_ica_factory
PIndepCompAnalysisFactory produce_ica_factory(const std::string &descr)
Definition core/ica.hh:200
mia::PIndepCompAnalysis
CIndepCompAnalysis::Pointer PIndepCompAnalysis
Definition core/ica.hh:158
mia::PIndepCompAnalysisFactory
std::shared_ptr< CIndepCompAnalysisFactory > PIndepCompAnalysisFactory
Definition core/ica.hh:182
std
Definition gsl_iterator.hh:324
slopevector.hh