Feature sequential sampling models - #139
Conversation
behinger
left a comment
There was a problem hiding this comment.
This is an intermediate review, I'm running out of time, but I didnt check everything yet
Wording DocString Co-authored-by: Benedikt Ehinger <benedikt.ehinger@vis.uni-stuttgart.de>
There was a problem hiding this comment.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
JuliaFormatter
[JuliaFormatter] reported by reviewdog 🐶
Line 370 in a0f9253
[JuliaFormatter] reported by reviewdog 🐶
UnfoldSim.jl/src/sequentialSamplingModelSimulation.jl
Lines 29 to 38 in a0f9253
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
UnfoldSim.jl/src/sequentialSamplingModelSimulation.jl
Lines 53 to 55 in a0f9253
[JuliaFormatter] reported by reviewdog 🐶
UnfoldSim.jl/src/sequentialSamplingModelSimulation.jl
Lines 82 to 84 in a0f9253
[JuliaFormatter] reported by reviewdog 🐶
UnfoldSim.jl/src/sequentialSamplingModelSimulation.jl
Lines 111 to 122 in a0f9253
[JuliaFormatter] reported by reviewdog 🐶
UnfoldSim.jl/src/sequentialSamplingModelSimulation.jl
Lines 124 to 125 in a0f9253
[JuliaFormatter] reported by reviewdog 🐶
UnfoldSim.jl/src/sequentialSamplingModelSimulation.jl
Lines 130 to 131 in a0f9253
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
UnfoldSim.jl/src/sequentialSamplingModelSimulation.jl
Lines 139 to 140 in a0f9253
[JuliaFormatter] reported by reviewdog 🐶
UnfoldSim.jl/src/sequentialSamplingModelSimulation.jl
Lines 142 to 143 in a0f9253
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
UnfoldSim.jl/test/component.jl
Lines 49 to 59 in a0f9253
[JuliaFormatter] reported by reviewdog 🐶
UnfoldSim.jl/test/component.jl
Lines 61 to 67 in a0f9253
[JuliaFormatter] reported by reviewdog 🐶
UnfoldSim.jl/test/component.jl
Lines 69 to 71 in a0f9253
[JuliaFormatter] reported by reviewdog 🐶
UnfoldSim.jl/test/component.jl
Lines 73 to 81 in a0f9253
[JuliaFormatter] reported by reviewdog 🐶
UnfoldSim.jl/test/component.jl
Lines 83 to 90 in a0f9253
[JuliaFormatter] reported by reviewdog 🐶
UnfoldSim.jl/test/component.jl
Line 93 in a0f9253
[JuliaFormatter] reported by reviewdog 🐶
Line 109 in a0f9253
[JuliaFormatter] reported by reviewdog 🐶
Lines 123 to 127 in a0f9253
[JuliaFormatter] reported by reviewdog 🐶
Lines 129 to 130 in a0f9253
[JuliaFormatter] reported by reviewdog 🐶
Line 132 in a0f9253
[JuliaFormatter] reported by reviewdog 🐶
Lines 143 to 146 in a0f9253
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
UnfoldSim.jl/test/sequentialSamplingModelSimulation.jl
Lines 10 to 11 in a0f9253
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
UnfoldSim.jl/test/sequentialSamplingModelSimulation.jl
Lines 32 to 35 in a0f9253
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
Co-authored-by: Benedikt Ehinger <benedikt.ehinger@vis.uni-stuttgart.de>
There was a problem hiding this comment.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
JuliaFormatter
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
UnfoldSim.jl/test/sequentialSamplingModelSimulation.jl
Lines 10 to 11 in ff43378
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
UnfoldSim.jl/test/sequentialSamplingModelSimulation.jl
Lines 32 to 35 in ff43378
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
Formatting Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Formatting Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
behinger
left a comment
There was a problem hiding this comment.
nicely done! The code is already in good shape.
I think either define our own UnfoldSequentialSamplingModel or use the SamplingModels.SSM1D maybe? I like the later approach even better, maybe other models can then easily be reused from SequentialSamplingModels.jl as well
Co-authored-by: Benedikt Ehinger <benedikt.ehinger@vis.uni-stuttgart.de>
behinger
left a comment
There was a problem hiding this comment.
very cool!! I will try to take this for a spin soon!
Co-authored-by: Benedikt Ehinger <benedikt.ehinger@vis.uni-stuttgart.de>
|
hey, I know you are official "out", but I'll come back to your offer at some point to still answer some questions ;-) Do you know why LBA needs vector of driftrates? That makes it a bit ugly, because I need to do: We definitely should try to catch that somehowedit |
|
Hey, no problem, you are always welcome to ask, but I may not answer so quickly. |
| """ | ||
| function KellyModel_simulate_cpp(rng, model::KellyModel, time_vec, Δt) | ||
| evidence = zeros(length(time_vec)) | ||
| evidence[time_vec.>=rand(rng, model.event_onset_distribution)] .= 1 |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| evidence[time_vec.>=rand(rng, model.event_onset_distribution)] .= 1 | |
| evidence[time_vec .>= rand(rng, model.event_onset_distribution)] .= 1 |
| """ | ||
| function SSM_Simulate(rng, model::KellyModel, sfreq, max_length) | ||
| Δt = 1 / sfreq | ||
| time_vec = 0:Δt:max_length*Δt |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| time_vec = 0:Δt:max_length*Δt | |
| time_vec = 0:Δt:(max_length*Δt) |
| ), | ||
| ) | ||
| # Deconvolution sucessfully removed the stimulus and response overlaps from our estimates, but it kept the drift-diffusion aspect nearly untouched. It is important to stress the "nearly", because depending on the `delay` parameters, this can potentially lead to problematic situation where it is unclear whether the drift activity should be assigned to S or R. In most realistic situations we found to be safe. | ||
| # Further note that the drift-diffusion amplitude can be reduced because it is split up between `S` and `R` events.` No newline at end of file |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| # Further note that the drift-diffusion amplitude can be reduced because it is split up between `S` and `R` events.` | |
| # Further note that the drift-diffusion amplitude can be reduced because it is split up between `S` and `R` events.` | |
| 360.1329203034039 | ||
| ``` | ||
| """ | ||
| function calculate_response_times_for_ssm(rng, component::DriftComponent, design::UnfoldSim.SubselectDesign) |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| function calculate_response_times_for_ssm(rng, component::DriftComponent, design::UnfoldSim.SubselectDesign) | |
| function calculate_response_times_for_ssm( | |
| rng, | |
| component::DriftComponent, | |
| design::UnfoldSim.SubselectDesign, | |
| ) |
| # Returns | ||
| - `simulate_interonset_distances`: function call. | ||
| """ | ||
| UnfoldSim.simulate_interonset_distances(rng, onset::AbstractOnset, design::AbstractDesign, components::AbstractComponent) = UnfoldSim.simulate_interonset_distances(rng,onset,design) |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| UnfoldSim.simulate_interonset_distances(rng, onset::AbstractOnset, design::AbstractDesign, components::AbstractComponent) = UnfoldSim.simulate_interonset_distances(rng,onset,design) | |
| UnfoldSim.simulate_interonset_distances( | |
| rng, | |
| onset::AbstractOnset, | |
| design::AbstractDesign, | |
| components::AbstractComponent, | |
| ) = UnfoldSim.simulate_interonset_distances(rng, onset, design) |
| # Returns | ||
| - `Vector{Int}`: the generated onsets for the drift components in the SequenceDesign. | ||
| """ | ||
| function UnfoldSim.simulate_interonset_distances(rng, onset::DriftOnset, design::AbstractDesign, components::AbstractComponent) |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| function UnfoldSim.simulate_interonset_distances(rng, onset::DriftOnset, design::AbstractDesign, components::AbstractComponent) | |
| function UnfoldSim.simulate_interonset_distances( | |
| rng, | |
| onset::DriftOnset, | |
| design::AbstractDesign, | |
| components::AbstractComponent, | |
| ) |
| function UnfoldSim.simulate_interonset_distances(rng, onset::Tuple, design::AbstractDesign, components::AbstractComponent) | ||
| return Int.(round.(reduce(.+, simulate_interonset_distances.(deepcopy(rng), onset, Ref(design), Ref(components))))) |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| function UnfoldSim.simulate_interonset_distances(rng, onset::Tuple, design::AbstractDesign, components::AbstractComponent) | |
| return Int.(round.(reduce(.+, simulate_interonset_distances.(deepcopy(rng), onset, Ref(design), Ref(components))))) | |
| function UnfoldSim.simulate_interonset_distances( | |
| rng, | |
| onset::Tuple, | |
| design::AbstractDesign, | |
| components::AbstractComponent, | |
| ) | |
| return Int.( | |
| round.( | |
| reduce( | |
| .+, | |
| simulate_interonset_distances.( | |
| deepcopy(rng), | |
| onset, | |
| Ref(design), | |
| Ref(components), | |
| ), | |
| ), | |
| ), | |
| ) |
| # Returns | ||
| - `Vector{Float64}`: the generated onsets for the end of a sequence in the SequenceDesign. | ||
| """ | ||
| function UnfoldSim.simulate_interonset_distances(rng, onset::Char, design::AbstractDesign, components::AbstractComponent) |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| function UnfoldSim.simulate_interonset_distances(rng, onset::Char, design::AbstractDesign, components::AbstractComponent) | |
| function UnfoldSim.simulate_interonset_distances( | |
| rng, | |
| onset::Char, | |
| design::AbstractDesign, | |
| components::AbstractComponent, | |
| ) |
| push!(final_onsets, onset_map[evt_k][onset_counter[evt_k]]) | ||
| onset_counter[evt_k] += 1 | ||
| end | ||
| final_onsets = vcat(final_onsets[end], final_onsets[1:end-1]) |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| final_onsets = vcat(final_onsets[end], final_onsets[1:end-1]) | |
| final_onsets = vcat(final_onsets[end], final_onsets[1:(end-1)]) |
| end | ||
| evidence = evidence[1:max_length] | ||
| return rt, evidence | ||
| end No newline at end of file |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| end | |
| end | |
| onset_counter = Dict() | ||
| for k in keys(onset.onset) | ||
| sub_design = UnfoldSim.SubselectDesign(simulation.design, k) | ||
| onsets_for_k = simulate_interonset_distances(rng, onset.onset[k], sub_design, simulation.components[k][1]) |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| onsets_for_k = simulate_interonset_distances(rng, onset.onset[k], sub_design, simulation.components[k][1]) | |
| onsets_for_k = simulate_interonset_distances( | |
| rng, | |
| onset.onset[k], | |
| sub_design, | |
| simulation.components[k][1], | |
| ) |
New Features:
Important Changes:
On Top I added unittests and docstrings for all new features
For better usability I have created two HowTo in the documentation: