test8.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 test8.cpp
00016  *
00017  * Backward test of NeuralBalloonModel.
00018  *
00019  * This test uses a default NeuralBalloonModel with a driving neural
00020  * activity function \f$u(t)\f$ consisting of a brief 1 s long burst
00021  * of activity followed by no activity. The model is first simulated
00022  * forward for a set time period, and then backward for the same
00023  * period of time.
00024  *
00025  * Results from the backward simulation are output on stdout, tab
00026  * delimited, with columns representing:
00027  *
00028  * \li \f$t\f$; time
00029  * \li \f$f_{in}(t)\f$
00030  * \li \f$f_{out}(t)\f$
00031  * \li \f$u(t)\f$
00032  * \li \f$q\f$
00033  * \li \f$v\f$
00034  * \li \f$f\f$
00035  * \li \f$s\f$
00036  * \li \f$y\f$; BOLD response
00037  *
00038  * Results are as follows:
00039  *
00040  * \image html test8.png "Results"
00041  * \image latex test8.eps "Results"
00042  *
00043  * These should be identical to those for test3, which represents a
00044  * forward pass under the same conditions.
00045  */
00046 
00047 
00048 /**
00049  * Duration of simulation (s).
00050  */
00051 static const double END = 30.0;
00052 
00053 /**
00054  * \f$u(t)\f$; 1 for 1 s, then 0.
00055  */
00056 double U(double t, const double y[], void* o) {
00057   double u;
00058   if (t < 1.0) {
00059     u = 1.0;
00060   } else {
00061     u = 0.0;
00062   }
00063   return u;
00064 }
00065 
00066 double F_OUT(double t, const double y[], void* o) {
00067   return y[NeuralBalloonModel::V];
00068 }
00069 
00070 double E(double t, const double y[], void* o) {
00071   return 0.4;
00072 }
00073 
00074 /**
00075  * Run tests.
00076  */
00077 int main(int argc, const char* argv[]) {
00078   NeuralBalloonModel balloonModel;
00079   AdaptiveRungeKutta ode(&balloonModel, balloonModel.suggestInitialState());
00080   BOLDCalculator boldCalculator(&balloonModel);
00081 
00082   ode.setErrorBounds(1.0e-12, 1.0e-12);
00083 
00084   /* set up balloon model */
00085   balloonModel.setFunction(NeuralBalloonModel::U, U);
00086   //balloonModel.setFunction(NeuralBalloonModel::F_OUT, F_OUT);
00087   //balloonModel.setFunction(NeuralBalloonModel::E, E);
00088   //balloonModel.setParameter(NeuralBalloonModel::ALPHA, 1.0);
00089 
00090   /* forward pass */
00091   double t = 0.0;
00092   while (t < END) {
00093     t = ode.step(END);
00094   }
00095 
00096   /* backward pass */
00097   while (t > 0.0) {
00098     cout << t << "\t";
00099     cout << balloonModel.getFunction(FlowBalloonModel::F_IN) << "\t";
00100     cout << balloonModel.getFunction(FlowBalloonModel::F_OUT) << "\t";
00101     cout << balloonModel.getFunction(NeuralBalloonModel::U) << "\t";
00102     cout << ode.getVariable(FlowBalloonModel::Q) << "\t";
00103     cout << ode.getVariable(FlowBalloonModel::V) << "\t";
00104     cout << ode.getVariable(NeuralBalloonModel::F) << "\t";
00105     cout << ode.getVariable(NeuralBalloonModel::S) << "\t";
00106     cout << boldCalculator.calculate(ode.getState()) * 100.0 << "\t";
00107     cout << endl;
00108     t = ode.stepBack(0.0);
00109   }
00110 
00111   return 0;
00112 }

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