test10.cpp

Go to the documentation of this file.
00001 #include "indii/fmri/hemodynamic/LogNeuralBalloonModel.hpp"
00002 #include "indii/fmri/hemodynamic/LogBOLDCalculator.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 test10.cpp
00015  *
00016  * Basic test of LogNeuralBalloonModel.
00017  *
00018  * This test uses a default LogNeuralBalloonModel with a driving
00019  * neural activity function \f$u(t)\f$ consisting of a brief 1 s long
00020  * burst of activity followed by no activity. Results are output on
00021  * stdout, tab delimited, with 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$ln(q)\f$
00028  * \li \f$ln(v)\f$
00029  * \li \f$ln(f)\f$
00030  * \li \f$s\f$
00031  * \li \f$y\f$; BOLD response
00032  *
00033  * Results are as follows:
00034  *
00035  * \image html test10.png "Results, c.f. test3.cpp"
00036  * \image latex test10.eps "Results, c.f. test3.cpp"
00037  */
00038 
00039 
00040 /**
00041  * Duration of simulation (s).
00042  */
00043 static const double END = 30.0;
00044 
00045 /**
00046  * \f$u(t)\f$; 1 for 1 s, then 0.
00047  */
00048 double U(double t, const double y[], void* o) {
00049   double u;
00050   if (t < 1.0) {
00051     u = 1.0;
00052   } else {
00053     u = 0.0;
00054   }
00055   return u;
00056 }
00057 
00058 /**
00059  * Run tests.
00060  */
00061 int main(int argc, const char* argv[]) {
00062   LogNeuralBalloonModel balloonModel;
00063   LogBOLDCalculator boldCalculator(&balloonModel);
00064   AdaptiveRungeKutta ode(&balloonModel, balloonModel.suggestInitialState());
00065 
00066   /* set up balloon model */
00067   balloonModel.setFunction(LogNeuralBalloonModel::U, U);
00068 
00069   double t = 0.0;
00070   while (t < END) {
00071     cout << t << "\t";
00072     cout << balloonModel.getFunction(LogNeuralBalloonModel::F_IN) << "\t";
00073     cout << balloonModel.getFunction(LogNeuralBalloonModel::F_OUT) << "\t";
00074     cout << balloonModel.getFunction(LogNeuralBalloonModel::U) << "\t";
00075     cout << ode.getVariable(LogNeuralBalloonModel::LN_Q) << "\t";
00076     cout << ode.getVariable(LogNeuralBalloonModel::LN_V) << "\t";
00077     cout << ode.getVariable(LogNeuralBalloonModel::LN_F) << "\t";
00078     cout << ode.getVariable(LogNeuralBalloonModel::S) << "\t";
00079     cout << boldCalculator.calculate(ode.getState()) * 100.0 << "\t";
00080     cout << endl;
00081     t = ode.step(END);
00082   }
00083 
00084   return 0;
00085 }

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