Skip to content

Add custom segmentation classes#70

Merged
harleensachdev merged 9 commits into
BodyMaps:mainfrom
harleensachdev:add-custom-segmentation-classes
Jul 14, 2026
Merged

Add custom segmentation classes#70
harleensachdev merged 9 commits into
BodyMaps:mainfrom
harleensachdev:add-custom-segmentation-classes

Conversation

@harleensachdev

Copy link
Copy Markdown
Collaborator

What this adds

Builds on #57 (mask editing). Lets a user create a brand-new annotation class at runtime (name + colour), paint it with the brush, see it in the organ list / hover-identify / 3D view, and download or save it alongside the edited mask.

How it works

  • createNewAnnotationClass (CornerstoneNifti2.tsx) picks the next free segment index, registers its colour in Cornerstone's LUT, and remembers its name for the session.
  • The mask-edit panel gained a "New class…" form wired to that function.
  • Since custom classes have no pre-generated 3D mesh, extractSegmentSurface runs marching cubes (vtk.js) client-side on the live labelmap, debounced so it doesn't rebuild on every brush stroke.
  • Saving to the server or downloading now also includes a labels.json sidecar (name + colour per custom index) whenever custom classes exist. The download path zips the mask + sidecar together so the metadata isn't lost, and the save-to-server path only sends the sidecar when there's actually something in it.

Testing done

  • Created 2 custom classes on a sample case, painted each, confirmed correct 2D colour, hover tooltip, and live 3D mesh.
  • Saved to server and downloaded the zip; confirmed labels.json contains the right name/colour pairs.
  • Confirmed no labels.json is sent/created when no custom classes exist.
  • Verified existing static-organ editing/saving/3D flows are unaffected.
  • npm run build passes with no TypeScript errors.

@harleensachdev
harleensachdev merged commit dc664c3 into BodyMaps:main Jul 14, 2026
7 checks passed
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