@jax-data-science/sci-image-visualizer 0.1.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 (311) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +404 -0
  3. package/esm2022/index.mjs +52 -0
  4. package/esm2022/jax-data-science-sci-image-visualizer.mjs +5 -0
  5. package/esm2022/lib/channel-histogram/channel-histogram.component.mjs +398 -0
  6. package/esm2022/lib/contracts/capabilities.contract.mjs +32 -0
  7. package/esm2022/lib/contracts/cell-segmenter.contract.mjs +12 -0
  8. package/esm2022/lib/contracts/channel-histogram-api.contract.mjs +14 -0
  9. package/esm2022/lib/contracts/colormap-lut.mjs +95 -0
  10. package/esm2022/lib/contracts/coordinate-transform.contract.mjs +2 -0
  11. package/esm2022/lib/contracts/display-types.mjs +8 -0
  12. package/esm2022/lib/contracts/image.contract.mjs +11 -0
  13. package/esm2022/lib/contracts/intensity.mjs +28 -0
  14. package/esm2022/lib/contracts/plot-type.mjs +112 -0
  15. package/esm2022/lib/contracts/ports/image-state.port.mjs +3 -0
  16. package/esm2022/lib/contracts/ports/preferences.port.mjs +3 -0
  17. package/esm2022/lib/contracts/ports/region-io.port.mjs +3 -0
  18. package/esm2022/lib/contracts/ports/tile-access.port.mjs +3 -0
  19. package/esm2022/lib/contracts/region-editor-api.contract.mjs +4 -0
  20. package/esm2022/lib/contracts/region-overlay.contract.mjs +2 -0
  21. package/esm2022/lib/contracts/region-store.contract.mjs +2 -0
  22. package/esm2022/lib/contracts/sam.contract.mjs +12 -0
  23. package/esm2022/lib/contracts/toolbar-config.mjs +8 -0
  24. package/esm2022/lib/contracts/visualizer.contract.mjs +10 -0
  25. package/esm2022/lib/contracts/viz-config.mjs +3 -0
  26. package/esm2022/lib/hex-color-picker/hex-color-picker.component.mjs +260 -0
  27. package/esm2022/lib/implementations/base-store-visualizer.mjs +76 -0
  28. package/esm2022/lib/implementations/napari-js/napari-axes-labels.mjs +106 -0
  29. package/esm2022/lib/implementations/napari-js/napari-region-overlay.mjs +847 -0
  30. package/esm2022/lib/implementations/napari-js/napari-scale-bar.mjs +92 -0
  31. package/esm2022/lib/implementations/napari-js/napari-visualizer.service.mjs +2283 -0
  32. package/esm2022/lib/implementations/napari-js/napari-volume-z-handle.mjs +126 -0
  33. package/esm2022/lib/implementations/osd/display-pipeline.mjs +143 -0
  34. package/esm2022/lib/implementations/osd/histogram-sampler.mjs +217 -0
  35. package/esm2022/lib/implementations/osd/openseadragon-visualizer.service.mjs +1780 -0
  36. package/esm2022/lib/implementations/osd/osd-coordinate-transform.mjs +25 -0
  37. package/esm2022/lib/implementations/osd/osd-coords.mjs +53 -0
  38. package/esm2022/lib/implementations/osd/osd-lib.mjs +20 -0
  39. package/esm2022/lib/implementations/osd/osd-region-overlay.mjs +1237 -0
  40. package/esm2022/lib/implementations/osd/osd-scale-bar.mjs +88 -0
  41. package/esm2022/lib/implementations/osd/slice-cache.mjs +488 -0
  42. package/esm2022/lib/implementations/osd/tile-client.mjs +29 -0
  43. package/esm2022/lib/implementations/plotly/plotly-coordinate-transform.mjs +37 -0
  44. package/esm2022/lib/implementations/plotly/plotly-region-overlay.mjs +31 -0
  45. package/esm2022/lib/implementations/plotly/plotly-trace-builders.mjs +183 -0
  46. package/esm2022/lib/implementations/plotly/plotly.service.mjs +2137 -0
  47. package/esm2022/lib/implementations/simple-slice-access.service.mjs +99 -0
  48. package/esm2022/lib/models/bezier.mjs +120 -0
  49. package/esm2022/lib/models/class-preset.mjs +46 -0
  50. package/esm2022/lib/models/geometry.mjs +198 -0
  51. package/esm2022/lib/models/region.mjs +166 -0
  52. package/esm2022/lib/models/shape.mjs +53 -0
  53. package/esm2022/lib/plot.utilities.mjs +693 -0
  54. package/esm2022/lib/processing/image-converter.service.mjs +90 -0
  55. package/esm2022/lib/processing/image-crop.mjs +62 -0
  56. package/esm2022/lib/processing/processing-image.mjs +50 -0
  57. package/esm2022/lib/provide-visualization.mjs +63 -0
  58. package/esm2022/lib/region-editor/mask-raster.mjs +95 -0
  59. package/esm2022/lib/region-editor/mask-worker.mjs +10 -0
  60. package/esm2022/lib/region-editor/region-editor.component.mjs +1190 -0
  61. package/esm2022/lib/region-ops.service.mjs +301 -0
  62. package/esm2022/lib/render-orchestrator.mjs +87 -0
  63. package/esm2022/lib/routing-visualizer.service.mjs +533 -0
  64. package/esm2022/lib/store/class-color.util.mjs +52 -0
  65. package/esm2022/lib/store/region-store.service.mjs +1029 -0
  66. package/esm2022/lib/store/visualizer-store.service.mjs +352 -0
  67. package/esm2022/lib/toolbar/brush/brush-tool.service.mjs +546 -0
  68. package/esm2022/lib/toolbar/crop/slide-crop.mjs +57 -0
  69. package/esm2022/lib/toolbar/segmentation/cell-segment-tool.service.mjs +115 -0
  70. package/esm2022/lib/toolbar/segmentation/cellpose-segmenter.service.mjs +84 -0
  71. package/esm2022/lib/toolbar/segmentation/onnx-sam-session.mjs +133 -0
  72. package/esm2022/lib/toolbar/segmentation/ort-runtime-config.mjs +31 -0
  73. package/esm2022/lib/toolbar/segmentation/sam-model-registry.mjs +108 -0
  74. package/esm2022/lib/toolbar/segmentation/sam-onnx-core.mjs +159 -0
  75. package/esm2022/lib/toolbar/segmentation/sam-point-tool.service.mjs +255 -0
  76. package/esm2022/lib/toolbar/segmentation/sam-prompt.mjs +94 -0
  77. package/esm2022/lib/toolbar/segmentation/sam-tool.service.mjs +188 -0
  78. package/esm2022/lib/toolbar/toolbar.component.mjs +311 -0
  79. package/esm2022/lib/toolbar/vertex-eraser/vertex-eraser-tool.service.mjs +234 -0
  80. package/esm2022/lib/toolbar/wand/wand-tool.service.mjs +499 -0
  81. package/esm2022/lib/toolbar/wand/wand.service.mjs +921 -0
  82. package/esm2022/lib/toolbar/zoom-to-box/zoom-to-box-tool.service.mjs +157 -0
  83. package/esm2022/lib/visualization.module.mjs +162 -0
  84. package/esm2022/lib/visualizer.component.mjs +1597 -0
  85. package/fesm2022/jax-data-science-sci-image-visualizer-mask-worker-uhepXUhM.mjs +12 -0
  86. package/fesm2022/jax-data-science-sci-image-visualizer-mask-worker-uhepXUhM.mjs.map +1 -0
  87. package/fesm2022/jax-data-science-sci-image-visualizer-onnx-sam-session-ci1q0xnJ.mjs +327 -0
  88. package/fesm2022/jax-data-science-sci-image-visualizer-onnx-sam-session-ci1q0xnJ.mjs.map +1 -0
  89. package/fesm2022/jax-data-science-sci-image-visualizer.mjs +21314 -0
  90. package/fesm2022/jax-data-science-sci-image-visualizer.mjs.map +1 -0
  91. package/fesm2022/mask.worker.js +989 -0
  92. package/fesm2022/onnx-sam.worker.js +202 -0
  93. package/index.d.ts +39 -0
  94. package/lib/channel-histogram/channel-histogram.component.d.ts +112 -0
  95. package/lib/contracts/capabilities.contract.d.ts +30 -0
  96. package/lib/contracts/cell-segmenter.contract.d.ts +40 -0
  97. package/lib/contracts/channel-histogram-api.contract.d.ts +98 -0
  98. package/lib/contracts/colormap-lut.d.ts +21 -0
  99. package/lib/contracts/coordinate-transform.contract.d.ts +43 -0
  100. package/lib/contracts/display-types.d.ts +41 -0
  101. package/lib/contracts/image.contract.d.ts +72 -0
  102. package/lib/contracts/intensity.d.ts +18 -0
  103. package/lib/contracts/plot-type.d.ts +108 -0
  104. package/lib/contracts/ports/image-state.port.d.ts +29 -0
  105. package/lib/contracts/ports/preferences.port.d.ts +19 -0
  106. package/lib/contracts/ports/region-io.port.d.ts +29 -0
  107. package/lib/contracts/ports/tile-access.port.d.ts +27 -0
  108. package/lib/contracts/region-editor-api.contract.d.ts +83 -0
  109. package/lib/contracts/region-overlay.contract.d.ts +47 -0
  110. package/lib/contracts/region-store.contract.d.ts +74 -0
  111. package/lib/contracts/sam.contract.d.ts +98 -0
  112. package/lib/contracts/toolbar-config.d.ts +24 -0
  113. package/lib/contracts/visualizer.contract.d.ts +346 -0
  114. package/lib/contracts/viz-config.d.ts +25 -0
  115. package/lib/hex-color-picker/hex-color-picker.component.d.ts +47 -0
  116. package/lib/implementations/base-store-visualizer.d.ts +71 -0
  117. package/lib/implementations/napari-js/napari-axes-labels.d.ts +47 -0
  118. package/lib/implementations/napari-js/napari-region-overlay.d.ts +115 -0
  119. package/lib/implementations/napari-js/napari-scale-bar.d.ts +31 -0
  120. package/lib/implementations/napari-js/napari-visualizer.service.d.ts +455 -0
  121. package/lib/implementations/napari-js/napari-volume-z-handle.d.ts +46 -0
  122. package/lib/implementations/osd/display-pipeline.d.ts +47 -0
  123. package/lib/implementations/osd/histogram-sampler.d.ts +85 -0
  124. package/lib/implementations/osd/openseadragon-visualizer.service.d.ts +476 -0
  125. package/lib/implementations/osd/osd-coordinate-transform.d.ts +17 -0
  126. package/lib/implementations/osd/osd-coords.d.ts +16 -0
  127. package/lib/implementations/osd/osd-lib.d.ts +19 -0
  128. package/lib/implementations/osd/osd-region-overlay.d.ts +191 -0
  129. package/lib/implementations/osd/osd-scale-bar.d.ts +17 -0
  130. package/lib/implementations/osd/slice-cache.d.ts +161 -0
  131. package/lib/implementations/osd/tile-client.d.ts +32 -0
  132. package/lib/implementations/plotly/plotly-coordinate-transform.d.ts +19 -0
  133. package/lib/implementations/plotly/plotly-region-overlay.d.ts +23 -0
  134. package/lib/implementations/plotly/plotly-trace-builders.d.ts +60 -0
  135. package/lib/implementations/plotly/plotly.service.d.ts +594 -0
  136. package/lib/implementations/simple-slice-access.service.d.ts +64 -0
  137. package/lib/models/bezier.d.ts +59 -0
  138. package/lib/models/class-preset.d.ts +39 -0
  139. package/lib/models/geometry.d.ts +66 -0
  140. package/lib/models/region.d.ts +132 -0
  141. package/lib/models/shape.d.ts +44 -0
  142. package/lib/plot.utilities.d.ts +107 -0
  143. package/lib/processing/image-converter.service.d.ts +28 -0
  144. package/lib/processing/image-crop.d.ts +18 -0
  145. package/lib/processing/processing-image.d.ts +17 -0
  146. package/lib/provide-visualization.d.ts +34 -0
  147. package/lib/region-editor/mask-raster.d.ts +61 -0
  148. package/lib/region-editor/mask-worker.d.ts +7 -0
  149. package/lib/region-editor/region-editor.component.d.ts +305 -0
  150. package/lib/region-ops.service.d.ts +92 -0
  151. package/lib/render-orchestrator.d.ts +59 -0
  152. package/lib/routing-visualizer.service.d.ts +227 -0
  153. package/lib/store/class-color.util.d.ts +26 -0
  154. package/lib/store/region-store.service.d.ts +315 -0
  155. package/lib/store/visualizer-store.service.d.ts +123 -0
  156. package/lib/toolbar/brush/brush-tool.service.d.ts +143 -0
  157. package/lib/toolbar/crop/slide-crop.d.ts +30 -0
  158. package/lib/toolbar/segmentation/cell-segment-tool.service.d.ts +32 -0
  159. package/lib/toolbar/segmentation/cellpose-segmenter.service.d.ts +39 -0
  160. package/lib/toolbar/segmentation/onnx-sam-session.d.ts +25 -0
  161. package/lib/toolbar/segmentation/ort-runtime-config.d.ts +4 -0
  162. package/lib/toolbar/segmentation/sam-model-registry.d.ts +36 -0
  163. package/lib/toolbar/segmentation/sam-onnx-core.d.ts +48 -0
  164. package/lib/toolbar/segmentation/sam-point-tool.service.d.ts +59 -0
  165. package/lib/toolbar/segmentation/sam-prompt.d.ts +34 -0
  166. package/lib/toolbar/segmentation/sam-tool.service.d.ts +50 -0
  167. package/lib/toolbar/toolbar.component.d.ts +167 -0
  168. package/lib/toolbar/vertex-eraser/vertex-eraser-tool.service.d.ts +64 -0
  169. package/lib/toolbar/wand/wand-tool.service.d.ts +149 -0
  170. package/lib/toolbar/wand/wand.service.d.ts +133 -0
  171. package/lib/toolbar/zoom-to-box/zoom-to-box-tool.service.d.ts +49 -0
  172. package/lib/visualization.module.d.ts +45 -0
  173. package/lib/visualizer.component.d.ts +378 -0
  174. package/package.json +73 -0
  175. package/src/lib/assets/3d-coordinates.svg +49 -0
  176. package/src/lib/assets/cells.svg +1 -0
  177. package/src/lib/assets/click.svg +1 -0
  178. package/src/lib/assets/colormap-luts.json +1 -0
  179. package/src/lib/assets/contour.svg +48 -0
  180. package/src/lib/assets/cube-3d.svg +1 -0
  181. package/src/lib/assets/edit-selection-white.svg +47 -0
  182. package/src/lib/assets/heatmap.svg +1 -0
  183. package/src/lib/assets/icons/colormap-Pastel1.png +0 -0
  184. package/src/lib/assets/icons/colormap-accent.png +0 -0
  185. package/src/lib/assets/icons/colormap-afmhot.png +0 -0
  186. package/src/lib/assets/icons/colormap-autumn.png +0 -0
  187. package/src/lib/assets/icons/colormap-berlin.png +0 -0
  188. package/src/lib/assets/icons/colormap-binary.png +0 -0
  189. package/src/lib/assets/icons/colormap-blackbody.png +0 -0
  190. package/src/lib/assets/icons/colormap-bluered.png +0 -0
  191. package/src/lib/assets/icons/colormap-blues.png +0 -0
  192. package/src/lib/assets/icons/colormap-bone.png +0 -0
  193. package/src/lib/assets/icons/colormap-brbg.png +0 -0
  194. package/src/lib/assets/icons/colormap-brg.png +0 -0
  195. package/src/lib/assets/icons/colormap-bugn.png +0 -0
  196. package/src/lib/assets/icons/colormap-bupu.png +0 -0
  197. package/src/lib/assets/icons/colormap-bwr.png +0 -0
  198. package/src/lib/assets/icons/colormap-cividis.png +0 -0
  199. package/src/lib/assets/icons/colormap-cmrmap.png +0 -0
  200. package/src/lib/assets/icons/colormap-cool.png +0 -0
  201. package/src/lib/assets/icons/colormap-coolwarm.png +0 -0
  202. package/src/lib/assets/icons/colormap-copper.png +0 -0
  203. package/src/lib/assets/icons/colormap-cubehelix.png +0 -0
  204. package/src/lib/assets/icons/colormap-dark2.png +0 -0
  205. package/src/lib/assets/icons/colormap-earth.png +0 -0
  206. package/src/lib/assets/icons/colormap-electric.png +0 -0
  207. package/src/lib/assets/icons/colormap-flag.png +0 -0
  208. package/src/lib/assets/icons/colormap-gist_earth.png +0 -0
  209. package/src/lib/assets/icons/colormap-gist_gray.png +0 -0
  210. package/src/lib/assets/icons/colormap-gist_heat.png +0 -0
  211. package/src/lib/assets/icons/colormap-gist_ncar.png +0 -0
  212. package/src/lib/assets/icons/colormap-gist_rainbow.png +0 -0
  213. package/src/lib/assets/icons/colormap-gist_stern.png +0 -0
  214. package/src/lib/assets/icons/colormap-gist_yarg.png +0 -0
  215. package/src/lib/assets/icons/colormap-gnbu.png +0 -0
  216. package/src/lib/assets/icons/colormap-gnuplot.png +0 -0
  217. package/src/lib/assets/icons/colormap-gnuplot2.png +0 -0
  218. package/src/lib/assets/icons/colormap-gray.png +0 -0
  219. package/src/lib/assets/icons/colormap-greens-inv.png +0 -0
  220. package/src/lib/assets/icons/colormap-greens.png +0 -0
  221. package/src/lib/assets/icons/colormap-greys-inv.png +0 -0
  222. package/src/lib/assets/icons/colormap-greys.png +0 -0
  223. package/src/lib/assets/icons/colormap-hot.png +0 -0
  224. package/src/lib/assets/icons/colormap-hsv.png +0 -0
  225. package/src/lib/assets/icons/colormap-inferno.png +0 -0
  226. package/src/lib/assets/icons/colormap-jet.png +0 -0
  227. package/src/lib/assets/icons/colormap-magma.png +0 -0
  228. package/src/lib/assets/icons/colormap-managua.png +0 -0
  229. package/src/lib/assets/icons/colormap-nipy_spectral.png +0 -0
  230. package/src/lib/assets/icons/colormap-ocean.png +0 -0
  231. package/src/lib/assets/icons/colormap-oranges.png +0 -0
  232. package/src/lib/assets/icons/colormap-orrd.png +0 -0
  233. package/src/lib/assets/icons/colormap-pastel2.png +0 -0
  234. package/src/lib/assets/icons/colormap-picnic.png +0 -0
  235. package/src/lib/assets/icons/colormap-pink.png +0 -0
  236. package/src/lib/assets/icons/colormap-piyg.png +0 -0
  237. package/src/lib/assets/icons/colormap-placeholder.png +0 -0
  238. package/src/lib/assets/icons/colormap-plasma.png +0 -0
  239. package/src/lib/assets/icons/colormap-portland.png +0 -0
  240. package/src/lib/assets/icons/colormap-prgn.png +0 -0
  241. package/src/lib/assets/icons/colormap-prism.png +0 -0
  242. package/src/lib/assets/icons/colormap-pubu.png +0 -0
  243. package/src/lib/assets/icons/colormap-pubugn.png +0 -0
  244. package/src/lib/assets/icons/colormap-puor.png +0 -0
  245. package/src/lib/assets/icons/colormap-purd.png +0 -0
  246. package/src/lib/assets/icons/colormap-purples.png +0 -0
  247. package/src/lib/assets/icons/colormap-rainbow.png +0 -0
  248. package/src/lib/assets/icons/colormap-rdbu.png +0 -0
  249. package/src/lib/assets/icons/colormap-rdgy.png +0 -0
  250. package/src/lib/assets/icons/colormap-rdpu.png +0 -0
  251. package/src/lib/assets/icons/colormap-rdylbu.png +0 -0
  252. package/src/lib/assets/icons/colormap-rdylgn.png +0 -0
  253. package/src/lib/assets/icons/colormap-reds.png +0 -0
  254. package/src/lib/assets/icons/colormap-seismic.png +0 -0
  255. package/src/lib/assets/icons/colormap-set1.png +0 -0
  256. package/src/lib/assets/icons/colormap-set2.png +0 -0
  257. package/src/lib/assets/icons/colormap-set3.png +0 -0
  258. package/src/lib/assets/icons/colormap-spectral.png +0 -0
  259. package/src/lib/assets/icons/colormap-spring.png +0 -0
  260. package/src/lib/assets/icons/colormap-summer.png +0 -0
  261. package/src/lib/assets/icons/colormap-tab10.png +0 -0
  262. package/src/lib/assets/icons/colormap-tab20.png +0 -0
  263. package/src/lib/assets/icons/colormap-tab20b.png +0 -0
  264. package/src/lib/assets/icons/colormap-tab20c.png +0 -0
  265. package/src/lib/assets/icons/colormap-terrain.png +0 -0
  266. package/src/lib/assets/icons/colormap-turbo.png +0 -0
  267. package/src/lib/assets/icons/colormap-twilight.png +0 -0
  268. package/src/lib/assets/icons/colormap-twilight_shifted.png +0 -0
  269. package/src/lib/assets/icons/colormap-vanimo.png +0 -0
  270. package/src/lib/assets/icons/colormap-viridis.png +0 -0
  271. package/src/lib/assets/icons/colormap-winter.png +0 -0
  272. package/src/lib/assets/icons/colormap-wistia.png +0 -0
  273. package/src/lib/assets/icons/colormap-ylgn.png +0 -0
  274. package/src/lib/assets/icons/colormap-ylgnbu-inv.png +0 -0
  275. package/src/lib/assets/icons/colormap-ylgnbu.png +0 -0
  276. package/src/lib/assets/icons/colormap-ylorbr.png +0 -0
  277. package/src/lib/assets/icons/colormap-ylorrd-inv.png +0 -0
  278. package/src/lib/assets/icons/colormap-ylorrd.png +0 -0
  279. package/src/lib/assets/interactive-segmentation-cursor.svg +1 -0
  280. package/src/lib/assets/invert.svg +1 -0
  281. package/src/lib/assets/isosurface.svg +7 -0
  282. package/src/lib/assets/mask.svg +1 -0
  283. package/src/lib/assets/paintbrush.svg +1 -0
  284. package/src/lib/assets/picture-segmentation.svg +43 -0
  285. package/src/lib/assets/polygon-vertices.svg +13 -0
  286. package/src/lib/assets/polyline.svg +3 -0
  287. package/src/lib/assets/redo.svg +39 -0
  288. package/src/lib/assets/region-editor.svg +37 -0
  289. package/src/lib/assets/region-move.svg +7 -0
  290. package/src/lib/assets/smooth.svg +56 -0
  291. package/src/lib/assets/spline-chart.svg +7 -0
  292. package/src/lib/assets/surface.svg +37 -0
  293. package/src/lib/assets/test/download-379.svg +1 -0
  294. package/src/lib/assets/test/download-98.svg +1 -0
  295. package/src/lib/assets/test/json-1.svg +1 -0
  296. package/src/lib/assets/test/load-53.svg +1 -0
  297. package/src/lib/assets/test/mask-44.svg +1 -0
  298. package/src/lib/assets/test/mask-download-44.svg +15 -0
  299. package/src/lib/assets/test/mask-save-44.svg +11 -0
  300. package/src/lib/assets/test/overlay-1.svg +1 -0
  301. package/src/lib/assets/test/overlay-4.svg +1 -0
  302. package/src/lib/assets/test/region-26.svg +1 -0
  303. package/src/lib/assets/test/save-56.svg +1 -0
  304. package/src/lib/assets/test/upload-43.svg +1 -0
  305. package/src/lib/assets/to-bezier.svg +15 -0
  306. package/src/lib/assets/to-polygon.svg +11 -0
  307. package/src/lib/assets/undo.svg +38 -0
  308. package/src/lib/assets/vertex-add.svg +12 -0
  309. package/src/lib/assets/vertex-delete.svg +12 -0
  310. package/src/lib/assets/wand.svg +54 -0
  311. package/src/lib/assets/zoom-box.svg +10 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 The Jackson Laboratory
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,404 @@
1
+ # @jax-data-science/sci-image-visualizer
2
+
3
+ [![npm](https://img.shields.io/npm/v/%40jax-data-science%2Fsci-image-visualizer.svg)](https://www.npmjs.com/package/@jax-data-science/sci-image-visualizer)
4
+ [![CI / CD](https://github.com/TheJacksonLaboratory/sci-image-visualizer/actions/workflows/ci-cd.yaml/badge.svg)](https://github.com/TheJacksonLaboratory/sci-image-visualizer/actions/workflows/ci-cd.yaml)
5
+ [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
6
+
7
+ A framework-style **Angular 17** library for **interactive scientific image
8
+ visualization and annotation**. It renders large / multi-channel images through
9
+ pluggable backends — a tiled [OpenSeadragon](https://openseadragon.github.io/)
10
+ viewer, [Plotly](https://plotly.com/javascript/) 2D/3D plots, and a
11
+ [napari-js](https://www.npmjs.com/package/napari-js) **WebGPU** backend — behind a
12
+ single `IVisualizer` contract, and provides a rich set of on-canvas region /
13
+ annotation tools including **AI-assisted segmentation that runs entirely in the
14
+ browser** (WebGPU / WASM via [`onnxruntime-web`](https://github.com/microsoft/onnxruntime)).
15
+
16
+ Extracted from [jit-ui](https://github.com/TheJacksonLaboratory/jit-ui) (JAX Image
17
+ Tools) — see [jit-ui#80](https://github.com/TheJacksonLaboratory/jit-ui/issues/80) —
18
+ so the same viewer can be reused across the `@jax-data-science` portfolio. Open
19
+ source; contributions welcome.
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ npm install @jax-data-science/sci-image-visualizer
25
+ ```
26
+
27
+ Install the Angular / rendering **peer dependencies** your app doesn't already
28
+ have:
29
+
30
+ ```bash
31
+ npm install @angular/animations @angular/router primeng \
32
+ openseadragon plotly.js-dist-min image-js file-saver buffer onnxruntime-web
33
+ ```
34
+
35
+ ### Peer dependencies
36
+
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) |
46
+ | `cellpose-js` | `^0.3.0` | automatic cellpose-SAM segmentation |
47
+
48
+ The rendering backends and helpers — `openseadragon`, `plotly.js-dist-min`,
49
+ `napari-js`, `fast-png`, and `tslib` — are declared as regular **dependencies**
50
+ and installed automatically; you don't add them yourself. See
51
+ [Quick start](#usage-host-integration-brief) below for wiring.
52
+
53
+ ## Live demo & running the example
54
+
55
+ A serverless, **in-browser** example lives in
56
+ [`examples/browser-image/`](examples/browser-image/): a gallery of sample images
57
+ that render in the viewer with the region + zoom tools, with no backend at all
58
+ (the "Mode B" path — each image is a self-contained `tiled: false` source).
59
+
60
+ **Live demo:** <https://thejacksonlaboratory.github.io/sci-image-visualizer/> —
61
+ published by CI (`.github/workflows/pages.yaml`) to GitHub Pages on every push to `main`.
62
+
63
+ ### Run on localhost
64
+
65
+ ```bash
66
+ npm install # repo + example toolchain (Vite + Analog)
67
+ git lfs pull # fetch the sample-image bytes (they're stored in Git LFS)
68
+ npm run build # build the library into dist/ (the example consumes it)
69
+ npm run start:example # dev server → http://localhost:5173
70
+ ```
71
+
72
+ `npm run build:example` produces a static build in `examples/browser-image/dist/`.
73
+ See [`examples/browser-image/README.md`](examples/browser-image/README.md) for the
74
+ full walkthrough (adapters, TIFF handling, the Angular-17 toolchain note).
75
+
76
+ ## Highlights
77
+
78
+ - **Three rendering backends** — a tiled [OpenSeadragon](https://openseadragon.github.io/)
79
+ viewer, [Plotly](https://plotly.com/javascript/) plots, and a
80
+ [napari-js](https://www.npmjs.com/package/napari-js) **WebGPU** backend — behind
81
+ one `IVisualizer` contract; the host picks per plot type via `RoutingVisualizerService`.
82
+ - **Plot types** — Image (OSD), Plotly (Heatmap, Contour, Scatter 2D, Surface 3D,
83
+ Scatter 3D, Isosurface), and napari · WebGPU (Image, Scatter 2D, Surface,
84
+ Scatter 3D, Volume, Isosurface).
85
+ - **Region / annotation tools** — selection, rectangle, polyline, freeform,
86
+ polygon + vertex editing, move, Bézier↔polygon, magic wand, brush, vertex eraser.
87
+ - **Channels & histogram** — brightness/contrast/gamma, per-channel display,
88
+ colormaps / LUTs.
89
+ - **Region editor** — a Regions panel to list, select, rename, classify, recolor,
90
+ import/export (GeoJSON), and delete regions.
91
+ - **Image stacks** — a z-stack can be a single server-tiled file (internal z) or
92
+ a set of self-contained per-slice image URLs (`IImageInfo.tiled === false`, one
93
+ URL per slice), e.g. a folder of numbered files assembled by the host. Slices
94
+ load on demand as you scrub.
95
+ - **Per-slice ROIs + QuPath planes** — GeoJSON import/export carries the QuPath
96
+ image-plane convention (`geometry.plane.z`), and the host can supply one ROI
97
+ set per slice (`IImageInfo.roiJsonStrs`) that the viewer swaps on scrub.
98
+ - **Browser-side segmentation** — promptable SAM (box + interactive points) and
99
+ automatic cellpose-SAM, all client-side (see below).
100
+
101
+ ## Visualization
102
+
103
+ Open an image and it renders through whichever backend best fits it; the
104
+ `RoutingVisualizerService` switches backends per plot type and keeps the shared
105
+ state (regions, channels, zoom) consistent across them.
106
+
107
+ ### OpenSeadragon — tiled image view
108
+ The default **Image** view is a natively tiled, deeply zoomable raster powered by
109
+ [OpenSeadragon](https://openseadragon.github.io/). It streams pyramid tiles (the
110
+ host supplies them through the `TILE_ACCESS_PORT`, e.g. a `/tiles/info` + `/tile`
111
+ service), so gigapixel slides pan and zoom smoothly without loading the whole
112
+ image. It includes:
113
+
114
+ - a **navigator minimap** and a physical-units **scale bar**;
115
+ - **click-to-zoom** toward the clicked point, scroll-zoom, and drag-pan;
116
+ - a **raw-pixel vs. smoothing** toggle — images open at nearest-neighbour so
117
+ zoomed-in pixels stay crisp for inspection; toggle **Smoothen** for bilinear;
118
+ - **WYSIWYG PNG download** of the current view and a **fit-to-view / autoscale**
119
+ reset.
120
+
121
+ ### Plotly — plots & 3D
122
+ Non-image plot types render with [Plotly](https://plotly.com/javascript/) and
123
+ support "real zooming" — a downscaled overview that re-fetches higher-resolution
124
+ data as you zoom in:
125
+
126
+ - **Contour** and **Scatter (regions)** 2D plots;
127
+ - **Surface 3D**, **Scatter 3D**, and **Isosurface** for z-stacks, with an
128
+ **isosurface band** slider and full **3D camera** controls (zoom, pan, orbit,
129
+ turntable, reset);
130
+ - scalar/3D types expect a grayscale image (the volume types also need a z-stack).
131
+
132
+ ### napari-js — WebGPU
133
+ GPU-accelerated renderings via [napari-js](https://www.npmjs.com/package/napari-js)
134
+ (WebGPU), selectable from the plot-type menu as the "napari · WebGPU" variants of
135
+ Image, Scatter 2D, Surface, Scatter 3D, **Volume**, and **Isosurface**. It
136
+ assembles the volume from the slice endpoints with a runtime **decimate factor**
137
+ (resolution slider, default ½), a surface **wireframe** toggle, a 3D **axes / scale
138
+ gizmo**, an in-view **Z-height drag handle** for the volume, **cancellable** loading,
139
+ and **multichannel volume** compositing (one additive tinted layer per channel).
140
+ Regions and display options stay in sync with the other backends via the shared
141
+ stores.
142
+
143
+ When a stack is open, a slice slider (Image view) or single-image/stack toggle
144
+ (other views) navigates the z-dimension. A stack may be one server-tiled file
145
+ (internal z) or a set of self-contained per-slice URLs (`IImageInfo.tiled ===
146
+ false`) — the latter (e.g. a host-assembled folder of numbered files) fetches
147
+ `urls[z]` per slice on demand. For a per-slice stack the host can also supply a
148
+ matching ROI GeoJSON per slice (`IImageInfo.roiJsonStrs`), which the viewer
149
+ shows for the displayed slice and swaps as you scrub.
150
+
151
+ ### Intensity profiles *(work in progress)*
152
+ A line-ROI tool draws coloured lines and plots intensity along each one in a live
153
+ floating inset chart that re-samples at the current zoom. It works today but the
154
+ API/UX are still stabilizing (see [In progress / roadmap](#in-progress--roadmap)).
155
+
156
+ ## Regions & annotation
157
+
158
+ Regions are stored in a shared **region store** and use a GeoJSON-friendly model
159
+ (rectangles, polygons, polylines, Bézier curves) with an optional zero-based
160
+ `z` slice — GeoJSON import/export uses QuPath's `geometry.plane.z` (written only
161
+ for non-default slices, so single-plane images round-trip byte-identically).
162
+ Every tool writes to the same store, so regions persist across backend/plot-type
163
+ switches and are editable from the Regions panel. The on-canvas tools:
164
+
165
+ - **Selection** — neutral mode; deactivates any drawing tool.
166
+ - **Rectangle**, **Polyline** (open `LineString`), **Freeform** (drag-to-draw
167
+ closed polygon), and **Polygon** (click vertices, click first to close).
168
+ - **Vertex editing** — add vertex, delete vertex, and **move region**.
169
+ - **Bézier ↔ polygon** — convert a region to a smooth Bézier curve or back.
170
+ - **Magic wand** — grow a region from similar-valued pixels around the click;
171
+ `Ctrl`/`Cmd` for exact-match flood fill; drag to extend; `Shift` to erase;
172
+ a sensitivity slider tunes strictness. Growing into another region merges them.
173
+ - **Brush** — paint/erase a region with a circular brush (QuPath-style); a size
174
+ slider sets the diameter, `Shift` erases, and erasing across a region can split it.
175
+ - **Vertex eraser** — remove vertices within a radius from any region.
176
+ - **Delete** the selected region.
177
+
178
+ Wand- and brush-drawn regions default to the `legend` class; SAM/cellpose masks
179
+ inherit the color of the rectangle they came from.
180
+
181
+ ## Channels, histogram & colormaps
182
+
183
+ A floating **Channels & Histogram** dialog controls how intensities are mapped to
184
+ display: **brightness / contrast / gamma**, **per-channel** display for
185
+ multi-channel images, and — for grayscale — **colormap / LUT** selection with a
186
+ **reverse** toggle (default: inverted greys). Changes apply live in both backends.
187
+
188
+ ## Region editor (Regions panel)
189
+
190
+ The `<region-editor>` component is the Regions tab: a table of all regions
191
+ where you can **select**, **rename**, assign a **classification / class name**,
192
+ set **per-class colors**, toggle labels, **import / export ROIs** as GeoJSON
193
+ (`REGION_IO_PORT`), and **delete**. Selecting a row highlights the region on the
194
+ canvas (and vice-versa), so it pairs with the on-canvas tools above.
195
+
196
+ ## Segmentation tools (SAM & cellpose)
197
+
198
+ All segmentation runs **client-side** — models are fetched once (a progress
199
+ toast is shown), cached, then executed with `onnxruntime-web` (WebGPU where
200
+ supported, WASM otherwise). Generated regions inherit the color of the rectangle
201
+ they came from.
202
+
203
+ ### Box-prompt SAM — "Segment"
204
+ Draw one or more **rectangles** around objects, then click **Segment**. Each
205
+ rectangle is sent to SAM as a box prompt and replaced by the segmented mask.
206
+
207
+ ### Interactive point prompts
208
+ Click directly on an object to segment it as a **new** region (each click is an
209
+ independent object — clicking another object won't grow the previous one).
210
+ `Shift`/`Alt`-click adds an *exclude* point that refines the current object;
211
+ `Enter` commits, `Esc` undoes.
212
+
213
+ ### Model picker
214
+ A dropdown on the Segment button chooses the SAM model; the choice applies to
215
+ **both** the box and point tools. An info button summarizes the trade-offs.
216
+
217
+ ### Cellpose — automatic
218
+ Draw rectangles, then click **Cellpose** to auto-segment every cell inside each
219
+ rectangle (client-side cellpose-SAM via [`cellpose-js`](https://www.npmjs.com/package/cellpose-js)) —
220
+ one region per detected cell, no per-object clicking. (Cellpose-SAM is *not*
221
+ promptable, so it's the automatic tool rather than a model in the SAM picker.)
222
+
223
+ ## Models
224
+
225
+ Promptable SAM models are SAM-v1 encoder/decoder ONNX pairs (the encoder runs
226
+ once per image; the decoder runs per prompt). The registry lives in
227
+ `src/lib/toolbar/sam-model-registry.ts`; the host supplies hosted URLs via
228
+ `setSamModelUrls(...)`. Export/quantization tooling lives in the sibling
229
+ `browser-onnx-tools` project.
230
+
231
+ | Picker id | Domain | Encoder | Runs on | HF model |
232
+ |---|---|---|---|---|
233
+ | `microsam-vit-t-lm` *(default)* | light microscopy | TinyViT, ~14 MB fp16 | WASM¹ | [Ballon999/microsam-vit-t-lm-onnx](https://huggingface.co/Ballon999/microsam-vit-t-lm-onnx) |
234
+ | `microsam-vit-b-lm` | light microscopy | ViT-B, ~172 MB fp16 | WebGPU | [Ballon999/microsam-vit-b-lm-onnx](https://huggingface.co/Ballon999/microsam-vit-b-lm-onnx) |
235
+ | `patho-sam-vit-b` | histopathology (H&E) | ViT-B, ~172 MB fp16 | WebGPU | [Ballon999/patho-sam-vit-b-onnx](https://huggingface.co/Ballon999/patho-sam-vit-b-onnx) |
236
+ | `patho-sam-vit-b-int8` | histopathology (H&E) | ViT-B, ~100 MB int8 | WASM | [Ballon999/patho-sam-vit-b-onnx](https://huggingface.co/Ballon999/patho-sam-vit-b-onnx) (`encoder.int8.onnx`) |
237
+ | cellpose-SAM *(automatic)* | cells (generalist) | SAM ViT + flow head | WebGPU/WASM | [ballon999/cellpose-sam-onnx](https://huggingface.co/ballon999/cellpose-sam-onnx) |
238
+
239
+ ¹ TinyViT's fp16 attention overflows on the onnxruntime-web WebGPU EP (returns an
240
+ empty mask); it is numerically correct and fast on WASM, so its encoder is pinned
241
+ to WASM. int8 models also run on WASM (no WebGPU int8 matmul).
242
+
243
+ micro-sam and patho-sam are distributed through micro-sam's model registry
244
+ (`vit_*_lm`, `vit_*_histopathology`); SAM 3 is a planned addition (it needs a
245
+ `variant: 'sam3'` decoder path, since SAM 2/3 differ in mask I/O). See
246
+ `docs/sam-segmentation-design.md` for the design.
247
+
248
+ ## In progress / roadmap
249
+
250
+ Work that is landed-but-unstable or planned (not yet available):
251
+
252
+ - **Intensity profile tool** *(work in progress — not yet stable)* — coloured line
253
+ ROIs with a floating inset chart that plots intensity along each line and updates
254
+ live as the line is dragged. Usable today but the API/UX and multi-line/stack
255
+ behaviour are still settling.
256
+ - **Example / test server + demos** *(planned)* — a small example server, bundled
257
+ with the library, that powers a set of runnable **demos** showcasing the
258
+ image-visualization use cases (tiled OSD viewing, Plotly plots, region tools,
259
+ and browser-side SAM/cellpose segmentation) against sample images — so the
260
+ library can be evaluated and developed standalone, outside jit-ui. Tracked in
261
+ the library-extraction SOW ([docs/JIT_UI_visualization_library_SOW.docx](docs/JIT_UI_visualization_library_SOW.docx)).
262
+ - **SAM 3 model** *(planned)* — a `variant: 'sam3'` decoder path + export tooling
263
+ (SAM 2/3 use a different mask I/O than the current SAM-v1 path). See
264
+ [docs/sam-segmentation-design.md](docs/sam-segmentation-design.md).
265
+ - **int8 patho-sam validation** — the `patho-sam-vit-b-int8` option is sanity-checked
266
+ (IoU ~0.99 vs fp16 on a synthetic prompt) but not yet validated on real H&E
267
+ slides, where int8 ViT attention can degrade on subtle boundaries.
268
+
269
+ ## Documentation
270
+
271
+ Design, architecture, and planning docs for the library:
272
+
273
+ - **[docs/sam-segmentation-design.md](docs/sam-segmentation-design.md)** — design of
274
+ the browser SAM segmentation: model choice, ONNX export/quantization recipe,
275
+ encoder/decoder I/O, the engine/session architecture, and the rollout phases.
276
+ - **Architecture diagrams**
277
+ - [docs/jit-ui-visualization-architecture.mmd](docs/jit-ui-visualization-architecture.mmd)
278
+ ([PNG](docs/img/jit-ui-visualization-architecture.png) ·
279
+ [SVG](docs/img/jit-ui-visualization-architecture.svg)) — host ⇄ library ⇄
280
+ rendering backends, ports, and the jit-service request flow (tiles, preview,
281
+ region/zoom, Plotly data).
282
+ - [docs/jit-ui-region-architecture.mmd](docs/jit-ui-region-architecture.mmd)
283
+ ([PNG](docs/img/jit-ui-region-architecture.png) ·
284
+ [SVG](docs/img/jit-ui-region-architecture.svg)) — the region interfaces +
285
+ region tools and how OSD and Plotly each implement the overlay.
286
+ - Diagram/SOW generators: [docs/gen_architecture_diagram.py](docs/gen_architecture_diagram.py),
287
+ [docs/gen_jit_ui_visualization_sow.py](docs/gen_jit_ui_visualization_sow.py).
288
+ - **[docs/JIT_UI_visualization_library_SOW.docx](docs/JIT_UI_visualization_library_SOW.docx)** —
289
+ statement of work for extracting/publishing this library (incl. test-coverage
290
+ results and the example-server task).
291
+ - **[REFACTORING-PLAN.md](docs/REFACTORING-PLAN.md)** — the plan that shaped the
292
+ current module/contract/implementation boundaries.
293
+
294
+ Related (host side, in jit-ui):
295
+
296
+ - **[USE-VISUALIZATION-LIB-IN-PIPELINE-DIALOG.md](https://github.com/TheJacksonLaboratory/jit-ui/blob/master/apps/jit-ui/src/app/main/components/processing-pipeline/USE-VISUALIZATION-LIB-IN-PIPELINE-DIALOG.md)** —
297
+ how the processing-pipeline dialog embeds `<visualizer>` and drives it
298
+ via `RoutingVisualizerService`.
299
+ - **[processing-pipeline/ARCHITECTURE.md](https://github.com/TheJacksonLaboratory/jit-ui/blob/master/apps/jit-ui/src/app/main/models/processing-pipeline/ARCHITECTURE.md)** —
300
+ the client/server processing-pipeline engines (OpenCV.js, transformers.js,
301
+ cellpose, client slide-crop, server) that consume this library's region tools.
302
+
303
+ ## Scientific references
304
+
305
+ **Segment Anything (SAM)** — the promptable segmentation foundation model.
306
+ > Kirillov, A. et al. *Segment Anything.* ICCV 2023. arXiv:[2304.02643](https://arxiv.org/abs/2304.02643).
307
+ > Code: [facebookresearch/segment-anything](https://github.com/facebookresearch/segment-anything).
308
+
309
+ **micro-sam** — SAM finetuned for microscopy (the `*_lm` models; default tool).
310
+ > 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).
311
+ > Code: [computational-cell-analytics/micro-sam](https://github.com/computational-cell-analytics/micro-sam).
312
+
313
+ **patho-sam** — SAM finetuned for histopathology (the `*_histopathology` models).
314
+ > *Segment Anything for Histopathology.* arXiv:[2502.00408](https://arxiv.org/abs/2502.00408) (computational-cell-analytics).
315
+ > Code: [computational-cell-analytics/patho-sam](https://github.com/computational-cell-analytics/patho-sam).
316
+
317
+ **Cellpose** — generalist cellular segmentation (flow-field algorithm).
318
+ > 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).
319
+ > Code: [MouseLand/cellpose](https://github.com/MouseLand/cellpose).
320
+
321
+ **Cellpose-SAM** — Cellpose built on a SAM ViT backbone (the automatic tool).
322
+ > 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).
323
+ > Model: [mouseland/cellpose-sam](https://huggingface.co/mouseland/cellpose-sam).
324
+
325
+ **MobileSAM** — the TinyViT encoder behind micro-sam ViT-T.
326
+ > Zhang, C. et al. *Faster Segment Anything: Towards Lightweight SAM for Mobile Applications.* arXiv:[2306.14289](https://arxiv.org/abs/2306.14289) (2023).
327
+ > Code: [ChaoningZhang/MobileSAM](https://github.com/ChaoningZhang/MobileSAM).
328
+
329
+ **Rendering & runtime libraries**
330
+
331
+ - **OpenSeadragon** — deep-zoom tiled image viewer.
332
+ [openseadragon.github.io](https://openseadragon.github.io/) ·
333
+ [GitHub](https://github.com/openseadragon/openseadragon).
334
+ - **Plotly.js** — interactive 2D/3D plotting.
335
+ [plotly.com/javascript](https://plotly.com/javascript/) ·
336
+ [GitHub](https://github.com/plotly/plotly.js).
337
+ - **napari** — multi-dimensional (n-D) scientific image viewer; the WebGPU
338
+ rendering backend here (`napari-js`) is modeled on it.
339
+ [napari.org](https://napari.org) · [GitHub](https://github.com/napari/napari) ·
340
+ doi:[10.5281/zenodo.3555620](https://doi.org/10.5281/zenodo.3555620).
341
+ - **onnxruntime-web** — WebGPU/WASM ONNX inference (the SAM & cellpose runtime).
342
+ [GitHub](https://github.com/microsoft/onnxruntime).
343
+
344
+ Please cite the relevant model papers when publishing results produced with these
345
+ tools.
346
+
347
+ ## Usage (host integration, brief)
348
+
349
+ Import `VisualizationModule`, render `<visualizer>` (and `<region-editor>` for
350
+ the Regions panel), and provide the DI ports (`TILE_ACCESS_PORT`,
351
+ `IMAGE_STATE_PORT`, `REGION_IO_PORT`, `VIZ_CONFIG`, and `CELL_SEGMENTER` for the
352
+ cellpose adapter). Configure hosted SAM model URLs once at startup:
353
+
354
+ ```ts
355
+ import { setSamModelUrls } from '@jax-data-science/sci-image-visualizer';
356
+
357
+ setSamModelUrls('microsam-vit-t-lm',
358
+ 'https://huggingface.co/Ballon999/microsam-vit-t-lm-onnx/resolve/main/encoder.fp16.onnx',
359
+ 'https://huggingface.co/Ballon999/microsam-vit-t-lm-onnx/resolve/main/decoder.onnx');
360
+ ```
361
+
362
+ `onnxruntime-web` WASM/JSEP sidecars must be served from `/assets/ort/`. See
363
+ jit-ui's `app.module.ts` for a full wiring example.
364
+
365
+ Each embeddable component uses a plain, unprefixed selector: `visualizer`,
366
+ `region-editor`, `plotting-toolbar`, `channel-histogram`, `hex-color-picker`.
367
+
368
+ ## Development
369
+
370
+ ```bash
371
+ npm install
372
+ npm run build # ng-packagr → ./dist (the publishable package)
373
+ npm test # jest (jest-preset-angular)
374
+ npm run typecheck # tsc --noEmit
375
+ npm run lint # eslint
376
+ npm run format # prettier --write
377
+ ```
378
+
379
+ `npm run build` emits a complete, publishable Angular package into `dist/`
380
+ (FESM2022 + ESM2022 bundles, type declarations, assets, README, LICENSE).
381
+
382
+ ## Releasing
383
+
384
+ Publishing is automated by CI (`.github/workflows/ci-cd.yaml`): pushing a
385
+ `v*.*.*` tag whose version matches `package.json` and is reachable from `main`
386
+ (or a `release/x.y.z` branch) builds, tests, and runs
387
+ `npm publish --access public --provenance` from `dist/`. It requires an
388
+ `NPM_TOKEN` repository secret with publish rights to the `@jax-data-science`
389
+ npm scope.
390
+
391
+ ```bash
392
+ # bump package.json to x.y.z first, commit, then:
393
+ git tag vx.y.z && git push origin vx.y.z
394
+ ```
395
+
396
+ ## Contributing
397
+
398
+ Issues and pull requests are welcome. Please run `npm run lint`, `npm test`, and
399
+ `npm run build` before opening a PR. Design and architecture notes live in
400
+ [`docs/`](docs/).
401
+
402
+ ## License
403
+
404
+ [MIT](./LICENSE) © The Jackson Laboratory.
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Public API of the jax-image-visualization library. External consumers import
3
+ * ONLY from here (`@jax-data-science/sci-image-visualizer`); everything else under `lib/` is
4
+ * internal. The surface is contracts + tokens + neutral models + the Angular
5
+ * module, plus the routing service the host's composition root binds the tokens
6
+ * to (`useExisting`).
7
+ */
8
+ // ── Contracts & DI tokens ────────────────────────────────────────────────
9
+ export * from './lib/contracts/visualizer.contract';
10
+ export * from './lib/contracts/region-editor-api.contract';
11
+ export * from './lib/contracts/ports/image-state.port';
12
+ export * from './lib/contracts/ports/tile-access.port';
13
+ export * from './lib/contracts/ports/region-io.port';
14
+ export * from './lib/contracts/ports/preferences.port';
15
+ export * from './lib/contracts/channel-histogram-api.contract';
16
+ export * from './lib/contracts/viz-config';
17
+ export * from './lib/contracts/image.contract';
18
+ export * from './lib/contracts/plot-type';
19
+ export * from './lib/contracts/toolbar-config';
20
+ export * from './lib/contracts/capabilities.contract';
21
+ export * from './lib/contracts/region-overlay.contract';
22
+ export * from './lib/contracts/display-types';
23
+ export * from './lib/contracts/sam.contract';
24
+ export * from './lib/contracts/cell-segmenter.contract';
25
+ export { CellposeSegmenterService } from './lib/toolbar/segmentation/cellpose-segmenter.service';
26
+ // ── Generic client-side image utilities (shared with the host's pipeline) ──
27
+ export { ProcessingImage } from './lib/processing/processing-image';
28
+ export { cropImage } from './lib/processing/image-crop';
29
+ export { ImageConverterService } from './lib/processing/image-converter.service';
30
+ // ── SAM model registry (host configures hosted ONNX URLs once available) ──
31
+ export { SAM_MODELS, DEFAULT_SAM_MODEL_ID, getSamModel, isSamModelReady, setSamModelUrls, setDefaultSamModel, getDefaultSamModelId, } from './lib/toolbar/segmentation/sam-model-registry';
32
+ // ── onnxruntime-web WASM location (host overrides once, at app init) ───────
33
+ export { setOrtWasmBase, getOrtWasmBase } from './lib/toolbar/segmentation/ort-runtime-config';
34
+ // ── Neutral data models ──────────────────────────────────────────────────
35
+ export * from './lib/models/region';
36
+ export * from './lib/models/class-preset';
37
+ export { ShapeSelection } from './lib/models/shape';
38
+ // ── Angular module + composition-root service ────────────────────────────
39
+ export { VisualizationModule } from './lib/visualization.module';
40
+ export { RoutingVisualizerService } from './lib/routing-visualizer.service';
41
+ // Provider factory for an isolated, component-scoped viewer instance (e.g. a
42
+ // modal that must not share the main viewer's region/image state).
43
+ export { provideVisualization } from './lib/provide-visualization';
44
+ // ── Public components (exported by VisualizationModule) ───────────────────
45
+ // ng-packagr requires module-exported components to be reachable from the
46
+ // entry point so consumers get their types; these are the embeddable elements
47
+ // (`<visualizer>`, `<region-editor>`, `<hex-color-picker>`).
48
+ export { VisualizerComponent } from './lib/visualizer.component';
49
+ export { RegionEditorComponent } from './lib/region-editor/region-editor.component';
50
+ export { HexColorPickerComponent } from './lib/hex-color-picker/hex-color-picker.component';
51
+ export { ChannelHistogramComponent } from './lib/channel-histogram/channel-histogram.component';
52
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsNEVBQTRFO0FBQzVFLGNBQWMscUNBQXFDLENBQUM7QUFDcEQsY0FBYyw0Q0FBNEMsQ0FBQztBQUMzRCxjQUFjLHdDQUF3QyxDQUFDO0FBQ3ZELGNBQWMsd0NBQXdDLENBQUM7QUFDdkQsY0FBYyxzQ0FBc0MsQ0FBQztBQUNyRCxjQUFjLHd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DilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIBcbmV4cG9ydCAqIGZyb20gJy4vbGliL2NvbnRyYWN0cy92aXN1YWxpemVyLmNvbnRyYWN0JztcbmV4cG9ydCAqIGZyb20gJy4vbGliL2NvbnRyYWN0cy9yZWdpb24tZWRpdG9yLWFwaS5jb250cmFjdCc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9jb250cmFjdHMvcG9ydHMvaW1hZ2Utc3RhdGUucG9ydCc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9jb250cmFjdHMvcG9ydHMvdGlsZS1hY2Nlc3MucG9ydCc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9jb250cmFjdHMvcG9ydHMvcmVnaW9uLWlvLnBvcnQnO1xuZXhwb3J0ICogZnJvbSAnLi9saWIvY29udHJhY3RzL3BvcnRzL3ByZWZlcmVuY2VzLnBvcnQnO1xuZXhwb3J0ICogZnJvbSAnLi9saWIvY29udHJhY3RzL2NoYW5uZWwtaGlzdG9ncmFtLWFwaS5jb250cmFjdCc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9jb250cmFjdHMvdml6LWNvbmZpZyc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9jb250cmFjdHMvaW1hZ2UuY29udHJhY3QnO1xuZXhwb3J0ICogZnJvbSAnLi9saWIvY29udHJhY3RzL3Bsb3QtdHlwZSc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9jb250cmFjdHMvdG9vbGJhci1jb25maWcnO1xuZXhwb3J0ICogZnJvbSAnLi9saWIvY29udHJhY3RzL2NhcGFiaWxpdGllcy5jb250cmFjdCc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9jb250cmFjdHMvcmVnaW9uLW92ZXJsYXkuY29udHJhY3QnO1xuZXhwb3J0ICogZnJvbSAnLi9saWIvY29udHJh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50YXRpb24vc2FtLW1vZGVsLXJlZ2lzdHJ5JztcblxuLy8g4pSA4pSAIG9ubnhydW50aW1lLXdlYiBXQVNNIGxvY2F0aW9uIChob3N0IG92ZXJyaWRlcyBvbmNlLCBhdCBhcHAgaW5pdCkg4pSA4pSA4pSA4pSA4pSA4pSA4pSAXG5leHBvcnQgeyBzZXRPcnRXYXNtQmFzZSwgZ2V0T3J0V2FzbUJhc2UgfSBmcm9tICcuL2xpYi90b29sYmFyL3NlZ21lbnRhdGlvbi9vcnQtcnVudGltZS1jb25maWcnO1xuXG4vLyDilIDilIAgTmV1dHJhbCBkYXRhIG1vZGVscyDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIBcbmV4cG9ydCAqIGZyb20gJy4vbGliL21vZGVscy9yZWdpb24nO1xuZXhwb3J0ICogZnJvbSAnLi9saWIvbW9kZWxzL2NsYXNzLXByZXNldCc7XG5leHBvcnQgeyBTaGFwZVNlbGVjdGlvbiB9IGZyb20gJy4vbGliL21vZGVscy9zaGFwZSc7XG5cbi8vIOKUgOKUgCBBbmd1bGFyIG1vZHVsZSArIGNvbXBvc2l0aW9uLXJvb3Qgc2VydmljZSDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIDilIBcbmV4cG9ydCB7IFZpc3VhbGl6YXRpb25Nb2R1bGUgfSBmcm9tICcuL2xpYi92aXN1YWxpemF0aW9uLm1vZHVsZSc7XG5leHBvcnQgeyBSb3V0aW5nVmlzdWFsaXplclNlcnZpY2UgfSBmcm9tICcuL2xpYi9yb3V0aW5nLXZpc3VhbGl6ZXIuc2VydmljZSc7XG4vLyBQcm92aWRlciBmYWN0b3J5IGZvciBhbiB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1Db21wb25lbnQgfSBmcm9tICcuL2xpYi9jaGFubmVsLWhpc3RvZ3JhbS9jaGFubmVsLWhpc3RvZ3JhbS5jb21wb25lbnQnO1xuIl19
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ export * from './index';
5
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiamF4LWRhdGEtc2NpZW5jZS1zY2ktaW1hZ2UtdmlzdWFsaXplci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9qYXgtZGF0YS1zY2llbmNlLXNjaS1pbWFnZS12aXN1YWxpemVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBRUgsY0FBYyxTQUFTLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEdlbmVyYXRlZCBidW5kbGUgaW5kZXguIERvIG5vdCBlZGl0LlxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vaW5kZXgnO1xuIl19