Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LarvaTagger.jl
Manage
Activity
Members
Labels
Plan
Issues
24
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nyx
LarvaTagger.jl
Commits
f0524fe6
Commit
f0524fe6
authored
3 years ago
by
François LAURENT
Browse files
Options
Downloads
Patches
Plain Diff
minor refacto
parent
178fe0d8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#73405
failed with stage
in 37 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
README.md
+1
-1
1 addition, 1 deletion
README.md
src/LarvaTagger.jl
+5
-20
5 additions, 20 deletions
src/LarvaTagger.jl
src/players.jl
+5
-0
5 additions, 0 deletions
src/players.jl
src/plots.jl
+3
-2
3 additions, 2 deletions
src/plots.jl
src/viewers.jl
+55
-15
55 additions, 15 deletions
src/viewers.jl
with
69 additions
and
38 deletions
README.md
+
1
−
1
View file @
f0524fe6
...
...
@@ -11,7 +11,7 @@ To run `LarvaTagger.jl`, you will need `julia>=1.6` and a `trx.mat` file in a fr
## Install
In a fresh directory:
```
julia --project=. -e 'using Pkg; Pkg.add(["https://gitlab.pasteur.fr/nyx/planarlarvae.jl.git","https://gitlab.pasteur.fr/nyx/larvatagger.jl.git"])
julia --project=. -e 'using Pkg; Pkg.add(["https://gitlab.pasteur.fr/nyx/planarlarvae.jl.git","https://gitlab.pasteur.fr/nyx/larvatagger.jl.git"])
'
```
Take note of the location of your new virtual environment, associated with the local directory (
`--project=.`
).
...
...
This diff is collapsed.
Click to expand it.
src/LarvaTagger.jl
+
5
−
20
View file @
f0524fe6
...
...
@@ -9,7 +9,7 @@ using Statistics
using
Observables
using
Meshes
export
larvaviewer
export
larvaviewer
#, larvaeditor
include
(
"sources.jl"
)
include
(
"models.jl"
)
...
...
@@ -19,26 +19,11 @@ include("controllers.jl")
include
(
"viewers.jl"
)
function
larvaviewer
(
path
)
tag_lut
=
Dict
(
:
small_motion
=>
:
grey90
,
:
stop_large
=>
:
green
,
:
run_large
=>
:
black
,
:
cast_large
=>
:
red
,
:
hunch_large
=>
:
blue
,
:
back_large
=>
:
cyan
,
:
roll_large
=>
:
yellow
,
)
# read the data
datasources
=
loaddata
(
path
)
# simplify
_
,
data
=
first
(
datasources
[
:
trx
]
.
data
)
# preprocess
times
=
PlanarLarvae
.
times
(
data
)
model
=
[
LarvaModel
(
id
,
ts
,
tag_lut
,
times
)
for
(
id
,
ts
)
in
pairs
(
data
)]
# view
model
,
ctrl
=
load_trx_large
(
path
)
scene
=
Figure
()
larvaplayer!
(
scene
,
model
,
tag_lut
,
times
)
# main loop
# playercontrols must be called before larvaviewer!
scene
.
layout
[
2
,
1
]
=
playercontrols
(
scene
,
ctrl
.
player
)
larvaviewer!
(
scene
.
layout
[
1
,
1
],
model
,
ctrl
)
return
scene
end
...
...
This diff is collapsed.
Click to expand it.
src/players.jl
+
5
−
0
View file @
f0524fe6
...
...
@@ -104,6 +104,11 @@ gettime(controller::Animator, step::Int) = controller.times[step]
)
end
"""
playercontrols(gridpos, animator)
Important note: must be called _before_ `larvaviewer!`
"""
function
playercontrols
(
scene
,
controller
::
Animator
)
bind!
(
controller
,
scene
)
times
=
controller
.
times
...
...
This diff is collapsed.
Click to expand it.
src/plots.jl
+
3
−
2
View file @
f0524fe6
...
...
@@ -37,9 +37,10 @@ function Makie.plot!(larva::LarvaPlot{<:MinimalLarva})
return
larva
end
function
gettag
(
tag_lut
,
tags
,
default_color
)
function
gettag
(
tag_lut
,
state
,
default_color
)
haskey
(
state
,
:
tags
)
||
return
(
nothing
,
default_color
)
tags′
=
collect
(
keys
(
tag_lut
))
tags
=
tags′
∩
ta
gs
.
tags
tags
=
tags′
∩
s
ta
te
.
tags
if
isempty
(
tags
)
return
(
nothing
,
default_color
)
else
...
...
This diff is collapsed.
Click to expand it.
src/viewers.jl
+
55
−
15
View file @
f0524fe6
@recipe
(
LarvaViewer
)
do
scene
Theme
(
:
show_grid
=>
false
,
)
end
##
function
larvaplayer!
(
scene
,
model
,
tag_lut
,
times
)
ctrl
=
GeneralController
(
model
,
tag_lut
,
times
)
mainview
=
Axis
(
scene
.
layout
[
1
,
1
],
aspect
=
DataAspect
())
scene
.
layout
[
2
,
1
]
=
playercontrols
(
scene
,
ctrl
.
player
)
views
=
nothing
function
Makie.plot!
(
viewer
::
LarvaViewer
{
Tuple
{
Vector
{
<:
LarvaModel
},
<:
GeneralController
}})
throw
(
ErrorException
(
"use larvaviewer! instead"
))
end
function
larvaviewer!
(
view
,
model
,
ctrl
)
if
view
isa
Axis
# ok
elseif
view
isa
GridPosition
view
=
Axis
(
view
,
aspect
=
DataAspect
())
elseif
view
isa
Figure
view
=
Axis
(
view
.
layout
[
1
,
1
],
aspect
=
DataAspect
())
else
throw
(
ErrorException
(
"not implemented for view type
$
(typeof(view))"
))
end
childviews
=
nothing
for
larva
in
model
@debug
"initializing larva
$
(larva.id)"
plot
=
larvaplot!
(
main
view
,
larva
,
ctrl
)
plot
=
larvaplot!
(
view
,
larva
,
ctrl
)
# store
if
isnothing
(
views
)
views
=
Dict
{
LarvaID
,
typeof
(
plot
)}()
if
isnothing
(
child
views
)
child
views
=
Dict
{
LarvaID
,
typeof
(
plot
)}()
end
views
[
larva
.
id
]
=
plot
child
views
[
larva
.
id
]
=
plot
end
@debug
"all larvae ok"
setbounds!
(
main
view
,
ctrl
,
model
)
setbounds!
(
view
,
ctrl
,
model
)
@debug
"main view ok"
DataInspector
(
main
view
,
range
=
2
,
textsize
=
14
)
DataInspector
(
view
,
range
=
2
,
textsize
=
14
)
@debug
"inspector ok"
setmouseevents!
(
mainview
,
views
,
ctrl
)
setkeyboardevents!
(
mainview
,
views
,
ctrl
)
# initial state
timestep!
(
ctrl
,
1
)
setmouseevents!
(
view
,
childviews
,
ctrl
)
setkeyboardevents!
(
view
,
childviews
,
ctrl
)
@debug
"event handling ok"
#hidedecorations!(view)
return
(
view
=
view
,
childviews
=
childviews
)
end
function
load_trx_large
(
path
)
tag_lut
=
Dict
(
:
small_motion
=>
:
grey90
,
:
stop_large
=>
:
green
,
:
run_large
=>
:
black
,
:
cast_large
=>
:
red
,
:
hunch_large
=>
:
blue
,
:
back_large
=>
:
cyan
,
:
roll_large
=>
:
yellow
,
)
# read the data
datasources
=
loaddata
(
path
)
# simplify
_
,
data
=
first
(
datasources
[
:
trx
]
.
data
)
# preprocess
times
=
PlanarLarvae
.
times
(
data
)
model
=
[
LarvaModel
(
id
,
ts
,
tag_lut
,
times
)
for
(
id
,
ts
)
in
pairs
(
data
)]
#
ctrl
=
GeneralController
(
model
,
tag_lut
,
times
)
#
return
(
model
=
model
,
controller
=
ctrl
)
end
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment