test6.cpp

Go to the documentation of this file.
00001 #include "indii/fmri/hemodynamic/NeuralBalloonModel.hpp"
00002 #include "indii/fmri/hemodynamic/FlowBalloonModel.hpp"
00003 #include "indii/fmri/hemodynamic/BOLDCalculator.hpp"
00004 #include "indii/ml/ode/AdaptiveRungeKutta.hpp"
00005 
00006 #include <iostream>
00007 #include <string.h>
00008 #include <math.h>
00009 
00010 using namespace std;
00011 using namespace indii::fmri::hemodynamic;
00012 using namespace indii::ml::ode;
00013 
00014 /**
00015  * @file test6.cpp
00016  *
00017  * Test of NeuralBalloonModel in comparison to Friston et
00018  * al. (2000). Results are output on stdout, tab delimited, with
00019  * columns representing:
00020  *
00021  * \li \f$t\f$; time
00022  * \li \f$u(t)\f$
00023  * \li \f$y\f$; BOLD response
00024  *
00025  * Results are as follows:
00026  *
00027  * \image html test6.png "Results, c.f. Friston et al. (2000) Figure 1."
00028  * \image latex test6.eps "Results, c.f. Friston et al. (2000) Figure 1."
00029  *
00030  * @remarks The results given in Friston et al. (2000) are not from
00031  * experimentation with the Balloon model. This does serve as a useful
00032  * comparison of the Balloon model against empirical results, however,
00033  * if nothing else demonstrating the need for a sustained stimulus to
00034  * get meaningful results.
00035  */
00036 
00037 
00038 /**
00039  * Duration of simulation (s).
00040  */
00041 static const double END = 35.0;
00042 
00043 /**
00044  * Impulse times
00045  */
00046 static const double IMPULSES[] = { 5.0, 6.0 };
00047 static const double IMPULSES_LENGTH = 2;
00048 
00049 /**
00050  * \f$u(t)\f$; impulse of 1 at times 5s and 6s
00051  */
00052 double U(double t, const double y[], void* o) {
00053   int i;
00054   for (i = 0; i < IMPULSES_LENGTH; i++) {
00055     if (t == IMPULSES[i]) {
00056       return 1.0;
00057     }
00058   }
00059   return 0.0;
00060 }
00061 
00062 /**
00063  * Run tests.
00064  */
00065 int main(int argc, const char* argv[]) {
00066   NeuralBalloonModel balloonModel;
00067   BOLDCalculator boldCalculator(&balloonModel);
00068   AdaptiveRungeKutta ode(&balloonModel, balloonModel.suggestInitialState());
00069 
00070   /* set up balloon model */
00071   balloonModel.setFunction(NeuralBalloonModel::U, U);
00072 
00073   /* simulate in such a way that impulse times are not skipped */
00074   double t = 0.0;
00075   int i;
00076   for (i = 0; i < IMPULSES_LENGTH; i++) {
00077     while (t < IMPULSES[i]) {
00078       cout << t << "\t";
00079       cout << balloonModel.getFunction(NeuralBalloonModel::U) << "\t";
00080       cout << boldCalculator.calculate(ode.getState()) << "\t";
00081       cout << endl;
00082       t = ode.step(IMPULSES[i]);
00083     }
00084     ode.setDiscontinuity(); // discontinuity
00085   }
00086   while (t < END) {
00087     cout << t << "\t";
00088     cout << balloonModel.getFunction(NeuralBalloonModel::U) << "\t";
00089     cout << boldCalculator.calculate(ode.getState()) << "\t";
00090     cout << endl;
00091     t = ode.step(END);
00092   }
00093 
00094   return 0;
00095 }

Generated on Mon Aug 13 19:51:39 2007 for fmrii Hemodynamic Models Test Suite by  doxygen 1.5.2