indii/fmri/model/MultiSeedModel.hpp

00001 #ifndef INDII_FMRI_MODEL_MULTISEEDMODEL_HPP
00002 #define INDII_FMRI_MODEL_MULTISEEDMODEL_HPP
00003 
00004 #include "../neural/MultiSeedNeuralModel.hpp"
00005 #include "../hemodynamic/LogNeuralBalloonModel.hpp"
00006 #include "../hemodynamic/LogBOLDCalculator.hpp"
00007 
00008 #include "indii/ml/aux/GaussianPdf.hpp"
00009 #include "indii/ml/ode/DifferentialModel.hpp"
00010 #include "indii/ml/filter/UnscentedKalmanFilterModel.hpp"
00011 #include "indii/ml/filter/ParticleSmootherModel.hpp"
00012 #include "indii/ml/ode/AdaptiveRungeKutta.hpp"
00013 
00014 #include <vector>
00015 
00016 namespace indii {
00017   namespace fmri {
00018     namespace model {
00019 
00020 /**
00021  * Multiple seed time-series %model combining
00022  * indii::fmri::neural::MultiSeedNeuralModel for %neural interactions,
00023  * indii::fmri::hemodynamic::LogNeuralBalloonModel for independent
00024  * %hemodynamic activity at each seed and
00025  * indii::fmri::hemodynamic::LogBOLDCalculator for predicted
00026  * measurements.
00027  *
00028  * @author Lawrence Murray <lawrence@indii.org>
00029  * @version $Rev: 317 $
00030  * @date $Date: 2007-10-05 17:18:14 +0100 (Fri, 05 Oct 2007) $
00031  *
00032  * Parameters of the %model may be estimated using
00033  * indii::ml::filter::UnscentedKalmanFilter<double>,
00034  * indii::ml::filter::ParticleFilter<double> or
00035  * indii::ml::filter::ParticleSmoother<double>. When retrieving the
00036  * state at any time from one of these methods, it will be arranged as
00037  * follows (for \f$N\f$ seeds):
00038  *
00039  * @li \f$\big( A_{1,1},A_{1,2},\ldots,A_{N,N-1},A_{N,N} \big)^T\f$,
00040  * %neural efficacies between seeds, arranged column-wise.
00041  *
00042  * @li \f$\big( (\ln q_1,\ln v_1,\ln f_1,s_1,u_1,b_1),\ldots,(\ln
00043  * q_N,\ln v_N,\ln f_N,s_N,u_N,b_N) \big)^T\f$, for each seed, its
00044  * %neural activity, four %hemodynamic parameters and baseline BOLD
00045  * signal.
00046  */
00047 class MultiSeedModel :
00048     public indii::ml::ode::DifferentialModel,
00049     virtual public indii::ml::filter::UnscentedKalmanFilterModel<double>,
00050     virtual public indii::ml::filter::ParticleSmootherModel<double> {
00051 public:
00052   /**
00053    * Order of state variables within each seed block of the state vector.
00054    */
00055   enum SeedVariables {
00056     LN_Q,
00057     LN_V,
00058     LN_F,
00059     S,
00060     U,
00061     B,
00062     /**
00063      * Number of state variables for each seed.
00064      */
00065     SEED_SIZE
00066   };
00067 
00068   /**
00069    * Construct new %model.
00070    *
00071    * @param N Number of seeds.
00072    */
00073   MultiSeedModel(unsigned int N);
00074 
00075   /**
00076    * Construct new %model.
00077    *
00078    * @param N Number of seeds.
00079    * @param w System noise.
00080    * @param v Measurement noise.
00081    * @param r Resampling noise.
00082    */
00083   MultiSeedModel(unsigned int N, const indii::ml::aux::GaussianPdf& w,
00084       const indii::ml::aux::GaussianPdf& v,
00085       const indii::ml::aux::GaussianPdf& r);
00086 
00087   /**
00088    * Destructor.
00089    */
00090   virtual ~MultiSeedModel();
00091 
00092   /**
00093    * Get state size.
00094    */
00095   virtual unsigned int getStateSize();
00096 
00097   /**
00098    * Get measurement size.
00099    */
00100   virtual unsigned int getMeasurementSize();
00101 
00102   /**
00103    * Get the %neural %model. Settings of this %model may be adjusted.
00104    *
00105    * @return The %neural %model.
00106    */
00107   indii::fmri::neural::MultiSeedNeuralModel* getNeuralModel();
00108 
00109   /**
00110    * Get the %hemodynamic %model for a particular seed. Settings of this
00111    * %model may be adjusted.
00112    *
00113    * @param seed The seed.
00114    *
00115    * @return The %hemodynamic %model for the given seed.
00116    */
00117   indii::fmri::hemodynamic::LogNeuralBalloonModel* getHemodynamicModel(
00118       const unsigned int seed);
00119 
00120   /**
00121    * Get the BOLD calculator for a particular seed. Settings of this
00122    * may be adjusted.
00123    *
00124    * @param seed The seed.
00125    *
00126    * @return The BOLD calculator for the given seed.
00127    */
00128   indii::fmri::hemodynamic::LogBOLDCalculator* getBOLDCalculator(
00129       const unsigned int seed);
00130 
00131   /**
00132    * Set system noise structure.
00133    *
00134    * @param w System noise.
00135    */
00136   void setSystemNoise(const indii::ml::aux::GaussianPdf& w);
00137 
00138   /**
00139    * Set measurement noise structure.
00140    *
00141    * @param v Measurement noise.
00142    */
00143   void setMeasurementNoise(const indii::ml::aux::GaussianPdf& v);
00144 
00145   /**
00146    * Set resampling noise structure.
00147    *
00148    * @param r Resampling noise.
00149    */
00150   void setResamplingNoise(const indii::ml::aux::GaussianPdf& r);
00151 
00152   /**
00153    * Calculate a suggested prior over the initial state of the system.
00154    * 
00155    * @return Suggested prior over the initial state of the system.
00156    */
00157   indii::ml::aux::GaussianPdf suggestPrior();
00158 
00159   /**
00160    * Calculate a suggested system noise structure.
00161    * 
00162    * @return Suggested system noise.
00163    */
00164   indii::ml::aux::GaussianPdf suggestSystemNoise();
00165 
00166   /**
00167    * Calculate a suggested measurement noise structure.
00168    * 
00169    * @return Suggested measurement noise.
00170    */
00171   indii::ml::aux::GaussianPdf suggestMeasurementNoise();
00172 
00173   /**
00174    * Calculate a suggested resampling noise structure.
00175    *
00176    * @return Suggested resampling noise.
00177    */
00178   indii::ml::aux::GaussianPdf suggestResamplingNoise();
00179 
00180   /**
00181    * @see indii::ml::model::UnscentedKalmanFilterModel
00182    */
00183   virtual indii::ml::aux::vector transition(const indii::ml::aux::vector &x,
00184       const indii::ml::aux::vector &w, double delta);
00185 
00186   /**
00187    * @see indii::ml::model::ParticleFilterModel
00188    */
00189   virtual indii::ml::aux::vector transition(const indii::ml::aux::vector& x,
00190       const double start, const double delta);
00191 
00192   /**
00193    * @see indii::ml::model::UnscentedKalmanFilterModel
00194    */
00195   virtual indii::ml::aux::vector measure(const indii::ml::aux::vector &x,
00196       const indii::ml::aux::vector &v);
00197 
00198   /**
00199    * @see indii::ml::model::ParticleFilterModel
00200    */
00201   virtual indii::ml::aux::vector measure(const indii::ml::aux::vector &x);
00202 
00203   /**
00204    * @see indii::ml::model::ParticleFilterModel
00205    */
00206   virtual double weight(const indii::ml::aux::vector& x,
00207       const indii::ml::aux::vector& y);
00208 
00209   /**
00210    * @see indii::ml::model::ParticleFilterModel
00211    */
00212   virtual indii::ml::aux::vector resample(const indii::ml::aux::vector& x);
00213 
00214   /**
00215    * @see indii::ml::model::ParticleSmootherModel
00216    */
00217   virtual indii::ml::aux::sparse_matrix alpha(
00218       const indii::ml::aux::DiracMixturePdf& p_xtn_ytn,
00219       const indii::ml::aux::DiracMixturePdf& p_xtnp1_ytnp1,
00220       const double start, const double delta);
00221 
00222   /**
00223    * @see indii::ml::ode::DifferentialModel
00224    */
00225   virtual void calculateDerivatives(double t, const double y[], double dydt[]);
00226 
00227 private:
00228   /**
00229    * Number of seeds.
00230    */
00231   unsigned int N;
00232 
00233   /**
00234    * System noise.
00235    */
00236   indii::ml::aux::GaussianPdf w;
00237 
00238   /**
00239    * Measurement noise.
00240    */
00241   indii::ml::aux::GaussianPdf v;
00242 
00243   /**
00244    * Resampling noise.
00245    */
00246   indii::ml::aux::GaussianPdf r;
00247 
00248   /**
00249    * Neural model.
00250    */
00251   indii::fmri::neural::MultiSeedNeuralModel* neural;
00252 
00253   /**
00254    * Hemodynamic models.
00255    */
00256   std::vector<indii::fmri::hemodynamic::LogNeuralBalloonModel*> hemodynamics;
00257 
00258   /**
00259    * BOLD calculators.
00260    */
00261   std::vector<indii::fmri::hemodynamic::LogBOLDCalculator*> bolds;
00262 
00263   /**
00264    * Runge--Kutta.
00265    */
00266   indii::ml::ode::AdaptiveRungeKutta ode;
00267 
00268   /**
00269    * Initialise models.
00270    */
00271   void init();
00272 
00273   /**
00274    * Neural function for passing values from neural model to
00275    * hemodynamic models.
00276    */
00277   static double U_PASSER(double t, const double y[], void *o);
00278 
00279 };
00280 
00281     }
00282   }
00283 }
00284 
00285 #endif

Generated on Tue Oct 9 22:02:07 2007 for fmrii fMRI Modelling Library by  doxygen 1.5.2