goFRAME

package module
v0.0.0-...-3d86cc7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

README

goFRAME

License Go Report Card

a Go-based Framework for Rapid Analytical Modeling in Electrophysiology (FRAME). goFRAME is a simple directory that can greatly improve the efficiency and organization of electrophysiological model simulations.

Authors

Working Examples

1952 Hodgkin-Huxley Model of a Neuronal Action Potential

/examples/hodgkinhuxley

original paper : https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1392413/

1991 Luo-Rudy Model of a Ventricular Action Potential (LR1)

/examples/luorudy1991

original paper : https://pubmed.ncbi.nlm.nih.gov/1709839/

Usage

Download

Use the following command to download the repository:

go get -t github.com/mylesmax/goFRAME

Model Generation

It is recommended to read the steps below for a general understanding of the framework, but for a more streamlined experience, follow the template tutorial in /template.

Step 1: Define Parameters, Gates, and Currents

Parameter, gate, and current formulation is demonstrated in detail in the examples and template. However, here are some key notes:

Parameters

Parameters should be defined in the initial State, which is recommended to be generated in a func init(). The general form of a State is:

type State struct {
	V, Cm, RTF, Stim, T float64
	Index                int
	//Nernst Potentials
	E map[string]float64

	//conductances
	GBar map[string]float64

	//currents
	I map[string]float64

	//gates
	Gate map[string]float64

	//ion concentrations
	ConcOut map[string]float64
	ConcIn map[string]float64

	//misc
	Misc map[string]float64
}

For the initial State, set V=Vrest and Index=0.

Gates

If a gate is defined by alpha and beta values (GateAB), it should be defined as

goFRAME.GateAB{Alpha, Beta, ID}

where Alpha and Beta are func (V float64) float64 and ID is of type string.

If a gate is defined by an analytical/direct solution (GateDirect), it should be defined as

goFRAME.GateDirect{Ss, ID}

where Ss is func(V float64) float64.

In both cases, the ID field should be matched to the gate name (e.g., ID is "m" for gate m).

Currents

The params...interface{} is flexible to three parameters: params[0] is the current State, params[1] is an Out (i.e., all saved States, which is []State), and params[2] is an int that represents the index.

Step 2: Define Derivative Functions

Most models have similar calculations of dvdt, the change in membrane voltage, which is given in examples. For further customization, the params...interface{} is flexible to three parameters: params[0] is the current Solver, params[1] is an int that represents the index, and params[2] is a float64 that represents the sum of all currents.

Step 3: Simulate

Define a stimulus array Stims that contains as many Stim instances as needed:

type Stim struct{
	Start, End, Intensity float64
}

Define a TSet array that contains the simulation start time, simulation end time, and dt:

type TSet struct {
	Start, Dt, End float64
}

Then, generate an array to capture the evolution of the system, and save its initial value to be the initial State. For example:

out = []goFRAME.State{initial}

Now, define the solver:

type Solver struct {
	Out         Out
	Tset        TSet
	Stims       Stims
	GatesAB     []GateAB
	GatesDirect []GateDirect
	Currents    []Current
	ToIntegrate map[string]func(params ...interface{}) float64
	Method      string
}

For usable methods, see the bottom of the README. After the Solver has been generated, you may solve the system with

solver.Solve()

and write to excel with

WriteExcel(O Out, filePath string)
Usable Numerical Methods

"RK1" : Euler Method (Runge-Kutta 1)

License

MIT License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGateAB

func GetGateAB(s State, gAB GateAB, tset TSet) float64

func GetGateDirect

func GetGateDirect(s State, gDirect GateDirect) float64

func GetStim

func GetStim(t float64, s Stims, tset TSet) (stimulus float64)

GetStim : get the stimulus according to the time value

func WriteExcel

func WriteExcel(O Out, filePath string) error

Types

type Current

type Current struct {
	Current func(params ...interface{}) float64
	ID      string
}

type GateAB

type GateAB struct {
	Alpha func(State) float64
	Beta  func(State) float64
	ID    string
}

GateAB : if a gate is defined by alpha and beta values

func (GateAB) Ss

func (g GateAB) Ss(s State) float64

func (GateAB) Tau

func (g GateAB) Tau(s State) float64

type GateDirect

type GateDirect struct {
	Ss func(State) float64
	ID string
}

GateDirect : if a gate is defined by an analytical solution

type Out

type Out []State

type Solver

type Solver struct {
	Out         Out
	Tset        TSet
	Stims       Stims
	GatesAB     []GateAB
	GatesDirect []GateDirect
	Currents    []Current
	ToIntegrate map[string]func(params ...interface{}) float64
	Method      string
}

func (Solver) Solve

func (solver Solver) Solve() Out

type State

type State struct {
	V, Cm, RTF, Stim, T float64
	Index               int
	//Nernst Potentials
	E map[string]float64

	//conductances
	GBar map[string]float64

	//currents
	I map[string]float64

	//gates
	Gate map[string]float64

	//ion concentrations
	ConcOut map[string]float64
	ConcIn  map[string]float64

	//misc
	Misc map[string]float64
}

type Stim

type Stim struct {
	Start, End, Intensity float64
}

type Stims

type Stims []Stim

type TSet

type TSet struct {
	Start, Dt, End float64
}

func (TSet) GenerateTSpan

func (tsp TSet) GenerateTSpan() (tspan []float64)

GenerateTSpan : generate an array of the stiff time span

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL