Skip to content

Commit

Permalink
Remove old component tests
Browse files Browse the repository at this point in the history
* Deleted `jansen_rit_component_tests.jl`.
* Renamed `jansen_rit_component_tests_new_timing.jl` to `jansen_rit_component_tests.jl` (removing old examples in favor of updated blocks with ms timing defaults).
* Deleted `temp_test.jl`
* Deleted `jansen_rit_hemodynamic_tests.jl`
* Deleted `test/old_component_tests/*`. These were all old neural mass model tests from pre-`BloxConnector` days that I kept around just in case. Seem redundant now.
* @hstrey I think `test/ode_from_graph.jl` can be deleted - looks like old Jansen Rit code that we've incorporated elsewhere or removed entirely.
  • Loading branch information
agchesebro committed Jan 15, 2024
1 parent b428247 commit f32d74c
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 339 deletions.
60 changes: 28 additions & 32 deletions test/jansen_rit_component_tests.jl
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
"""
DEPRECATED
This file uses the old blocks before timing update to be consistent. Use jansen_rit_component_tests_new_timing.jl instead.
"""

using Neuroblox, DifferentialEquations, DataFrames, Test, Distributions, Statistics, LinearAlgebra, Graphs, MetaGraphs, Random

τ_factor = 1000 #needed because the old units were in seconds, and we need ms to be consistent

# Create Regions
@named Str = jansen_ritC=0.0022, H=20, λ=300, r=0.3)
@named GPe = jansen_ritC=0.04, H=20, λ=400, r=0.1)
@named STN = jansen_ritC=0.01, H=20, λ=500, r=0.1)
@named GPi = jansen_ritSC=0.014, H=20, λ=400, r=0.1)
@named Th = jansen_ritSC=0.002, H=10, λ=20, r=5)
@named EI = jansen_ritSC=0.01, H=20, λ=5, r=5)
@named PY = jansen_ritSC=0.001, H=20, λ=5, r=0.15)
@named II = jansen_ritSC=2.0, H=60, λ=5, r=5)
@named Str = jansen_ritC=0.0022*τ_factor, H=20, λ=300, r=0.3)
@named gpe = jansen_ritC=0.04*τ_factor, H=20, λ=400, r=0.1)
@named stn = jansen_ritC=0.01*τ_factor, H=20, λ=500, r=0.1)
@named gpi = jansen_ritSC=0.014*τ_factor, H=20, λ=400, r=0.1)
@named Th = jansen_ritSC=0.002*τ_factor, H=10, λ=20, r=5)
@named EI = jansen_ritSC=0.01*τ_factor, H=20, λ=5, r=5)
@named PY = jansen_ritSC=0.001*τ_factor, H=20, λ=5, r=0.15)
@named II = jansen_ritSC=2.0*τ_factor, H=60, λ=5, r=5)

# Connect Regions through Adjacency Matrix
blox = [Str, GPe, STN, GPi, Th, EI, PY, II]
blox = [Str, gpe, stn, gpi, Th, EI, PY, II]
sys = [s.odesystem for s in blox]
connect = [s.connector for s in blox]

Expand All @@ -34,10 +30,10 @@ adj_matrix_lin = [0 0 0 0 0 0 0 0;

@named CBGTC_Circuit_lin = LinearConnections(sys=sys, adj_matrix=adj_matrix_lin, connector=connect)

sim_dur = 10.0 # Simulate for 10 Seconds
sim_dur = 2000.0 # Simulate for 2 seconds
mysys = structural_simplify(CBGTC_Circuit_lin)
sol = simulate(mysys, [], (0.0, sim_dur), [], Vern7(); saveat=0.001)
@test sol[!, "GPi₊x(t)"][4] -0.48421810231972134
sol = simulate(mysys, [], (0.0, sim_dur), [], Vern7(); saveat=1)
@test sol[!, "gpi₊x(t)"][4] -2219.2560209502685 #updated to new value in ms

"""
Testing new Jansen-Rit blox
Expand All @@ -50,15 +46,15 @@ same thing as the old simulate call with AutoVern7(Rodas4() since there are no d
"""

# test new Jansen-Rit blox
@named Str = JansenRit=0.0022, H=20, λ=300, r=0.3)
@named GPe = JansenRit=0.04, cortical=false) # all default subcortical except τ
@named STN = JansenRit=0.01, H=20, λ=500, r=0.1)
@named GPi = JansenRit(cortical=false) # default parameters subcortical Jansen Rit blox
@named Th = JansenRit=0.002, H=10, λ=20, r=5)
@named EI = JansenRit=0.01, H=20, λ=5, r=5)
@named Str = JansenRit=0.0022*τ_factor, H=20, λ=300, r=0.3)
@named gpe = JansenRit=0.04*τ_factor, cortical=false) # all default subcortical except τ
@named stn = JansenRit=0.01*τ_factor, H=20, λ=500, r=0.1)
@named gpi = JansenRit(cortical=false) # default parameters subcortical Jansen Rit blox
@named Th = JansenRit=0.002*τ_factor, H=10, λ=20, r=5)
@named EI = JansenRit=0.01*τ_factor, H=20, λ=5, r=5)
@named PY = JansenRit(cortical=true) # default parameters cortical Jansen Rit blox
@named II = JansenRit=2.0, H=60, λ=5, r=5)
blox = [Str, GPe, STN, GPi, Th, EI, PY, II]
@named II = JansenRit=2.0*τ_factor, H=60, λ=5, r=5)
blox = [Str, gpe, stn, gpi, Th, EI, PY, II]

# test graphs
g = MetaDiGraph()
Expand Down Expand Up @@ -99,16 +95,16 @@ add_edge!(g, 8, 8, Dict(:weight => 3.3*C_Cor))

@named final_system = system_from_graph(g, params)
final_delays = graph_delays(g)
sim_dur = 10.0 # Simulate for 10 Seconds
sim_dur = 2000.0 # Simulate for 2 Seconds
final_system_sys = structural_simplify(final_system)
prob = DDEProblem(final_system_sys,
[],
(0.0, sim_dur),
constant_lags = final_delays)
alg = MethodOfSteps(Vern7())
sol_dde_no_delays = solve(prob, alg, saveat=0.001)
sol_dde_no_delays = solve(prob, alg, saveat=1)
sol2 = DataFrame(sol_dde_no_delays)
@test isapprox(sol2[!, "GPi₊x(t)"][500:1000], sol[!, "GPi₊x(t)"][500:1000], rtol=1e-8)
@test isapprox(sol2[!, "gpi₊x(t)"][500:1000], sol[!, "gpi₊x(t)"][500:1000], rtol=1e-8)


# Alternative version using adjacency matrix
Expand All @@ -118,13 +114,13 @@ create_adjacency_edges!(g2, adj_matrix_lin)

@named final_system = system_from_graph(g2, params)
final_delays = graph_delays(g2)
sim_dur = 600.0 # Simulate for 10 Seconds
sim_dur = 2000.0 # Simulate for 2 Seconds
final_system_sys = structural_simplify(final_system)
prob = DDEProblem(final_system_sys,
[],
(0.0, sim_dur),
constant_lags = final_delays)
alg = MethodOfSteps(Vern7())
sol_dde_no_delays = solve(prob, alg, saveat=0.001)
sol_dde_no_delays = solve(prob, alg, saveat=1)
sol3 = DataFrame(sol_dde_no_delays)
@test isapprox(sol3[!, "GPi₊x(t)"][500:1000], sol[!, "GPi₊x(t)"][500:1000], rtol=1e-8)
@test isapprox(sol3[!, "gpi₊x(t)"][500:1000], sol[!, "gpi₊x(t)"][500:1000], rtol=1e-8)
126 changes: 0 additions & 126 deletions test/jansen_rit_component_tests_new_timing.jl

This file was deleted.

43 changes: 0 additions & 43 deletions test/jansen_rit_hemodynamic_tests.jl

This file was deleted.

79 changes: 0 additions & 79 deletions test/old_component_tests/jansen_rit_tests.jl

This file was deleted.

21 changes: 0 additions & 21 deletions test/old_component_tests/larter_breakspear_tests.jl

This file was deleted.

Loading

0 comments on commit f32d74c

Please sign in to comment.