diff --git a/Manifest.toml b/Manifest.toml index cfd7dc3f29a8222adc8d24d05b98c9e7e6bfb03e..b9b49267e0067bbfb7237a029a41692916656455 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -1,6 +1,6 @@ # This file is machine-generated - editing it directly is not advised -julia_version = "1.7.1" +julia_version = "1.7.0" manifest_format = "2.0" [[deps.AbstractFFTs]] @@ -864,11 +864,11 @@ version = "0.1.1" [[deps.PlanarLarvae]] deps = ["DelimitedFiles", "JSON3", "MAT", "Meshes", "OrderedCollections", "SHA", "StaticArrays", "StructTypes"] -git-tree-sha1 = "20a9e95162e6226283a7024ab2352f9d08822d4a" -repo-rev = "dev" +git-tree-sha1 = "d231f3b1d82d26c4d4ce6077db95ddeb2e8236f0" +repo-rev = "main" repo-url = "https://gitlab.pasteur.fr/nyx/planarlarvae.jl" uuid = "c2615984-ef14-4d40-b148-916c85b43307" -version = "0.4.0" +version = "0.5.0" [[deps.PlotUtils]] deps = ["ColorSchemes", "Colors", "Dates", "Printf", "Random", "Reexport", "Statistics"] diff --git a/Project.toml b/Project.toml index c6ee36b81e6758e58dde345cfa265c7c44d8157c..1065fe0451fa0df87b736929708f1fe57df28e07 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "LarvaTagger" uuid = "8b3b36f1-dfed-446e-8561-ea19fe966a4d" authors = ["François Laurent", "Institut Pasteur"] -version = "0.3.0" +version = "0.4.0" [deps] Colors = "5ae59095-9a9b-59fe-a467-6f913c188581" diff --git a/README.md b/README.md index fe95e78e241f4ecc91cf3f0af6c8e140d741edb6..eb4c88026285b2c37f4e0823e7905b771dd906af 100644 --- a/README.md +++ b/README.md @@ -9,43 +9,60 @@ To run `LarvaTagger.jl`, you will need [`julia>=1.6`](https://julialang.org/down An example install procedure can be found in `scripts/make_demontrator.sh`. ## Install -In a fresh directory: + ``` +git clone https://gitlab.pasteur.fr/nyx/larvatagger.jl LarvaTagger +cd LarvaTagger julia --project=. -e 'using Pkg; Pkg.instantiate()' ``` ## Run -In the same directory as above, launch the Julia interpreter: + +### Using the Julia interpreter + +In the `LarvaTagger` directory created above, launch the Julia interpreter: ``` julia --project=. ``` In the interpreter, to launch the editor, type: ``` -julia> using LarvaTagger; larvaeditor("path/to/file") +julia> using LarvaTagger; larvaeditor("path/to/data/file") ``` The first time the editor is loaded, it may take a while for a window in your webbrowser to open, and the data to be plotted. -The Firefox webbrowser showed better performance than Chrome-like webbrowsers. +The Firefox web browser showed better performance than Chrome-like browsers. + +To exit the interpreter, type `exit()` or press Ctrl+D. + +### Using the `larvatagger.jl` script -To exit the interpreter, type `exit()`. +The `LarvaTagger/scripts` directory contains a `larvatagger.jl` executable file. +To launch the editor, type: +``` +scripts/larvatagger.jl open path/to/data/file +``` ## Automatic tagging -To extend the editor with `MaggotUBA` automatic tagging, still in the same directory: +To extend the editor with `MaggotUBA` automatic tagging: ``` git clone https://gitlab.pasteur.fr/nyx/MaggotUBA-adapter MaggotUBA -b 20220418 cd MaggotUBA -poetry install +poetry install -vvv cd .. -julia --project=. ``` +To let *larvaeditor* know about MaggotUBA, in the Julia interpreter, type: The last command launches the Julia interpreter again. There, you can type: ``` -julia> using LarvaTagger; larvaeditor("path/to/file"; backend_directory=".") +julia> using LarvaTagger; larvaeditor("path/to/data/file"; backend_directory="path/to/MaggotUBA's/parent/directory") +``` +Similarly, to let *larvatagger.jl* know about MaggotUBA: +``` +scripts/larvatagger.jl open "path/to/data/file" --backends="path/to/MaggotUBA's/parent/directory" ``` -Note however that [`MaggotUBA-adapter`](https://gitlab.pasteur.fr/nyx/MaggotUBA-adapter) requires the actual [`MaggotUBA`](https://gitlab.pasteur.fr/les-larves/structured-temporal-convolution/-/tree/dev-branch) code that is not open access. +Note however that [`MaggotUBA-adapter`](https://gitlab.pasteur.fr/nyx/MaggotUBA-adapter) requires the actual [`MaggotUBA`](https://gitlab.pasteur.fr/les-larves/structured-temporal-convolution/-/tree/dev-branch) code that is not open access yet. As a consequence, it is likely the installation step fails. -`MaggotUBA` and a supervised variant will be released in the near future. +The `MaggotUBA` tagging core will be fully released in the near future. diff --git a/scripts/larvatagger.jl b/scripts/larvatagger.jl index e8b41522f4dbec4f172f0ff8b15acd82d4d2c3e3..4506d0ca54b434b8cdc0ee503d25ae9ec09e8513 100755 --- a/scripts/larvatagger.jl +++ b/scripts/larvatagger.jl @@ -37,6 +37,10 @@ function main() parsed_args = docopt(usage) if parsed_args["import"] infile = parsed_args["<input-path>"] + if !isfile(infile) + @error "File not found" $infile + return + end outfile = parsed_args["<output-file>"] kwargs = Dict{Symbol, Any}() framerate = parsed_args["--framerate"] @@ -52,11 +56,16 @@ function main() if isnothing(outfile) Datasets.write_json(stdout, run) else + outfile = joinpath(dirname(infile), outfile) Datasets.to_json_file(outfile, run) end elseif parsed_args["open"] verbose = !parsed_args["--quiet"] infile = parsed_args["<input-path>"] + if !isfile(infile) + @error "File not found" $infile + return + end if parsed_args["--viewer"] app = larvaviewer(infile) else @@ -81,7 +90,7 @@ function main() @info "Press Ctrl+D to kill the server" end elseif parsed_args["train"] - @error "not implemented yet" + @error "Not implemented yet" end end diff --git a/scripts/make_demonstrator.sh b/scripts/make_demonstrator.sh index e9cde1a6dc4b5e11aeceb6f3ab5e4548b45fef2b..bdc43a7ba4993e824c32b7c84b7e7da518b285a1 100755 --- a/scripts/make_demonstrator.sh +++ b/scripts/make_demonstrator.sh @@ -16,42 +16,52 @@ fi # make the `julia` command available on the commandline export PATH=~/.local/bin:$PATH # get LarvaTagger.jl source -git clone https://gitlab.pasteur.fr/nyx/larvatagger.jl LarvaTagger +# (the dev branch is used here for testing before release) +git clone https://gitlab.pasteur.fr/nyx/larvatagger.jl LarvaTagger -b dev cd LarvaTagger # install LarvaTagger.jl julia --project=. -e 'using Pkg; Pkg.instantiate()' +if ! [ -x ~/.local/bin/larvatagger.jl ]; then +pushd ~/.local/bin +ln -s ~/LarvaTagger/scripts/larvatagger.jl . +popd +fi # get MaggotUBA source and trained models - open-source part git clone https://gitlab.pasteur.fr/nyx/MaggotUBA-adapter MaggotUBA -b 20220418 cd MaggotUBA # install Poetry python3 -m pip install poetry -# copy MaggotUBA source - "firmware" part -cp -r /home/share/structured-temporal-convolution . -# install MaggotUBA -python3 -m poetry add ./structured-temporal-convolution +# install MaggotUBA; this step requires access to a private repo; +# for a new user with no ssh or gpg keys, this is done logging in with `ssh -A` instead of `su` python3 -m poetry install -cd .. +cd # copy sample data cp -r /home/share/t15 . -# autolaunch `larvaeditor` on starting `julia` -mkdir -p ~/.julia/config -cat <<"EOT" > ~/.julia/config/startup.jl -if endswith(pwd(), "LarvaTagger") -using JSServe -port = occursin("anzhou", pwd()) ? 9285 : 9286 -JSServe.configure_server!(listen_port=port) -using LarvaTagger -app = larvaeditor("t15/GMR_SS02113@UAS_Chrimson_Venus_X_0070/r_LED100_30s2x15s30s#n#n#n@100/20140918_170215/20140918_170215@GMR_SS02113@UAS_Chrimson_Venus_X_0070@t15@r_LED100_30s2x15s30s#n#n#n@100.spine"; backend_directory=".") -println("As soon as the `julia>` prompt appears below, in your web browser") -println("you can go to: http://127.0.0.1:$port/browser-display") -display(app) -end -EOT +example_file="$HOME/t15/GMR_SS02113@UAS_Chrimson_Venus_X_0070/r_LED100_30s2x15s30s#n#n#n@100/20140918_170215/20140918_170215@GMR_SS02113@UAS_Chrimson_Venus_X_0070@t15@r_LED100_30s2x15s30s#n#n#n@100.spine" # make a `larvatagger` command -if [ -z "$(grep 'alias larvatagger=' ~/.bash_aliases)" ]; then -echo "alias larvatagger='cd ~/LarvaTagger; julia --project=. --banner=no'" >> ~/.bash_aliases +if [ $USER = anzhou ]; then +# for user 1 +port=9285 +else +# for user 2 +port=9286 +fi +if ! [ -f ~/.bash_aliases ] || [ -z "$(grep 'alias larvatagger=' ~/.bash_aliases)" ]; then +echo "alias larvatagger='$HOME/LarvaTagger/scripts/larvatagger.jl open \"${example_file}\" --port=${port} --backends=\"$HOME/LarvaTagger\"'" >> ~/.bash_aliases fi # let the user know about the latter command on every login if [ -z "$(grep 'echo start the Nyx' ~/.bashrc)" ]; then -echo "echo start the Nyx tagging UI with command: larvatagger" >> ~/.bashrc +cat <<EOT >> ~/.bashrc +echo start the Nyx tagging UI with command: larvatagger +echo or, for a richer interface, type: larvatagger.jl +echo +echo more changes with v0.4: +echo \* no need to add \"/browser-display\" after http://localhost:$port +echo \* step forward/backward with the right/left arrow keys on your keyboard +echo \* simultaneously tag individual time steps with buttons at the bottom +echo +echo a few tips: +echo \* pan the larva view holding the right mouse button +echo \* to properly refresh the page, press Ctrl+F5 instead of F5 alone +EOT fi