Vertex2D.raw forwards none of description, state or priority to the
VertexRGB it builds. Volume2D.raw, Volume.raw and Vertex.raw all forward
all three.
import numpy as np, cortex
from cortex.dataset.view2D import Vertex2D
n = cortex.db.get_surf("S1", "flat", merge=True)[0].shape[0]
d1, d2 = np.linspace(0, 1, n), np.linspace(1, 0, n)
raw = Vertex2D(d1, d2, "S1", description="d", state="s", priority=7).raw
print(repr(raw.description), repr(raw.state), raw.priority)
On main at d01dccf this prints '' None 1. The equivalent Volume2D prints
'd' 's' 7.
priority is what orders views inside a Dataset and description is what the
viewer shows, so a figure built from several Vertex2D views comes out labelled
and ordered as though nothing had been set.
Cause
Vertex2D.raw, cortex/dataset/view2D.py:283:
kws = dict(subject=self.dim1.subject)
Volume2D.raw at 199 lists state and description and picks up priority
from **self.attrs.
Fix
Splatting **self.attrs the way Volume2D does is not available here, and
views.py:86 already says why, twice, in this project's own words:
# RGB classes don't accept arbitrary kwargs (e.g. cmap, vmin, vmax),
# so filter to only the parameters they support.
rgb_kwargs = {
k: v for k, v in kwargs.items() if k in ("description", "state", "priority")
}
VertexRGB takes no **kwargs, so a splat would make Vertex2D(zzz=1).raw
start raising TypeError where it succeeds today. Naming the same three
attributes that block names, the way Vertex.raw does at views.py:518, avoids
that:
kws = dict(subject=self.dim1.subject, state=self.state,
description=self.description, priority=self.priority)
One regression test, asserting the Volume2D case first as a control so a
failure points at the surface class rather than at the shared colormapping. It
fails on d01dccf and passes with the change. pytest cortex goes from 1 failed
61 passed 55 skipped to 1 failed 62 passed 55 skipped; that failure is
test_warn_non_perceptually_uniform_2D_cmap, which wants Inkscape and fails the
same way before and after.
The alpha guard immediately below is untouched and the alpha arrays are
unchanged either way, which I checked rather than assumed. Vertex2D also does
something questionable with an explicit alpha=, but that runs into the
commented-out block at view2D.py:99 where the interaction between a caller's
alpha, the colormap alpha and NaN vertices is written down and left open, so it
is a separate thing and I would rather measure it properly than bundle it here.
Linux, CPython 3.12.3, numpy 2.5.1, cortex 1.3.3.dev14 editable from d01dccf.
One leg of a matrix covering 3.10 through 3.14, on a machine with no Inkscape,
Playwright or FreeSurfer.
Vertex2D.rawforwards none ofdescription,stateorpriorityto theVertexRGBit builds.Volume2D.raw,Volume.rawandVertex.rawall forwardall three.
On main at d01dccf this prints
'' None 1. The equivalentVolume2Dprints'd' 's' 7.priorityis what orders views inside aDatasetanddescriptionis what theviewer shows, so a figure built from several
Vertex2Dviews comes out labelledand ordered as though nothing had been set.
Cause
Vertex2D.raw,cortex/dataset/view2D.py:283:Volume2D.rawat 199 listsstateanddescriptionand picks uppriorityfrom
**self.attrs.Fix
Splatting
**self.attrsthe wayVolume2Ddoes is not available here, andviews.py:86already says why, twice, in this project's own words:VertexRGBtakes no**kwargs, so a splat would makeVertex2D(zzz=1).rawstart raising
TypeErrorwhere it succeeds today. Naming the same threeattributes that block names, the way
Vertex.rawdoes atviews.py:518, avoidsthat:
One regression test, asserting the
Volume2Dcase first as a control so afailure points at the surface class rather than at the shared colormapping. It
fails on d01dccf and passes with the change.
pytest cortexgoes from 1 failed61 passed 55 skipped to 1 failed 62 passed 55 skipped; that failure is
test_warn_non_perceptually_uniform_2D_cmap, which wants Inkscape and fails thesame way before and after.
The alpha guard immediately below is untouched and the alpha arrays are
unchanged either way, which I checked rather than assumed.
Vertex2Dalso doessomething questionable with an explicit
alpha=, but that runs into thecommented-out block at
view2D.py:99where the interaction between a caller'salpha, the colormap alpha and NaN vertices is written down and left open, so it
is a separate thing and I would rather measure it properly than bundle it here.
Linux, CPython 3.12.3, numpy 2.5.1, cortex 1.3.3.dev14 editable from d01dccf.
One leg of a matrix covering 3.10 through 3.14, on a machine with no Inkscape,
Playwright or FreeSurfer.