MultiScaleTreeGraph.jl
Read, analyse, compute, write and convert MTG files
Install / Use
/learn @VEZY/MultiScaleTreeGraph.jlREADME
MultiScaleTreeGraph
The goal of MultiScaleTreeGraph.jl is to read, write, analyse and plot MTG (Multi-scale Tree Graph) files. These files describe the plant topology (i.e. structure) along with some attributes for each node (e.g. geometry, colors, state...).
The package is under intensive development and is in a very early version. The functions may heavily change from one version to another until a more stable version is released.
1. Installation
You can install the latest stable version of MultiScaleTreeGraph.jl using this command:
] add MultiScaleTreeGraph
Or if you prefer the development version:
using Pkg
Pkg.add(url="https://github.com/VEZY/MultiScaleTreeGraph.jl", rev="master")
2. Example
Read a simple MTG file:
using MultiScaleTreeGraph
file = joinpath(dirname(dirname(pathof(MultiScaleTreeGraph))),"test","files","simple_plant.mtg")
mtg = read_mtg(file)
Then you can compute new variables in the MTG using a DataFrame.jl's alike syntax:
transform!(mtg, :Length => (x -> x * 1000.) => :length_mm)
And then write the MTG back to disk:
write_mtg("test.mtg",mtg)
3. Conversion
You can expose an MTG as a Tables.jl source:
to_table(mtg)
to_table(mtg, symbol=:Leaf)
to_table(mtg, vars=[:Length, :Width])
If you use DataFrames.jl, DataFrame(mtg) works out of the box through the Tables.jl interface.
Or convert it to a MetaGraph:
MetaGraph(mtg)
4. Compatibility
We can plot the MTG using the companion package PlantGeom.jl.
MultiScaleTreeGraph.jl trees are compatible with the AbstractTrees.jl package, which means you can use all functions from that package, e.g.:
using AbstractTrees
node = get_node(mtg, 4)
nodevalue(node)
parent(node)
nextsibling(node)
prevsibling(nextsibling(node))
childrentype(node)
childtype(node)
childstatetype(node)
getdescendant(mtg, (1, 1, 1, 2))
collect(PreOrderDFS(mtg))
collect(PostOrderDFS(mtg))
collect(Leaves(mtg))
collect(nodevalues(PreOrderDFS(mtg)))
print_tree(mtg)
You can learn more about MultiScaleTreeGraph.jl in the documentation of the package.
3. Acknowledgments
Several tree-related functions in use are adapted from DataTrees.jl.
This package is heavily inspired by OpenAlea's MTG implementation in Python.
4. Similar packages
Related Skills
node-connect
342.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
342.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.7kCommit, push, and open a PR
