骨架分析 (skan) 插件用户手册
Skeleton Analysis (skan) - User Manual
Dragonfly Prototype Apps · Skeleton Analysis (skan)...
版本 Version 1.0 · 2026-07-04
第一部分 中文手册
目录
1. 简介
2. 适用场景
3. 安装与启用
4. 运行环境与首次配置
5. 界面说明
6. 使用步骤
7. 参数说明
8. 输出结果
9. 常见问题与故障排除
10. 注意事项与已知限制
11. 参考资料
1. 简介
骨架分析 (skan) 是一个 Dragonfly 插件,用于把三维数据中的二值结构"细化"成一条一像素宽的中心线网络(即骨架),并对该网络进行定量测量。您在面板中选择一个输入对象——可以是一个 ROI(二值掩膜)、一个 MultiROI(按标签)、或者一个按强度阈值二值化的 Channel——然后点击运行。插件会在三维空间中把形状细化为中心线,并计算分支统计信息:分支数量、各分支长度、端点与连接点的类型、直线距离与弯曲度等。
结果会以分支表格的形式显示在面板中,可导出为 CSV;同时,计算得到的骨架会作为一个与原始数据对齐的新 uint8 Channel 发布回场景,便于您在三维视图中叠加查看原始结构与其中心线。
底层引擎与算法
本插件的核心计算不在 Dragonfly 自身的 Python 中运行,而是在一个专用的虚拟环境(venv)中通过子进程执行,并使用 JSON 文件进行进程间通信。所用的开源组件包括:
- skan(Skeleton Analysis,项目主页 skeleton-analysis.org):负责把骨架体素解析为分支图,并汇总分支统计(
skan.Skeleton+skan.summarize)。要求版本skan>=0.11。 - scikit-image(
skimage.morphology.skeletonize):对二值掩膜进行三维细化,得到中心线体素。要求版本scikit-image>=0.22。 - numpy(
>=1.24)、pandas(>=2.0)、networkx(>=3.0)、imageio(>=2.31):数值计算、表格构建、图结构与图像读写支持。
所有依赖均从默认的 PyPI 源安装,属于轻量级组件——本插件不需要 CUDA / PyTorch,也不需要 GPU。
许可证要点
skan、scikit-image、numpy、pandas、networkx、imageio 均为使用广泛的开源科学计算库,采用各自宽松的开源许可(如 BSD 类许可)。这些依赖在您首次点击"Setup Environment(设置环境)"时才从 PyPI 下载安装到插件自己的虚拟环境中,不会写入 Dragonfly 自带的 Python。具体许可条款以各上游项目发布的为准(见"参考资料")。
2. 适用场景
凡是需要量化网络状或纤维状结构本身(而不仅仅是其体积)的场合,本插件都适用。它把复杂结构简化成中心线网络后,再报告长度与连接关系,便于统计与比较。典型应用包括:
- 生命科学成像:测量血管、神经元或植物根系的分支长度与连接性。
- 材料科学与工业 CT:表征纤维、裂纹或孔隙通道网络的形态。
- 通用三维图像分析:分析丝状、树突状或其他分叉结构。
输入既可以是二维单层图像(单个切片),也可以是三维体数据;skeletonize 与 skan 的处理流程会自动适配二维或三维情况。
3. 安装与启用
本插件随 Prototype Labs & Apps 完整安装包(Full Package) 一起分发。安装步骤如下:
1. 将安装包压缩文件解压到任意较短的目录(如 C:\PL\),避免解压到过深的路径。
2. 双击运行 `Install_FullPackage.bat`。
3. 在弹出的对话框中选择核心安装模式(Fresh 全新安装 / Compatible 兼容安装),然后在插件列表中勾选 "Skeleton Analysis (skan)"。
4. 点击 Install,等待控制台完成安装。
5. 完全退出并重启 Dragonfly(菜单只在启动时被扫描)。
注意:所有插件在安装器中默认未勾选。您必须手动勾选 "Skeleton Analysis (skan)" 才会部署。仅轻量级菜单项默认开启。
重启后,插件出现在 Dragonfly 菜单的以下位置:
- Prototype Apps ▸ Skeleton Analysis (skan)...(归类于 "Measurements & Analysis" 分组)。点击后会打开一个可停靠 / 浮动的面板窗口。
以后修改勾选
如需以后启用或停用本插件,最方便的方式是在 Dragonfly 内操作:打开 Developer ▸ Prototype Labs... ▸ Menu Item Manager,在底部的 "Prototype Apps (Full Package)" 列表中找到本插件的勾选框——勾选=部署,取消=移除菜单项;修改后重启 Dragonfly 生效。停用从不会删除插件已搭建好的环境(venv),重新启用后立即可用。
此外,也可以随时重新运行安装器(它会记住上次的选择作为新的默认值);即使删除了解压出的文件夹,也可运行 %LOCALAPPDATA%\DragonflyPrototypeLabs\FullPackage\installer\Install_FullPackage.bat。
4. 运行环境与首次配置
本插件采用"环境随代码"(venv_in_code)的方式:计算所用的重型库不装入 Dragonfly 的 Python,而是构建在插件代码目录内的一个专用虚拟环境中。安装时不下载任何东西,只有在您首次点击"Setup Environment"时才联网构建环境。
Setup Environment(设置环境)做了什么
1. 在插件代码目录下创建一个虚拟环境(<code>\venv)。基础解释器默认使用 本机这套 Dragonfly 自带的 Python(Python_env\python.exe)——Dragonfly 2025.1 / 2027.1 均自带一套完整的 CPython 3.10,其标准库的 venv 与 ensurepip 可用,因此您无需额外安装 Python。
2. 在该 venv 内升级 pip / setuptools / wheel。
3. 从默认的 PyPI 源 pip install 安装 skan、scikit-image、numpy、pandas、networkx、imageio。
4. 运行一次导入自检,报告各库版本;成功后把 venv 的 Python 路径记录到插件配置中,面板的"Analysis venv python"字段随之填好。
下载体积、联网与硬件要求
项目 | 要求 |
联网 | 仅首次设置环境时需要(从 PyPI 下载依赖,约几百 MB)。之后的分析全部离线运行。 |
GPU | 不需要。全部为 CPU 计算。 |
WSL / 外部软件 | 不需要。默认在 Windows 上以子进程运行(面板另保留一个 "wsl" 运行模式选项,但本插件按 Windows 方式分发)。 |
令牌 / 账号 | 不需要任何 API token 或登录。 |
环境安装到哪些路径
- 虚拟环境:安装在已部署插件代码目录内的
venv\子目录(即...\pythonUserExtensions\GenericMenuItems\SkanAnalysis\venv),由面板的 "Setup Environment" 按钮就地构建。 - 任务输出目录(Job root):默认
C:\SkanJobs(可在 Setup 页修改)。每次运行会在其下生成中间文件(掩膜、骨架、状态、结果、CSV)。
失败时的替代方案
如果使用 Dragonfly 自带 Python 构建环境失败(例如个别环境缺少 ensurepip),可在 Setup 页的 "Base Python (build)" 字段中手动指定一个可用的 CPython 3.9+ 解释器,再重新点击 "Setup Environment"。例如:
C:\Python312\python.exe
(或在 PATH 中可用时填写: py -3.12)
提示:"Base Python" 字段留空时,插件优先使用当前这套 Dragonfly 自带的 Python;一旦填入路径或 py -3.12 之类的命令,则以您填写的为准。设置脚本会自检——若发现半成品的 venv(有 python 但 pip 不可用),会自动删除并重建。
5. 界面说明
面板顶部是一段蓝色说明文字,概述插件功能。主体是一个双分页控件(Setup 与 Analyze);面板底部有一行绿色的结果状态栏和一个只读的 Log(日志) 文本框。以下逐一说明两个分页的控件(与实际代码一致)。
5.1 Setup(设置)分页
控件 | 类型 | 默认值 / 说明 |
Analysis venv python | 文本框 | 分析所用虚拟环境的 Python 路径。通常由 "Setup Environment" 自动填写,一般无需手动修改。 |
Base Python (build) | 文本框 | 构建 venv 所用的基础解释器。留空 = 使用本机这套 Dragonfly 自带的 python.exe(推荐);也可填入一个路径或形如 |
Run mode | 下拉框 |
|
Job root | 文本框 | 任务输出根目录,默认 `C:\SkanJobs`。 |
Setup Environment (build venv + install skan) | 按钮 | 点击后开始构建 venv 并安装 skan 组件(首次约需数分钟)。 |
5.2 Analyze(分析)分页
Input(输入)分组:
控件 | 类型 | 默认值 / 说明 |
Input type | 下拉框 + Refresh 按钮 | 输入类型,三选一:ROI (binary) / MultiROI (per-label) / Channel (threshold),默认第一项 ROI。点击 Refresh 重新扫描当前场景中的对象。 |
Object | 下拉框 | 根据所选输入类型,列出场景中对应的对象(按标题显示)。 |
Channel threshold (>=) | 浮点数框 | 仅在输入类型为 Channel 时可用。以该阈值二值化:前景 = 强度 ≥ 阈值。默认 1.0,可设 4 位小数。 |
MultiROI label (0 = all) | 整数框 | 仅在输入类型为 MultiROI 时可用。指定单个标签;0 = 全部标签(显示为 "(all labels)")。默认 0。 |
Use voxel spacing for distances | 复选框 | 勾选后使用体素间距(spacing)换算真实物理长度,默认 勾选。 |
Publish skeleton as a new Channel | 复选框 | 勾选后把计算得到的骨架作为新 Channel 发布回场景,默认 勾选。 |
Result title | 文本框 | 骨架 Channel 的标题;留空则自动命名。 |
操作按钮行:
- Run Skeleton Analysis(蓝色按钮):开始骨架化并计算统计。
- Export CSV:把当前分支统计表导出为 CSV 文件(有结果后才可用)。
- Open Output Folder:打开本次运行的输出文件夹。
Branch statistics(分支统计)表格: 一个表格控件,显示每条分支的统计行(见"输出结果"章节的列说明)。
6. 使用步骤
6.1 首次使用:搭建环境
1. 打开 Prototype Apps ▸ Skeleton Analysis (skan)...。
2. 切换到 Setup 分页(通常保持 "Base Python" 为空以使用 Dragonfly 自带 Python)。
3. 确认已联网,点击 Setup Environment。日志区会显示构建与安装进度,完成后 "Analysis venv python" 字段会自动填好。
6.2 分析一个 ROI(二值掩膜)
1. 准备一个表示目标结构的二值 ROI(前景 = 非零体素)。
2. 在 Analyze 分页,把 Input type 设为 ROI (binary),必要时点 Refresh。
3. 在 Object 下拉框中选择该 ROI。
4. 根据需要设置 "Use voxel spacing" 与 "Publish skeleton" 复选框。
5. 点击 Run Skeleton Analysis。运行结束后,下方表格显示分支统计,状态栏显示分支数量与总长度;若勾选了发布,场景中会出现新的骨架 Channel。
6.3 分析一个 MultiROI(按标签)
1. 把 Input type 设为 MultiROI (per-label),在 Object 中选择目标 MultiROI。
2. 在 MultiROI label (0 = all) 中输入要分析的单个标签编号;若填 0(显示 "(all labels)"),则把 MultiROI 中所有非零标签合并为一个掩膜后分析。
3. 点击 Run Skeleton Analysis 查看结果。
6.4 分析一个 Channel(按阈值)
1. 把 Input type 设为 Channel (threshold),在 Object 中选择目标 Channel。
2. 在 Channel threshold (>=) 中设定阈值——强度大于等于该值的体素被视为前景。
3. 点击 Run Skeleton Analysis。若结果为空,请调整阈值后重试。
6.5 导出与查看
1. 点击 Export CSV,选择保存位置,即可把分支统计表导出为 CSV。
2. 点击 Open Output Folder 打开本次运行目录,其中包含 summary.csv、summary.json、skeleton.npy 等中间文件。
3. 在 Dragonfly 三维视图中,把新发布的骨架 Channel 与原始数据叠加显示,直观检查中心线是否与结构走向一致。
7. 参数说明
参数 | 默认值 | 说明 |
Input type(输入类型) | ROI (binary) | 选择输入对象类别:ROI(按非零二值化)/ MultiROI(按标签)/ Channel(按阈值)。 |
Channel threshold (>=) | 1.0 | Channel 输入的二值化阈值,前景 = 强度 ≥ 阈值。仅 Channel 类型有效,支持 4 位小数。 |
MultiROI label (0 = all) | 0(全部标签) | MultiROI 输入要分析的单个标签编号;0 表示合并所有非零标签。仅 MultiROI 类型有效。 |
Use voxel spacing for distances | 勾选 | 是否使用体素间距把分支长度换算为真实物理距离;取消则以体素为单位。 |
Publish skeleton as a new Channel | 勾选 | 是否把骨架作为新 uint8 Channel 发布回场景。 |
Result title(结果标题) | 空(自动命名) | 发布的骨架 Channel 标题。 |
Base Python (build) | 空(=Dragonfly 自带 Python) | 构建 venv 的基础解释器;留空使用 Dragonfly 自带 Python,或填一个 CPython 3.9+ 路径 / 命令。 |
Run mode(运行模式) | windows | 子进程运行方式;本插件按 Windows 分发,通常保持 windows。 |
Job root(任务根目录) | C:\SkanJobs | 存放每次运行中间文件与结果的根目录。 |
8. 输出结果
运行成功后,插件产出两类结果:面板中的分支统计表格,以及场景中新增的骨架 Channel。
8.1 分支统计表格
表格中的每一行代表骨架网络中的一条分支。实际列取决于所安装的 skan 版本,插件会把 skan 的原始列名归一化为稳定的显示名。常见列包括:
列名 | 含义 |
skeleton-id | 该分支所属的骨架(连通分量)编号。 |
branch-distance | 沿分支路径的长度(启用体素间距时为物理距离)。 |
branch-type | 分支类型代码(整数)。 |
branch-type-name | 分支类型的可读名称(见下表),由插件根据类型代码附加。 |
euclidean-distance | 分支两端点之间的直线距离。 |
tortuosity | 弯曲度 = 路径长度 / 直线距离(≥ 1;闭环取 1)。 |
src-coord-0/1/2、dst-coord-0/1/2 | 分支起点与终点的坐标(3D 为 z, y, x;2D 时缺少的坐标列会自动省略)。 |
分支类型代码与名称的对应关系:
代码 | 名称 | 含义 |
0 | endpoint-to-endpoint (isolated) | 端点到端点(孤立分支)。 |
1 | junction-to-endpoint | 连接点到端点。 |
2 | junction-to-junction | 连接点到连接点。 |
3 | isolated-cycle | 孤立环路。 |
状态栏还会给出汇总信息,如分支总数、总分支长度(total length)与平均分支长度(mean)。
8.2 骨架 Channel
若勾选 "Publish skeleton as a new Channel",插件会把骨架体素写成一个 uint8(0/1)Channel,并将其网格间距(spacing)与原点(origin)对齐到源对象,使其在三维视图中与原始结构精确叠加。可用 "Result title" 指定标题。
8.3 磁盘上的中间文件
每次运行会在任务目录(默认位于 C:\SkanJobs 之下)生成以下文件,可通过 Open Output Folder 打开:
summary.csv—— 分支统计表的 CSV 版本(与 Export CSV 内容一致)。summary.json—— 表头、行、原始列、记录与统计的 JSON。skeleton.npy—— 骨架掩膜的 numpy 数组。status.json/results.json—— 运行状态与结果(供面板轮询;出错时含完整 traceback)。
9. 常见问题与故障排除
问:点击 Run 提示 "analysis venv not set. Click 'Setup Environment' first." 怎么办?
答:说明尚未搭建分析环境。请先到 Setup 分页点击 Setup Environment 完成 venv 构建与依赖安装,"Analysis venv python" 字段填好后再运行。
问:Setup Environment 失败(提示没有 venv 模块或 venv 创建失败)怎么办?
答:多为基础解释器不满足要求。请在 Base Python (build) 中填入一个带标准库 venv + pip 的 CPython 3.9+(如 C:\Python312\python.exe),再重新点击 Setup Environment。设置脚本会自动删除半成品 venv 并重建。首次安装还需确认已联网。
问:结果提示 "the binarized mask is empty (no foreground voxels)" 或骨架为空,怎么办?
答:说明二值化后没有前景体素。对 Channel 输入请降低 Channel threshold;对 MultiROI 请确认 label 编号确实存在(或填 0 用全部标签);对 ROI 请确认其中确有非零体素。
问:Object 下拉框里看不到我的对象怎么办?
答:先确认 Input type 与对象类别一致(ROI / MultiROI / Channel),再点 Refresh 重新扫描场景。日志会显示找到的 ROI / MultiROI / Channel 数量。
问:测得的长度单位是什么?
答:勾选 "Use voxel spacing for distances" 时,长度按体素间距换算为物理单位(3D 轴序为 z, y, x);取消勾选时以体素数为单位。
问:处理很大的三维体数据时很慢或内存不足怎么办?
答:skeletonize 与 skan 在超大三维掩膜上会消耗较多内存与时间;若出现内存错误(错误类别 oom),建议先裁剪感兴趣区域或降低分辨率后再分析。
10. 注意事项与已知限制
- 计算在插件专用 venv 的子进程中运行,不占用 Dragonfly 的 Python;运行期间面板会显示 "Running…"。
- 首次设置环境需要联网;之后的分析可离线运行。
- 骨架化会把结构细化到一像素宽,较细的分支或噪声可能影响分支计数,必要时先对输入做去噪 / 形态学处理。
skan.summarize的列集合会随 skan 版本略有差异;插件已对多种列名做兼容映射,缺失的列会自动省略(例如二维输入缺少第三个坐标)。- MultiROI 选择单个标签时,只分析该标签;填 0 会把所有非零标签合并为一个掩膜一起骨架化。
- 菜单只在 Dragonfly 启动时扫描,启用 / 停用插件后需要重启一次。
11. 参考资料
- skan(Skeleton Analysis)项目主页:https://skeleton-analysis.org/
- scikit-image 文档(
skimage.morphology.skeletonize):https://scikit-image.org/ - NumPy:https://numpy.org/ ,pandas:https://pandas.pydata.org/ ,NetworkX:https://networkx.org/ ,imageio:https://imageio.readthedocs.io/
- Full Package 安装 / 启用 / 卸载说明:见随包
README.md(Prototype Labs & Apps — Full Package)。
Part II English Manual
Contents
1. Overview
2. Use Cases
3. Installation and Enabling
4. Runtime Environment and First-Run Setup
5. User Interface
6. Step-by-Step Usage
7. Parameter Reference
8. Outputs
9. FAQ and Troubleshooting
10. Notes and Known Limitations
11. References
1. Overview
Skeleton Analysis (skan) is a Dragonfly plugin that thins a binary structure in your 3D data down to a one-voxel-thick centerline network (a skeleton) and measures it. In the panel you pick an input — an ROI (binary mask), a MultiROI (per-label), or a Channel binarized by an intensity threshold — then click Run. The plugin thins the shape to its centerlines in 3D and computes branch statistics: the number of branches, each branch's length, endpoint/junction types, straight-line distance, tortuosity, and more.
Results appear as a branch table in the panel (exportable to CSV), and the computed skeleton is published back into the scene as a new uint8 Channel aligned to your original data, so you can overlay the source structure and its centerlines in 3D.
Underlying engine and algorithm
The heavy computation does NOT run inside Dragonfly's own Python. Instead it runs in a dedicated virtual environment (venv) as a subprocess, communicating over JSON files. The open-source components used are:
- skan (Skeleton Analysis, skeleton-analysis.org): parses skeleton voxels into a branch graph and summarizes branch statistics (
skan.Skeleton+skan.summarize). Requiresskan>=0.11. - scikit-image (
skimage.morphology.skeletonize): thins the binary mask in 3D to centerline voxels. Requiresscikit-image>=0.22. - numpy (
>=1.24), pandas (>=2.0), networkx (>=3.0), imageio (>=2.31): numerics, table building, graph structures, and image I/O.
All dependencies come from the default PyPI index and are lightweight — this plugin needs no CUDA / PyTorch and no GPU.
License notes
skan, scikit-image, numpy, pandas, networkx, and imageio are widely used open-source scientific libraries under their own permissive licenses (typically BSD-style). They are downloaded from PyPI only when you first click Setup Environment, and are installed into the plugin's own venv — never into Dragonfly's bundled Python. The authoritative license terms are those published by each upstream project (see References).
2. Use Cases
The plugin is useful anywhere you need to quantify a network- or fiber-like structure itself (not just its volume). It reduces a complex structure to a centerline network and then reports lengths and connectivity, which makes structures easy to compare statistically. Typical applications:
- Life-science imaging: measuring branch length and connectivity of blood vessels, neurons, or plant roots.
- Materials science and industrial CT: characterizing fiber, crack, or pore-channel networks.
- General 3D image analysis: analyzing filament, dendrite, or other branching structures.
Inputs may be a single 2D slice or a full 3D volume; the skeletonize and skan pipeline adapts automatically to 2D or 3D.
3. Installation and Enabling
This plugin ships with the Prototype Labs & Apps Full Package. To install:
1. Unzip the package into a short folder (e.g. C:\PL\); avoid very deep paths.
2. Double-click `Install_FullPackage.bat`.
3. In the dialog, pick a core install mode (Fresh or Compatible), then tick "Skeleton Analysis (skan)" in the plugin list.
4. Click Install and wait for the console to finish.
5. Quit Dragonfly completely and restart it (menus are scanned only at startup).
Note: all plugins are unchecked by default in the installer. You must tick "Skeleton Analysis (skan)" for it to be deployed. Only the lightweight menu items are on by default.
After the restart, the plugin appears in the Dragonfly menu here:
- Prototype Apps ▸ Skeleton Analysis (skan)... (grouped under "Measurements & Analysis"). Clicking it opens a dockable / floating panel window.
Changing your choices later
To enable or disable the plugin later, the easiest way is inside Dragonfly: open Developer ▸ Prototype Labs... ▸ Menu Item Manager and find this plugin's checkbox in the "Prototype Apps (Full Package)" list at the bottom — tick = deploy, untick = remove the menu entry; restart Dragonfly to apply. Disabling never deletes the plugin's built environment (venv); re-enabling is instant.
Alternatively, you can re-run the installer anytime (it remembers your previous choices as the new defaults). Even after deleting the unzipped folder, run %LOCALAPPDATA%\DragonflyPrototypeLabs\FullPackage\installer\Install_FullPackage.bat.
4. Runtime Environment and First-Run Setup
This plugin uses an "environment-in-code" (venv_in_code) approach: the heavy compute libraries are NOT installed into Dragonfly's Python but into a dedicated virtual environment inside the plugin's code folder. Nothing is downloaded at install time — the environment is built (with internet) only when you first click Setup Environment.
What Setup Environment does
1. Creates a virtual environment (<code>\venv) inside the plugin's code folder. The base interpreter defaults to this machine's own Dragonfly Python (Python_env\python.exe) — Dragonfly 2025.1 / 2027.1 both bundle a complete CPython 3.10 whose stdlib venv + ensurepip work, so you need no separate Python install.
2. Upgrades pip / setuptools / wheel inside that venv.
3. Runs pip install for skan, scikit-image, numpy, pandas, networkx, imageio from the default PyPI index.
4. Runs an import self-check and reports versions; on success it records the venv Python path to the plugin config and fills the panel's "Analysis venv python" field.
Download size, internet and hardware requirements
Item | Requirement |
Internet | Needed only for the first-time environment setup (downloading dependencies from PyPI, a few hundred MB). All later analysis runs offline. |
GPU | Not required. Everything is CPU-only. |
WSL / external software | Not required. Runs as a subprocess on Windows by default (the panel keeps a "wsl" run-mode option, but this plugin ships for Windows). |
Tokens / accounts | None. No API token or login required. |
Where the environment is installed
- Virtual environment: inside the deployed plugin code folder's
venv\subfolder (i.e....\pythonUserExtensions\GenericMenuItems\SkanAnalysis\venv), built in place by the panel's Setup Environment button. - Job root (output):
C:\SkanJobsby default (changeable on the Setup tab). Each run writes its intermediate files (mask, skeleton, status, results, CSV) beneath it.
Fallback when setup fails
If building the environment with Dragonfly's bundled Python fails (e.g. a particular install lacks ensurepip), enter a working CPython 3.9+ interpreter in the Setup tab's "Base Python (build)" field and click Setup Environment again. For example:
C:\Python312\python.exe
(or, if on PATH: py -3.12)
Tip: when the "Base Python" field is blank, the plugin prefers this machine's Dragonfly Python; once you enter a path or a command like py -3.12, that wins. The setup script self-heals — if it finds a half-built venv (python present but pip broken), it deletes and rebuilds it.
5. User Interface
The top of the panel shows a blue note describing the plugin. The body is a two-tab widget (Setup and Analyze); the bottom has a green result status line and a read-only Log text box. Below, each tab's controls are described (matching the actual code).
5.1 Setup tab
Control | Type | Default / description |
Analysis venv python | text field | Path to the analysis venv's Python. Usually filled automatically by Setup Environment; rarely edited by hand. |
Base Python (build) | text field | Base interpreter used to build the venv. Blank = use this machine's Dragonfly python.exe (recommended); or enter a path or a command like |
Run mode | dropdown |
|
Job root | text field | Root output directory, default `C:\SkanJobs`. |
Setup Environment (build venv + install skan) | button | Builds the venv and installs the skan stack (a couple of minutes on first run). |
5.2 Analyze tab
Input group:
Control | Type | Default / description |
Input type | dropdown + Refresh button | Input category, one of: ROI (binary) / MultiROI (per-label) / Channel (threshold), default ROI. Click Refresh to rescan objects in the scene. |
Object | dropdown | Lists the matching objects in the scene for the chosen input type (by title). |
Channel threshold (>=) | double spinbox | Enabled only for a Channel input. Binarizes as foreground = intensity >= threshold. Default 1.0, up to 4 decimals. |
MultiROI label (0 = all) | spinbox | Enabled only for a MultiROI input. Picks a single label; 0 = all labels (shown as "(all labels)"). Default 0. |
Use voxel spacing for distances | checkbox | When checked, uses voxel spacing to convert distances to physical units. Default checked. |
Publish skeleton as a new Channel | checkbox | When checked, publishes the computed skeleton back into the scene as a new Channel. Default checked. |
Result title | text field | Title for the skeleton Channel; blank = auto-named. |
Action button row:
- Run Skeleton Analysis (blue button): starts skeletonization and statistics.
- Export CSV: exports the current branch-statistics table to a CSV file (enabled once results exist).
- Open Output Folder: opens the output folder for the current run.
Branch statistics table: a table widget listing one row per branch (see the column descriptions in the Outputs chapter).
6. Step-by-Step Usage
6.1 First use: build the environment
1. Open Prototype Apps ▸ Skeleton Analysis (skan)....
2. Go to the Setup tab (usually leave "Base Python" blank to use Dragonfly's own Python).
3. Make sure you are online, then click Setup Environment. The Log shows build/install progress; when done, "Analysis venv python" is filled automatically.
6.2 Analyze an ROI (binary mask)
1. Prepare a binary ROI of your target structure (foreground = non-zero voxels).
2. On the Analyze tab, set Input type to ROI (binary); click Refresh if needed.
3. Select the ROI in the Object dropdown.
4. Set the "Use voxel spacing" and "Publish skeleton" checkboxes as desired.
5. Click Run Skeleton Analysis. When it finishes, the table below shows the branch statistics, the status line shows branch count and total length, and (if publishing is on) a new skeleton Channel appears in the scene.
6.3 Analyze a MultiROI (per-label)
1. Set Input type to MultiROI (per-label) and select the target MultiROI in Object.
2. Enter the single label number in MultiROI label (0 = all); if you enter 0 (shown as "(all labels)"), all non-zero labels of the MultiROI are merged into one mask before analysis.
3. Click Run Skeleton Analysis to view results.
6.4 Analyze a Channel (by threshold)
1. Set Input type to Channel (threshold) and select the target Channel in Object.
2. Set the Channel threshold (>=) — voxels with intensity greater than or equal to it are treated as foreground.
3. Click Run Skeleton Analysis. If the result is empty, adjust the threshold and retry.
6.5 Export and review
1. Click Export CSV, choose a save location, and export the branch-statistics table to CSV.
2. Click Open Output Folder to open the run directory, which contains summary.csv, summary.json, skeleton.npy, and other intermediate files.
3. In Dragonfly's 3D view, overlay the newly published skeleton Channel on your original data to confirm the centerlines follow the structure.
7. Parameter Reference
Parameter | Default | Description |
Input type | ROI (binary) | Input category: ROI (binarized by non-zero) / MultiROI (per-label) / Channel (by threshold). |
Channel threshold (>=) | 1.0 | Binarization threshold for a Channel; foreground = intensity >= threshold. Channel only; up to 4 decimals. |
MultiROI label (0 = all) | 0 (all labels) | Single label to analyze for a MultiROI; 0 merges all non-zero labels. MultiROI only. |
Use voxel spacing for distances | checked | Whether to use voxel spacing to convert branch lengths to physical distances; unchecked = voxel units. |
Publish skeleton as a new Channel | checked | Whether to publish the skeleton as a new uint8 Channel in the scene. |
Result title | blank (auto) | Title of the published skeleton Channel. |
Base Python (build) | blank (= Dragonfly Python) | Base interpreter for building the venv; blank uses Dragonfly's Python, or enter a CPython 3.9+ path/command. |
Run mode | windows | Subprocess run mode; this plugin ships for Windows, so keep windows. |
Job root | C:\SkanJobs | Root directory for each run's intermediate files and results. |
8. Outputs
On success the plugin produces two kinds of output: the branch-statistics table in the panel and a new skeleton Channel in the scene.
8.1 Branch-statistics table
Each table row represents one branch in the skeleton network. The exact columns depend on the installed skan version; the plugin normalizes skan's raw column names to stable display names. Common columns include:
Column | Meaning |
skeleton-id | The skeleton (connected component) this branch belongs to. |
branch-distance | Path length along the branch (physical distance when voxel spacing is enabled). |
branch-type | Branch type code (integer). |
branch-type-name | Human-readable name for the branch type (see below), appended by the plugin from the type code. |
euclidean-distance | Straight-line distance between the branch's two endpoints. |
tortuosity | Tortuosity = path length / straight-line length (>= 1; a closed loop is 1). |
src-coord-0/1/2, dst-coord-0/1/2 | Coordinates of the branch's start and end (z, y, x in 3D; missing coordinate columns are omitted in 2D). |
The branch-type codes map to names as follows:
Code | Name | Meaning |
0 | endpoint-to-endpoint (isolated) | Endpoint to endpoint (isolated branch). |
1 | junction-to-endpoint | Junction to endpoint. |
2 | junction-to-junction | Junction to junction. |
3 | isolated-cycle | Isolated cycle (loop). |
The status line also reports summary figures such as branch count, total branch length, and mean branch length.
8.2 Skeleton Channel
If "Publish skeleton as a new Channel" is checked, the plugin writes the skeleton voxels as a uint8 (0/1) Channel and aligns its grid spacing and origin to the source object, so it overlays exactly on the original structure in 3D. You can set the title via "Result title".
8.3 Intermediate files on disk
Each run writes the following files to the job directory (under C:\SkanJobs by default), reachable via Open Output Folder:
summary.csv— CSV version of the branch-statistics table (same content as Export CSV).summary.json— JSON of the headers, rows, raw columns, records, and stats.skeleton.npy— the skeleton mask as a numpy array.status.json/results.json— run status and results (polled by the panel; includes a full traceback on error).
9. FAQ and Troubleshooting
Q: Run says "analysis venv not set. Click 'Setup Environment' first." — what now?
A: The analysis environment has not been built yet. Go to the Setup tab, click Setup Environment to build the venv and install dependencies; once "Analysis venv python" is filled, run again.
Q: Setup Environment fails (no venv module, or venv creation failed).
A: This usually means the base interpreter is unsuitable. Enter a CPython 3.9+ with stdlib venv + pip (e.g. C:\Python312\python.exe) in Base Python (build) and click Setup Environment again. The setup script deletes any half-built venv and rebuilds. Also confirm you are online for the first install.
Q: The result says "the binarized mask is empty (no foreground voxels)" or the skeleton is empty.
A: No foreground voxels survived binarization. For a Channel input, lower the Channel threshold; for a MultiROI, confirm the label number exists (or use 0 for all labels); for an ROI, confirm it actually contains non-zero voxels.
Q: My object doesn't show in the Object dropdown.
A: First make sure Input type matches the object's category (ROI / MultiROI / Channel), then click Refresh to rescan the scene. The Log reports how many ROIs / MultiROIs / Channels were found.
Q: What units are the measured lengths?
A: With "Use voxel spacing for distances" checked, lengths are in physical units derived from voxel spacing (axis order z, y, x in 3D); unchecked, they are in voxel counts.
Q: It's slow or runs out of memory on very large 3D volumes.
A: skeletonize and skan can use a lot of memory/time on huge 3D masks; if you hit a memory error (error category oom), crop to a region of interest or downsample before analyzing.
10. Notes and Known Limitations
- Computation runs in a subprocess using the plugin's dedicated venv, never in Dragonfly's Python; the panel shows "Running…" while it works.
- First-run environment setup requires internet; later analysis runs offline.
- Skeletonization thins the structure to one voxel wide, so thin branches or noise can affect branch counts — denoise / clean up the input (morphology) beforehand if needed.
- The
skan.summarizecolumn set varies slightly across skan versions; the plugin maps multiple column spellings and omits columns skan did not emit (e.g. the third coordinate for 2D input). - For a MultiROI with a single label chosen, only that label is analyzed; entering 0 merges all non-zero labels into one mask and skeletonizes them together.
- Menus are scanned only at Dragonfly startup, so enabling/disabling the plugin requires one restart.
11. References
- skan (Skeleton Analysis) project homepage: https://skeleton-analysis.org/
- scikit-image docs (
skimage.morphology.skeletonize): https://scikit-image.org/ - NumPy: https://numpy.org/ , pandas: https://pandas.pydata.org/ , NetworkX: https://networkx.org/ , imageio: https://imageio.readthedocs.io/
- Full Package install / enable / uninstall instructions: see the bundled
README.md(Prototype Labs & Apps — Full Package).