Skip to content

Add per-bundle label properties; fix shard-size and alignment bugs - #6

Open
chourroutm wants to merge 1 commit into
lincbrain:mainfrom
chourroutm:add-bundle-label-properties
Open

chourroutm wants to merge 1 commit into
lincbrain:mainfrom
chourroutm:add-bundle-label-properties

Conversation

@chourroutm

Copy link
Copy Markdown
Member

Adds label_id/label_name/label_color annotation properties, populated from a trk's per-point "label_id" scalar (e.g. bundle group id) and an optional {bundle_name: label_id} sidecar JSON, with label_name carrying enum_values/enum_labels so Neuroglancer displays bundle names and label_color assigning a deterministic random color per label id.

While wiring this up, found and fixed two pre-existing correctness bugs that this change would otherwise have made worse:

  • length_of_tract_chunk/length_of_tract_minishard and length_of_id_chunk/length_of_id_minishard undercounted each record's on-disk size by 4 bytes (48/52 vs. the true 44/56-byte layout + id trailer), corrupting minishard index offsets for any shard spanning more than one minishard.
  • Neuroglancer requires each record's byte size to be a multiple of 4; the label fields add 7 bytes, which isn't. Records now get an extra 1-byte alignment field when labels are present.

Also:

  • generate_info_dict now declares real per-axis voxel-size dimensions (derived from the trk's affine) instead of a hardcoded 1mm, which was silently misplacing annotations relative to a paired image layer using the same affine.
  • new sharding=False path (skip_relationships in main()) writes only the spatial pyramid with relationships: [] and by_id: {"key": ""}, matching a known-working minimal structure, for callers who don't need by-streamline-ID lookup.
  • --label_json, --skip_segmentation, --skip_relationships CLI flags.

Adds label_id/label_name/label_color annotation properties, populated
from a trk's per-point "label_id" scalar (e.g. bundle group id) and an
optional {bundle_name: label_id} sidecar JSON, with label_name carrying
enum_values/enum_labels so Neuroglancer displays bundle names and
label_color assigning a deterministic random color per label id.

While wiring this up, found and fixed two pre-existing correctness bugs
that this change would otherwise have made worse:

- length_of_tract_chunk/length_of_tract_minishard and
  length_of_id_chunk/length_of_id_minishard undercounted each record's
  on-disk size by 4 bytes (48/52 vs. the true 44/56-byte layout + id
  trailer), corrupting minishard index offsets for any shard spanning
  more than one minishard.
- Neuroglancer requires each record's byte size to be a multiple of 4;
  the label fields add 7 bytes, which isn't. Records now get an extra
  1-byte alignment field when labels are present.

Also:
- generate_info_dict now declares real per-axis voxel-size dimensions
  (derived from the trk's affine) instead of a hardcoded 1mm, which was
  silently misplacing annotations relative to a paired image layer
  using the same affine.
- new sharding=False path (skip_relationships in main()) writes only
  the spatial pyramid with relationships: [] and by_id: {"key": ""},
  matching a known-working minimal structure, for callers who don't
  need by-streamline-ID lookup.
- --label_json, --skip_segmentation, --skip_relationships CLI flags.

This branch has not been deployed

No deployments
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