Permalink
Browse files

General code cleanup.

Removed dependency from boost libraries.
  • Loading branch information...
1 parent 861ce23 commit f3c245c3cbb44cb08b54068a4e30fdfd228454dd @miscco committed Dec 29, 2015
Showing with 206 additions and 404 deletions.
  1. +0 −187 .cproject
  2. +0 −83 .project
  3. 0 saves.h → Data_Storage.h
  4. +20 −0 NM_Thalamus.pro
  5. +81 −0 Random_Stream.h
  6. +0 −17 T_model.pro
  7. +19 −18 Thalamic_Column.cpp
  8. +12 −21 Thalamic_Column.h
  9. +23 −53 Thalamus.cpp
  10. +51 −25 Main.cpp → Thalamus_mex.cpp
View
187 .cproject

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,83 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>Steyn-Ross</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
- <triggers>clean,full,incremental,</triggers>
- <arguments>
- <dictionary>
- <key>?name?</key>
- <value></value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.append_environment</key>
- <value>true</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.autoBuildTarget</key>
- <value>all</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.buildArguments</key>
- <value></value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.buildCommand</key>
- <value>make</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.buildLocation</key>
- <value>${workspace_loc:/Steyn-Ross/Debug}</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
- <value>clean</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.contents</key>
- <value>org.eclipse.cdt.make.core.activeConfigSettings</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
- <value>false</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
- <value>true</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.enableFullBuild</key>
- <value>true</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.fullBuildTarget</key>
- <value>all</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.stopOnError</key>
- <value>true</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
- <value>true</value>
- </dictionary>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
- <triggers>full,incremental,</triggers>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.cdt.core.cnature</nature>
- <nature>org.eclipse.cdt.core.ccnature</nature>
- <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
- <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
- </natures>
-</projectDescription>
File renamed without changes.
View
@@ -0,0 +1,20 @@
+TEMPLATE = app
+CONFIG += console
+CONFIG -= app_bundle
+CONFIG -= qt
+
+TARGET = Thalamus.cpp
+
+SOURCES += Thalamic_Column.cpp \
+ Thalamus_mex.cpp \
+ Thalamus.cpp
+
+HEADERS += Data_Storage.h \
+ ODE.h \
+ Random_Stream.h \
+ Stimulation.h \
+ Thalamic_Column.h
+
+QMAKE_CXXFLAGS += -std=c++11 -O3
+
+SOURCES -= Thalamus_mex.cpp
View
@@ -0,0 +1,81 @@
+/*
+ * 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 */
+/****************************************************************************************************/
+#pragma once
+#include <random>
+
+/****************************************************************************************************/
+/* Struct for normal distribution */
+/****************************************************************************************************/
+struct random_stream_normal
+{
+ /* Random number engine: Mersenne-Twister */
+ std::mt19937_64 mt;
+ /* Random number generator: Normal-distribution */
+ std::normal_distribution<double> norm_dist;
+
+ /* Constructors */
+ random_stream_normal(){}
+ random_stream_normal(double mean, double stddev)
+ : mt(rand()) , norm_dist(mean, stddev)
+ {}
+
+ /* Overwrites the function-call operator "( )" */
+ double operator( )(void) {
+ return norm_dist(mt);
+ }
+};
+/****************************************************************************************************/
+/* end */
+/****************************************************************************************************/
+
+/****************************************************************************************************/
+/* Struct for uniform int distribution */
+/****************************************************************************************************/
+struct random_stream_uniform_int
+{
+ /* Random number engine: Mersenne-Twister */
+ std::mt19937_64 mt;
+ /* Random number generator: Uniform integer-distribution */
+ std::uniform_int_distribution<> uniform_dist;
+
+ /* Constructors */
+ random_stream_uniform_int(){}
+ random_stream_uniform_int(double lower_bound, double upper_bound)
+ : mt(rand()) , uniform_dist(lower_bound, upper_bound)
+ {}
+
+ /* Overwrites the function-call operator "( )" */
+ double operator( )(void) {
+ return uniform_dist(mt);
+ }
+};
+/****************************************************************************************************/
+/* end */
+/****************************************************************************************************/
View
@@ -1,17 +0,0 @@
-TEMPLATE = app
-CONFIG += console
-CONFIG -= app_bundle
-CONFIG -= qt
-
-SOURCES += Main.cpp \
- Thalamic_Column.cpp \
- Thalamus.cpp
-
-HEADERS += ODE.h \
- saves.h \
- Thalamic_Column.h \
- Stimulation.h
-
-QMAKE_CXXFLAGS += -std=c++11 -O3
-
-SOURCES -= Thalamus.cpp
View
@@ -46,8 +46,8 @@ void Thalamic_Column::set_RNG(void) {
/* Create RNG for each stream */
for (int i=0; i<N; ++i){
/* Add the RNG for I_{l} and I_{l,0}*/
- MTRands.push_back({ENG(rand()), DIST (0.0, dphi*dt)});
- MTRands.push_back({ENG(rand()), DIST (0.0, dt)});
+ MTRands.push_back(random_stream_normal(0.0, dphi*dt));
+ MTRands.push_back(random_stream_normal(0.0, dt));
/* Get the random number for the first iteration */
Rand_vars.push_back(MTRands[2*i]());
@@ -83,23 +83,23 @@ double Thalamic_Column::get_Qr (int N) const{
/****************************************************************************************************/
/* Excitatory input to TC population */
double Thalamic_Column::I_et (int N) const{
- double psi = y_tt[N]* (Vt[N]- E_AMPA);
+ double psi = y_et[N]* (Vt[N]- E_AMPA);
return psi;
}
/* Inhibitory input to TC population */
-double Thalamic_Column::I_it (int N) const{
+double Thalamic_Column::I_rt (int N) const{
double psi = y_rt[N]* (Vt[N]- E_GABA);
return psi;
}
/* Excitatory input to RE population */
double Thalamic_Column::I_er (int N) const{
- double psi = y_tr[N]* (Vr[N]- E_AMPA);
+ double psi = y_er[N]* (Vr[N]- E_AMPA);
return psi;
}
/* Inhibitory input to RE population */
-double Thalamic_Column::I_ir (int N) const{
+double Thalamic_Column::I_rr (int N) const{
double psi = y_rr[N]* (Vr[N]- E_GABA);
return psi;
}
@@ -168,7 +168,8 @@ double Thalamic_Column::tau_m_h (int N) const{
/* Instantaneous calcium binding onto messenger protein after Chen2012 */
double Thalamic_Column::P_h (int N) const{
- double P_h = k1 * pow(Ca[N], n_P)/(k1*pow(Ca[N], n_P)+k2);
+ /*double P_h = k1 * pow(Ca[N], n_P)/(k1*pow(Ca[N], n_P)+k2); */
+ double P_h = k1 * Ca[N]*Ca[N]*Ca[N]*Ca[N]/(k1*Ca[N]*Ca[N]*Ca[N]*Ca[N]+k2);
return P_h;
}
@@ -211,7 +212,7 @@ double Thalamic_Column::I_LK_r (int N) const{
/* T-type current of TC population */
double Thalamic_Column::I_T_t (int N) const{
- double I = g_T_t * pow(m_inf_T_t(N), 2) * h_T_t[N] * (Vt[N]- E_Ca);
+ double I = g_T_t * m_inf_T_t(N) * m_inf_T_t(N) * h_T_t[N] * (Vt[N]- E_Ca);
return I;
}
@@ -251,19 +252,19 @@ double Thalamic_Column::noise_aRK(int M) const{
/****************************************************************************************************/
void Thalamic_Column::set_RK (int N) {
extern const double dt;
- Vt [N+1] = Vt [0] + A[N]*dt*(-(I_L_t(N) + I_et(N) + I_it(N))/tau_t - (I_LK_t(N) + I_T_t(N) + I_h(N)));
- Vr [N+1] = Vr [0] + A[N]*dt*(-(I_L_r(N) + I_er(N) + I_ir(N))/tau_r - (I_LK_r(N) + I_T_r(N)));
+ Vt [N+1] = Vt [0] + A[N]*dt*(-(I_L_t(N) + I_et(N) + I_rt(N))/tau_t - (I_LK_t(N) + I_T_t(N) + I_h(N)));
+ Vr [N+1] = Vr [0] + A[N]*dt*(-(I_L_r(N) + I_er(N) + I_rr(N))/tau_r - (I_LK_r(N) + I_T_r(N)));
Ca [N+1] = Ca [0] + A[N]*dt*(alpha_Ca * I_T_t(N) - (Ca[N] - Ca_0)/tau_Ca);
h_T_t [N+1] = h_T_t[0] + A[N]*dt*(h_inf_T_t(N) - h_T_t[N])/tau_h_T_t(N);
h_T_r [N+1] = h_T_r[0] + A[N]*dt*(h_inf_T_r(N) - h_T_r[N])/tau_h_T_r(N);
m_h [N+1] = m_h [0] + A[N]*dt*((m_inf_h(N) * (1 - m_h2[N]) - m_h[N])/tau_m_h(N) - k3 * P_h(N) * m_h[N] + k4 * m_h2[N]);
m_h2 [N+1] = m_h2 [0] + A[N]*dt*(k3 * P_h(N) * m_h[N] - k4 * m_h2[N]);
- y_tt [N+1] = y_tt [0] + A[N]*dt*(x_tt[N]);
- y_tr [N+1] = y_tr [0] + A[N]*dt*(x_tr[N]);
+ y_et [N+1] = y_et [0] + A[N]*dt*(x_et[N]);
+ y_er [N+1] = y_er [0] + A[N]*dt*(x_er[N]);
y_rt [N+1] = y_rt [0] + A[N]*dt*(x_rt[N]);
y_rr [N+1] = y_rr [0] + A[N]*dt*(x_rr[N]);
- x_tt [N+1] = x_tt [0] + A[N]*dt*(pow(gamma_e, 2) * ( - y_tt[N]) - 2 * gamma_e * x_tt[N]) + noise_xRK(N,0);
- x_tr [N+1] = x_tr [0] + A[N]*dt*(pow(gamma_e, 2) * (N_tr * get_Qt(N) - y_tr[N]) - 2 * gamma_e * x_tr[N]);
+ x_et [N+1] = x_et [0] + A[N]*dt*(pow(gamma_e, 2) * ( - y_et[N]) - 2 * gamma_e * x_et[N]) + noise_xRK(N,0);
+ x_er [N+1] = x_er [0] + A[N]*dt*(pow(gamma_e, 2) * (N_tr * get_Qt(N) - y_er[N]) - 2 * gamma_e * x_er[N]);
x_rt [N+1] = x_rt [0] + A[N]*dt*(pow(gamma_i, 2) * (N_rt * get_Qr(N) - y_rt[N]) - 2 * gamma_i * x_rt[N]);
x_rr [N+1] = x_rr [0] + A[N]*dt*(pow(gamma_i, 2) * (N_rr * get_Qr(N) - y_rr[N]) - 2 * gamma_i * x_rr[N]);
}
@@ -279,12 +280,12 @@ void Thalamic_Column::add_RK(void) {
Vt [0] =(-3*Vt [0] + 2*Vt [1] + 4*Vt [2] + 2* Vt [3] + Vt [4])/6;
Vr [0] =(-3*Vr [0] + 2*Vr [1] + 4*Vr [2] + 2* Vr [3] + Vr [4])/6;
Ca [0] =(-3*Ca [0] + 2*Ca [1] + 4*Ca [2] + 2* Ca [3] + Ca [4])/6;
- y_tt [0] =(-3*y_tt [0] + 2*y_tt [1] + 4*y_tt [2] + 2* y_tt [3] + y_tt [4])/6;
- y_tr [0] =(-3*y_tr [0] + 2*y_tr [1] + 4*y_tr [2] + 2* y_tr [3] + y_tr [4])/6;
+ y_et [0] =(-3*y_et [0] + 2*y_et [1] + 4*y_et [2] + 2* y_et [3] + y_et [4])/6;
+ y_er [0] =(-3*y_er [0] + 2*y_er [1] + 4*y_er [2] + 2* y_er [3] + y_er [4])/6;
y_rt [0] =(-3*y_rt [0] + 2*y_rt [1] + 4*y_rt [2] + 2* y_rt [3] + y_rt [4])/6;
y_rr [0] =(-3*y_rr [0] + 2*y_rr [1] + 4*y_rr [2] + 2* y_rr [3] + y_rr [4])/6;
- x_tt [0] =(-3*x_tt [0] + 2*x_tt [1] + 4*x_tt [2] + 2* x_tt [3] + x_tt [4])/6 + noise_aRK(0);
- x_tr [0] =(-3*x_tr [0] + 2*x_tr [1] + 4*x_tr [2] + 2* x_tr [3] + x_tr [4])/6;
+ x_et [0] =(-3*x_et [0] + 2*x_et [1] + 4*x_et [2] + 2* x_et [3] + x_et [4])/6 + noise_aRK(0);
+ x_er [0] =(-3*x_er [0] + 2*x_er [1] + 4*x_er [2] + 2* x_er [3] + x_er [4])/6;
x_rt [0] =(-3*x_rt [0] + 2*x_rt [1] + 4*x_rt [2] + 2* x_rt [3] + x_rt [4])/6;
x_rr [0] =(-3*x_rr [0] + 2*x_rr [1] + 4*x_rr [2] + 2* x_rr [3] + x_rr [4])/6;
h_T_t [0] =(-3*h_T_t[0] + 2*h_T_t[1] + 4*h_T_t[2] + 2* h_T_t [3] + h_T_t [4])/6;
View
@@ -26,23 +26,10 @@
#pragma once
#include <cmath>
#include <vector>
-#include <boost/random/mersenne_twister.hpp>
-#include <boost/random/normal_distribution.hpp>
-#include <boost/random/variate_generator.hpp>
+#include "Random_Stream.h"
using std::vector;
/****************************************************************************************************/
-/* Typedefs for RNG */
-/****************************************************************************************************/
-typedef boost::mt11213b ENG; /* Mersenne Twister */
-typedef boost::normal_distribution<double> DIST; /* Normal Distribution */
-typedef boost::variate_generator<ENG,DIST> GEN; /* Variate generator */
-/****************************************************************************************************/
-/* end */
-/****************************************************************************************************/
-
-
-/****************************************************************************************************/
/* Macro for vector initialization */
/****************************************************************************************************/
#ifndef _INIT
@@ -80,9 +67,9 @@ class Thalamic_Column {
/* Synaptic currents */
double I_et (int) const;
- double I_it (int) const;
+ double I_rt (int) const;
double I_er (int) const;
- double I_ir (int) const;
+ double I_rr (int) const;
/* Activation functions */
double m_inf_T_t (int) const;
@@ -124,12 +111,12 @@ class Thalamic_Column {
vector<double> 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_tt = _INIT(0.0), /* PostSP from TC population to TC population */
- y_tr = _INIT(0.0), /* PostSP from TC population to RE 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_tt = _INIT(0.0), /* derivative of y_tt */
- x_tr = _INIT(0.0), /* derivative of y_tr */
+ 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 */
@@ -138,7 +125,7 @@ class Thalamic_Column {
m_h2 = _INIT(0.0); /* activation of h channel bound with protein */
/* Random number generators */
- vector<GEN> MTRands;
+ vector<random_stream_normal> MTRands;
/* Container for noise */
vector<double> Rand_vars;
@@ -224,6 +211,10 @@ class Thalamic_Column {
const double N_rt = 5;
const double N_rr = 30;
+ /* Parameters for SRK iteration */
+ const vector<double> A = {0.5, 0.5, 1.0, 1.0};
+ const vector<double> B = {0.75, 0.75, 0.0, 0.0};
+
friend class Stim;
};
/****************************************************************************************************/
Oops, something went wrong.

0 comments on commit f3c245c

Please sign in to comment.