Skip to content
Snippets Groups Projects
Commit 0a1b2f24 authored by François  LAURENT's avatar François LAURENT
Browse files

implements #39 with 2 levels

parent ea08fead
No related branches found
No related tags found
No related merge requests found
Pipeline #82406 passed
...@@ -270,3 +270,13 @@ function medianlarvasize(larvae::Vector{LarvaModel}; n::Int=100) ...@@ -270,3 +270,13 @@ function medianlarvasize(larvae::Vector{LarvaModel}; n::Int=100)
end end
return median(sizes) return median(sizes)
end end
function simultaneouslarvae(larvae)
laststep = maximum([larva.alignedsteps[end] for larva in values(larvae)])
n = 0
for step in 1:20:laststep
n = max(n, count(larva -> larva.alignedsteps[1] <= step <= larva.alignedsteps[end],
values(larvae)))
end
return n
end
...@@ -67,7 +67,14 @@ function larvaviewer(controller; ...@@ -67,7 +67,14 @@ function larvaviewer(controller;
controller[:player] = player = timecontroller(times) controller[:player] = player = timecontroller(times)
controller[:larva] = larva = LarvaController(controller, model, tag_lut, player) controller[:larva] = larva = LarvaController(controller, model, tag_lut, player)
delayed_controller = slave(larva, PeriodicObservation(1.0))
n_simultaneous_larvae = simultaneouslarvae(model)
if 40 < n_simultaneous_larvae
@info "Refresh rate throttled to 1Hz" n_simultaneous_larvae
delayed_controller = slave(larva, PeriodicObservation(1.0))
else
delayed_controller = larva
end
on(getactivelarva(controller)) do id on(getactivelarva(controller)) do id
@info isnothing(id) ? "No active larva" : "Activating larva #$(id)" @info isnothing(id) ? "No active larva" : "Activating larva #$(id)"
......
...@@ -129,10 +129,15 @@ function AssayPlot(ctrl, larvae::DecoratedLarvae; size=(1000, 750)) ...@@ -129,10 +129,15 @@ function AssayPlot(ctrl, larvae::DecoratedLarvae; size=(1000, 750))
AssayPlot(ctrl, fig, ax, larvae, button) AssayPlot(ctrl, fig, ax, larvae, button)
end end
function AssayPlot(ctrl, larvae::Vector{LarvaModel}; kwargs...) function AssayPlot(ctrl, larvae::Vector{LarvaModel}; downsampling_threshold=1e5, kwargs...)
sample = downsampler() npoints = sum([length(larva.path) for larva in larvae])
if downsampling_threshold <= npoints
@info "Trajectory down-sampling active" npoints
sample = downsampler()
larvae = sample.(larvae)
end
plot = AssayPlot(ctrl, plot = AssayPlot(ctrl,
DecoratedLarvae(sample.(larvae), DecoratedLarvae(larvae,
gettags(ctrl), gettags(ctrl),
gettimestep(ctrl)); gettimestep(ctrl));
kwargs...) kwargs...)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment