indii/fmri/model/MultiSeedModelMk2.hpp

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

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