diff --git a/.cproject b/.cproject
deleted file mode 100644
index bcd7e28..0000000
--- a/.cproject
+++ /dev/null
@@ -1,123 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/.project b/.project
deleted file mode 100644
index c9fe22a..0000000
--- a/.project
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
- TC_v2
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.core.ccnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
diff --git a/Cortical_Column.cpp b/Cortical_Column.cpp
index 5443cff..5956877 100644
--- a/Cortical_Column.cpp
+++ b/Cortical_Column.cpp
@@ -1,24 +1,32 @@
/*
-* Copyright (c) 2014 Michael Schellenberger Costa
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-* THE SOFTWARE.
-*/
+ * Copyright (c) 2015 University of Lübeck
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * AUTHORS: Michael Schellenberger Costa: mschellenbergercosta@gmail.com
+ *
+ * Based on: A thalamocortical neural mass model of the EEG during NREM sleep and its response
+ * to auditory stimulation.
+ * M Schellenberger Costa, A Weigenand, H-VV Ngo, L Marshall, J Born, T Martinetz,
+ * JC Claussen.
+ * PLoS Computational Biology In Review (in review).
+ */
/****************************************************************************************************/
/* Functions of the cortical module */
diff --git a/Cortical_Column.h b/Cortical_Column.h
index bcfe2f0..bd8f92d 100644
--- a/Cortical_Column.h
+++ b/Cortical_Column.h
@@ -1,24 +1,32 @@
/*
-* Copyright (c) 2014 Michael Schellenberger Costa
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-* THE SOFTWARE.
-*/
+ * Copyright (c) 2015 University of Lübeck
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * AUTHORS: Michael Schellenberger Costa: mschellenbergercosta@gmail.com
+ *
+ * Based on: A thalamocortical neural mass model of the EEG during NREM sleep and its response
+ * to auditory stimulation.
+ * M Schellenberger Costa, A Weigenand, H-VV Ngo, L Marshall, J Born, T Martinetz,
+ * JC Claussen.
+ * PLoS Computational Biology In Review (in review).
+ */
/************************************************************************************************/
/* Header file of a cortical module */
diff --git a/Main.cpp b/Main.cpp
deleted file mode 100644
index c288b3e..0000000
--- a/Main.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
-* Copyright (c) 2014 Michael Schellenberger Costa
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-* THE SOFTWARE.
-*/
-
-/****************************************************************************************************/
-/* Main file for compilation tests */
-/* The Simulation requires the following boost libraries: Preprocessor */
-/* Random */
-/****************************************************************************************************/
-#include
-#include
-#include "Cortical_Column.h"
-#include "Thalamic_Column.h"
-#include "ODE.h"
-
-
-/****************************************************************************************************/
-/* Fixed simulation settings */
-/****************************************************************************************************/
-extern const int T = 30; /* Simulation length s */
-extern const int res = 1E4; /* Number of iteration steps per s */
-extern const int red = 1E2; /* Fraction of iterations that is saved */
-extern const double dt = 1E3/res; /* Duration of a iteration step in ms */
-extern const double h = sqrt(dt); /* Square root of dt for SRK iteration */
-/****************************************************************************************************/
-/* end */
-/****************************************************************************************************/
-
-
-/****************************************************************************************************/
-/* Main simulation routine */
-/****************************************************************************************************/
-int main(void) {
- /* Initializing the seeder */
- srand(time(0));
-
- /* Initialize the populations */
- Cortical_Column Cortex;
- Thalamic_Column Thalamus;
-
- /* Connect both modules */
- Cortex.get_Thalamus(Thalamus);
- Thalamus.get_Cortex(Cortex);
-
- /* Take the time of the simulation */
- time_t start,end;
- time (&start);
- /* Simulation */
- for (int t=0; t< T*res; ++t) {
- ODE (Cortex, Thalamus);
- }
-
- time (&end);
- /* Time consumed by the simulation */
- double dif = difftime(end,start);
- std::cout << "simulation done!\n";
- std::cout << "took " << dif << " seconds" << "\n";
- std::cout << "end\n";
-}
-/****************************************************************************************************/
-/* end */
-/****************************************************************************************************/
diff --git a/NM_TC.pro b/NM_TC.pro
new file mode 100644
index 0000000..43414a5
--- /dev/null
+++ b/NM_TC.pro
@@ -0,0 +1,21 @@
+TEMPLATE = app
+CONFIG += console
+CONFIG -= app_bundle
+CONFIG -= qt
+
+TARGET = TC.cpp
+
+SOURCES += Cortical_Column.cpp \
+ TC.cpp \
+ TC_mex.cpp \
+ Thalamic_Column.cpp
+
+HEADERS += Cortical_Column.h \
+ ODE.h \
+ saves.h \
+ Stimulation.h \
+ Thalamic_Column.h
+
+QMAKE_CXXFLAGS += -std=c++11 -O3
+
+SOURCES -= TC_mex.cpp
diff --git a/ODE.h b/ODE.h
index a659131..c17a319 100644
--- a/ODE.h
+++ b/ODE.h
@@ -1,24 +1,32 @@
/*
-* Copyright (c) 2014 Michael Schellenberger Costa
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-* THE SOFTWARE.
-*/
+ * Copyright (c) 2015 University of Lübeck
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * AUTHORS: Michael Schellenberger Costa: mschellenbergercosta@gmail.com
+ *
+ * Based on: A thalamocortical neural mass model of the EEG during NREM sleep and its response
+ * to auditory stimulation.
+ * M Schellenberger Costa, A Weigenand, H-VV Ngo, L Marshall, J Born, T Martinetz,
+ * JC Claussen.
+ * PLoS Computational Biology In Review (in review).
+ */
/****************************************************************************************************/
/* Implementation of the ODE solver */
diff --git a/Plots.m b/Plots.m
index c43fd57..6334f90 100644
--- a/Plots.m
+++ b/Plots.m
@@ -1,12 +1,12 @@
% mex command is given by:
-% mex CXXFLAGS="\$CXXFLAGS -std=c++11 -O3 -lgopm" TC.cpp Cortical_Column.cpp Thalamic_Column.cpp
+% mex CXXFLAGS="\$CXXFLAGS -std=c++11 -O3" TC_mex.cpp Cortical_Column.cpp Thalamic_Column.cpp
function Plots(type)
if nargin == 0
type = 2;
end
-%mex CXXFLAGS="\$CXXFLAGS -std=c++11 -O3 -lgopm" TC.cpp Cortical_Column.cpp Thalamic_Column.cpp
+%mex CXXFLAGS="\$CXXFLAGS -std=c++11 -O3" TC_mex.cpp Cortical_Column.cpp Thalamic_Column.cpp
if type == 1
Param_Cortex = [4.7; % sigma_e
@@ -46,7 +46,7 @@ function Plots(type)
T = 30; % duration of the simulation
-[Ve, Vt, Ca, ah, Marker_Stim] = TC(T, Param_Cortex, Param_Thalamus, Connectivity, var_stim);
+[Ve, Vt, Ca, ah, Marker_Stim] = TC_mex(T, Param_Cortex, Param_Thalamus, Connectivity, var_stim);
L = length(Vt);
timeaxis = linspace(0,T,L);
diff --git a/Stimulation.h b/Stimulation.h
index e372121..557b62a 100644
--- a/Stimulation.h
+++ b/Stimulation.h
@@ -1,24 +1,32 @@
/*
-* Copyright (c) 2014 Michael Schellenberger Costa
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-* THE SOFTWARE.
-*/
+ * Copyright (c) 2015 University of Lübeck
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * AUTHORS: Michael Schellenberger Costa: mschellenbergercosta@gmail.com
+ *
+ * Based on: A thalamocortical neural mass model of the EEG during NREM sleep and its response
+ * to auditory stimulation.
+ * M Schellenberger Costa, A Weigenand, H-VV Ngo, L Marshall, J Born, T Martinetz,
+ * JC Claussen.
+ * PLoS Computational Biology In Review (in review).
+ */
/****************************************************************************************************/
/* Implementation of the stimulation protocol */
@@ -44,7 +52,7 @@ class Stim {
/* Empty constructor for compiling */
Stim(void);
- /* Constructor with references and stimulation variables */
+ /* Constructor with references and stimulation variables */
Stim(Cortical_Column& C, Thalamic_Column& T, double* var)
{ Cortex = &C;
Thalamus = &T;
@@ -64,7 +72,7 @@ class Stim {
/* 0 == none */
/* 1 == semi-periodic */
/* 2 == phase dependent */
- int mode = 0;
+ int mode = 0;
/* Default values already in dt: E1==ms, E4==s */
/* Stimulation strength */
@@ -105,11 +113,11 @@ class Stim {
/* If a stimulation event has occurred and there is a minimal time (pause) until the next one */
bool stimulation_paused = false;
- /* If burst mode is enabled */
- bool burst_enabled = false;
+ /* If burst mode is enabled */
+ bool burst_enabled = false;
/* In case of bursted stimulation start the bursts */
- bool burst_started = true;
+ bool burst_started = true;
/* Length of a burst stimulus */
int burst_length = 10;
@@ -136,7 +144,7 @@ class Stim {
int count_pause = 0;
/* Old voltage value for minimum detection */
- double Ve_old = 0.0;
+ double Ve_old = 0.0;
/* Pointer to columns */
Cortical_Column* Cortex;
@@ -186,8 +194,8 @@ void Stim::setup (double* var_stim) {
time_between_stimuli = (int) var_stim[6] * res / 1000;
/* Scale the length of burst_length and burst_ISI from ms to dt*/
- burst_length = (int) 2 * res / 1000;
- burst_ISI = (int) 28 * res / 1000;
+ burst_length = (int) 2 * res / 1000;
+ burst_ISI = (int) 28 * res / 1000;
/* If ISI is fixed do not create RNG */
if (mode == 1) {
@@ -292,15 +300,15 @@ void Stim::check_stim (int time) {
count_stimuli = 1;
}
}
- /* Update counter */
+ /* Update counter */
count_to_start++;
}
break;
}
- /* Actual stimulation protocols */
+ /* Actual stimulation protocols */
if(stimulation_started) {
- /* Wait to switch the stimulation off */
+ /* Wait to switch the stimulation off */
if(count_duration==duration) {
stimulation_started = false;
burst_started = true;
@@ -313,21 +321,21 @@ void Stim::check_stim (int time) {
count_bursts++;
/* Switch stimulation on and off wrt burst parameters */
- if(burst_enabled) {
- if(burst_started) {
- if(count_bursts%burst_length==0) {
- count_bursts = 0;
- burst_started = false;
- Thalamus->set_input(0.0);
- }
- } else {
- if(count_bursts%burst_ISI==0) {
- count_bursts = 0;
- burst_started = true;
- Thalamus->set_input(strength);
- }
- }
- }
+ if(burst_enabled) {
+ if(burst_started) {
+ if(count_bursts%burst_length==0) {
+ count_bursts = 0;
+ burst_started = false;
+ Thalamus->set_input(0.0);
+ }
+ } else {
+ if(count_bursts%burst_ISI==0) {
+ count_bursts = 0;
+ burst_started = true;
+ Thalamus->set_input(strength);
+ }
+ }
+ }
}
/* Wait if there is a pause between stimulation events */
@@ -343,9 +351,9 @@ void Stim::check_stim (int time) {
mxArray* Stim::get_marker(void) {
extern const int red;
mxArray* Marker = mxCreateDoubleMatrix(0, 0, mxREAL);
- mxSetM(Marker, 1);
- mxSetN(Marker, marker_stimulation.size());
- mxSetData(Marker, mxMalloc(sizeof(double)*marker_stimulation.size()));
+ mxSetM(Marker, 1);
+ mxSetN(Marker, marker_stimulation.size());
+ mxSetData(Marker, mxMalloc(sizeof(double)*marker_stimulation.size()));
double* Pr_Marker = mxGetPr(Marker);
for(unsigned i=0; i
#include
-#include "mex.h"
-#include "matrix.h"
#include "Cortical_Column.h"
#include "Thalamic_Column.h"
-#include "Stimulation.h"
-#include "saves.h"
#include "ODE.h"
+
/****************************************************************************************************/
/* Fixed simulation settings */
/****************************************************************************************************/
-extern const int onset = 20; /* Time until data is stored in s */
+extern const int T = 30; /* Simulation length s */
extern const int res = 1E4; /* Number of iteration steps per s */
-extern const int red = 1E2; /* Fraction of iterations that is saved */
+extern const int red = 1E2; /* Fraction of iterations that is saved */
extern const double dt = 1E3/res; /* Duration of a iteration step in ms */
extern const double h = sqrt(dt); /* Square root of dt for SRK iteration */
/****************************************************************************************************/
@@ -50,61 +53,34 @@ extern const double h = sqrt(dt); /* Square root of dt for SRK iteration *
/****************************************************************************************************/
-/* Simulation routine */
+/* Main simulation routine */
/****************************************************************************************************/
-void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
- /* Initialize the seeder */
- srand(time(NULL));
-
- /* Fetch inputs */
- const int T = (int) (mxGetScalar(prhs[0])); /* Duration of simulation in s */
- const int Time = (T+onset)*res; /* Total number of iteration steps */
- double* Param_Cortex = mxGetPr (prhs[1]); /* Parameters of cortical module */
- double* Param_Thalamus = mxGetPr (prhs[2]); /* Parameters of thalamic module */
- double* Connections = mxGetPr (prhs[3]); /* Connectivity values C <-> T */
- double* var_stim = mxGetPr (prhs[4]); /* Parameters of stimulation protocol */
+int main(void) {
+ /* Initializing the seeder */
+ srand(time(0));
/* Initialize the populations */
- Cortical_Column Cortex = Cortical_Column(Param_Cortex, Connections);
- Thalamic_Column Thalamus = Thalamic_Column(Param_Thalamus, Connections);
+ Cortical_Column Cortex;
+ Thalamic_Column Thalamus;
- /* Link both modules */
+ /* Connect both modules */
Cortex.get_Thalamus(Thalamus);
Thalamus.get_Cortex(Cortex);
- /* Initialize the stimulation protocol */
- Stim Stimulation(Cortex, Thalamus, var_stim);
-
- /* Create data containers */
- vector Data;
- Data.push_back(GetMexArray(1, T*res/red)); // Vt
- Data.push_back(GetMexArray(1, T*res/red)); // Vr
- Data.push_back(GetMexArray(1, T*res/red)); // Ca
- Data.push_back(GetMexArray(1, T*res/red)); // act_h
-
- /* Pointer to the actual data block */
- vector pData(Data.size(), NULL);
- for(unsigned i=0; i=onset*res && t%red==0){
- get_data(count, Cortex, Thalamus, pData);
- ++count;
- }
}
- /* Output of the simulation */
- /* Return the data containers */
- for(unsigned i=0; i
+#include "mex.h"
+#include "matrix.h"
+#include "Cortical_Column.h"
+#include "ODE.h"
+#include "saves.h"
+#include "Stimulation.h"
+#include "Thalamic_Column.h"
+mxArray* GetMexArray(int N, int M);
+
+/****************************************************************************************************/
+/* Fixed simulation settings */
+/****************************************************************************************************/
+extern const int onset = 20; /* Time until data is stored in s */
+extern const int res = 1E4; /* Number of iteration steps per s */
+extern const int red = 1E2; /* Fraction of iterations that is saved */
+extern const double dt = 1E3/res; /* Duration of a iteration step in ms */
+extern const double h = sqrt(dt); /* Square root of dt for SRK iteration */
+/****************************************************************************************************/
+/* end */
+/****************************************************************************************************/
+
+
+/****************************************************************************************************/
+/* Simulation routine */
+/****************************************************************************************************/
+void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
+ /* Initialize the seeder */
+ srand(time(NULL));
+
+ /* Fetch inputs */
+ const int T = (int) (mxGetScalar(prhs[0])); /* Duration of simulation in s */
+ const int Time = (T+onset)*res; /* Total number of iteration steps */
+ double* Param_Cortex = mxGetPr (prhs[1]); /* Parameters of cortical module */
+ double* Param_Thalamus = mxGetPr (prhs[2]); /* Parameters of thalamic module */
+ double* Connections = mxGetPr (prhs[3]); /* Connectivity values C <-> T */
+ double* var_stim = mxGetPr (prhs[4]); /* Parameters of stimulation protocol */
+
+ /* Initialize the populations */
+ Cortical_Column Cortex = Cortical_Column(Param_Cortex, Connections);
+ Thalamic_Column Thalamus = Thalamic_Column(Param_Thalamus, Connections);
+
+ /* Link both modules */
+ Cortex.get_Thalamus(Thalamus);
+ Thalamus.get_Cortex(Cortex);
+
+ /* Initialize the stimulation protocol */
+ Stim Stimulation(Cortex, Thalamus, var_stim);
+
+ /* Create data containers */
+ vector Data;
+ Data.push_back(GetMexArray(1, T*res/red)); // Vt
+ Data.push_back(GetMexArray(1, T*res/red)); // Vr
+ Data.push_back(GetMexArray(1, T*res/red)); // Ca
+ Data.push_back(GetMexArray(1, T*res/red)); // act_h
+
+ /* Pointer to the actual data block */
+ vector pData(Data.size(), NULL);
+ for(unsigned i=0; i=onset*res && t%red==0){
+ get_data(count, Cortex, Thalamus, pData);
+ ++count;
+ }
+ }
+
+ /* Output of the simulation */
+ /* Return the data containers */
+ for(unsigned i=0; i