Skip to content

[3D Visualizer] Searchable label picker + subcortical field PLY export#132

Open
idossha wants to merge 3 commits into
mainfrom
feature/3d-visualizer-labels-subcortical-ply
Open

[3D Visualizer] Searchable label picker + subcortical field PLY export#132
idossha wants to merge 3 commits into
mainfrom
feature/3d-visualizer-labels-subcortical-ply

Conversation

@idossha

@idossha idossha commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Summary

Two improvements to the 3D Visual Exporter GUI extension (tit/gui/extensions/visual_exporter.py) and mesh tooling (tit/tools/nifti_to_mesh.py):

1. Reuse the shared searchable label picker

The subcortical "Show Label Lookup Table" button (a static, read-only table) is replaced with "Search & Select Labels...", which opens AtlasRegionFinderDialog — the same searchable, multi-select widget the flex optimizer and analyzer already use.

  • Selected label ids merge into the "Labels to extract" field (de-duplicated) via merge_into_lineedit.
  • Labels already present are pre-selected when the dialog opens.
  • New _parse_lut_entries() parses labeling_LUT.txt into (id, name, rgb) tuples.

2. Subcortical PLY with local field

Subcortical structures come from a label segmentation volume with no field, so previously only STL/MSH geometry was exported. Now, mirroring the cortical STL+PLY export, a field-colored PLY is written by sampling the simulation's field volume at each surface vertex.

  • tit/tools/nifti_to_mesh.py: extracted mask_to_surface(), added sample_field_at_points() (trilinear sampling) and nifti_to_field_ply() (per-vertex colors via shared tit/blender/io.py helpers).
  • New "Field (for PLY)" input (default TI_max) + _find_field_nifti() locate the subject-space *_subject_{field}.nii.gz volume for the selected simulation.
  • When a simulation is selected and its field volume is found, subcortical_{suffix}.ply is written alongside STL/MSH; otherwise geometry-only export is unchanged (logs a note).

Testing

  • Edited modules byte-compile.
  • Field-sampling/PLY logic smoke-tested on synthetic volumes.
  • Verified working in the Dockerized GUI by the author.

Notes

The AtlasRegionFinderDialog and merge_into_lineedit imports are intentionally local to _show_lut_tablemain.py's extension-class discovery scans the module namespace and would otherwise mistake the imported QDialog for the extension widget.

idossha added 3 commits July 9, 2026 17:57
- Subcortical label lookup now opens AtlasRegionFinderDialog (the shared
  searchable/multi-select widget used by flex and analyzer); selected label
  ids merge into the 'Labels to extract' field.
- nifti_to_mesh: add mask_to_surface(), sample_field_at_points(), and
  nifti_to_field_ply() to color a subcortical surface by a sampled field
  volume (per-vertex colors via tit.blender.io helpers).
- Subcortical export now also writes subcortical_{suffix}.ply when a
  simulation field volume is found, mirroring the cortical STL+PLY export.
…omponent path

The <=1 component branch returned a bare ndarray while both callers unpack
two values, raising on clean_components=True for a single-component mask.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant