Permalink
Browse files

Fixed a bug in the stimulation protocol regarding multiple stimuli.

Signed-off-by: Schellenberger <schellenberger@inb.uni-luebeck.de>
  • Loading branch information...
1 parent 790a3f1 commit 9705fb9f858c645a2aa33a710a3e745305bee432 @miscco committed Oct 1, 2014
Showing with 55 additions and 58 deletions.
  1. +29 −23 Plots.m
  2. +17 −26 Stimulation.h
  3. +9 −9 Thalamic_Column.h
View
52 Plots.m
@@ -31,21 +31,23 @@ function Plots(T)
% stimulation parameters
% first number is the mode of stimulation
% 0 == none
- % 1 == periodic
- % 2 == phase dependend up state
- % 3 == phase dependend down state
+ % 1 == semi-periodic
+ % 2 == phase dependend
- var_stim = [ 0; % mode of stimulation
- 60; % strength of the stimulus in Hz (spikes per second)
- 200; % duration of the stimulus in ms
- 5; % time between stimuli in s
- 300]; % time until stimuli after negativ peak in ms
+ var_stim = [ 2; % mode of stimulation
+ 25; % strength of the stimulus in Hz (spikes per second)
+ 120; % duration of the stimulus in ms
+ 5; % time between stimulation events in s (ISI)
+ 0; % range of ISI in s [ISI-range,ISI+range]
+ 2; % Number of stimuli per event
+ 950; % time between stimuli within a event in ms
+ 500]; % time until stimuli after minimum in ms
- T = 600; % duration of the simulation
+ T = 30; % duration of the simulation
end
-%[Ve, Vt, Marker_Stim] = TC(T, Param_Cortex_N2, Param_Thalamus_N2, Connectivity, var_stim);
-[Ve, Vt, Marker_Stim] = TC(T, Param_Cortex_N3, Param_Thalamus_N3, Connectivity, var_stim);
+[Ve, Vt, Marker_Stim] = TC(T, Param_Cortex_N2, Param_Thalamus_N2, Connectivity, var_stim);
+%[Ve, Vt, Marker_Stim] = TC(T, Param_Cortex_N3, Param_Thalamus_N3, Connectivity, var_stim);
L = max(size(Vt));
timeaxis = linspace(0,T,L);
@@ -55,22 +57,26 @@ function Plots(T)
title('Pyramidal membrane voltage'), xlabel('time in s'), ylabel('Ve in mV')
ylim([-80, -40])
% vertical line for markers
-hx1 = graph2d.constantline(Marker_Stim(2,:), 'color', 'black');
-hx2 = graph2d.constantline(Marker_Stim(1,:), 'color', 'red');
-changedependvar(hx1,'x');
+for i=1:var_stim(6)
+ hx = graph2d.constantline(Marker_Stim/1E2+(i-1)*var_stim(7)/1E3,'ydata', get(gca,'ylim'), 'color', 'black', 'LineStyle', ':');
+ changedependvar(hx,'x');
+end
+hx2 = graph2d.constantline((Marker_Stim/1E2 -var_stim(8)/1E3), 'color', 'red');
changedependvar(hx2,'x');
subplot(212), plot(timeaxis,Vt)
title('Thalamic relay membrane voltage'), xlabel('time in s'), ylabel('Vt in mV')
+ylim(get(gca,'ylim'));
% vertical line for markers
-hx = graph2d.constantline(Marker_Stim(2,:));
-changedependvar(hx,'x');
-
-[Pxx,f] = pwelch(Ve-mean(Ve),hamming(L/30), 4*L/T, 2048, L/T);
-n = find(f<=30, 1, 'last' );
-
-figure(2)
-plot(f(1:n),log(Pxx(1:n)))
-title('Powerspectrum with pwelch'), xlabel('frequency in Hz'), ylabel('Power (log)')
+for i=1:var_stim(6)
+ hx = graph2d.constantline(Marker_Stim/1E2+(i-1)*var_stim(7)/1E3,'ydata', get(gca,'ylim'), 'color', 'black', 'LineStyle', ':');
+ changedependvar(hx,'x');
+end
+% [Pxx,f] = pwelch(Ve-mean(Ve),hamming(L/30), 4*L/T, 2048, L/T);
+% n = find(f<=30, 1, 'last' );
+%
+% figure(2)
+% plot(f(1:n),log(Pxx(1:n)))
+% title('Powerspectrum with pwelch'), xlabel('frequency in Hz'), ylabel('Power (log)')
%save('Timeseries', 'Ve', 'Vt');
end
View
@@ -127,7 +127,6 @@ class Stim {
Thalamic_Column* Thalamus;
/* Data containers */
- vector<int> marker_minimum;
vector<int> marker_stimulation;
/* Random number generator in case of semi-periodic stimulation */
@@ -206,6 +205,11 @@ void Stim::check_stim (int time) {
stimulation_started = true;
Thalamus->set_input(strength);
+ /* Add marker for the first stimuli in the event */
+ if(count_stimuli == 1) {
+ marker_stimulation.push_back(time - onset_correction);
+ }
+
/* Check if multiple stimuli should be applied */
if (count_stimuli < number_of_stimuli) {
/* Update the timer with respect to time between stimuli */
@@ -217,14 +221,8 @@ void Stim::check_stim (int time) {
time_to_stimuli += (ISI_range==0)? ISI : Uniform_Distribution(Generator);
/* Reset the stimulus counter for next stimulation event */
- if (number_of_stimuli != 1) {
- count_stimuli = 1;
- }
+ count_stimuli = 1;
}
-
- /* Add marker */
- marker_minimum.push_back(0);
- marker_stimulation.push_back(time - onset_correction);
}
break;
@@ -242,10 +240,6 @@ void Stim::check_stim (int time) {
if(Cortex->Ve[0]>Ve_old) {
threshold_crossed = false;
minimum_found = true;
- /* add one marker for every stimuli in the event */
- for(int i=0; i<number_of_stimuli; ++i) {
- marker_minimum.push_back(time - onset_correction);
- }
Ve_old = 0;
} else {
Ve_old = Cortex->Ve[0];
@@ -255,14 +249,18 @@ void Stim::check_stim (int time) {
/* Wait until the stimulation should start */
if(minimum_found) {
/* Start stimulation after time_to_stimuli has passed */
- if(count_to_start==time_to_stimuli) {
+ if(count_to_start==time_to_stimuli + (count_stimuli-1) * time_between_stimuli) {
stimulation_started = true;
Thalamus->set_input(strength);
+ /* Add marker for the first stimuli in the event */
+ if(count_stimuli == 1) {
+ marker_stimulation.push_back(time - onset_correction);
+ }
+
/* Check if multiple stimuli should be applied */
if (count_stimuli < number_of_stimuli) {
- /* Update the timer with respect to time between stimuli */
- time_to_stimuli += time_between_stimuli;
+ /* Update the number of stimuli */
count_stimuli++;
} else {
/* After last stimulus in event pause the stimulation */
@@ -271,15 +269,9 @@ void Stim::check_stim (int time) {
count_to_start = 0;
/* Reset the stimulus counter for next stimulation event */
- if (number_of_stimuli != 1) {
- count_stimuli = 1;
- }
+ count_stimuli = 1;
}
-
- /* Add marker */
- marker_stimulation.push_back(time - onset_correction);
}
-
count_to_start++;
}
break;
@@ -308,14 +300,13 @@ void Stim::check_stim (int time) {
mxArray* Stim::get_marker(void) {
extern const int red;
mxArray* Marker = mxCreateDoubleMatrix(0, 0, mxREAL);
- mxSetM(Marker, 2);
+ mxSetM(Marker, 1);
mxSetN(Marker, marker_stimulation.size());
- mxSetData(Marker, mxMalloc(sizeof(double)*2*marker_stimulation.size()));
+ mxSetData(Marker, mxMalloc(sizeof(double)*marker_stimulation.size()));
double* Pr_Marker = mxGetPr(Marker);
for(unsigned i=0; i<marker_stimulation.size(); ++i) {
/* Division by res transforms marker time from dt to sampling rate */
- Pr_Marker[0+i*2] = marker_minimum [i]/red;
- Pr_Marker[1+i*2] = marker_stimulation [i]/red;
+ Pr_Marker[i] = marker_stimulation [i]/red;
}
return Marker;
};
View
@@ -179,10 +179,10 @@ class Thalamic_Column {
/* T current */
const double g_T_t = 3;
- const double g_T_r = 2;
+ const double g_T_r = 2.3;
/* h current */
- const double g_h = 0.09;
+ const double g_h = 0.05;
/* Reversal potentials in mV */
/* Synaptic */
@@ -200,16 +200,16 @@ class Thalamic_Column {
const double E_Ca = 120;
/* I_h current */
- const double E_h = -43;
+ const double E_h = -40;
/* Calcium parameters */
- const double alpha_Ca = -50E-6; /* influx per spike in nmol */
+ const double alpha_Ca = -52E-6; /* influx per spike in nmol */
const double tau_Ca = 10; /* calcium time constant in ms */
- const double Ca_0 = 2E-4; /* resting concentration */
+ const double Ca_0 = 2.4E-4; /* resting concentration */
/* I_h activation parameters */
const double k1 = 2.5E7;
- const double k2 = 5E-4;
+ const double k2 = 4E-4;
const double k3 = 1E-1;
const double k4 = 1E-3;
const double n_P = 4;
@@ -222,9 +222,9 @@ class Thalamic_Column {
/* Connectivities (dimensionless) */
- const double N_tr = 6;
- const double N_rt = 5;
- const double N_rr = 100;
+ const double N_tr = 4;
+ const double N_rt = 4;
+ const double N_rr = 20;
const double N_et = 10;
const double N_er = 10;

0 comments on commit 9705fb9

Please sign in to comment.