-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix/aln_input_index
- Loading branch information
Showing
25 changed files
with
643 additions
and
139 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .model import KuramotoModel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import numpy as np | ||
|
||
from neurolib.utils.collections import dotdict | ||
|
||
|
||
def loadDefaultParams(Cmat=None, Dmat=None, seed=None): | ||
"""Load default parameters for the Kuramoto Model model | ||
:param Cmat: Structural connectivity matrix (adjacency matrix) of coupling strengths, will be normalized to 1. If not given, then a single node simulation will be assumed, defaults to None | ||
:type Cmat: numpy.ndarray, optional | ||
:param Dmat: Fiber length matrix, will be used for computing the delay matrix together with the signal transmission speed parameter `signalV`, defaults to None | ||
:type Dmat: numpy.ndarray, optional | ||
:param seed: Seed for the random number generator, defaults to None | ||
:type seed: int, optional | ||
:return: A dictionary with the default parameters of the model | ||
:rtype: dict | ||
""" | ||
params = dotdict({}) | ||
|
||
### runtime parameters | ||
|
||
params.dt = 0.1 | ||
params.duration = 2000 | ||
|
||
np.random.seed(seed) | ||
params.seed = seed | ||
|
||
# model parameters | ||
params.N = 1 | ||
params.k = 2 | ||
|
||
# connectivity | ||
if Cmat is None: | ||
params.N = 1 | ||
params.Cmat = np.zeros((1, 1)) | ||
params.lengthMat = np.zeros((1, 1)) | ||
else: | ||
params.Cmat = Cmat.copy() # coupling matrix | ||
np.fill_diagonal(params.Cmat, 0) # no self connections | ||
params.N = len(params.Cmat) # override number of nodes | ||
params.lengthMat = Dmat | ||
|
||
params.omega = np.ones((params.N,)) * np.pi | ||
|
||
params.signalV = 20.0 | ||
|
||
# Ornstein-Uhlenbeck process | ||
params.tau_ou = 5.0 # ms Timescale of the Ornstein-Uhlenbeck noise process | ||
params.sigma_ou = 0.0 # 1/ms/sqrt(ms) noise intensity | ||
|
||
# init values | ||
params.theta_init = np.random.uniform(low=0, high=2*np.pi, size=(params.N, 1)) | ||
|
||
# Ornstein-Uhlenbeck process | ||
params.theta_ou = np.zeros((params.N,)) | ||
|
||
# external input | ||
params.theta_ext = np.zeros((params.N,)) | ||
|
||
return params | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from . import loadDefaultParams as dp | ||
from . import timeIntegration as ti | ||
|
||
from neurolib.models.model import Model | ||
|
||
|
||
class KuramotoModel(Model): | ||
""" | ||
Kuramoto Model | ||
Based on: | ||
Kuramoto, Yoshiki (1975). H. Araki (ed.). Lecture Notes in Physics, International Symposium on Mathematical Problems in Theoretical Physics. | ||
""" | ||
|
||
name = "kuramoto" | ||
description = "Kuramoto Model" | ||
|
||
init_vars = ['theta_init', 'theta_ou'] | ||
state_vars = ['theta', 'theta_ou'] | ||
output_vars = ['theta'] | ||
default_output = 'theta' | ||
input_vars = ['theta_ext'] | ||
default_input = 'theta_ext' | ||
|
||
def __init__(self, params=None, Cmat=None, Dmat=None, seed=None): | ||
self.Cmat = Cmat | ||
self.Dmat = Dmat | ||
self.seed = seed | ||
|
||
integration = ti.timeIntegration | ||
|
||
if params is None: | ||
params = dp.loadDefaultParams(Cmat=self.Cmat, Dmat=self.Dmat, seed=self.seed) | ||
|
||
super().__init__(params=params, integration=integration) |
Oops, something went wrong.