Skip to content
Snippets Groups Projects
Commit ace65739 authored by Maximilian Schmidt's avatar Maximilian Schmidt
Browse files

Fix calculation of stability matrix in Theory class, formatting in...

Fix calculation of stability matrix in Theory class, formatting in MultiAreaModel class, remove deprecated functions from analysis_helpers
parent 5f3fd04b
No related branches found
No related tags found
1 merge request!1Add all necessary files for the multi-area model
...@@ -327,45 +327,6 @@ Analysis functions ...@@ -327,45 +327,6 @@ Analysis functions
""" """
def online_hist(fname, tmin, tmax, resolution=1.):
"""
Compute spike histogram from gdf file by reading line after line.
Avoids reading in the entire file first, which makes it more suitable
for very large spike files.
Parameters
----------
fname : string
Name of file to be read.
tmin : float
Minimal time for the calculation of the histogram.
tmax : float
Maximal time for the calculation of the histogram.
resolution : float, optional
Bin width of the histogram. Defaults to 1 ms.
Returns
-------
bins : numpy.ndarray
Array containing the left edges of the histogram bins
valyes : numpy.ndarray
Array containing the population rate value in each bin
"""
gdf_file = open(fname, 'r')
bins = np.arange(tmin, tmax + resolution, resolution) + resolution / 2.
vals = np.zeros_like(bins)
current_bin_index = 0
for l in gdf_file:
data = l.split()
if np.logical_and(float(data[1]) > tmin, float(data[1]) < tmax):
while float(data[1]) >= bins[current_bin_index + 1]:
current_bin_index += 1
vals[current_bin_index] += 1
elif float(data[1]) > tmax:
break
return bins[:-1], vals[:-1] / (resolution / 1000.)
def pop_rate(data_array, t_min, t_max, num_neur): def pop_rate(data_array, t_min, t_max, num_neur):
""" """
Calculates firing rate of a given array of spikes. Calculates firing rate of a given array of spikes.
......
...@@ -139,9 +139,9 @@ class MultiAreaModel: ...@@ -139,9 +139,9 @@ class MultiAreaModel:
raise NotImplementedError('Stabilization procedure has ' raise NotImplementedError('Stabilization procedure has '
'to be integrated.') 'to be integrated.')
elif isinstance(self.params['connection_params']['K_stable'], np.ndarray): elif isinstance(self.params['connection_params']['K_stable'], np.ndarray):
raise ValueError("Not supported. Please store the " raise NotImplementedError("Not supported. Please store the "
"matrix in a file and define the path to the file as " "matrix in a file and define the path to the file as "
"the parameter value.") "the parameter value.")
else: # Assume that the parameter defines a filename containing the matrix else: # Assume that the parameter defines a filename containing the matrix
K_stable = np.load(self.params['connection_params']['K_stable']) K_stable = np.load(self.params['connection_params']['K_stable'])
ext = {area: {pop: ind[area][pop]['external'] for pop in ext = {area: {pop: ind[area][pop]['external'] for pop in
......
...@@ -152,7 +152,7 @@ class Theory(): ...@@ -152,7 +152,7 @@ class Theory():
# Loop over all iterations of different initial conditions # Loop over all iterations of different initial conditions
for nsim in range(num_iter): for nsim in range(num_iter):
print("Iteration {}".format(nsim)) print('Iteration: {}'.format(nsim))
initial_rates = next(gen) initial_rates = next(gen)
for ii in range(dim): for ii in range(dim):
nest.SetStatus([neurons[ii]], {'rate': initial_rates[ii]}) nest.SetStatus([neurons[ii]], {'rate': initial_rates[ii]})
...@@ -344,7 +344,6 @@ class Theory(): ...@@ -344,7 +344,6 @@ class Theory():
N_post[:, ii] = N N_post[:, ii] = N
# Connection probabilities between populations # Connection probabilities between populations
C = 1. - (1.-1./(N_pre * N_post))**(K*N_post)
mu, sigma = self.mu_sigma(rates) mu, sigma = self.mu_sigma(rates)
if np.any(vector_filter is not None): if np.any(vector_filter is not None):
...@@ -370,17 +369,14 @@ class Theory(): ...@@ -370,17 +369,14 @@ class Theory():
slope_matrix = np.zeros_like(J) slope_matrix = np.zeros_like(J)
slope_sigma_matrix = np.zeros_like(J) slope_sigma_matrix = np.zeros_like(J)
for ii in range(N.size): for ii in range(N.size):
slope_matrix[:, ii] = slope slope_mu_matrix[:, ii] = d_nu_d_mu
slope_sigma_matrix[:, ii] = slope_sigma slope_sigma_matrix[:, ii] = d_nu_d_sigma
V = C*(1-C) G = self.NP['tau_m'] * 1e-3 * (slope_mu_matrix * K * J +
G = (self.NP['tau_m'] * 1e-3)**2 * (slope_matrix*J + slope_sigma_matrix * K * J**2)
slope_sigma_matrix*J**2)**2
G_N = N_pre * G
M = G_N * V
if full_output: if full_output:
return M, slope, slope_sigma, M, C, V, G_N, J, N_pre return G, d_nu_d_mu, d_nu_d_sigma
else: else:
return M return G
def lambda_max(self, rates, matrix_filter=None, def lambda_max(self, rates, matrix_filter=None,
vector_filter=None, full_output=False): vector_filter=None, full_output=False):
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment