feat: add cortical region boundary contours (contours parameter)#12
Open
GalKepler wants to merge 10 commits into
Open
feat: add cortical region boundary contours (contours parameter)#12GalKepler wants to merge 10 commits into
GalKepler wants to merge 10 commits into
Conversation
Extends draw_contours with a contour_regions parameter that restricts which atlas regions get boundary lines. Accepts a list of region names, a boolean mask over LUT order, or a dict mapping region name to per-region style kwargs (merged with the global draw_contours defaults). Internally, get_region_boundaries gains a region_ids filter and _render_cortical_views now takes a contour_layers list of (lh_mesh, rh_mesh, kwargs) tuples, allowing multiple style groups to render in one pass. Notebook updated with examples for all three input forms. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Owner
- Merge draw_contours + contour_regions into single contours parameter:
True → all regions default style; style-dict → all regions custom style;
list/bool-ndarray → those regions default style; region-dict (values are
dicts) → per-region style for listed regions only.
- Add smooth_iterations to get_region_boundaries: Laplacian smoothing on
boundary line vertices reduces triangular jaggedness. Auto-set to 10
when proc_vertices='sharp', otherwise 0. User-overridable via
contours={'smooth_iterations': N}.
- Remove CLAUDE.md from .gitignore.
- Update notebook: section 5 uses new contours param throughout, adds
sharp-mode smoothing example; section 6 folded into section 5 as a
subsection.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
smooth_iterations defaults to 10 for all contour rendering modes —
jaggedness is a mesh-topology artefact present in all proc_vertices
modes, not just 'sharp'. User can disable with
contours={'smooth_iterations': 0}. Removes the proc_vertices dependency
from _build_contour_layers.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Plain Laplacian moves junction vertices (where ≥3 region boundaries meet) toward their neighbors' centroid, tearing the lines apart. Fix: pin vertices with degree != 2 (junctions and endpoints) and only smooth degree-2 chain vertices. Boundaries now converge cleanly at meeting points. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Degree-based pinning (len(neighbors) == 2) fails on dense cortical meshes where boundary vertices regularly have 3-6 boundary edges even on simple two-region chains, causing nearly all vertices to be pinned and no smoothing to apply. Replace with label-count check: pin vertices where ≥3 distinct region labels converge in the boundary-edge neighborhood (true junctions); smooth all others regardless of degree. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Smoothing attempts produced gaps and artifacts. Reverts mesh.py, plotting.py, and the notebook to the state before any smoothing was introduced. Also restores two-param API (draw_contours + contour_regions) since consolidation and smoothing were bundled in the same commit. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…s param Single parameter accepts: True (all regions, default style), style-dict (all regions, custom style), list/bool-ndarray (those regions, default style), or region-dict (per-region style for listed regions only). No smoothing. Notebook updated accordingly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Width of 2 is barely visible in rendered output. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Adds a
contoursparameter toplot_corticalfor drawing atlas region boundary lines on the surface, with support for selective regions and per-region styling.Changes
yabplot/mesh.pyget_region_boundaries: newregion_idsfilter (draw outlines for specific regions only) andsmooth_iterations(Laplacian smoothing on boundary line vertices to reduce triangular jaggedness — especially useful withproc_vertices='sharp').yabplot/plotting.pycontoursparameter onplot_cortical(replaces earlier draft'sdraw_contours+contour_regions)._build_contour_layers()helper resolvescontoursinto a list of(lh_mesh, rh_mesh, kwargs)render groups, allowing multiple style groups per call.proc_vertices='sharp', otherwise 0 (user-overridable).docs/tutorials/plot_styling.ipynbcontoursforms and a sharp-mode smoothing example.API
contoursdisambiguationFalse/NoneTrueBreaking changes
None —
contoursdefaults toFalse.🤖 Generated with Claude Code