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
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
00044
00045
00046 static const double END = 30.0;
00047
00048
00049
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
00063
00064 int main(int argc, const char* argv[]) {
00065 NeuralBalloonModel balloonModel;
00066 BOLDCalculator boldCalculator(&balloonModel);
00067 AdaptiveRungeKutta ode(&balloonModel, balloonModel.suggestInitialState());
00068
00069
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 }