test4.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 test4.cpp
00016  *
00017  * Recurrent test of NeuralBalloonModel.
00018  *
00019  * This test uses a default NeuralBalloonModel with a driving neural
00020  * activity boxcar function.
00021  *
00022  * \li \f$t\f$; time
00023  * \li \f$f_{in}(t)\f$
00024  * \li \f$f_{out}(t)\f$
00025  * \li \f$u(t)\f$
00026  * \li \f$q\f$
00027  * \li \f$v\f$
00028  * \li \f$f\f$
00029  * \li \f$s\f$
00030  * \li \f$y\f$; BOLD response
00031  *
00032  * Results are as follows:
00033  *
00034  * \image html test4.png "Results"
00035  * \image latex test4.eps "Results"
00036  *
00037  * Note in particular that the curve for the state variable \f$f\f$
00038  * should match that for the function \f$f_{in}(t)\f$.
00039  */
00040 
00041 
00042 /**
00043  * Duration of simulation (s).
00044  */
00045 static const double END = 60.0;
00046 
00047 /**
00048  * \f$u(t)\f$; 1 for 1 s, then 0.
00049  */
00050 double U(double t, const double y[], void* o) {
00051   double u;
00052 
00053   int block = (int)floor(t / 10.0);
00054   if (block >> 1 << 1 == block) {
00055     // even number
00056     u = 1.0;
00057   } else {
00058     u = 0.0;
00059   }
00060   return u;
00061 }
00062 
00063 /**
00064  * Run tests.
00065  */
00066 int main(int argc, const char* argv[]) {
00067   NeuralBalloonModel balloonModel;
00068   BOLDCalculator boldCalculator(&balloonModel);
00069   AdaptiveRungeKutta ode(&balloonModel, balloonModel.suggestInitialState());
00070 
00071   /* set up balloon model */
00072   balloonModel.setFunction(NeuralBalloonModel::U, U);
00073 
00074   double t = 0.0;
00075   while (t < END) {
00076     cout << t << "\t";
00077     cout << balloonModel.getFunction(FlowBalloonModel::F_IN) << "\t";
00078     cout << balloonModel.getFunction(FlowBalloonModel::F_OUT) << "\t";
00079     cout << balloonModel.getFunction(NeuralBalloonModel::U) << "\t";
00080     cout << ode.getVariable(FlowBalloonModel::Q) << "\t";
00081     cout << ode.getVariable(FlowBalloonModel::V) << "\t";
00082     cout << ode.getVariable(NeuralBalloonModel::F) << "\t";
00083     cout << ode.getVariable(NeuralBalloonModel::S) << "\t";
00084     cout << boldCalculator.calculate(ode.getState()) * 100.0 << "\t";
00085     cout << endl;
00086     t = ode.step(END);
00087   }
00088 
00089   return 0;
00090 }

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