# neuronsim

The goal of `{neuronsim}`

is to simulate the dynamics of neuronal ensembles using the model of FREs and QIF neurons.

## Installation

The development version can be installed from GitHub with:

```
# install.packages("devtools")
devtools::install_github("aldomann/neuronsim")
```

## Examples

```
library(neuronsim)
init_state <- c(r = 0, v = -2)
params <- c(delta = 1, etabar = -5, J = 15)
times_seq <- seq(from = -10, to = 40, by = 0.001)
current <- constant_input(t, current = 3, t_start = 0, t_end = 30)
```

The macroscopic dynamics of neuronal ensembles can be described by solving the firing-rate equations (FREs):

```
fre_output <- solve_fre(
params = params,
init_state = init_state,
times = times_seq,
input = current,
method = "rk4"
)
```

The microscopic dynamics of neuronal ensembles can be described by running a QIF neurons simulation:

```
qif_output <- simulate_qif(
params = params,
init_state = init_state,
times = times_seq,
input = current(times_seq)
)
```

To plot the macroscopic and microscopic dynamics of the ensemble we can run:

```
plot_dynamics(
data = list(fre_output, qif_output$data),
raster_data = qif_output$raster
)
```