test3.cpp

Go to the documentation of this file.
00001 #include "indii/fmri/hemodynamic/NeuralBalloonModel.hpp"
00002 #include "indii/fmri/hemodynamic/BOLDCalculator.hpp"
00003 #include "indii/ml/ode/AdaptiveRungeKutta.hpp"
00004 
00005 #include <iostream>
00006 #include <string.h>
00007 #include <math.h>
00008 
00009 using namespace std;
00010 using namespace indii::fmri::hemodynamic;
00011 using namespace indii::ml::ode;
00012 
00013 /**
00014  * @file test3.cpp
00015  *
00016  * Basic test of NeuralBalloonModel.
00017  *
00018  * This test uses a default NeuralBalloonModel with a driving neural activity
00019  * function \f$u(t)\f$ consisting of a brief 1 s long burst of activity
00020  * followed by no activity. Results are output on stdout, tab delimited, with
00021  * columns representing:
00022  *
00023  * \li \f$t\f$; time
00024  * \li \f$f_{in}(t)\f$
00025  * \li \f$f_{out}(t)\f$
00026  * \li \f$u(t)\f$
00027  * \li \f$q\f$
00028  * \li \f$v\f$
00029  * \li \f$f\f$
00030  * \li \f$s\f$
00031  * \li \f$y\f$; BOLD response
00032  *
00033  * Results are as follows:
00034  *
00035  * \image html test3.png "Results"
00036  * \image latex test3.eps "Results"
00037  *
00038  * Note in particular that the curve for the state variable \f$f\f$
00039  * should match that for the function \f$f_{in}(t)\f$.
00040  */
00041 
00042 
00043 /**
00044  * Duration of simulation (s).
00045  */
00046 static const double END = 30.0;
00047 
00048 /**
00049  * \f$u(t)\f$; 1 for 1 s, then 0.
00050  */
00051 double U(double t, const double y[], void* o) {
00052   double u;
00053   if (t < 1.0) {
00054     u = 1.0;
00055   } else {
00056     u = 0.0;
00057   }
00058   return u;
00059 }
00060 
00061 /**
00062  * Run tests.
00063  */
00064 int main(int argc, const char* argv[]) {
00065   NeuralBalloonModel balloonModel;
00066   BOLDCalculator boldCalculator(&balloonModel);
00067   AdaptiveRungeKutta ode(&balloonModel, balloonModel.suggestInitialState());
00068 
00069   /* set up balloon model */
00070   balloonModel.setFunction(NeuralBalloonModel::U, U);
00071 
00072   double t = 0.0;
00073   while (t < END) {
00074     cout << t << "\t";
00075     cout << balloonModel.getFunction(NeuralBalloonModel::F_IN) << "\t";
00076     cout << balloonModel.getFunction(NeuralBalloonModel::F_OUT) << "\t";
00077     cout << balloonModel.getFunction(NeuralBalloonModel::U) << "\t";
00078     cout << ode.getVariable(NeuralBalloonModel::Q) << "\t";
00079     cout << ode.getVariable(NeuralBalloonModel::V) << "\t";
00080     cout << ode.getVariable(NeuralBalloonModel::F) << "\t";
00081     cout << ode.getVariable(NeuralBalloonModel::S) << "\t";
00082     cout << boldCalculator.calculate(ode.getState()) * 100.0 << "\t";
00083     cout << endl;
00084     t = ode.step(END);
00085   }
00086 
00087   return 0;
00088 }

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