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
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 static const double END = 30.0;
00044
00045
00046
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
00060
00061 int main(int argc, const char* argv[]) {
00062 LogNeuralBalloonModel balloonModel;
00063 LogBOLDCalculator boldCalculator(&balloonModel);
00064 AdaptiveRungeKutta ode(&balloonModel, balloonModel.suggestInitialState());
00065
00066
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 }