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
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
00047
00048
00049
00050
00051 static const double END = 30.0;
00052
00053
00054
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
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
00085 balloonModel.setFunction(NeuralBalloonModel::U, U);
00086
00087
00088
00089
00090
00091 double t = 0.0;
00092 while (t < END) {
00093 t = ode.step(END);
00094 }
00095
00096
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 }