Skip to content

Add cat35 categorical palette (BSD-compatible substitute for fs_colours2 from #91) - #160

Merged
zihuaihuai merged 1 commit into
masterfrom
add-cat35-categorical-palette
May 4, 2026
Merged

zihuaihuai merged 1 commit into
masterfrom
add-cat35-categorical-palette

Conversation

@zihuaihuai

Copy link
Copy Markdown
Collaborator

Resolves the last unmerged piece of #91.

Why a substitute, not the original

The original `fs_colours2` array is a verbatim copy of FreeSurfer's parcellation color LUT. FreeSurfer is licensed for non-commercial use only, which is incompatible with BrainSpace's BSD-3 license. Shipping those exact RGB tuples would create a license-mismatch downstream.

What this is

A 35-entry palette named `cat35`:

  • Same shape as the original (`(35, 4)` uint8 RGBA), so it's a drop-in replacement for any code that wanted a Desikan-Killiany-style 35-color palette (34 cortical labels + 1 unknown/medial-wall slot).
  • Built programmatically from matplotlib's `tab20` + `tab20b` qualitative colormaps (PSF/BSD-compatible), with a leading black row for the unknown slot.
  • Construction lives in `_build_cat35()` so the colors are auditable rather than hand-listed.

Test plan

  • `pytest brainspace/tests/test_colormaps.py` → 4 passed (registration, shape, opaque-alpha, leading-black, all-distinct).
  • Full suite still green.

The remaining unmerged piece of #91 was fs_colours2, a 35-entry palette
copied from FreeSurfer's color LUT. FreeSurfer's license is
non-commercial only, incompatible with BSD-3, so the palette could not
ship as-is.

Add cat35 instead: same 35-entry size (matches Desikan-Killiany cortical
parcellation: 34 labels + 1 unknown/medial-wall slot), built
deterministically from matplotlib's tab20 + tab20b qualitative
colormaps (PSF/BSD license). Construction lives in _build_cat35() so
the source is auditable instead of hand-listed.

Tests verify the registration, shape, opaque alpha, distinct entries,
and the leading black slot.
@zihuaihuai
zihuaihuai merged commit 298730b into master May 4, 2026
16 checks passed
@zihuaihuai
zihuaihuai deleted the add-cat35-categorical-palette branch May 4, 2026 17:29
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