Models#
- class whobpyt.models.jansen_rit.jansen_rit.JansenRitModel(params: JansenRitParams, node_size=200, TRs_per_window=20, step_size=0.0001, output_size=64, tr=0.001, sc=array([[1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], ..., [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.]]), lm=array([[1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], ..., [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.]]), dist=array([[1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], ..., [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.]]), use_fit_gains=True, use_laplacian=True, use_fit_lfm=False)[source]#
A module for forward model (JansenRit) to simulate EEG signals
Methods
createIC(self, ver):
Creates the initial conditions for the model.
createDelayIC(self, ver):
Creates the initial conditions for the delays.
setModelParameters(self):
Sets the parameters of the model.
forward(input, noise_out, hx)
Forward pass for generating a number of EEG signals with current model parameters
- __init__(params: JansenRitParams, node_size=200, TRs_per_window=20, step_size=0.0001, output_size=64, tr=0.001, sc=array([[1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], ..., [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.]]), lm=array([[1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], ..., [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.]]), dist=array([[1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], ..., [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.]]), use_fit_gains=True, use_laplacian=True, use_fit_lfm=False)[source]#
- Parameters:
- node_size: int
Number of ROIs
- TRs_per_window: int # TODO: CHANGE THE NAME
Number of EEG signals to simulate
- step_size: float
Integration step for forward model
- output_sizeint
Number of EEG channels.
- trfloat # TODO: CHANGE THE NAME TO sampling_rate
Sampling rate of the simulated EEG signals
- sc: ndarray node_size x node_size float array
Structural connectivity
- lm: ndarray float array
Leadfield matrix from source space to EEG space
- dist: ndarray float array
Distance matrix
- use_fit_gains: bool
Flag for fitting gains. 1: fit, 0: not fit
- use_laplacian: bool
Flat for using laplacian. 1: yes, 0: no.
- use_fit_lfm: bool
Flag for fitting the leadfield matrix. 1: fit, 0: not fit
- params: ParamsJR
Model parameters object.
- createDelayIC(ver, delays_max=500, state_lb=-0.5, state_ub=0.5)[source]#
Creates the initial conditions for the delays.
- Parameters:
- verint
Initial condition version. (in the JR model, the version is not used. It is just for consistency with other models)
- Returns:
- torch.Tensor
Tensor of shape (node_size, delays_max) with random values between state_lb and state_ub.
- createIC(ver, state_lb=-0.5, state_ub=0.5)[source]#
Creates the initial conditions for the model.
- Parameters:
- verint # TODO: ADD MORE DESCRIPTION
Initial condition version. (in the JR model, the version is not used. It is just for consistency with other models)
- Returns:
- torch.Tensor
Tensor of shape (node_size, state_size) with random values between state_lb and state_ub.
- forward(external, hx, hE)[source]#
This function carries out the forward Euler integration method for the JR neural mass model, with time delays, connection gains, and external inputs considered. Each population (pyramidal, excitatory, inhibitory) in the network is modeled as a nonlinear second order system. The function updates the state of each neural population and computes the EEG signals at each time step.
- Parameters:
- externaltorch.Tensor
Input tensor of shape (batch_size, num_ROIs) representing the input to the model.
- hxOptional[torch.Tensor]
Optional tensor of shape (batch_size, state_size, num_ROIs) representing the initial hidden state.
- hEOptional[torch.Tensor]
Optional tensor of shape (batch_size, num_ROIs, delays_max) representing the initial delays.
- Returns:
- next_statedict
Dictionary containing the updated current state, EEG signals, and the history of each population’s current and voltage at each time step.
- hEtorch.Tensor
Tensor representing the updated history of the pyramidal population’s current.
- info()#
- setModelParameters()#
Sets the parameters of the model.