Skip to content

Add color-grouping + per-region export options to plot_subcortical - #15

Open
anniegbryant wants to merge 5 commits into
teanijarv:mainfrom
anniegbryant:feature/subcortical-new-params
Open

Add color-grouping + per-region export options to plot_subcortical#15
anniegbryant wants to merge 5 commits into
teanijarv:mainfrom
anniegbryant:feature/subcortical-new-params

Conversation

@anniegbryant

Copy link
Copy Markdown
Contributor

Summary

Adds three new keyword arguments to plot_subcortical for controlling region coloring/export in atlas mode (i.e., no data passed in), plus a naming helper and test coverage. Builds on top of the .round() fix from #14 — no further changes to atlas_builder.py.

Motivation

The functionality introduced in this PR is designed to increase user flexibility in region rendering separately for visibility of occluded regions. Additionally, this functionality is designed to integrate with the subcortex_visualization pipeline for converting from three-dimensional NIFTI volume to mesh to two-dimensional vector graphic.

What has changed

  • hemisphere_colors (bool, default False): Bilateral region pairs (e.g., left/right putamen) share one color instead of each getting its own, via a new get_base_name() helper that strips hemisphere naming conventions (l/r, -lh/-rh, l-/r-, left/right/etc).
  • shuffle_colors (bool, default False): Reproducibly (seed-fixed) shuffles the generated palette across regions to help separate adjacent regions with similar neighboring colors.
  • plot_regions_separately (bool, default False): Renders one transparent-background PNG per region/view ({region}_{view_face}.png) into export_path as an output directory, for downstream SVG-tracing pipelines. Returns None in this mode.
  • cmap can now optionally drive atlas-mode region colors too (sampled across linspace(0, 1, n_regions)) when explicitly passed as a colormap name. This is opt-in only; default behavior (generate_distinct_colors) is unchanged.

Testing

Unit tests were added for get_base_name, hemisphere_colors=True, and plot_regions_separately=True. The full suite (51 tests) passes locally via uv run pytest tests/.

@teanijarv

Copy link
Copy Markdown
Owner

@anniegbryant I made some edits to your PR; feel free to take a look/test and tell me if these edits are good and would be compatible with subcortex_visualization now. I will plan to release the new version somewhere before the end of August, and then this PR would be integrated to it.

@anniegbryant

Copy link
Copy Markdown
Contributor Author

@teanijarv, your changes look great! I've confirmed everything works smoothly with subcortex_visualization atlas + vector generation now. Thank you 😊

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.

2 participants