@jax-data-science/sci-image-visualizer 0.8.2 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (525) hide show
  1. package/README.md +201 -460
  2. package/esm2022/index.mjs +28 -15
  3. package/esm2022/lib/channel-histogram/channel-histogram.component.mjs +163 -91
  4. package/esm2022/lib/contracts/capabilities.contract.mjs +4 -3
  5. package/esm2022/lib/contracts/cell-segmenter.contract.mjs +1 -1
  6. package/esm2022/lib/contracts/channel-histogram-api.contract.mjs +5 -1
  7. package/esm2022/lib/contracts/color.mjs +60 -0
  8. package/esm2022/lib/contracts/colormap-lut.mjs +213 -57
  9. package/esm2022/lib/contracts/coordinate-transform.contract.mjs +1 -1
  10. package/esm2022/lib/contracts/display-types.mjs +11 -1
  11. package/esm2022/lib/contracts/instance-segmenter.contract.mjs +1 -1
  12. package/esm2022/lib/contracts/intensity.mjs +48 -5
  13. package/esm2022/lib/contracts/plot-type-contribution.contract.mjs +1 -1
  14. package/esm2022/lib/contracts/plot-type.mjs +134 -17
  15. package/esm2022/lib/contracts/ports/image-state.port.mjs +4 -1
  16. package/esm2022/lib/contracts/ports/preferences.port.mjs +5 -1
  17. package/esm2022/lib/contracts/ports/region-io.port.mjs +2 -1
  18. package/esm2022/lib/contracts/ports/spatial-data.port.mjs +5 -1
  19. package/esm2022/lib/contracts/ports/tile-access.port.mjs +2 -1
  20. package/esm2022/lib/contracts/region-editor-api.contract.mjs +1 -1
  21. package/esm2022/lib/contracts/region-overlay.contract.mjs +1 -1
  22. package/esm2022/lib/contracts/sam.contract.mjs +1 -1
  23. package/esm2022/lib/contracts/semantic-segmenter.contract.mjs +1 -1
  24. package/esm2022/lib/contracts/spatial-dataset.contract.mjs +3 -1
  25. package/esm2022/lib/contracts/toolbar-tool.contract.mjs +6 -4
  26. package/esm2022/lib/contracts/visualizer.contract.mjs +1 -1
  27. package/esm2022/lib/contracts/viz-config.mjs +2 -1
  28. package/esm2022/lib/geometry/contour.mjs +63 -0
  29. package/esm2022/lib/geometry/raster.mjs +98 -0
  30. package/esm2022/lib/geometry/ring.mjs +201 -0
  31. package/esm2022/lib/hex-color-picker/hex-color-picker.component.mjs +202 -102
  32. package/esm2022/lib/implementations/base-store-visualizer.mjs +201 -48
  33. package/esm2022/lib/implementations/napari-js/napari-axes-gizmo.mjs +65 -0
  34. package/esm2022/lib/implementations/napari-js/napari-display-state.mjs +136 -0
  35. package/esm2022/lib/implementations/napari-js/napari-helpers.mjs +199 -0
  36. package/esm2022/lib/implementations/napari-js/napari-image-2d-scene.mjs +602 -0
  37. package/esm2022/lib/implementations/napari-js/napari-loading-badge.mjs +3 -4
  38. package/esm2022/lib/implementations/napari-js/napari-loading-state.mjs +66 -0
  39. package/esm2022/lib/implementations/napari-js/napari-region-overlay.mjs +157 -591
  40. package/esm2022/lib/implementations/napari-js/napari-scene.mjs +2 -0
  41. package/esm2022/lib/implementations/napari-js/napari-spatial-2d-scene.mjs +614 -0
  42. package/esm2022/lib/implementations/napari-js/napari-spatial-3d-scene.mjs +769 -0
  43. package/esm2022/lib/implementations/napari-js/napari-spatial-encoding.mjs +199 -0
  44. package/esm2022/lib/implementations/napari-js/napari-spatial-hover.mjs +263 -0
  45. package/esm2022/lib/implementations/napari-js/napari-spatial-scene.mjs +159 -0
  46. package/esm2022/lib/implementations/napari-js/napari-spatial-tiles.mjs +106 -1408
  47. package/esm2022/lib/implementations/napari-js/napari-spatial-tooltip.mjs +2 -2
  48. package/esm2022/lib/implementations/napari-js/napari-surface-scene.mjs +271 -0
  49. package/esm2022/lib/implementations/napari-js/napari-tile-client.mjs +562 -0
  50. package/esm2022/lib/implementations/napari-js/napari-tool-bridge.mjs +344 -0
  51. package/esm2022/lib/implementations/napari-js/napari-visualizer.service.mjs +361 -4184
  52. package/esm2022/lib/implementations/napari-js/napari-volume-scene.mjs +439 -0
  53. package/esm2022/lib/implementations/napari-js/napari-volume-z-handle.mjs +6 -6
  54. package/esm2022/lib/implementations/napari-js/region-overlay/overlay-projection.mjs +96 -0
  55. package/esm2022/lib/implementations/napari-js/region-overlay/region-edit.mjs +35 -0
  56. package/esm2022/lib/implementations/napari-js/region-overlay/region-svg-renderer.mjs +182 -0
  57. package/esm2022/lib/implementations/napari-js/spatial-tiles/categorical-lookup.mjs +30 -0
  58. package/esm2022/lib/implementations/napari-js/spatial-tiles/cell-layers.mjs +274 -0
  59. package/esm2022/lib/implementations/napari-js/spatial-tiles/density-layer.mjs +144 -0
  60. package/esm2022/lib/implementations/napari-js/spatial-tiles/layer-groups.mjs +165 -0
  61. package/esm2022/lib/implementations/napari-js/spatial-tiles/plan-context.mjs +78 -0
  62. package/esm2022/lib/implementations/napari-js/spatial-tiles/transcript-hover.mjs +182 -0
  63. package/esm2022/lib/implementations/napari-js/spatial-tiles/transcript-jobs.mjs +369 -0
  64. package/esm2022/lib/implementations/napari-js/spatial-tiles/transcript-layers.mjs +306 -0
  65. package/esm2022/lib/implementations/osd/display-pipeline.mjs +102 -40
  66. package/esm2022/lib/implementations/osd/histogram-sampler.mjs +56 -31
  67. package/esm2022/lib/implementations/osd/openseadragon-viewer-options.mjs +128 -0
  68. package/esm2022/lib/implementations/osd/openseadragon-visualizer.service.mjs +333 -1685
  69. package/esm2022/lib/implementations/osd/osd-coordinate-transform.mjs +1 -1
  70. package/esm2022/lib/implementations/osd/osd-coords.mjs +5 -6
  71. package/esm2022/lib/implementations/osd/osd-export.mjs +122 -0
  72. package/esm2022/lib/implementations/osd/osd-lib.mjs +15 -1
  73. package/esm2022/lib/implementations/osd/osd-navigator-chrome.mjs +205 -0
  74. package/esm2022/lib/implementations/osd/osd-pixel-readback.mjs +68 -0
  75. package/esm2022/lib/implementations/osd/osd-region-overlay-draw.mjs +153 -0
  76. package/esm2022/lib/implementations/osd/osd-region-overlay.mjs +185 -718
  77. package/esm2022/lib/implementations/osd/osd-scale-bar.mjs +52 -60
  78. package/esm2022/lib/implementations/osd/osd-tile-source.mjs +105 -0
  79. package/esm2022/lib/implementations/osd/osd-viewer-like.mjs +2 -0
  80. package/esm2022/lib/implementations/osd/osd-viewer-mount.mjs +44 -0
  81. package/esm2022/lib/implementations/osd/osd-viewport.mjs +184 -0
  82. package/esm2022/lib/implementations/osd/osd-zoom.mjs +7 -1
  83. package/esm2022/lib/implementations/osd/simple-source.mjs +395 -0
  84. package/esm2022/lib/implementations/osd/slice-cache.mjs +53 -48
  85. package/esm2022/lib/implementations/osd/tile-client.mjs +32 -11
  86. package/esm2022/lib/implementations/osd/tile-recolor.mjs +330 -0
  87. package/esm2022/lib/implementations/plotly/omics-trace-builders.mjs +161 -73
  88. package/esm2022/lib/implementations/plotly/plotly-coordinate-transform.mjs +1 -1
  89. package/esm2022/lib/implementations/plotly/plotly-image-loader.mjs +112 -0
  90. package/esm2022/lib/implementations/plotly/plotly-image-recolor.mjs +178 -0
  91. package/esm2022/lib/implementations/plotly/plotly-intensity-inset.mjs +33 -0
  92. package/esm2022/lib/implementations/plotly/plotly-isosurface-controls.mjs +83 -0
  93. package/esm2022/lib/implementations/plotly/plotly-layouts.mjs +121 -0
  94. package/esm2022/lib/implementations/plotly/plotly-readback.mjs +117 -0
  95. package/esm2022/lib/implementations/plotly/plotly-region-overlay.mjs +19 -10
  96. package/esm2022/lib/implementations/plotly/plotly-shape-projection.mjs +223 -0
  97. package/esm2022/lib/implementations/plotly/plotly-trace-builders.mjs +79 -19
  98. package/esm2022/lib/implementations/plotly/plotly-zoom-controller.mjs +223 -0
  99. package/esm2022/lib/implementations/plotly/plotly.service.mjs +439 -1655
  100. package/esm2022/lib/implementations/region-centroids.mjs +47 -0
  101. package/esm2022/lib/implementations/simple-slice-access.service.mjs +22 -12
  102. package/esm2022/lib/implementations/spatial-data-http/spatial-data-http.service.mjs +172 -92
  103. package/esm2022/lib/implementations/spatial-data-http/spatial-wire.mjs +103 -22
  104. package/esm2022/lib/implementations/tile-server/index.mjs +6 -0
  105. package/esm2022/lib/implementations/tile-server/native-histogram.mjs +30 -0
  106. package/esm2022/lib/implementations/tile-server/poll-descriptor.mjs +65 -0
  107. package/esm2022/lib/implementations/tile-server/tile-protocol.mjs +42 -0
  108. package/esm2022/lib/implementations/tile-server/transport.mjs +135 -0
  109. package/esm2022/lib/intensity/intensity-profile.mjs +107 -0
  110. package/esm2022/lib/intensity/intensity-profile.service.mjs +223 -0
  111. package/esm2022/lib/intensity-inset/intensity-inset.component.mjs +133 -0
  112. package/esm2022/lib/models/bezier.mjs +1 -11
  113. package/esm2022/lib/models/class-preset.mjs +41 -3
  114. package/esm2022/lib/models/geometry.mjs +27 -164
  115. package/esm2022/lib/models/polygon-edit.mjs +254 -0
  116. package/esm2022/lib/models/polygon-factory.mjs +118 -0
  117. package/esm2022/lib/models/region-clone.mjs +68 -0
  118. package/esm2022/lib/models/region-geojson.mjs +373 -0
  119. package/esm2022/lib/models/region.mjs +34 -33
  120. package/esm2022/lib/models/shape.mjs +18 -16
  121. package/esm2022/lib/plot-mode/contribution-host.mjs +297 -0
  122. package/esm2022/lib/plot-mode/plot-mode-controller.mjs +9 -6
  123. package/esm2022/lib/plot-mode/plot-type-menu.mjs +85 -0
  124. package/esm2022/lib/plot-mode/tool-params-model.mjs +87 -0
  125. package/esm2022/lib/plot.utilities.mjs +296 -473
  126. package/esm2022/lib/processing/image-crop.mjs +1 -1
  127. package/esm2022/lib/processing/processing-image.mjs +28 -15
  128. package/esm2022/lib/provide-visualization.mjs +40 -14
  129. package/esm2022/lib/region-editor/classes-panel/classes-panel.component.mjs +99 -0
  130. package/esm2022/lib/region-editor/file-stem.mjs +13 -0
  131. package/esm2022/lib/region-editor/manage-classes-dialog/manage-classes-dialog.component.mjs +118 -0
  132. package/esm2022/lib/region-editor/mask-export.service.mjs +98 -0
  133. package/esm2022/lib/region-editor/mask-raster.mjs +11 -5
  134. package/esm2022/lib/region-editor/region-color-dialog/region-color-dialog.component.mjs +56 -0
  135. package/esm2022/lib/region-editor/region-editor-help/region-editor-help.component.mjs +28 -0
  136. package/esm2022/lib/region-editor/region-editor.component.mjs +402 -651
  137. package/esm2022/lib/region-editor/region-metrics.mjs +68 -0
  138. package/esm2022/lib/region-editor/region-persistence.service.mjs +134 -0
  139. package/esm2022/lib/region-editor/region-table/region-table.component.mjs +153 -0
  140. package/esm2022/lib/region-editor/save-mask-dialog/save-mask-dialog.component.mjs +91 -0
  141. package/esm2022/lib/region-editor/save-regions-dialog/save-regions-dialog.component.mjs +92 -0
  142. package/esm2022/lib/region-ops.service.mjs +28 -70
  143. package/esm2022/lib/region-overlay/region-geometry.mjs +360 -0
  144. package/esm2022/lib/region-overlay/region-hit-test.mjs +103 -0
  145. package/esm2022/lib/region-overlay/svg-region-renderer.mjs +228 -0
  146. package/esm2022/lib/render-orchestrator.mjs +14 -11
  147. package/esm2022/lib/render-session.mjs +207 -0
  148. package/esm2022/lib/routing-visualizer.service.mjs +459 -411
  149. package/esm2022/lib/spatial/density-raster.mjs +14 -0
  150. package/esm2022/lib/spatial/embedding-compute-coordinator.mjs +239 -0
  151. package/esm2022/lib/spatial/embedding-compute.mjs +43 -10
  152. package/esm2022/lib/spatial/gene-search.mjs +1 -1
  153. package/esm2022/lib/spatial/glyphs.mjs +97 -0
  154. package/esm2022/lib/spatial/lod.mjs +187 -0
  155. package/esm2022/lib/spatial/spatial-controls.facade.mjs +200 -0
  156. package/esm2022/lib/spatial/spatial-density.mjs +25 -16
  157. package/esm2022/lib/spatial/spatial-encoding.mjs +26 -82
  158. package/esm2022/lib/spatial/spatial-expression.mjs +43 -42
  159. package/esm2022/lib/spatial/spatial-framing.mjs +1 -1
  160. package/esm2022/lib/spatial/spatial-heatmap.mjs +6 -3
  161. package/esm2022/lib/spatial/spatial-hover.mjs +5 -33
  162. package/esm2022/lib/spatial/spatial-panel-model.mjs +282 -0
  163. package/esm2022/lib/spatial/spatial-sections.mjs +1 -1
  164. package/esm2022/lib/spatial/spatial-selection.mjs +33 -46
  165. package/esm2022/lib/spatial/spatial-tile-merge.mjs +219 -0
  166. package/esm2022/lib/spatial/spatial-tiles.mjs +12 -648
  167. package/esm2022/lib/spatial/spatial-volume-image.mjs +2 -4
  168. package/esm2022/lib/spatial/stats.mjs +71 -0
  169. package/esm2022/lib/spatial/transcript-grouping.mjs +307 -0
  170. package/esm2022/lib/spatial-controls/spatial-cells-panel/spatial-cells-panel.component.mjs +150 -0
  171. package/esm2022/lib/spatial-controls/spatial-charts/chart-data-model.mjs +309 -0
  172. package/esm2022/lib/spatial-controls/spatial-charts/chart-help.mjs +145 -0
  173. package/esm2022/lib/spatial-controls/spatial-charts/plotly-chart-host.mjs +158 -0
  174. package/esm2022/lib/spatial-controls/spatial-charts/spatial-chart-window/spatial-chart-window.component.mjs +47 -0
  175. package/esm2022/lib/spatial-controls/spatial-charts/spatial-charts.component.mjs +297 -802
  176. package/esm2022/lib/spatial-controls/spatial-charts/spatial-embedding-controls/spatial-embedding-controls.component.mjs +89 -0
  177. package/esm2022/lib/spatial-controls/spatial-charts/spatial-heatmap-controls/spatial-heatmap-controls.component.mjs +52 -0
  178. package/esm2022/lib/spatial-controls/spatial-controls.component.mjs +143 -1238
  179. package/esm2022/lib/spatial-controls/spatial-gene-picker.mjs +153 -0
  180. package/esm2022/lib/spatial-controls/spatial-gene-tree/spatial-gene-tree.component.mjs +241 -0
  181. package/esm2022/lib/spatial-controls/spatial-groups-panel/spatial-groups-panel.component.mjs +193 -0
  182. package/esm2022/lib/spatial-controls/spatial-key/spatial-key.component.mjs +132 -0
  183. package/esm2022/lib/spatial-controls/spatial-key/spatial-key.model.mjs +67 -0
  184. package/esm2022/lib/spatial-controls/spatial-marker-genes-form/spatial-marker-genes-form.component.mjs +147 -0
  185. package/esm2022/lib/spatial-controls/spatial-observations-panel/spatial-observations-panel.component.mjs +300 -0
  186. package/esm2022/lib/spatial-controls/spatial-transcripts-panel/spatial-transcripts-panel.component.mjs +370 -0
  187. package/esm2022/lib/store/class-color.util.mjs +46 -3
  188. package/esm2022/lib/store/region-history.mjs +146 -0
  189. package/esm2022/lib/store/region-scope-cache.mjs +140 -0
  190. package/esm2022/lib/store/region-selection.mjs +82 -0
  191. package/esm2022/lib/store/region-store.service.mjs +279 -675
  192. package/esm2022/lib/store/spatial-selection.service.mjs +2 -2
  193. package/esm2022/lib/store/visualizer-store.service.mjs +49 -71
  194. package/esm2022/lib/toast-outlets.mjs +5 -4
  195. package/esm2022/lib/toolbar/brush/brush-tool.service.mjs +92 -434
  196. package/esm2022/lib/toolbar/canvas-tools.mjs +20 -0
  197. package/esm2022/lib/toolbar/crop/slide-crop.mjs +26 -42
  198. package/esm2022/lib/toolbar/plot-type-selector/plot-type-selector.component.mjs +85 -0
  199. package/esm2022/lib/toolbar/region-tools/region-tool-buttons.mjs +74 -0
  200. package/esm2022/lib/toolbar/region-tools/region-tools.component.mjs +114 -0
  201. package/esm2022/lib/toolbar/segmentation/cell-segment-tool.service.mjs +74 -78
  202. package/esm2022/lib/toolbar/segmentation/cellpose-segmenter.service.mjs +50 -8
  203. package/esm2022/lib/toolbar/segmentation/onnx-sam-session.mjs +61 -42
  204. package/esm2022/lib/toolbar/segmentation/pending-calls.mjs +47 -0
  205. package/esm2022/lib/toolbar/segmentation/sam-model-registry.mjs +12 -4
  206. package/esm2022/lib/toolbar/segmentation/sam-onnx-core.mjs +70 -14
  207. package/esm2022/lib/toolbar/segmentation/sam-point-tool.service.mjs +135 -172
  208. package/esm2022/lib/toolbar/segmentation/sam-prompt.mjs +9 -90
  209. package/esm2022/lib/toolbar/segmentation/sam-session.service.mjs +183 -0
  210. package/esm2022/lib/toolbar/segmentation/sam-tool.service.mjs +95 -150
  211. package/esm2022/lib/toolbar/segmentation/segmentation-commit.mjs +12 -0
  212. package/esm2022/lib/toolbar/segmentation/segmentation-runner.mjs +108 -0
  213. package/esm2022/lib/toolbar/segmentation-tools/segmentation-tools.component.mjs +155 -0
  214. package/esm2022/lib/toolbar/stack-controls/stack-controls.component.mjs +81 -0
  215. package/esm2022/lib/toolbar/tool-kit/async-tool-status.mjs +37 -0
  216. package/esm2022/lib/toolbar/tool-kit/canvas-tool-manager.mjs +63 -0
  217. package/esm2022/lib/toolbar/tool-kit/canvas-tool.mjs +2 -0
  218. package/esm2022/lib/toolbar/tool-kit/frame-pixels.mjs +108 -0
  219. package/esm2022/lib/toolbar/tool-kit/mask-stroke-editor.mjs +306 -0
  220. package/esm2022/lib/toolbar/tool-kit/matrix-frame.mjs +61 -0
  221. package/esm2022/lib/toolbar/tool-kit/tool-overlay.mjs +140 -0
  222. package/esm2022/lib/toolbar/tool-kit/undo-gesture.mjs +24 -0
  223. package/esm2022/lib/toolbar/tool-slider/tool-slider.component.mjs +63 -0
  224. package/esm2022/lib/toolbar/toolbar-help-dialog/toolbar-help-dialog.component.mjs +50 -0
  225. package/esm2022/lib/toolbar/toolbar.component.mjs +68 -117
  226. package/esm2022/lib/toolbar/vertex-eraser/vertex-eraser-tool.service.mjs +93 -115
  227. package/esm2022/lib/toolbar/view-controls/view-controls.component.mjs +107 -0
  228. package/esm2022/lib/toolbar/wand/wand-region-grow.mjs +321 -0
  229. package/esm2022/lib/toolbar/wand/wand-tool.service.mjs +121 -416
  230. package/esm2022/lib/toolbar/wand/wand.service.mjs +30 -894
  231. package/esm2022/lib/toolbar/zoom-to-box/zoom-to-box-tool.service.mjs +48 -90
  232. package/esm2022/lib/util/mark-for-check.mjs +17 -0
  233. package/esm2022/lib/util/supersede.mjs +56 -0
  234. package/esm2022/lib/visualization.module.mjs +39 -141
  235. package/esm2022/lib/visualizer/floating-drag.directive.mjs +58 -0
  236. package/esm2022/lib/visualizer/region-actions.mjs +149 -0
  237. package/esm2022/lib/visualizer/region-load.mjs +60 -0
  238. package/esm2022/lib/visualizer/spatial-dataset-binder.mjs +163 -0
  239. package/esm2022/lib/visualizer/tool-modes.mjs +113 -0
  240. package/esm2022/lib/visualizer/viewer-shortcuts.mjs +167 -0
  241. package/esm2022/lib/visualizer/visualizer-context-menu.mjs +119 -0
  242. package/esm2022/lib/visualizer.component.mjs +480 -1902
  243. package/esm2022/lib/workers/spatial-math-ops.mjs +43 -0
  244. package/esm2022/lib/workers/spatial-math-worker.mjs +10 -0
  245. package/esm2022/lib/workers/spatial-math.mjs +190 -0
  246. package/fesm2022/jax-data-science-sci-image-visualizer-jax-data-science-sci-image-visualizer-Csxlnq7I.mjs +41083 -0
  247. package/fesm2022/jax-data-science-sci-image-visualizer-jax-data-science-sci-image-visualizer-Csxlnq7I.mjs.map +1 -0
  248. package/fesm2022/jax-data-science-sci-image-visualizer-onnx-sam-session-Bkujqg7m.mjs +238 -0
  249. package/fesm2022/jax-data-science-sci-image-visualizer-onnx-sam-session-Bkujqg7m.mjs.map +1 -0
  250. package/fesm2022/jax-data-science-sci-image-visualizer-spatial-math-worker-BzVFFqGS.mjs +12 -0
  251. package/fesm2022/jax-data-science-sci-image-visualizer-spatial-math-worker-BzVFFqGS.mjs.map +1 -0
  252. package/fesm2022/jax-data-science-sci-image-visualizer.mjs +41 -34430
  253. package/fesm2022/jax-data-science-sci-image-visualizer.mjs.map +1 -1
  254. package/fesm2022/mask.worker.js +36 -917
  255. package/fesm2022/onnx-sam.worker.js +52 -16
  256. package/fesm2022/spatial-math.worker.js +471 -0
  257. package/fesm2022/tsne.worker.js +32 -15
  258. package/index.d.ts +13 -10
  259. package/lib/channel-histogram/channel-histogram.component.d.ts +53 -43
  260. package/lib/contracts/capabilities.contract.d.ts +4 -2
  261. package/lib/contracts/cell-segmenter.contract.d.ts +1 -0
  262. package/lib/contracts/channel-histogram-api.contract.d.ts +4 -0
  263. package/lib/contracts/color.d.ts +27 -0
  264. package/lib/contracts/colormap-lut.d.ts +19 -4
  265. package/lib/contracts/coordinate-transform.contract.d.ts +3 -3
  266. package/lib/contracts/display-types.d.ts +21 -0
  267. package/lib/contracts/instance-segmenter.contract.d.ts +5 -0
  268. package/lib/contracts/intensity.d.ts +13 -2
  269. package/lib/contracts/plot-type.d.ts +3 -1
  270. package/lib/contracts/ports/image-state.port.d.ts +6 -2
  271. package/lib/contracts/ports/preferences.port.d.ts +4 -0
  272. package/lib/contracts/ports/region-io.port.d.ts +1 -0
  273. package/lib/contracts/ports/spatial-data.port.d.ts +4 -10
  274. package/lib/contracts/ports/tile-access.port.d.ts +1 -0
  275. package/lib/contracts/region-editor-api.contract.d.ts +1 -1
  276. package/lib/contracts/region-overlay.contract.d.ts +5 -0
  277. package/lib/contracts/sam.contract.d.ts +7 -0
  278. package/lib/contracts/semantic-segmenter.contract.d.ts +6 -0
  279. package/lib/contracts/spatial-dataset.contract.d.ts +19 -6
  280. package/lib/contracts/toolbar-tool.contract.d.ts +1 -0
  281. package/lib/contracts/visualizer.contract.d.ts +221 -54
  282. package/lib/contracts/viz-config.d.ts +1 -0
  283. package/lib/geometry/contour.d.ts +24 -0
  284. package/lib/geometry/raster.d.ts +42 -0
  285. package/lib/geometry/ring.d.ts +67 -0
  286. package/lib/hex-color-picker/hex-color-picker.component.d.ts +61 -27
  287. package/lib/implementations/base-store-visualizer.d.ts +61 -15
  288. package/lib/implementations/napari-js/napari-axes-gizmo.d.ts +36 -0
  289. package/lib/implementations/napari-js/napari-display-state.d.ts +76 -0
  290. package/lib/implementations/napari-js/napari-helpers.d.ts +129 -0
  291. package/lib/implementations/napari-js/napari-image-2d-scene.d.ts +162 -0
  292. package/lib/implementations/napari-js/napari-loading-badge.d.ts +0 -1
  293. package/lib/implementations/napari-js/napari-loading-state.d.ts +30 -0
  294. package/lib/implementations/napari-js/napari-region-overlay.d.ts +62 -70
  295. package/lib/implementations/napari-js/napari-scene.d.ts +93 -0
  296. package/lib/implementations/napari-js/napari-spatial-2d-scene.d.ts +163 -0
  297. package/lib/implementations/napari-js/napari-spatial-3d-scene.d.ts +212 -0
  298. package/lib/implementations/napari-js/napari-spatial-encoding.d.ts +114 -0
  299. package/lib/implementations/napari-js/napari-spatial-hover.d.ts +89 -0
  300. package/lib/implementations/napari-js/napari-spatial-scene.d.ts +118 -0
  301. package/lib/implementations/napari-js/napari-spatial-tiles.d.ts +56 -263
  302. package/lib/implementations/napari-js/napari-spatial-tooltip.d.ts +1 -1
  303. package/lib/implementations/napari-js/napari-surface-scene.d.ts +76 -0
  304. package/lib/implementations/napari-js/napari-tile-client.d.ts +214 -0
  305. package/lib/implementations/napari-js/napari-tool-bridge.d.ts +179 -0
  306. package/lib/implementations/napari-js/napari-visualizer.service.d.ts +121 -878
  307. package/lib/implementations/napari-js/napari-volume-scene.d.ts +104 -0
  308. package/lib/implementations/napari-js/napari-volume-z-handle.d.ts +8 -12
  309. package/lib/implementations/napari-js/region-overlay/overlay-projection.d.ts +59 -0
  310. package/lib/implementations/napari-js/region-overlay/region-edit.d.ts +15 -0
  311. package/lib/implementations/napari-js/region-overlay/region-svg-renderer.d.ts +54 -0
  312. package/lib/implementations/napari-js/spatial-tiles/categorical-lookup.d.ts +26 -0
  313. package/lib/implementations/napari-js/spatial-tiles/cell-layers.d.ts +70 -0
  314. package/lib/implementations/napari-js/spatial-tiles/density-layer.d.ts +61 -0
  315. package/lib/implementations/napari-js/spatial-tiles/layer-groups.d.ts +67 -0
  316. package/lib/implementations/napari-js/spatial-tiles/plan-context.d.ts +38 -0
  317. package/lib/implementations/napari-js/spatial-tiles/transcript-hover.d.ts +71 -0
  318. package/lib/implementations/napari-js/spatial-tiles/transcript-jobs.d.ts +105 -0
  319. package/lib/implementations/napari-js/spatial-tiles/transcript-layers.d.ts +56 -0
  320. package/lib/implementations/osd/display-pipeline.d.ts +38 -9
  321. package/lib/implementations/osd/histogram-sampler.d.ts +22 -12
  322. package/lib/implementations/osd/openseadragon-viewer-options.d.ts +35 -0
  323. package/lib/implementations/osd/openseadragon-visualizer.service.d.ts +78 -354
  324. package/lib/implementations/osd/osd-coordinate-transform.d.ts +2 -1
  325. package/lib/implementations/osd/osd-coords.d.ts +6 -4
  326. package/lib/implementations/osd/osd-export.d.ts +36 -0
  327. package/lib/implementations/osd/osd-lib.d.ts +7 -0
  328. package/lib/implementations/osd/osd-navigator-chrome.d.ts +69 -0
  329. package/lib/implementations/osd/osd-pixel-readback.d.ts +22 -0
  330. package/lib/implementations/osd/osd-region-overlay-draw.d.ts +37 -0
  331. package/lib/implementations/osd/osd-region-overlay.d.ts +36 -48
  332. package/lib/implementations/osd/osd-scale-bar.d.ts +8 -6
  333. package/lib/implementations/osd/osd-tile-source.d.ts +49 -0
  334. package/lib/implementations/osd/osd-viewer-like.d.ts +100 -0
  335. package/lib/implementations/osd/osd-viewer-mount.d.ts +14 -0
  336. package/lib/implementations/osd/osd-viewport.d.ts +77 -0
  337. package/lib/implementations/osd/osd-zoom.d.ts +6 -0
  338. package/lib/implementations/osd/simple-source.d.ts +161 -0
  339. package/lib/implementations/osd/slice-cache.d.ts +12 -3
  340. package/lib/implementations/osd/tile-client.d.ts +11 -14
  341. package/lib/implementations/osd/tile-recolor.d.ts +141 -0
  342. package/lib/implementations/plotly/omics-trace-builders.d.ts +32 -20
  343. package/lib/implementations/plotly/plotly-image-loader.d.ts +49 -0
  344. package/lib/implementations/plotly/plotly-image-recolor.d.ts +75 -0
  345. package/lib/implementations/plotly/plotly-intensity-inset.d.ts +8 -0
  346. package/lib/implementations/plotly/plotly-isosurface-controls.d.ts +38 -0
  347. package/lib/implementations/plotly/plotly-layouts.d.ts +188 -0
  348. package/lib/implementations/plotly/plotly-readback.d.ts +41 -0
  349. package/lib/implementations/plotly/plotly-region-overlay.d.ts +2 -2
  350. package/lib/implementations/plotly/plotly-shape-projection.d.ts +92 -0
  351. package/lib/implementations/plotly/plotly-trace-builders.d.ts +23 -12
  352. package/lib/implementations/plotly/plotly-zoom-controller.d.ts +86 -0
  353. package/lib/implementations/plotly/plotly.service.d.ts +136 -401
  354. package/lib/implementations/region-centroids.d.ts +14 -0
  355. package/lib/implementations/simple-slice-access.service.d.ts +7 -4
  356. package/lib/implementations/spatial-data-http/spatial-data-http.service.d.ts +42 -18
  357. package/lib/implementations/spatial-data-http/spatial-wire.d.ts +34 -9
  358. package/lib/implementations/tile-server/index.d.ts +5 -0
  359. package/lib/implementations/tile-server/native-histogram.d.ts +25 -0
  360. package/lib/implementations/tile-server/poll-descriptor.d.ts +39 -0
  361. package/lib/implementations/tile-server/tile-protocol.d.ts +80 -0
  362. package/lib/implementations/tile-server/transport.d.ts +62 -0
  363. package/lib/intensity/intensity-profile.d.ts +66 -0
  364. package/lib/intensity/intensity-profile.service.d.ts +108 -0
  365. package/lib/intensity-inset/intensity-inset.component.d.ts +58 -0
  366. package/lib/models/bezier.d.ts +0 -5
  367. package/lib/models/class-preset.d.ts +18 -0
  368. package/lib/models/geometry.d.ts +14 -48
  369. package/lib/models/polygon-edit.d.ts +72 -0
  370. package/lib/models/polygon-factory.d.ts +40 -0
  371. package/lib/models/region-clone.d.ts +20 -0
  372. package/lib/models/region-geojson.d.ts +17 -0
  373. package/lib/models/region.d.ts +40 -4
  374. package/lib/models/shape.d.ts +8 -0
  375. package/lib/plot-mode/contribution-host.d.ts +125 -0
  376. package/lib/plot-mode/plot-type-menu.d.ts +60 -0
  377. package/lib/plot-mode/tool-params-model.d.ts +49 -0
  378. package/lib/plot.utilities.d.ts +19 -30
  379. package/lib/processing/processing-image.d.ts +5 -2
  380. package/lib/provide-visualization.d.ts +19 -2
  381. package/lib/region-editor/classes-panel/classes-panel.component.d.ts +56 -0
  382. package/lib/region-editor/file-stem.d.ts +7 -0
  383. package/lib/region-editor/manage-classes-dialog/manage-classes-dialog.component.d.ts +45 -0
  384. package/lib/region-editor/mask-export.service.d.ts +54 -0
  385. package/lib/region-editor/mask-raster.d.ts +2 -8
  386. package/lib/region-editor/region-color-dialog/region-color-dialog.component.d.ts +29 -0
  387. package/lib/region-editor/region-editor-help/region-editor-help.component.d.ts +11 -0
  388. package/lib/region-editor/region-editor.component.d.ts +166 -199
  389. package/lib/region-editor/region-metrics.d.ts +26 -0
  390. package/lib/region-editor/region-persistence.service.d.ts +69 -0
  391. package/lib/region-editor/region-table/region-table.component.d.ts +83 -0
  392. package/lib/region-editor/save-mask-dialog/save-mask-dialog.component.d.ts +36 -0
  393. package/lib/region-editor/save-regions-dialog/save-regions-dialog.component.d.ts +37 -0
  394. package/lib/region-ops.service.d.ts +1 -7
  395. package/lib/region-overlay/region-geometry.d.ts +157 -0
  396. package/lib/region-overlay/region-hit-test.d.ts +38 -0
  397. package/lib/region-overlay/svg-region-renderer.d.ts +110 -0
  398. package/lib/render-orchestrator.d.ts +6 -2
  399. package/lib/render-session.d.ts +75 -0
  400. package/lib/routing-visualizer.service.d.ts +110 -58
  401. package/lib/spatial/density-raster.d.ts +6 -0
  402. package/lib/spatial/embedding-compute-coordinator.d.ts +123 -0
  403. package/lib/spatial/embedding-compute.d.ts +21 -2
  404. package/lib/spatial/glyphs.d.ts +16 -0
  405. package/lib/spatial/lod.d.ts +94 -0
  406. package/lib/spatial/spatial-controls.facade.d.ts +64 -0
  407. package/lib/spatial/spatial-density.d.ts +15 -5
  408. package/lib/spatial/spatial-encoding.d.ts +11 -44
  409. package/lib/spatial/spatial-expression.d.ts +40 -22
  410. package/lib/spatial/spatial-framing.d.ts +1 -0
  411. package/lib/spatial/spatial-heatmap.d.ts +2 -0
  412. package/lib/spatial/spatial-hover.d.ts +4 -16
  413. package/lib/spatial/spatial-panel-model.d.ts +135 -0
  414. package/lib/spatial/spatial-selection.d.ts +21 -26
  415. package/lib/spatial/spatial-tile-merge.d.ts +41 -0
  416. package/lib/spatial/spatial-tiles.d.ts +9 -256
  417. package/lib/spatial/stats.d.ts +38 -0
  418. package/lib/spatial/transcript-grouping.d.ts +119 -0
  419. package/lib/spatial-controls/spatial-cells-panel/spatial-cells-panel.component.d.ts +64 -0
  420. package/lib/spatial-controls/spatial-charts/chart-data-model.d.ts +153 -0
  421. package/lib/spatial-controls/spatial-charts/chart-help.d.ts +69 -0
  422. package/lib/spatial-controls/spatial-charts/plotly-chart-host.d.ts +98 -0
  423. package/lib/spatial-controls/spatial-charts/spatial-chart-window/spatial-chart-window.component.d.ts +26 -0
  424. package/lib/spatial-controls/spatial-charts/spatial-charts.component.d.ts +101 -260
  425. package/lib/spatial-controls/spatial-charts/spatial-embedding-controls/spatial-embedding-controls.component.d.ts +43 -0
  426. package/lib/spatial-controls/spatial-charts/spatial-heatmap-controls/spatial-heatmap-controls.component.d.ts +27 -0
  427. package/lib/spatial-controls/spatial-controls.component.d.ts +68 -448
  428. package/lib/spatial-controls/spatial-gene-picker.d.ts +86 -0
  429. package/lib/spatial-controls/spatial-gene-tree/spatial-gene-tree.component.d.ts +102 -0
  430. package/lib/spatial-controls/spatial-groups-panel/spatial-groups-panel.component.d.ts +72 -0
  431. package/lib/spatial-controls/spatial-key/spatial-key.component.d.ts +66 -0
  432. package/lib/spatial-controls/spatial-key/spatial-key.model.d.ts +33 -0
  433. package/lib/spatial-controls/spatial-marker-genes-form/spatial-marker-genes-form.component.d.ts +64 -0
  434. package/lib/spatial-controls/spatial-observations-panel/spatial-observations-panel.component.d.ts +117 -0
  435. package/lib/spatial-controls/spatial-transcripts-panel/spatial-transcripts-panel.component.d.ts +142 -0
  436. package/lib/store/class-color.util.d.ts +35 -1
  437. package/lib/store/region-history.d.ts +66 -0
  438. package/lib/store/region-scope-cache.d.ts +63 -0
  439. package/lib/store/region-selection.d.ts +36 -0
  440. package/lib/store/region-store.service.d.ts +104 -112
  441. package/lib/store/visualizer-store.service.d.ts +22 -33
  442. package/lib/toast-outlets.d.ts +4 -3
  443. package/lib/toolbar/brush/brush-tool.service.d.ts +31 -98
  444. package/lib/toolbar/canvas-tools.d.ts +20 -0
  445. package/lib/toolbar/crop/slide-crop.d.ts +10 -4
  446. package/lib/toolbar/plot-type-selector/plot-type-selector.component.d.ts +38 -0
  447. package/lib/toolbar/region-tools/region-tool-buttons.d.ts +21 -0
  448. package/lib/toolbar/region-tools/region-tools.component.d.ts +60 -0
  449. package/lib/toolbar/segmentation/cell-segment-tool.service.d.ts +10 -14
  450. package/lib/toolbar/segmentation/cellpose-segmenter.service.d.ts +12 -2
  451. package/lib/toolbar/segmentation/onnx-sam-session.d.ts +22 -3
  452. package/lib/toolbar/segmentation/pending-calls.d.ts +31 -0
  453. package/lib/toolbar/segmentation/sam-model-registry.d.ts +9 -3
  454. package/lib/toolbar/segmentation/sam-onnx-core.d.ts +18 -5
  455. package/lib/toolbar/segmentation/sam-point-tool.service.d.ts +46 -32
  456. package/lib/toolbar/segmentation/sam-prompt.d.ts +7 -31
  457. package/lib/toolbar/segmentation/sam-session.service.d.ts +74 -0
  458. package/lib/toolbar/segmentation/sam-tool.service.d.ts +23 -30
  459. package/lib/toolbar/segmentation/segmentation-commit.d.ts +8 -0
  460. package/lib/toolbar/segmentation/segmentation-runner.d.ts +52 -0
  461. package/lib/toolbar/segmentation-tools/segmentation-tools.component.d.ts +87 -0
  462. package/lib/toolbar/stack-controls/stack-controls.component.d.ts +40 -0
  463. package/lib/toolbar/tool-kit/async-tool-status.d.ts +21 -0
  464. package/lib/toolbar/tool-kit/canvas-tool-manager.d.ts +36 -0
  465. package/lib/toolbar/tool-kit/canvas-tool.d.ts +86 -0
  466. package/lib/toolbar/tool-kit/frame-pixels.d.ts +45 -0
  467. package/lib/toolbar/tool-kit/mask-stroke-editor.d.ts +125 -0
  468. package/lib/toolbar/tool-kit/matrix-frame.d.ts +40 -0
  469. package/lib/toolbar/tool-kit/tool-overlay.d.ts +60 -0
  470. package/lib/toolbar/tool-kit/undo-gesture.d.ts +17 -0
  471. package/lib/toolbar/tool-slider/tool-slider.component.d.ts +33 -0
  472. package/lib/toolbar/toolbar-help-dialog/toolbar-help-dialog.component.d.ts +24 -0
  473. package/lib/toolbar/toolbar.component.d.ts +47 -83
  474. package/lib/toolbar/vertex-eraser/vertex-eraser-tool.service.d.ts +33 -40
  475. package/lib/toolbar/view-controls/view-controls.component.d.ts +54 -0
  476. package/lib/toolbar/wand/wand-region-grow.d.ts +49 -0
  477. package/lib/toolbar/wand/wand-tool.service.d.ts +39 -124
  478. package/lib/toolbar/wand/wand.service.d.ts +22 -116
  479. package/lib/toolbar/zoom-to-box/zoom-to-box-tool.service.d.ts +17 -37
  480. package/lib/util/mark-for-check.d.ts +11 -0
  481. package/lib/util/supersede.d.ts +53 -0
  482. package/lib/visualization.module.d.ts +18 -39
  483. package/lib/visualizer/floating-drag.directive.d.ts +30 -0
  484. package/lib/visualizer/region-actions.d.ts +54 -0
  485. package/lib/visualizer/region-load.d.ts +27 -0
  486. package/lib/visualizer/spatial-dataset-binder.d.ts +74 -0
  487. package/lib/visualizer/tool-modes.d.ts +49 -0
  488. package/lib/visualizer/viewer-shortcuts.d.ts +71 -0
  489. package/lib/visualizer/visualizer-context-menu.d.ts +55 -0
  490. package/lib/visualizer.component.d.ts +201 -447
  491. package/lib/workers/spatial-math-ops.d.ts +65 -0
  492. package/lib/workers/spatial-math-worker.d.ts +7 -0
  493. package/lib/workers/spatial-math.d.ts +74 -0
  494. package/package.json +12 -3
  495. package/src/lib/styles/_viz-icons-rules.scss +73 -0
  496. package/src/lib/styles/viz-icons.scss +14 -0
  497. package/esm2022/lib/implementations/napari-js/napari-axes-labels.mjs +0 -97
  498. package/esm2022/lib/implementations/napari-js/napari-navigator.mjs +0 -195
  499. package/esm2022/lib/implementations/napari-js/napari-scale-bar.mjs +0 -92
  500. package/fesm2022/jax-data-science-sci-image-visualizer-onnx-sam-session-BwP-A11m.mjs +0 -329
  501. package/fesm2022/jax-data-science-sci-image-visualizer-onnx-sam-session-BwP-A11m.mjs.map +0 -1
  502. package/lib/implementations/napari-js/napari-axes-labels.d.ts +0 -49
  503. package/lib/implementations/napari-js/napari-navigator.d.ts +0 -72
  504. package/lib/implementations/napari-js/napari-scale-bar.d.ts +0 -35
  505. package/src/lib/assets/cell-detection.svg +0 -37
  506. package/src/lib/assets/click.svg +0 -1
  507. package/src/lib/assets/colormap-luts.json +0 -1
  508. package/src/lib/assets/edit-selection-white.svg +0 -47
  509. package/src/lib/assets/icons/colormap-earth.png +0 -0
  510. package/src/lib/assets/icons/colormap-placeholder.png +0 -0
  511. package/src/lib/assets/icons/colormap-pubu.png +0 -0
  512. package/src/lib/assets/interactive-segmentation-cursor.svg +0 -1
  513. package/src/lib/assets/picture-segmentation.svg +0 -43
  514. package/src/lib/assets/test/download-379.svg +0 -1
  515. package/src/lib/assets/test/download-98.svg +0 -1
  516. package/src/lib/assets/test/json-1.svg +0 -1
  517. package/src/lib/assets/test/load-53.svg +0 -1
  518. package/src/lib/assets/test/mask-44.svg +0 -1
  519. package/src/lib/assets/test/mask-download-44.svg +0 -15
  520. package/src/lib/assets/test/mask-save-44.svg +0 -11
  521. package/src/lib/assets/test/overlay-1.svg +0 -1
  522. package/src/lib/assets/test/overlay-4.svg +0 -1
  523. package/src/lib/assets/test/region-26.svg +0 -1
  524. package/src/lib/assets/test/save-56.svg +0 -1
  525. package/src/lib/assets/test/upload-43.svg +0 -1
package/README.md CHANGED
@@ -24,33 +24,118 @@ source; contributions welcome.
24
24
  npm install @jax-data-science/sci-image-visualizer
25
25
  ```
26
26
 
27
- Install the Angular / rendering **peer dependencies** your app doesn't already
28
- have:
27
+ Then install the **peer dependencies** your app doesn't already have:
29
28
 
30
29
  ```bash
31
- npm install @angular/animations @angular/router primeng \
32
- openseadragon plotly.js-dist-min image-js file-saver buffer onnxruntime-web
30
+ npm install @angular/animations @angular/router primeng primeicons primeflex \
31
+ image-js file-saver buffer onnxruntime-web
33
32
  ```
34
33
 
35
34
  ### Peer dependencies
36
35
 
37
- | Package | Range | Notes |
38
- |---|---|---|
39
- | `@angular/common` · `core` · `forms` · `animations` · `router` | `^17.3.0` | Angular 17 (animations + router are needed by the PrimeNG components) |
40
- | `rxjs` | `^7.8.0` | |
41
- | `primeng` | `^17.18.0` | toolbar / dialogs / table / dropdown UI |
42
- | `image-js` | `^0.35.6` | client-side image processing |
43
- | `file-saver` | `^2.0.5` | GeoJSON / mask export |
44
- | `buffer` | `^5.7.1` | |
45
- | `onnxruntime-web` | `~1.26.0` | browser SAM / cellpose inference (WebGPU/WASM) |
36
+ | Package | Range | Notes |
37
+ | -------------------------------------------------------------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
38
+ | `@angular/common` · `core` · `forms` · `animations` · `router` | `^17.3.0` | Angular 17. The library does not use animations or the router itself; PrimeNG's dialog, table, toast and menus need them |
39
+ | `rxjs` | `^7.8.0` | |
40
+ | `primeng` | `^17.18.0` | toolbar / dialogs / table / dropdown UI |
41
+ | `primeicons` · `primeflex` | `^7.0.0` · `^3.3.0` or `^4.0.0` | optional peers, but the templates use their icon and utility classes; load their CSS (see [Host setup](#host-setup)) |
42
+ | `image-js` | `^0.35.6` | client-side image processing |
43
+ | `file-saver` | `^2.0.5` | GeoJSON / mask export |
44
+ | `buffer` | `^5.7.1` | Node `Buffer` polyfill for the Plotly backend |
45
+ | `onnxruntime-web` | `~1.26.0` | browser SAM / cellpose inference (WebGPU/WASM) |
46
46
 
47
47
  The rendering backends and helpers — `openseadragon`, `plotly.js-dist-min`,
48
48
  `napari-js`, `cellpose-js`, `fast-png`, and `tslib` — are declared as regular
49
49
  **dependencies** and installed automatically; you don't add them yourself.
50
- `cellpose-js` is still lazy-imported at runtime, so apps that never open the
50
+ `cellpose-js` is lazy-imported at runtime, so apps that never open the
51
51
  Cellpose tool don't pay for it in the bundle — but it does need
52
- `onnxruntime-web` (its own peer, listed above) present. See
53
- [Quick start](#usage-host-integration-brief) below for wiring.
52
+ `onnxruntime-web` (its own peer, listed above) present.
53
+
54
+ ## Host setup
55
+
56
+ Besides the ports, the library expects these from the host app. The
57
+ [host integration guide](docs/guides/host-integration.md) has the details and
58
+ [`examples/browser-image/main.ts`](examples/browser-image/main.ts) shows all of
59
+ it working.
60
+
61
+ 1. **Providers:** `provideHttpClient()`, `provideAnimations()`, and PrimeNG's
62
+ `MessageService` and `ConfirmationService`.
63
+ 2. **CSS:** `primeicons/primeicons.css`, `primeng/resources/primeng.min.css`,
64
+ `primeflex/primeflex.css` and a PrimeNG theme.
65
+ 3. **Assets:** serve the package's `src/lib/assets` at `assets/plotting/`
66
+ (icons and colormap previews). In `angular.json`:
67
+ ```json
68
+ {
69
+ "glob": "**/*",
70
+ "input": "node_modules/@jax-data-science/sci-image-visualizer/src/lib/assets",
71
+ "output": "assets/plotting"
72
+ }
73
+ ```
74
+ 4. **onnxruntime-web sidecars** at `/assets/ort/` (copy
75
+ `node_modules/onnxruntime-web/dist/*.{wasm,mjs}`), or call `setOrtWasmBase(url)`
76
+ once at startup.
77
+ 5. **Icon stylesheet (optional):** the toolbar and context-menu icon classes
78
+ (`.wand-icon`, `.brush-icon`, … and the active context-menu entry) are global,
79
+ because those menus are appended to `<body>`. The visualizer defines them when
80
+ it first loads; to have them defined up front and independent of stylesheet
81
+ order (say, for a host menu that reuses the icons), add the shipped stylesheet
82
+ to `angular.json`:
83
+ ```json
84
+ "styles": ["node_modules/@jax-data-science/sci-image-visualizer/src/lib/styles/viz-icons.scss"]
85
+ ```
86
+
87
+ ## Quick start
88
+
89
+ ```ts
90
+ import { Component } from '@angular/core';
91
+ import {
92
+ VisualizerComponent,
93
+ RegionEditorComponent,
94
+ provideVisualization,
95
+ IMAGE_STATE_PORT,
96
+ TILE_ACCESS_PORT,
97
+ REGION_IO_PORT,
98
+ VIZ_CONFIG,
99
+ setSamModelUrls,
100
+ } from '@jax-data-science/sci-image-visualizer';
101
+
102
+ // Once at startup: where the SAM model files are hosted.
103
+ setSamModelUrls(
104
+ 'microsam-vit-t-lm',
105
+ 'https://huggingface.co/jax-image-tools/microsam-vit-t-lm-onnx/resolve/main/encoder.fp16.onnx',
106
+ 'https://huggingface.co/jax-image-tools/microsam-vit-t-lm-onnx/resolve/main/decoder.onnx',
107
+ );
108
+
109
+ @Component({
110
+ selector: 'app-viewer',
111
+ standalone: true,
112
+ imports: [VisualizerComponent, RegionEditorComponent],
113
+ template: `<visualizer></visualizer> <region-editor></region-editor>`,
114
+ providers: [
115
+ // The viewer chain. In `bootstrapApplication` providers it is the one app-wide
116
+ // viewer; in a component's providers it is an isolated viewer for that subtree.
117
+ ...provideVisualization(),
118
+ // Your adapters: the library reaches the host only through these ports.
119
+ { provide: IMAGE_STATE_PORT, useClass: MyImageStateAdapter },
120
+ { provide: TILE_ACCESS_PORT, useClass: MyTileAccessAdapter },
121
+ { provide: REGION_IO_PORT, useClass: MyRegionIoAdapter },
122
+ { provide: VIZ_CONFIG, useValue: { slideCropServer: 'https://tiles.example.org' } },
123
+ ],
124
+ })
125
+ export class ViewerComponent {}
126
+ ```
127
+
128
+ `CELL_SEGMENTER` is optional: override it only to replace the default
129
+ `CellposeSegmenterService`. `SPATIAL_DATA_PORT` and `PREFERENCES_PORT` are
130
+ optional too.
131
+
132
+ All components are standalone. `VisualizationModule` still works for NgModule hosts but is
133
+ deprecated: import the components and add `provideVisualization()` instead.
134
+
135
+ The embeddable components use plain, unprefixed selectors: `visualizer`,
136
+ `region-editor`, `channel-histogram`, `hex-color-picker`, `spatial-controls` and
137
+ `spatial-charts`. Their inputs and outputs are listed in the
138
+ [host integration guide](docs/guides/host-integration.md#6-components).
54
139
 
55
140
  ## Live demo & running the example
56
141
 
@@ -107,6 +192,7 @@ Open an image and it renders through whichever backend best fits it; the
107
192
  state (regions, channels, zoom) consistent across them.
108
193
 
109
194
  ### OpenSeadragon — tiled image view
195
+
110
196
  The default **Image** view is a natively tiled, deeply zoomable raster powered by
111
197
  [OpenSeadragon](https://openseadragon.github.io/). It streams pyramid tiles (the
112
198
  host supplies them through the `TILE_ACCESS_PORT`, e.g. a `/tiles/info` + `/tile`
@@ -130,6 +216,7 @@ resolution there is no finer level to switch to, and the setting only moves the
130
216
  jump to full-resolution tiles to a lower zoom.
131
217
 
132
218
  ### Plotly — plots & 3D
219
+
133
220
  Non-image plot types render with [Plotly](https://plotly.com/javascript/) and
134
221
  support "real zooming" — a downscaled overview that re-fetches higher-resolution
135
222
  data as you zoom in:
@@ -141,6 +228,7 @@ data as you zoom in:
141
228
  - scalar/3D types expect a grayscale image (the volume types also need a z-stack).
142
229
 
143
230
  ### napari-js — WebGPU
231
+
144
232
  GPU-accelerated renderings via [napari-js](https://www.npmjs.com/package/napari-js)
145
233
  (WebGPU), selectable from the plot-type menu as the "napari · WebGPU" variants of
146
234
  Image, Scatter 2D, Surface, Scatter 3D, **Volume**, **Isosurface**, and the two
@@ -168,191 +256,30 @@ false`) — the latter (e.g. a host-assembled folder of numbered files) fetches
168
256
  matching ROI GeoJSON per slice (`IImageInfo.roiJsonStrs`), which the viewer
169
257
  shows for the displayed slice and swaps as you scrub.
170
258
 
171
- ### Intensity profiles *(work in progress)*
259
+ ### Intensity profiles _(work in progress)_
260
+
172
261
  A line-ROI tool draws coloured lines and plots intensity along each one in a live
173
262
  floating inset chart that re-samples at the current zoom. It works today but the
174
263
  API/UX are still stabilizing (see [In progress / roadmap](#in-progress--roadmap)).
175
264
 
176
265
  ## Spatial omics
177
266
 
178
- Contracts for **spatial-omics datasets**: N observations (Visium spots,
179
- segmented cells) positioned in a tissue image's pixel space, each carrying
180
- categorical and continuous annotations plus a lazily-fetched feature (gene)
181
- matrix.
182
-
183
- ```ts
184
- import {
185
- SPATIAL_DATA_PORT, SpatialDataHttpService, SpatialDataset,
186
- } from '@jax-data-science/sci-image-visualizer';
187
-
188
- providers: [
189
- SpatialDataHttpService,
190
- { provide: SPATIAL_DATA_PORT, useExisting: SpatialDataHttpService },
191
- ]
192
- ```
267
+ Two napari-js plot modes for **spatial-omics datasets** — N observations (Visium
268
+ spots, segmented cells) positioned in a tissue image's pixel space, each with
269
+ categorical and continuous annotations plus a lazily-fetched gene matrix:
193
270
 
194
- Like `TILE_ACCESS_PORT`, this is a **port**: the library consumes typed arrays
195
- and never learns how the data is stored. `SpatialDataHttpService` is an optional
196
- reference adapter for the format the bundled example server speaks; a host with
197
- its own backend implements `SpatialDataPort` instead and imports neither.
198
-
199
- Two properties the design turns on:
200
-
201
- - **Metadata is eager, values are lazy.** A `SpatialDataset` holds coordinates
202
- plus column and feature *descriptors*; vectors arrive one at a time, for the
203
- one column or gene being displayed. A Visium table is ~31k genes wide — the
204
- dense matrix is ~800 MB — so loading a dataset can never mean loading its
205
- matrix.
206
- - **Struct-of-arrays, not object-per-cell.** Datasets run 10³ (Visium) to 10⁶
207
- (Xenium/CosMx) observations; two `Float32Array`s beat 500k `{x, y}` objects
208
- and upload to the GPU without a copy.
209
-
210
- Once a dataset is published, the spatial plot types appear in the selector (and
211
- disappear when it is cleared — the same gating that hides Volume without a
212
- z-stack):
213
-
214
- - **Spatial omics** — one marker per observation over the tissue image the
215
- coordinates live in, positioned through `imageRef`'s affine.
216
- - **Spatial omics 3D** — gated additionally on the observations carrying a `z`
217
- (`requiresSpatial3d`): the same observations as a point cloud under an orbit
218
- camera, inside the dataset's reference volume if it has one.
219
-
220
- **A dataset whose 3D data is one file gets an image made from it.** A registered
221
- volume (`SpatialDataset.volume` + `SpatialDataPort.getVolume()`) is published *as*
222
- a grayscale z-stack image — one plane per slice, opened mid-volume — so the whole
223
- image surface applies to it: the toolbar slice slider, the contrast window,
224
- colormaps, the region tools, the physical scale bar, and Volume / Isosurface
225
- through the ordinary stack path. In the 2D mode the displayed plane then draws
226
- **that plane's** observations over that plane's anatomy, in the volume's own pixel
227
- grid, and a region drawn there selects that plane's cells rather than the whole
228
- depth behind them.
229
-
230
- **Cluster density volumes** *(3D mode, optional)* — a checkbox that raymarches
231
- each cluster as a smooth density field beside the cloud, tinted with its legend
232
- colour and blended additively. Serial sections hundreds of microns apart cannot be
233
- read as an anatomical distribution from points alone: the eye will not integrate a
234
- stack of discs into a shape, and every gap between sections reads as absence.
235
- Individual cells are never interpolated — consecutive sections sample different
236
- cells, so there is nothing to interpolate along — but a density *field* is an
237
- estimate legitimately defined between the imaged planes, and it renders as a
238
- translucent cloud so it cannot be mistaken for measurement. The kernel is
239
- anisotropic (σ along z clears one section gap) and the field is coverage-normalised
240
- along z, so unimaged planes do not read as empty tissue.
241
-
242
- In **3D** the same `Gene map` checkbox draws one field per imaged section, at its
243
- own depth, with the gaps between sections empty — the measured slides, stacked.
244
- `One map section at a time` isolates a single sheet (its own control, separate from
245
- the cloud's, so every combination stays reachable), and `Volume rendering
246
- (interpolate along z)` smooths the sheets into a continuous volume. The last is a
247
- different object and the panel labels it as one: the planes between sections then
248
- carry an estimate smoothed from their neighbours' mean, nothing is drawn past the
249
- outermost section, and the section restriction is ignored because a volume built
250
- from one slide would smear it through the whole specimen. It is estimated on the
251
- reference volume's lattice — coarsened in-plane but never along z, so one plane is
252
- one section — and shares the 2D map's bandwidth, window and colormap.
253
-
254
- **Show** *(3D mode)* — the reference volume, the observation cloud and the cluster
255
- density volumes share one space, so any two of them hide each other; 374k points
256
- drawn as a stack of discs hide the density volumes almost entirely. Each is
257
- toggled independently, so every combination is reachable — the estimated fields
258
- alone, the fields with the anatomy behind them, the anatomy on its own. These are
259
- visibility only: the layers stay built, so a toggle never re-fetches the template
260
- or re-rasterises a field, and none of them re-frames the orbit camera. (The
261
- density checkbox is the exception and still gates construction, since building six
262
- volumes is not free.) **Volume opacity** is the backdrop's own slider, separate
263
- from the markers': reading the cloud or a density field *through* the anatomy
264
- means turning the anatomy down, not the data over it. **One section at a time** restricts the cloud to a single
265
- imaged section, which is how you check whether the estimated field follows the
266
- cells that were actually measured. Sections are the distinct z of the
267
- observations — every cell on a slide shares that slide's registered z, so no
268
- section-label column is needed — and a dataset whose z is continuous rather than
269
- sectioned is offered no section control instead of having one invented for it.
270
-
271
- **Hover and click** — hovering an observation names it in a cursor tooltip: the
272
- class for a categorical column, the value with its unit for a gene or numeric one,
273
- and nothing at all when no colour source is set (there is no cluster to name).
274
- Clicking a marker selects that whole class, the same selection the legend's rows
275
- produce, and clicking it again clears. Because a click means "select" here,
276
- napari's click-to-zoom is off in the spatial modes — the wheel, the zoom buttons
277
- and the zoom-box tool still zoom. A gene cannot be clicked to select: no set of
278
- cells "is" a value.
279
-
280
- **Colormap** *(continuous colouring)* — the low→high gradient for a gene or a
281
- numeric column, chosen from the library's own `COLORMAP_OPTIONS` with the same
282
- swatch previews the image's colormap picker uses. It defaults to following the
283
- image's colormap (with a Viridis fallback, since a grey measurement over grey
284
- anatomy cannot be told apart from it), and clearing the picker returns to that.
285
- One setting drives the markers, both gene maps and the panel's colour bar, so none
286
- of them can disagree about what a colour means.
287
-
288
- **Gene map** *(2D mode, optional, with a gene selected)* — a checkbox that draws
289
- the selected gene's expression as a smooth field *beneath* the cells. Coloured
290
- markers answer "which cells express this gene"; they do not answer "where is it
291
- expressed", because the eye cannot integrate thousands of small dots into a
292
- territory. The field is the kernel-weighted **mean per cell, not a sum** — a sum
293
- would make a crowded region glow whatever its cells were doing — and smoothing the
294
- numerator and denominator together spreads *where*, not *how much*. That
295
- denominator is also what lets the layer say nothing: where no cell was measured the
296
- mean is undefined rather than zero, so those pixels stay fully transparent instead
297
- of taking the colormap's low end, and alpha ramps with local support so a thinly
298
- sampled pixel reads as tentative. `Smoothing` sets the kernel σ; `Map opacity` is
299
- the field's own opacity, separate from the markers' — turn the markers down to read
300
- the field under them. On a volume-backed dataset the field is re-estimated per
301
- plane from that plane's cells.
302
-
303
- Colour it through `getSpatialControls()`:
271
+ - **Spatial omics** — one marker per observation over the tissue image, with
272
+ 10x Xenium cell outlines, transcripts and a density map read in place;
273
+ - **Spatial omics 3D** — the observations as a point cloud under an orbit camera,
274
+ inside the dataset's reference volume, with per-cluster density volumes.
304
275
 
305
- ```ts
306
- const controls = viz.getSpatialControls(); // null unless a port is bound
307
- controls?.colorByColumn('region'); // categorical -> the column's palette
308
- controls?.colorByFeature('Ttr'); // gene -> colormap, log, percentile-clipped
309
- controls?.setViewState({ pointScale: 2 });
310
- ```
276
+ The data arrive through an optional `SPATIAL_DATA_PORT`; `SpatialDataHttpService`
277
+ is a reference adapter for the bundled example server. A controls panel
278
+ (`<spatial-controls>`) colours by column or gene, selects from ROIs or legend
279
+ rows, and shows linked distributions. The modes appear only when a dataset is
280
+ published.
311
281
 
312
- The view state lives in the shared store, so the controls work before any
313
- backend has mounted and survive a plot-type switch.
314
-
315
- The [example server](examples/tile-server/README.md#spatial-omics-endpoints)
316
- implements the endpoints, and `npm run make-spatial-demo` generates a synthetic
317
- Visium-geometry dataset **and a matching tissue image** so the
318
- [browser example](examples/browser-image/README.md#spatial-omics-demo) runs the
319
- whole path with no download. A converter for real SpatialData Zarr stores ships
320
- alongside it.
321
-
322
- A **Spatial omics** controls panel (`<spatial-controls>`, opened from the
323
- toolbar) drives all of this from the UI: a column dropdown, a gene search over
324
- the feature panel, a legend for categorical colourings and a colour bar for
325
- continuous ones, plus point-size, opacity, log-scale and outlier-clip controls.
326
- Its legend swatches and colour bar are built with the same functions the
327
- renderer uses, so the key cannot drift from the canvas.
328
-
329
- **Selection** reuses the region tools you already have: draw a rectangle,
330
- polygon, freehand shape, wand or brush region, then *Select from ROIs* selects
331
- every observation inside their union and mutes the rest. Legend rows select
332
- their category on click.
333
-
334
- **Linked distributions** sit in the same panel, below the colour controls, over
335
- whatever the map is coloured by: histogram, violin or box for a continuous column
336
- or a gene, and per-category **counts** for a categorical one — a histogram of a
337
- category code would be meaningless, but "how many cells per class" is the question
338
- the legend implies and never answers. Violin and box are splittable by a
339
- categorical column. One dialog on purpose — changing the gene
340
- and watching the distribution move is a single action. They follow the selection: the histogram
341
- overlays *Selected* on the full distribution, violin and box narrow to it. The
342
- chart's subject is the map's colour source rather than an independent picker, so
343
- the two cannot disagree about what is being shown.
344
-
345
- Categorical colouring has one renderer-specific limit worth knowing: the 3D
346
- points layer maps a per-point scalar through a 256-entry LUT, which keeps 96
347
- blocks apart exactly — one of them reserved for a missing value, so **95
348
- categories** fit — and above that the cloud draws flat and the panel says so.
349
- The 2D markers (per-point RGBA) and the density volumes (a scalar field per
350
- cluster) have no such limit — which is why the example server serves `subclass`
351
- (338) even though the cloud cannot colour by it.
352
-
353
- Still to build: hover tooltips, chart → map brushing, and a GPU layer for cell
354
- boundary polygons (they are served, not yet drawn) — see
355
- [docs/spatial-omics-plot-mode-design.md](docs/spatial-omics-plot-mode-design.md).
282
+ Full guide: [docs/guides/spatial-omics.md](docs/guides/spatial-omics.md).
356
283
 
357
284
  ## Regions & annotation
358
285
 
@@ -373,7 +300,8 @@ switches and are editable from the Regions panel. The on-canvas tools:
373
300
  a sensitivity slider tunes strictness. Growing into another region merges them.
374
301
  - **Brush** — paint/erase a region with a circular brush (QuPath-style); a size
375
302
  slider sets the diameter, `Shift` erases, and erasing across a region can split it.
376
- - **Vertex eraser** — remove vertices within a radius from any region.
303
+ - **Vertex eraser** — remove vertices within a radius from any region; the outline is rejoined
304
+ where it crosses the eraser's edge (a Bézier region loses the anchors outright).
377
305
  - **Delete** the selected region.
378
306
 
379
307
  Wand- and brush-drawn regions default to the `legend` class; SAM/cellpose masks
@@ -384,7 +312,9 @@ inherit the color of the rectangle they came from.
384
312
  A floating **Channels & Histogram** dialog controls how intensities are mapped to
385
313
  display: **brightness / contrast / gamma**, **per-channel** display for
386
314
  multi-channel images, and — for grayscale — **colormap / LUT** selection with a
387
- **reverse** toggle (default: inverted greys). Changes apply live in both backends.
315
+ **reverse** toggle (default: inverted greys). Changes apply live on every backend: OSD, napari-js
316
+ and the Plotly heatmap. (A tiled multichannel image's heatmap is the server's flat composite
317
+ preview, so its channels are adjusted in the OSD and napari-js image views.)
388
318
 
389
319
  ## Region editor (Regions panel)
390
320
 
@@ -396,115 +326,82 @@ canvas (and vice-versa), so it pairs with the on-canvas tools above.
396
326
 
397
327
  ## Segmentation tools (SAM & cellpose)
398
328
 
399
- All segmentation runs **client-side** — models are fetched once (a progress
400
- toast is shown), cached, then executed with `onnxruntime-web` (WebGPU where
401
- supported, WASM otherwise). Generated regions inherit the color of the rectangle
402
- they came from.
403
-
404
- ### Box-prompt SAM — "Segment"
405
- Draw one or more **rectangles** around objects, then click **Segment**. Each
406
- rectangle is sent to SAM as a box prompt and replaced by the segmented mask.
407
-
408
- ### Interactive point prompts
409
- Click directly on an object to segment it as a **new** region (each click is an
410
- independent object — clicking another object won't grow the previous one).
411
- `Shift`/`Alt`-click adds an *exclude* point that refines the current object;
412
- `Enter` commits, `Esc` undoes.
413
-
414
- ### Model picker
415
- A dropdown on the Segment button chooses the SAM model; the choice applies to
416
- **both** the box and point tools. An info button summarizes the trade-offs.
417
-
418
- ### Cellpose — automatic
419
- Draw rectangles, then click **Cellpose** to auto-segment every cell inside each
420
- rectangle (client-side cellpose-SAM via [`cellpose-js`](https://www.npmjs.com/package/cellpose-js)) —
421
- one region per detected cell, no per-object clicking. (Cellpose-SAM is *not*
422
- promptable, so it's the automatic tool rather than a model in the SAM picker.)
423
-
424
- ## Models
425
-
426
- Promptable SAM models are SAM-v1 encoder/decoder ONNX pairs (the encoder runs
427
- once per image; the decoder runs per prompt). The registry lives in
428
- `src/lib/toolbar/sam-model-registry.ts`; the host supplies hosted URLs via
429
- `setSamModelUrls(...)`. Export/quantization tooling lives in the sibling
430
- `browser-onnx-tools` project.
431
-
432
- | Picker id | Domain | Encoder | Runs on | HF model |
433
- |---|---|---|---|---|
434
- | `microsam-vit-t-lm` *(default)* | light microscopy | TinyViT, ~14 MB fp16 | WASM¹ | [jax-image-tools/microsam-vit-t-lm-onnx](https://huggingface.co/jax-image-tools/microsam-vit-t-lm-onnx) |
435
- | `microsam-vit-b-lm` | light microscopy | ViT-B, ~172 MB fp16 | WebGPU | [jax-image-tools/microsam-vit-b-lm-onnx](https://huggingface.co/jax-image-tools/microsam-vit-b-lm-onnx) |
436
- | `patho-sam-vit-b` | histopathology (H&E) | ViT-B, ~172 MB fp16 | WebGPU | [jax-image-tools/patho-sam-vit-b-onnx](https://huggingface.co/jax-image-tools/patho-sam-vit-b-onnx) |
437
- | `patho-sam-vit-b-int8` | histopathology (H&E) | ViT-B, ~100 MB int8 | WASM | [jax-image-tools/patho-sam-vit-b-onnx](https://huggingface.co/jax-image-tools/patho-sam-vit-b-onnx) (`encoder.int8.onnx`) |
438
- | cellpose-SAM *(automatic)* | cells (generalist) | SAM ViT + flow head | WebGPU/WASM | [jax-image-tools/cellpose-sam-onnx](https://huggingface.co/jax-image-tools/cellpose-sam-onnx) |
439
-
440
- ¹ TinyViT's fp16 attention overflows on the onnxruntime-web WebGPU EP (returns an
441
- empty mask); it is numerically correct and fast on WASM, so its encoder is pinned
442
- to WASM. int8 models also run on WASM (no WebGPU int8 matmul).
443
-
444
- micro-sam and patho-sam are distributed through micro-sam's model registry
445
- (`vit_*_lm`, `vit_*_histopathology`); SAM 3 is a planned addition (it needs a
446
- `variant: 'sam3'` decoder path, since SAM 2/3 differ in mask I/O). See
447
- `docs/sam-segmentation-design.md` for the design.
329
+ All segmentation runs **client-side** with `onnxruntime-web` (WebGPU where
330
+ supported, WASM otherwise); models are fetched once and cached.
448
331
 
449
- ## In progress / roadmap
332
+ - **Segment** — draw rectangles, then each box becomes a SAM box prompt.
333
+ - **Point prompts** — click an object to segment it as a new region;
334
+ `Shift`/`Alt`-click excludes, `Enter` commits, `Esc` undoes.
335
+ - **Model picker** — micro-sam ViT-T (default) / ViT-B for light microscopy,
336
+ patho-sam ViT-B (fp16 or int8) for H&E.
337
+ - **Cellpose** — automatic cellpose-SAM: one region per detected cell inside each
338
+ rectangle.
339
+
340
+ Models, hosting and the host configuration:
341
+ [docs/guides/segmentation.md](docs/guides/segmentation.md).
342
+
343
+ ## Extending the viewer
344
+
345
+ Other packages can add to the viewer through Angular DI, with plain objects and
346
+ no Angular compiler required:
450
347
 
451
- Work that is landed-but-unstable or planned (not yet available):
348
+ - **Plot modes** on `PLOT_TYPE_CONTRIBUTIONS` — a new entry in the plot-type
349
+ selector that rides on a built-in view and gets the viewport, the visualizer
350
+ and an optional side panel. See
351
+ [docs/guides/plot-type-contributions.md](docs/guides/plot-type-contributions.md).
352
+ - **Toolbar tools** on `TOOLBAR_TOOLS` — a parameter dialog that runs once, or an
353
+ interactive **dialog tool** (`kind: 'dialog'`) with its own session. See
354
+ [docs/guides/dialog-tools.md](docs/guides/dialog-tools.md).
452
355
 
453
- - **Intensity profile tool** *(work in progress — not yet stable)* — coloured line
356
+ ## In progress / roadmap
357
+
358
+ - **Intensity profile tool** _(work in progress — not yet stable)_ — coloured line
454
359
  ROIs with a floating inset chart that plots intensity along each line and updates
455
360
  live as the line is dragged. Usable today but the API/UX and multi-line/stack
456
361
  behaviour are still settling.
457
- - **Example / test server + demos** *(planned)* — a small example server, bundled
458
- with the library, that powers a set of runnable **demos** showcasing the
459
- image-visualization use cases (tiled OSD viewing, Plotly plots, region tools,
460
- and browser-side SAM/cellpose segmentation) against sample images — so the
461
- library can be evaluated and developed standalone, outside jit-ui. Tracked in
462
- the library-extraction SOW ([docs/JIT_UI_visualization_library_SOW.docx](docs/JIT_UI_visualization_library_SOW.docx)).
463
- - **Spatial-omics follow-ons** *(planned — the modes themselves shipped in
464
- 0.4.0, see [Spatial omics](#spatial-omics))* — hover tooltips over
465
- observations, brushing a chart selection back onto the map, and a GPU shapes
466
- layer for cell-boundary polygons (the example server serves them; nothing draws
467
- them yet, since a DOM overlay will not hold 10⁴–10⁵ outlines). The GPU layer is
468
- measured as feasible — generating the geometry in a compute pass is bit-exact
469
- and ~16× faster than JS, and 10⁵–10⁶ outlines draw in single-digit
470
- milliseconds; the constraint is napari-js's closed renderer, not WebGPU. See
471
- [.planning/research/cell-boundary-polygons-webgpu.md](.planning/research/cell-boundary-polygons-webgpu.md)
472
- and [docs/spatial-omics-plot-mode-design.md](docs/spatial-omics-plot-mode-design.md).
473
- - **SAM 3 model** *(planned)* — a `variant: 'sam3'` decoder path + export tooling
362
+ - **Chart → map brushing** _(planned)_ — brushing a selection in a spatial-omics
363
+ distribution chart back onto the map. See
364
+ [docs/design/spatial-omics-plot-mode-design.md](docs/design/spatial-omics-plot-mode-design.md).
365
+ - **SAM 3 model** _(planned)_ — a `variant: 'sam3'` decoder path + export tooling
474
366
  (SAM 2/3 use a different mask I/O than the current SAM-v1 path). See
475
- [docs/sam-segmentation-design.md](docs/sam-segmentation-design.md).
367
+ [docs/design/sam-segmentation-design.md](docs/design/sam-segmentation-design.md).
476
368
  - **int8 patho-sam validation** — the `patho-sam-vit-b-int8` option is sanity-checked
477
369
  (IoU ~0.99 vs fp16 on a synthetic prompt) but not yet validated on real H&E
478
370
  slides, where int8 ViT attention can degrade on subtle boundaries.
479
371
 
480
372
  ## Documentation
481
373
 
482
- Design, architecture, and planning docs for the library:
483
-
484
- - **[docs/sam-segmentation-design.md](docs/sam-segmentation-design.md)** — design of
485
- the browser SAM segmentation: model choice, ONNX export/quantization recipe,
486
- encoder/decoder I/O, the engine/session architecture, and the rollout phases.
487
- - **[docs/spatial-omics-plot-mode-design.md](docs/spatial-omics-plot-mode-design.md)** —
488
- design and phased plan for the spatial-omics plot mode: current-state audit,
489
- what the CosMx / Spatial-Live / SpatialData references contribute, the data
490
- plane, MoSCoW requirements, and the open questions still to settle.
491
- - **Architecture diagrams**
492
- - [docs/jit-ui-visualization-architecture.mmd](docs/jit-ui-visualization-architecture.mmd)
493
- ([PNG](docs/img/jit-ui-visualization-architecture.png) ·
494
- [SVG](docs/img/jit-ui-visualization-architecture.svg)) — host ⇄ library ⇄
495
- rendering backends, ports, and the jit-service request flow (tiles, preview,
496
- region/zoom, Plotly data).
497
- - [docs/jit-ui-region-architecture.mmd](docs/jit-ui-region-architecture.mmd)
498
- ([PNG](docs/img/jit-ui-region-architecture.png) ·
499
- [SVG](docs/img/jit-ui-region-architecture.svg)) — the region interfaces +
500
- region tools and how OSD and Plotly each implement the overlay.
501
- - Diagram/SOW generators: [docs/gen_architecture_diagram.py](docs/gen_architecture_diagram.py),
502
- [docs/gen_jit_ui_visualization_sow.py](docs/gen_jit_ui_visualization_sow.py).
374
+ - **[docs/ARCHITECTURE.md](docs/ARCHITECTURE.md)** — how `src/lib` is laid out:
375
+ layers, backends, contracts, stores, regions, tools, workers and testing.
376
+ - **Guides** — [host integration](docs/guides/host-integration.md) ·
377
+ [spatial omics](docs/guides/spatial-omics.md) ·
378
+ [segmentation](docs/guides/segmentation.md) ·
379
+ [plot-type contributions](docs/guides/plot-type-contributions.md) ·
380
+ [dialog tools](docs/guides/dialog-tools.md).
381
+ - **Design records** ([docs/design/](docs/design/)) — each with a Status line:
382
+ [SAM segmentation](docs/design/sam-segmentation-design.md) ·
383
+ [spatial-omics plot mode](docs/design/spatial-omics-plot-mode-design.md) ·
384
+ [region holes](docs/design/region-holes-design.md) ·
385
+ [region boolean ops](docs/design/region-boolean-ops-design.md) ·
386
+ [MCP control bridge](docs/design/mcp-control-design.md) ·
387
+ [omics preprocessing in JIT](docs/design/omics-preprocessing-jit.md).
388
+ - **Architecture diagrams** (Mermaid sources, ELK layout) in [docs/diagrams/](docs/diagrams/):
389
+ - [siv-architecture.mmd](docs/diagrams/siv-architecture.mmd) — host ⇄ contracts ⇄
390
+ router ⇄ OSD / Plotly / napari-js backends, the stores, spatial omics, the
391
+ workers, and the servers the library talks to.
392
+ - [siv-regions.mmd](docs/diagrams/siv-regions.mmd) — the region interfaces, the
393
+ three region overlays, the on-canvas tools with their tool kit and geometry,
394
+ and the `RegionStore`.
395
+
396
+ The PNG/SVG renders in `docs/img/` are of the earlier, pre-napari diagrams that
397
+ the SOW documents embed.
398
+
503
399
  - **[docs/JIT_UI_visualization_library_SOW.docx](docs/JIT_UI_visualization_library_SOW.docx)** —
504
- statement of work for extracting/publishing this library (incl. test-coverage
505
- results and the example-server task).
506
- - **[REFACTORING-PLAN.md](docs/REFACTORING-PLAN.md)** — the plan that shaped the
507
- current module/contract/implementation boundaries.
400
+ statement of work for extracting/publishing this library.
401
+ - **History** ([docs/history/](docs/history/)) — the 2026-06 refactoring plan, the
402
+ shared-backend refactor, the OpenSeadragon backend investigation, past bug
403
+ write-ups and review records. Kept for
404
+ context; not current.
508
405
 
509
406
  Related (host side, in jit-ui):
510
407
 
@@ -518,27 +415,33 @@ Related (host side, in jit-ui):
518
415
  ## Scientific references
519
416
 
520
417
  **Segment Anything (SAM)** — the promptable segmentation foundation model.
521
- > Kirillov, A. et al. *Segment Anything.* ICCV 2023. arXiv:[2304.02643](https://arxiv.org/abs/2304.02643).
418
+
419
+ > Kirillov, A. et al. _Segment Anything._ ICCV 2023. arXiv:[2304.02643](https://arxiv.org/abs/2304.02643).
522
420
  > Code: [facebookresearch/segment-anything](https://github.com/facebookresearch/segment-anything).
523
421
 
524
422
  **micro-sam** — SAM finetuned for microscopy (the `*_lm` models; default tool).
525
- > Archit, A. et al. *Segment Anything for Microscopy.* Nature Methods (2025); bioRxiv:[2023.08.21.554208](https://doi.org/10.1101/2023.08.21.554208).
423
+
424
+ > Archit, A. et al. _Segment Anything for Microscopy._ Nature Methods (2025); bioRxiv:[2023.08.21.554208](https://doi.org/10.1101/2023.08.21.554208).
526
425
  > Code: [computational-cell-analytics/micro-sam](https://github.com/computational-cell-analytics/micro-sam).
527
426
 
528
427
  **patho-sam** — SAM finetuned for histopathology (the `*_histopathology` models).
529
- > *Segment Anything for Histopathology.* arXiv:[2502.00408](https://arxiv.org/abs/2502.00408) (computational-cell-analytics).
428
+
429
+ > _Segment Anything for Histopathology._ arXiv:[2502.00408](https://arxiv.org/abs/2502.00408) (computational-cell-analytics).
530
430
  > Code: [computational-cell-analytics/patho-sam](https://github.com/computational-cell-analytics/patho-sam).
531
431
 
532
432
  **Cellpose** — generalist cellular segmentation (flow-field algorithm).
533
- > Stringer, C. et al. *Cellpose: a generalist algorithm for cellular segmentation.* Nature Methods 18, 100–106 (2021). doi:[10.1038/s41592-020-01018-x](https://doi.org/10.1038/s41592-020-01018-x).
433
+
434
+ > Stringer, C. et al. _Cellpose: a generalist algorithm for cellular segmentation._ Nature Methods 18, 100–106 (2021). doi:[10.1038/s41592-020-01018-x](https://doi.org/10.1038/s41592-020-01018-x).
534
435
  > Code: [MouseLand/cellpose](https://github.com/MouseLand/cellpose).
535
436
 
536
437
  **Cellpose-SAM** — Cellpose built on a SAM ViT backbone (the automatic tool).
537
- > Stringer, C. & Pachitariu, M. *Cellpose-SAM: superhuman generalization for cellular segmentation.* bioRxiv:[2025.04.28.651001](https://doi.org/10.1101/2025.04.28.651001).
438
+
439
+ > Stringer, C. & Pachitariu, M. _Cellpose-SAM: superhuman generalization for cellular segmentation._ bioRxiv:[2025.04.28.651001](https://doi.org/10.1101/2025.04.28.651001).
538
440
  > Model: [mouseland/cellpose-sam](https://huggingface.co/mouseland/cellpose-sam).
539
441
 
540
442
  **MobileSAM** — the TinyViT encoder behind micro-sam ViT-T.
541
- > Zhang, C. et al. *Faster Segment Anything: Towards Lightweight SAM for Mobile Applications.* arXiv:[2306.14289](https://arxiv.org/abs/2306.14289) (2023).
443
+
444
+ > Zhang, C. et al. _Faster Segment Anything: Towards Lightweight SAM for Mobile Applications._ arXiv:[2306.14289](https://arxiv.org/abs/2306.14289) (2023).
542
445
  > Code: [ChaoningZhang/MobileSAM](https://github.com/ChaoningZhang/MobileSAM).
543
446
 
544
447
  **Rendering & runtime libraries**
@@ -559,173 +462,11 @@ Related (host side, in jit-ui):
559
462
  Please cite the relevant model papers when publishing results produced with these
560
463
  tools.
561
464
 
562
- ## Usage (host integration, brief)
563
-
564
- Import `VisualizationModule`, render `<visualizer>` (and `<region-editor>` for
565
- the Regions panel), and provide the DI ports (`TILE_ACCESS_PORT`,
566
- `IMAGE_STATE_PORT`, `REGION_IO_PORT`, `VIZ_CONFIG`, and `CELL_SEGMENTER` for the
567
- cellpose adapter). Configure hosted SAM model URLs once at startup:
568
-
569
- ```ts
570
- import { setSamModelUrls } from '@jax-data-science/sci-image-visualizer';
571
-
572
- setSamModelUrls('microsam-vit-t-lm',
573
- 'https://huggingface.co/jax-image-tools/microsam-vit-t-lm-onnx/resolve/main/encoder.fp16.onnx',
574
- 'https://huggingface.co/jax-image-tools/microsam-vit-t-lm-onnx/resolve/main/decoder.onnx');
575
- ```
576
-
577
- `onnxruntime-web` WASM/JSEP sidecars must be served from `/assets/ort/`. See
578
- jit-ui's `app.module.ts` for a full wiring example.
579
-
580
- Each embeddable component uses a plain, unprefixed selector: `visualizer`,
581
- `region-editor`, `plotting-toolbar`, `channel-histogram`, `hex-color-picker`.
582
-
583
- ## Contributed plot types
584
-
585
- Another package can add a mode to the plot-type selector at runtime, through
586
- Angular DI — the same way `TOOLBAR_TOOLS` contributes toolbar tools. Nothing
587
- registers at import time: a mode appears only when the host provides it on the
588
- `PLOT_TYPE_CONTRIBUTIONS` multi-provider token, and with no provider the
589
- library behaves exactly as before. A contribution is a plain object, so the
590
- contributing package needs no Angular compiler and no decorators.
591
-
592
- ```ts
593
- import {
594
- PLOT_TYPE_CONTRIBUTIONS, PlotType, PlotTypeContribution,
595
- } from '@jax-data-science/sci-image-visualizer';
596
-
597
- const myMode: PlotTypeContribution = {
598
- descriptor: {
599
- type: 'my-mode', // namespaced; must not clash with a PlotType
600
- label: 'Image + my overlay', // test-mode label
601
- productionLabel: 'My overlay', // omit to make the mode test-only
602
- icon: 'pi pi-pencil',
603
- dimensions: '2d',
604
- baseType: PlotType.IMAGE, // v1: only the OpenSeadragon Image view
605
- },
606
- activate(ctx) {
607
- // ctx.visualizer — the public IVisualizer (regions, region overlay, undo…)
608
- // ctx.viewport — overlay container, dataToClient / clientToData, frame$ / settled$
609
- // ctx.imageInfo$ — the current image
610
- // ctx.tools — arm the toolbar brush for a class (0.6.0+):
611
- // ctx.tools?.armBrush({ label: 'tumour', color: '#1E88E5' })
612
- const sub = ctx.viewport.frame$.subscribe((visible) => redraw(visible));
613
- return { deactivate: () => sub.unsubscribe() };
614
- },
615
- // Optional side panel, in the right-hand panel area while the mode is active.
616
- // Either an Angular component (it can inject PLOT_MODE_CONTEXT / PLOT_MODE_SESSION)…
617
- // panel: { title: 'My overlay', component: MyPanelComponent },
618
- // …or plain DOM, for a package built without the Angular compiler:
619
- panel: {
620
- title: 'My overlay',
621
- mount(host, ctx, session) {
622
- host.textContent = 'Hello';
623
- return () => { host.textContent = ''; }; // teardown
624
- },
625
- },
626
- };
627
-
628
- // Host composition root:
629
- providers: [{ provide: PLOT_TYPE_CONTRIBUTIONS, useValue: myMode, multi: true }]
630
- ```
631
-
632
- Selecting the mode plots exactly as its `baseType` would (same backend, toolbar,
633
- region tools and wheel handling), then calls `activate(ctx)` once the viewport
634
- is ready. `session.deactivate()` runs exactly once when the user leaves the
635
- mode, when the image changes (a fresh session starts for the new image), or
636
- when the visualizer is destroyed. Anything a contribution throws or rejects is
637
- caught and logged. Failing to start falls back to `baseType`, and so does failing
638
- to clean up when the same mode is about to be re-activated (re-render, image
639
- switch). Contributed descriptors take the same `requiresGrayscale`,
640
- `requiresStack`, `requiresSpatialData` and `requiresSpatial3d` gates as the
641
- built-ins. The full contract
642
- and its guarantees are documented in
643
- [`plot-type-contribution.contract.ts`](./src/lib/contracts/plot-type-contribution.contract.ts).
644
-
645
- ## Contributed dialog tools
646
-
647
- An interactive tool that is not "set parameters, run once" can be a **dialog
648
- tool** (0.6.0+). It is provided on `TOOLBAR_TOOLS`, like the run tools, with
649
- `kind: 'dialog'`:
650
-
651
- - **Button:** it sits with the host's own projected buttons at the start of the
652
- toolbar, and shows in the Image view only.
653
- - **Dialog:** clicking the button opens a floating, non-modal dialog and starts
654
- a session. The tool fills the dialog body with plain DOM.
655
- - **Context:** the same one a plot mode gets (the public visualizer, the Image
656
- view's viewport, the current image), with `ctx.tools` always present.
657
-
658
- ```ts
659
- import { TOOLBAR_TOOLS, ToolbarDialogToolContribution } from '@jax-data-science/sci-image-visualizer';
660
-
661
- const myTool: ToolbarDialogToolContribution = {
662
- kind: 'dialog',
663
- id: 'my-tool',
664
- label: 'My tool',
665
- icon: { pi: 'pi-pencil' },
666
- tooltip: 'Open my tool',
667
- dialog: { title: 'My tool', width: '22rem' },
668
- activate(ctx) {
669
- const sub = ctx.viewport.frame$.subscribe((visible) => redraw(visible));
670
- return { deactivate: () => sub.unsubscribe() };
671
- },
672
- // After activate(), once the dialog has rendered: `host` is in the document here,
673
- // so the body can measure itself.
674
- mount(host, ctx, session) {
675
- host.textContent = 'Hello';
676
- return () => { host.textContent = ''; }; // teardown, before deactivate()
677
- },
678
- };
679
-
680
- providers: [{ provide: TOOLBAR_TOOLS, useValue: myTool, multi: true }]
681
- ```
682
-
683
- **Lifecycle:**
684
- - Clicking the button again, or closing the dialog, tears the body down and then
685
- calls `session.deactivate()`, exactly once.
686
- - Re-rendering the Image view (another image or slice) ends the session. The
687
- dialog stays open, and a fresh session starts on the new view.
688
- - Leaving the Image view closes the dialog.
689
- - A failed start closes the dialog with a warning. As with plot modes, nothing
690
- the tool throws or rejects escapes.
691
-
692
- ## Development
693
-
694
- ```bash
695
- npm install
696
- npm run build # ng-packagr → ./dist (the publishable package)
697
- npm test # jest (jest-preset-angular)
698
- npm run typecheck # tsc --noEmit
699
- npm run lint # eslint
700
- npm run format # prettier --write
701
- ```
702
-
703
- `npm run build` emits a complete, publishable Angular package into `dist/`
704
- (FESM2022 + ESM2022 bundles, type declarations, assets, README, LICENSE).
705
-
706
- ## Releasing
707
-
708
- Publishing is automated by CI (`.github/workflows/ci-cd.yaml`): pushing a
709
- `v*.*.*` tag whose version matches `package.json` and is reachable from `main`
710
- (or a `release/x.y.z` branch) builds, tests, and runs
711
- `npm publish --access public --provenance` from `dist/`. It requires an
712
- `NPM_TOKEN` repository secret with publish rights to the `@jax-data-science`
713
- npm scope.
714
-
715
- ```bash
716
- # bump package.json to x.y.z first, commit, then:
717
- git tag vx.y.z && git push origin vx.y.z
718
- ```
719
-
720
- Released versions and what changed in each are recorded in
721
- [`CHANGELOG.md`](./CHANGELOG.md); add an entry there as part of the change, not
722
- at tag time.
723
-
724
465
  ## Contributing
725
466
 
726
- Issues and pull requests are welcome. Please run `npm run lint`, `npm test`, and
727
- `npm run build` before opening a PR. Design and architecture notes live in
728
- [`docs/`](docs/).
467
+ Issues and pull requests are welcome. [CONTRIBUTING.md](CONTRIBUTING.md) covers
468
+ the dev loop (`npm run typecheck`, `npm run lint`, `npm test`, `npm run build`),
469
+ the branch and pull-request rules, and how releases are published.
729
470
 
730
471
  ## License
731
472