Skip to content

Commit

Permalink
Making code consistent with SPM25 (#501)
Browse files Browse the repository at this point in the history
* updated CMC code (#474)

* switched from symbolic arrays to list of symbolic parameters. Needed to be able to set tunable flag for individual parameters of the array. Added untune! utility function to set tunable flag to false on list elements.

* added new approach to set tunable flag for the connection matrix also to the tutorial

* use generate_weight_param also in StimulusBlox and ObserverBlox connectors and set standard connection weight to non-tunable

* fixed and cleaned code

* minor changes

* update MTK compat

* added Project.toml to test

* fixed MTK compat once more

* added more packages to test environment needed in GraphDynamics tests

* remove test deps and unnecessary deps

* add Test to tect project

* remove Test dep from main Project

* add missing test deps

* add Statistics dep

* removed [extras] from Project.toml

* added [extras] again.

* fixed norm difference between MATLAB and Julia, MATLAB provides operator norms as default, thus use opnorm in Julia.

* fixed untune in tutorial
  • Loading branch information
david-hofmann committed Jan 3, 2025
1 parent 86c06db commit 69f5644
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions docs/src/tutorials/spectralDCM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ end

# ## Run the simulation and plot the results

# setup simulation of the model, time in milliseconds
# setup simulation of the model, time in seconds
tspan = (0.0, 512.0)
prob = SDEProblem(simmodel, [], tspan)
dt = 2 # 2 seconds (units are milliseconds) as measurement interval for fMRI
Expand Down Expand Up @@ -155,7 +155,7 @@ for (i, idx) in enumerate(CartesianIndices(A_prior))
end
# we avoid simplification of the model in order to exclude some parameters from fitting
@named fitmodel = system_from_graph(g, simplify=false)
# With the function `changetune` we can provide a dictionary of parameters whose tunable flag should be changed, for instance set to false to exclude them from the optimizatoin procedure.
# With the function `changetune`` we can provide a dictionary of parameters whose tunable flag should be changed, for instance set to false to exclude them from the optimizatoin procedure.
# For instance the the effective connections that are set to zero in the simulation:
untune = Dict(A[3] => false, A[7] => false)
fitmodel = changetune(fitmodel, untune) # 3 and 7 are not present in the simulation model
Expand Down
6 changes: 3 additions & 3 deletions src/datafitting/spDCM_VL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ function integration_step(dfdx, f, v, solenoid=false)
Q = Q/opnorm(Q, 2)/8;

f = f - Q*f;
dfdx = dfdx - Q*dfdx;
dfdx = dfdx - Q*dfdx;
end

# (expm(dfdx*t) - I)*inv(dfdx)*f ~~~ could also be done with expv (expv(t, dFdθθ, dFdθθ \ dFdθ) - dFdθθ \ dFdθ) but doesn't work with Dual.
Expand All @@ -320,9 +320,9 @@ function integration_step(dfdx, f, v, solenoid=false)
t = exp(v - spm_logdet(dfdx)/n)

if t > exp(16)
dx = - dfdx \ f # -inv(dfdx)*f
dx = - dfdx \ f # -inv(dfdx)*f
else
dx = (exp(t * dfdx) - I) * inv(dfdx)*f # (expm(dfdx*t) - I)*inv(dfdx)*f
dx = (exp(t * dfdx) - I) * inv(dfdx)*f # (expm(dfdx*t) - I)*inv(dfdx)*f
end

return dx
Expand Down

0 comments on commit 69f5644

Please sign in to comment.