From a3bfdaeaad81b9eeae393373bf9353a195e21b42 Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Mon, 1 Feb 2016 12:00:35 +0100 Subject: [PATCH] Updated the naming convention and switched to the Random_stream header --- Data_Storage.h | 75 +++++++----------- NM_Thalamus.pro | 16 ++-- Plots.m | 10 +-- Random_Stream.h | 51 ++++++------ Stimulation.h | 62 +++++++-------- Thalamic_Column.cpp | 223 +++++++++++++++++++++++++--------------------------- Thalamic_Column.h | 163 +++++++++++++++++++------------------- Thalamus.cpp | 85 ++++++++++---------- Thalamus_mex.cpp | 77 +++++++++++------- 9 files changed, 378 insertions(+), 384 deletions(-) diff --git a/Data_Storage.h b/Data_Storage.h index ed0d682..6ebed5a 100644 --- a/Data_Storage.h +++ b/Data_Storage.h @@ -1,32 +1,32 @@ /* -* Copyright (c) 2015 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. -* -* 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 Compuational Biology (in review) -*/ + * 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 for data storage */ @@ -37,26 +37,11 @@ /****************************************************************************************************/ /* Save data */ /****************************************************************************************************/ -inline void get_data(int counter, Thalamic_Column& Col, double* Vt, double* Vr, double* ah) { +void get_data(int counter, Thalamic_Column& Col, double* Vt, double* Vr, double* ah) { Vt [counter] = Col.Vt [0]; Vr [counter] = Col.Vr [0]; ah [counter] = Col.act_h (); } /****************************************************************************************************/ /* end */ -/****************************************************************************************************/ - - -/****************************************************************************************************/ -/* Create MATLAB data container */ -/****************************************************************************************************/ -mxArray* SetMexArray(int N, int M) { - mxArray* Array = mxCreateDoubleMatrix(0, 0, mxREAL); - mxSetM(Array, N); - mxSetN(Array, M); - mxSetData(Array, mxMalloc(sizeof(double)*M*N)); - return Array; -} -/****************************************************************************************************/ -/* end */ -/****************************************************************************************************/ +/****************************************************************************************************/ \ No newline at end of file diff --git a/NM_Thalamus.pro b/NM_Thalamus.pro index c1f904d..c3a1c12 100644 --- a/NM_Thalamus.pro +++ b/NM_Thalamus.pro @@ -3,17 +3,17 @@ CONFIG += console CONFIG -= app_bundle CONFIG -= qt -TARGET = Thalamus.cpp +TARGET = Thalamus.cpp SOURCES += Thalamic_Column.cpp \ - Thalamus_mex.cpp \ - Thalamus.cpp + Thalamus.cpp \ + Thalamus_mex.cpp -HEADERS += Data_Storage.h \ - ODE.h \ - Random_Stream.h \ - Stimulation.h \ - Thalamic_Column.h +HEADERS += ODE.h \ + Data_Storage.h \ + Random_Stream.h \ + Stimulation.h \ + Thalamic_Column.h QMAKE_CXXFLAGS += -std=c++11 -O3 diff --git a/Plots.m b/Plots.m index b8da657..affc4ed 100644 --- a/Plots.m +++ b/Plots.m @@ -1,11 +1,11 @@ % mex command is given by: -% mex CXXFLAGS="\$CXXFLAGS -std=c++11 -O3" Thalamus.cpp Thalamic_Column.cpp +% mex CXXFLAGS="\$CXXFLAGS -std=c++11 -O3" Thalamus_mex.cpp Thalamic_Column.cpp function Plots(T) if nargin == 0 - Con = [ 0.063; % g_h - 0.02; % g_LK_t + Con = [ 0.01; % g_h + 0.05; % g_LK 3; % N_tr 5; % N_rt 30]; % N_rr @@ -23,9 +23,9 @@ function Plots(T) 70; % duration of the stimulus in ms 5; % time between stimuli in s 1]; % time until stimuli after min in ms - T = 30; % duration of the simulation + T = 90; % duration of the simulation end -[Vt, Vr, ah] = Thalamus(T, Con, var_stim); +[Vt, Vr, ah] = Thalamus_mex(T, Con, var_stim); L = max(size(Vt)); timeaxis = linspace(0,T,L); diff --git a/Random_Stream.h b/Random_Stream.h index b4e7270..f5fb19a 100644 --- a/Random_Stream.h +++ b/Random_Stream.h @@ -1,32 +1,27 @@ /* -* Copyright (c) 2015 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. -* -* 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 Compuational Biology (in review) -*/ + * 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 + * Stefanie Gareis: gareis@inb.uni-luebeck.de + */ /****************************************************************************************************/ /* Random number streams */ diff --git a/Stimulation.h b/Stimulation.h index 39786b8..512cc3f 100644 --- a/Stimulation.h +++ b/Stimulation.h @@ -1,32 +1,32 @@ /* -* Copyright (c) 2015 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. -* -* 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 Compuational Biology (in review) -*/ + * 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 */ @@ -117,9 +117,9 @@ class Stim { /* Create MATLAB container for marker storage */ mxArray* get_marker(void) { 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 A = {0.5, 0.5, 1.0, 1.0}; -extern const vector B = {0.75, 0.75, 0.0, 0.0}; -/****************************************************************************************************/ -/* end */ -/****************************************************************************************************/ - - /****************************************************************************************************/ /* Initialization of RNG */ /****************************************************************************************************/ void Thalamic_Column::set_RNG(void) { - extern const double dt; - /* Number of independent random variables */ - int N = 1; - - /* Create RNG for each stream */ - for (int i=0; i Vt = _INIT(E_L_t), /* TC membrane voltage */ - Vr = _INIT(E_L_r), /* RE membrane voltage */ - Ca = _INIT(Ca_0), /* Calcium concentration of TC population */ - y_et = _INIT(0.0), /* PostSP from TC population to TC population */ - y_er = _INIT(0.0), /* PostSP from TC population to RE population */ - y_rt = _INIT(0.0), /* PostSP from RE population to TC population */ - y_rr = _INIT(0.0), /* PostSP from RE population to RE population */ - x_et = _INIT(0.0), /* derivative of y_tt */ - x_er = _INIT(0.0), /* derivative of y_tr */ - x_rt = _INIT(0.0), /* derivative of y_rt */ - x_rr = _INIT(0.0), /* derivative of y_rr */ - h_T_t = _INIT(0.0), /* inactivation of T channel */ - h_T_r = _INIT(0.0), /* inactivation of T channel */ - m_h = _INIT(0.0), /* activation of h channel */ - m_h2 = _INIT(0.0); /* activation of h channel bound with protein */ - - /* Random number generators */ - vector MTRands; - - /* Container for noise */ - vector Rand_vars; /* Declaration and Initialization of parameters */ /* Membrane time in ms */ @@ -156,27 +136,29 @@ class Thalamic_Column { const double sigma_r = 6; /* Scaling parameter for sigmoidal mapping (dimensionless) */ - const double C1 = (3.14159265/sqrt(3)); + const double C1 = (M_PI/sqrt(3)); /* PSP rise time in ms^-1 */ const double gamma_e = 70E-3; - const double gamma_r = 100E-3; + const double gamma_g = 100E-3; - /* Conductivities in mS/cm^-2 */ - /* Leak current */ - const double g_L_t = 1; - const double g_L_r = 1; + /* Conductivities */ + /* Leak in aU */ + const double g_L = 1.; - /* Potassium leak current */ - const double g_LK_t = 0.02; - const double g_LK_r = 0.02; + /* Synaptic conductivity in ms */ + const double g_AMPA = 1.; + const double g_GABA = 1.; - /* T current */ + /* Potassium leak current in mS/m^2 */ + const double g_LK = 0.02; + + /* T current in mS/m^2 */ const double g_T_t = 3; const double g_T_r = 2.3; - /* h current */ - const double g_h = 0.062; + /* h current in mS/m^2 */ + const double g_h = 0.051; /* Reversal potentials in mV */ /* Synaptic */ @@ -211,7 +193,7 @@ class Thalamic_Column { /* Noise parameters in ms^-1 */ const double mphi = 0E-3; - const double dphi = 120E-3; + const double dphi = 0E-3; double input = 0.0; /* Connectivities (dimensionless) */ @@ -219,11 +201,34 @@ class Thalamic_Column { const double N_rt = 5; const double N_rr = 30; - /* Parameters for SRK iteration */ - const vector A = {0.5, 0.5, 1.0, 1.0}; - const vector B = {0.75, 0.75, 0.0, 0.0}; - friend class Stim; + + /* Parameters for SRK4 iteration */ + const vector A = {0.5, 0.5, 1.0, 1.0}; + const vector B = {0.75, 0.75, 0.0, 0.0}; + + /* Random number generators */ + vector MTRands; + + /* Container for noise */ + vector Rand_vars; + + /* Population variables */ + vector Vt = _INIT(E_L_t), /* TC membrane voltage */ + Vr = _INIT(E_L_r), /* RE membrane voltage */ + Ca = _INIT(Ca_0), /* Calcium concentration of TC population */ + s_tt = _INIT(0.0), /* PostSP from TC population to TC population */ + s_tr = _INIT(0.0), /* PostSP from TC population to RE population */ + s_rt = _INIT(0.0), /* PostSP from RE population to TC population */ + s_rr = _INIT(0.0), /* PostSP from RE population to RE population */ + x_tt = _INIT(0.0), /* derivative of s_tt */ + x_tr = _INIT(0.0), /* derivative of s_tr */ + x_rt = _INIT(0.0), /* derivative of s_rt */ + x_rr = _INIT(0.0), /* derivative of s_rr */ + h_T_t = _INIT(0.0), /* inactivation of T channel */ + h_T_r = _INIT(0.0), /* inactivation of T channel */ + m_h = _INIT(0.0), /* activation of h channel */ + m_h2 = _INIT(0.0); /* activation of h channel bound with protein */ }; /****************************************************************************************************/ /* end */ diff --git a/Thalamus.cpp b/Thalamus.cpp index 49ca487..f55e2a1 100644 --- a/Thalamus.cpp +++ b/Thalamus.cpp @@ -1,35 +1,36 @@ /* -* Copyright (c) 2015 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. -* -* 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 Compuational Biology (in review) -*/ + * 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). + */ /****************************************************************************************************/ /* Main file for compilation tests */ +/* The Simulation requires the following boost libraries: Random */ /****************************************************************************************************/ #include #include @@ -53,23 +54,23 @@ extern const double h = sqrt(dt); /* squareroot of dt for SRK iteration */ /****************************************************************************************************/ int main(void) { /* Initialize the populations */ - Thalamic_Column Thalamus = Thalamic_Column(); + Thalamic_Column Thalamus = Thalamic_Column(); - /* Take the time of the simulation */ - timer start,end; + /* Take the time of the simulation */ + timer start,end; - /* Simulation */ - start = std::chrono::high_resolution_clock::now(); - for (int t=0; t< T*res; ++t) { - Thalamus.iterate_ODE(); - } - end = std::chrono::high_resolution_clock::now(); + /* Simulation */ + start = std::chrono::high_resolution_clock::now(); + for (int t=0; t< T*res; ++t) { + Thalamus.iterate_ODE(); + } + end = std::chrono::high_resolution_clock::now(); - /* Time consumed by the simulation */ - double dif = 1E-3*std::chrono::duration_cast( end - start ).count(); - std::cout << "simulation done!\n"; - std::cout << "took " << dif << " seconds" << "\n"; - std::cout << "end\n"; + /* Time consumed by the simulation */ + double dif = 1E-3*std::chrono::duration_cast( end - start ).count(); + std::cout << "simulation done!\n"; + std::cout << "took " << dif << " seconds" << "\n"; + std::cout << "end\n"; } /****************************************************************************************************/ /* end */ diff --git a/Thalamus_mex.cpp b/Thalamus_mex.cpp index ff2f1ab..639720b 100644 --- a/Thalamus_mex.cpp +++ b/Thalamus_mex.cpp @@ -1,48 +1,50 @@ /* -* Copyright (c) 2015 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. -* -* 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 Compuational Biology (in review) -*/ + * 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 simulation as MATLAB routine (mex compiler) */ /* mex command is given by: */ -/* mex CXXFLAGS="\$CXXFLAGS -std=gnu++0x -fpermissive" Thalamus_mex.cpp Thalamic_Column.cpp */ +/* mex CXXFLAGS="\$CXXFLAGS -std=c++11" Thalamus_mex.cpp Thalamic_Column.cpp */ +/* The Simulation requires the following boost libraries: Random */ /****************************************************************************************************/ #include "mex.h" #include "matrix.h" #include "Data_Storage.h" #include "Stimulation.h" +mxArray* SetMexArray(int N, int M); /****************************************************************************************************/ /* Fixed simulation settings */ /****************************************************************************************************/ extern const int onset = 15; /* time until data is stored in s */ -extern const int res = 1E4; /* number of iteration steps per s */ +extern const int res = 1E3; /* number of iteration steps per s */ extern const int red = res/100; /* number of iterations that is saved */ extern const double dt = 1E3/res; /* duration of a timestep in ms */ extern const double h = sqrt(dt); /* squareroot of dt for SRK iteration */ @@ -101,3 +103,18 @@ return; /****************************************************************************************************/ /* end */ /****************************************************************************************************/ + + +/****************************************************************************************************/ +/* Create MATLAB data container */ +/****************************************************************************************************/ +mxArray* SetMexArray(int N, int M) { + mxArray* Array = mxCreateDoubleMatrix(0, 0, mxREAL); + mxSetM(Array, N); + mxSetN(Array, M); + mxSetData(Array, mxMalloc(sizeof(double)*M*N)); + return Array; +} +/****************************************************************************************************/ +/* end */ +/****************************************************************************************************/