@fideus-labs/ngff-zarr 0.2.4 → 0.2.5

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 (192) hide show
  1. package/README.md +268 -76
  2. package/esm/browser-mod.js +1 -0
  3. package/esm/browser-mod.js.map +1 -0
  4. package/esm/io/from_ngff_zarr.d.ts.map +1 -1
  5. package/esm/io/from_ngff_zarr.js +2 -2
  6. package/esm/io/from_ngff_zarr.js.map +1 -0
  7. package/esm/io/hcs.js +1 -0
  8. package/esm/io/hcs.js.map +1 -0
  9. package/esm/io/itk_image_to_ngff_image.js +1 -0
  10. package/esm/io/itk_image_to_ngff_image.js.map +1 -0
  11. package/esm/io/ngff_image_to_itk_image.js +1 -0
  12. package/esm/io/ngff_image_to_itk_image.js.map +1 -0
  13. package/esm/io/to_ngff_image.js +1 -0
  14. package/esm/io/to_ngff_image.js.map +1 -0
  15. package/esm/io/to_ngff_zarr.d.ts.map +1 -1
  16. package/esm/io/to_ngff_zarr.js +2 -2
  17. package/esm/io/to_ngff_zarr.js.map +1 -0
  18. package/esm/methods/itkwasm-browser.js +1 -0
  19. package/esm/methods/itkwasm-browser.js.map +1 -0
  20. package/esm/methods/itkwasm-node.js +1 -0
  21. package/esm/methods/itkwasm-node.js.map +1 -0
  22. package/esm/methods/itkwasm-shared.js +1 -0
  23. package/esm/methods/itkwasm-shared.js.map +1 -0
  24. package/esm/methods/itkwasm.d.ts +14 -0
  25. package/esm/methods/itkwasm.d.ts.map +1 -0
  26. package/esm/methods/itkwasm.js +18 -0
  27. package/esm/methods/itkwasm.js.map +1 -0
  28. package/esm/mod.js +1 -0
  29. package/esm/mod.js.map +1 -0
  30. package/esm/process/to_multiscales-browser.js +1 -0
  31. package/esm/process/to_multiscales-browser.js.map +1 -0
  32. package/esm/process/to_multiscales-node.js +1 -0
  33. package/esm/process/to_multiscales-node.js.map +1 -0
  34. package/esm/process/to_multiscales-shared.js +1 -0
  35. package/esm/process/to_multiscales-shared.js.map +1 -0
  36. package/esm/schemas/coordinate_systems.js +1 -0
  37. package/esm/schemas/coordinate_systems.js.map +1 -0
  38. package/esm/schemas/index.js +1 -0
  39. package/esm/schemas/index.js.map +1 -0
  40. package/esm/schemas/methods.js +1 -0
  41. package/esm/schemas/methods.js.map +1 -0
  42. package/esm/schemas/multiscales.js +1 -0
  43. package/esm/schemas/multiscales.js.map +1 -0
  44. package/esm/schemas/ngff_image.js +1 -0
  45. package/esm/schemas/ngff_image.js.map +1 -0
  46. package/esm/schemas/ome_zarr.js +1 -0
  47. package/esm/schemas/ome_zarr.js.map +1 -0
  48. package/esm/schemas/rfc4.js +1 -0
  49. package/esm/schemas/rfc4.js.map +1 -0
  50. package/esm/schemas/units.js +1 -0
  51. package/esm/schemas/units.js.map +1 -0
  52. package/esm/schemas/zarr_metadata.js +1 -0
  53. package/esm/schemas/zarr_metadata.js.map +1 -0
  54. package/esm/types/array_interface.js +1 -0
  55. package/esm/types/array_interface.js.map +1 -0
  56. package/esm/types/hcs.js +1 -0
  57. package/esm/types/hcs.js.map +1 -0
  58. package/esm/types/methods.js +1 -0
  59. package/esm/types/methods.js.map +1 -0
  60. package/esm/types/multiscales.js +1 -0
  61. package/esm/types/multiscales.js.map +1 -0
  62. package/esm/types/ngff_image.js +1 -0
  63. package/esm/types/ngff_image.js.map +1 -0
  64. package/esm/types/rfc4.js +1 -0
  65. package/esm/types/rfc4.js.map +1 -0
  66. package/esm/types/units.js +1 -0
  67. package/esm/types/units.js.map +1 -0
  68. package/esm/types/zarr_metadata.js +1 -0
  69. package/esm/types/zarr_metadata.js.map +1 -0
  70. package/esm/utils/create_queue.js +1 -0
  71. package/esm/utils/create_queue.js.map +1 -0
  72. package/esm/utils/factory.js +1 -0
  73. package/esm/utils/factory.js.map +1 -0
  74. package/esm/utils/method_metadata.js +1 -0
  75. package/esm/utils/method_metadata.js.map +1 -0
  76. package/esm/utils/validation.js +1 -0
  77. package/esm/utils/validation.js.map +1 -0
  78. package/package.json +23 -34
  79. package/esm/_dnt.shims.d.ts +0 -2
  80. package/esm/_dnt.shims.d.ts.map +0 -1
  81. package/esm/_dnt.shims.js +0 -57
  82. package/esm/package.json +0 -3
  83. package/script/_dnt.shims.d.ts +0 -2
  84. package/script/_dnt.shims.d.ts.map +0 -1
  85. package/script/_dnt.shims.js +0 -60
  86. package/script/browser-mod.d.ts +0 -16
  87. package/script/browser-mod.d.ts.map +0 -1
  88. package/script/browser-mod.js +0 -51
  89. package/script/io/from_ngff_zarr.d.ts +0 -10
  90. package/script/io/from_ngff_zarr.d.ts.map +0 -1
  91. package/script/io/from_ngff_zarr.js +0 -234
  92. package/script/io/hcs.d.ts +0 -18
  93. package/script/io/hcs.d.ts.map +0 -1
  94. package/script/io/hcs.js +0 -55
  95. package/script/io/itk_image_to_ngff_image.d.ts +0 -30
  96. package/script/io/itk_image_to_ngff_image.d.ts.map +0 -1
  97. package/script/io/itk_image_to_ngff_image.js +0 -153
  98. package/script/io/ngff_image_to_itk_image.d.ts +0 -30
  99. package/script/io/ngff_image_to_itk_image.d.ts.map +0 -1
  100. package/script/io/ngff_image_to_itk_image.js +0 -244
  101. package/script/io/to_ngff_image.d.ts +0 -17
  102. package/script/io/to_ngff_image.d.ts.map +0 -1
  103. package/script/io/to_ngff_image.js +0 -162
  104. package/script/io/to_ngff_zarr.d.ts +0 -10
  105. package/script/io/to_ngff_zarr.d.ts.map +0 -1
  106. package/script/io/to_ngff_zarr.js +0 -346
  107. package/script/methods/itkwasm-browser.d.ts +0 -6
  108. package/script/methods/itkwasm-browser.d.ts.map +0 -1
  109. package/script/methods/itkwasm-browser.js +0 -488
  110. package/script/methods/itkwasm-node.d.ts +0 -6
  111. package/script/methods/itkwasm-node.d.ts.map +0 -1
  112. package/script/methods/itkwasm-node.js +0 -493
  113. package/script/methods/itkwasm-shared.d.ts +0 -68
  114. package/script/methods/itkwasm-shared.d.ts.map +0 -1
  115. package/script/methods/itkwasm-shared.js +0 -524
  116. package/script/mod.d.ts +0 -24
  117. package/script/mod.d.ts.map +0 -1
  118. package/script/mod.js +0 -50
  119. package/script/package.json +0 -3
  120. package/script/process/to_multiscales-browser.d.ts +0 -17
  121. package/script/process/to_multiscales-browser.d.ts.map +0 -1
  122. package/script/process/to_multiscales-browser.js +0 -17
  123. package/script/process/to_multiscales-node.d.ts +0 -18
  124. package/script/process/to_multiscales-node.d.ts.map +0 -1
  125. package/script/process/to_multiscales-node.js +0 -21
  126. package/script/process/to_multiscales-shared.d.ts +0 -28
  127. package/script/process/to_multiscales-shared.d.ts.map +0 -1
  128. package/script/process/to_multiscales-shared.js +0 -66
  129. package/script/schemas/coordinate_systems.d.ts +0 -251
  130. package/script/schemas/coordinate_systems.d.ts.map +0 -1
  131. package/script/schemas/coordinate_systems.js +0 -142
  132. package/script/schemas/index.d.ts +0 -9
  133. package/script/schemas/index.d.ts.map +0 -1
  134. package/script/schemas/index.js +0 -101
  135. package/script/schemas/methods.d.ts +0 -3
  136. package/script/schemas/methods.d.ts.map +0 -1
  137. package/script/schemas/methods.js +0 -11
  138. package/script/schemas/multiscales.d.ts +0 -4
  139. package/script/schemas/multiscales.d.ts.map +0 -1
  140. package/script/schemas/multiscales.js +0 -24
  141. package/script/schemas/ngff_image.d.ts +0 -20
  142. package/script/schemas/ngff_image.d.ts.map +0 -1
  143. package/script/schemas/ngff_image.js +0 -24
  144. package/script/schemas/ome_zarr.d.ts +0 -617
  145. package/script/schemas/ome_zarr.d.ts.map +0 -1
  146. package/script/schemas/ome_zarr.js +0 -211
  147. package/script/schemas/rfc4.d.ts +0 -334
  148. package/script/schemas/rfc4.d.ts.map +0 -1
  149. package/script/schemas/rfc4.js +0 -132
  150. package/script/schemas/units.d.ts +0 -78
  151. package/script/schemas/units.d.ts.map +0 -1
  152. package/script/schemas/units.js +0 -70
  153. package/script/schemas/zarr_metadata.d.ts +0 -55
  154. package/script/schemas/zarr_metadata.d.ts.map +0 -1
  155. package/script/schemas/zarr_metadata.js +0 -71
  156. package/script/types/array_interface.d.ts +0 -7
  157. package/script/types/array_interface.d.ts.map +0 -1
  158. package/script/types/array_interface.js +0 -2
  159. package/script/types/hcs.d.ts +0 -70
  160. package/script/types/hcs.d.ts.map +0 -1
  161. package/script/types/hcs.js +0 -233
  162. package/script/types/methods.d.ts +0 -7
  163. package/script/types/methods.d.ts.map +0 -1
  164. package/script/types/methods.js +0 -12
  165. package/script/types/multiscales.d.ts +0 -21
  166. package/script/types/multiscales.d.ts.map +0 -1
  167. package/script/types/multiscales.js +0 -38
  168. package/script/types/ngff_image.d.ts +0 -27
  169. package/script/types/ngff_image.d.ts.map +0 -1
  170. package/script/types/ngff_image.js +0 -48
  171. package/script/types/rfc4.d.ts +0 -94
  172. package/script/types/rfc4.d.ts.map +0 -1
  173. package/script/types/rfc4.js +0 -143
  174. package/script/types/units.d.ts +0 -12
  175. package/script/types/units.d.ts.map +0 -1
  176. package/script/types/units.js +0 -66
  177. package/script/types/zarr_metadata.d.ts +0 -58
  178. package/script/types/zarr_metadata.d.ts.map +0 -1
  179. package/script/types/zarr_metadata.js +0 -20
  180. package/script/utils/create_queue.d.ts +0 -6
  181. package/script/utils/create_queue.d.ts.map +0 -1
  182. package/script/utils/create_queue.js +0 -17
  183. package/script/utils/factory.d.ts +0 -13
  184. package/script/utils/factory.d.ts.map +0 -1
  185. package/script/utils/factory.js +0 -108
  186. package/script/utils/method_metadata.d.ts +0 -10
  187. package/script/utils/method_metadata.d.ts.map +0 -1
  188. package/script/utils/method_metadata.js +0 -40
  189. package/script/utils/validation.d.ts +0 -6
  190. package/script/utils/validation.d.ts.map +0 -1
  191. package/script/utils/validation.js +0 -78
  192. /package/{LICENSE → LICENSE.txt} +0 -0
package/esm/package.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }
@@ -1,2 +0,0 @@
1
- export declare const dntGlobalThis: Omit<typeof globalThis, never>;
2
- //# sourceMappingURL=_dnt.shims.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_dnt.shims.d.ts","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,gCAA2C,CAAC"}
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.dntGlobalThis = void 0;
4
- const dntGlobals = {};
5
- exports.dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
6
- function createMergeProxy(baseObj, extObj) {
7
- return new Proxy(baseObj, {
8
- get(_target, prop, _receiver) {
9
- if (prop in extObj) {
10
- return extObj[prop];
11
- }
12
- else {
13
- return baseObj[prop];
14
- }
15
- },
16
- set(_target, prop, value) {
17
- if (prop in extObj) {
18
- delete extObj[prop];
19
- }
20
- baseObj[prop] = value;
21
- return true;
22
- },
23
- deleteProperty(_target, prop) {
24
- let success = false;
25
- if (prop in extObj) {
26
- delete extObj[prop];
27
- success = true;
28
- }
29
- if (prop in baseObj) {
30
- delete baseObj[prop];
31
- success = true;
32
- }
33
- return success;
34
- },
35
- ownKeys(_target) {
36
- const baseKeys = Reflect.ownKeys(baseObj);
37
- const extKeys = Reflect.ownKeys(extObj);
38
- const extKeysSet = new Set(extKeys);
39
- return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
40
- },
41
- defineProperty(_target, prop, desc) {
42
- if (prop in extObj) {
43
- delete extObj[prop];
44
- }
45
- Reflect.defineProperty(baseObj, prop, desc);
46
- return true;
47
- },
48
- getOwnPropertyDescriptor(_target, prop) {
49
- if (prop in extObj) {
50
- return Reflect.getOwnPropertyDescriptor(extObj, prop);
51
- }
52
- else {
53
- return Reflect.getOwnPropertyDescriptor(baseObj, prop);
54
- }
55
- },
56
- has(_target, prop) {
57
- return prop in extObj || prop in baseObj;
58
- },
59
- });
60
- }
@@ -1,16 +0,0 @@
1
- export * from "./types/units.js";
2
- export * from "./types/methods.js";
3
- export * from "./types/array_interface.js";
4
- export * from "./types/zarr_metadata.js";
5
- export * from "./types/ngff_image.js";
6
- export * from "./types/multiscales.js";
7
- export * from "./schemas/units.js";
8
- export * from "./schemas/methods.js";
9
- export * from "./schemas/zarr_metadata.js";
10
- export * from "./schemas/ngff_image.js";
11
- export * from "./schemas/multiscales.js";
12
- export { isValidDimension, isValidUnit, validateMetadata, } from "./utils/validation.js";
13
- export { createAxis, createDataset, createMetadata, createMultiscales, createNgffImage, } from "./utils/factory.js";
14
- export { getMethodMetadata } from "./utils/method_metadata.js";
15
- export * from "./process/to_multiscales-browser.js";
16
- //# sourceMappingURL=browser-mod.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"browser-mod.d.ts","sourceRoot":"","sources":["../src/browser-mod.ts"],"names":[],"mappings":"AASA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AAEzC,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,UAAU,EACV,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAG/D,cAAc,qCAAqC,CAAC"}
@@ -1,51 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.getMethodMetadata = exports.createNgffImage = exports.createMultiscales = exports.createMetadata = exports.createDataset = exports.createAxis = exports.validateMetadata = exports.isValidUnit = exports.isValidDimension = void 0;
18
- // SPDX-FileCopyrightText: Copyright (c) Fideus Labs LLC
19
- // SPDX-License-Identifier: MIT
20
- // Browser-compatible module exports
21
- // This module excludes I/O functionality (from_ngff_zarr, to_ngff_zarr)
22
- // because those modules depend on Node.js/Deno-specific filesystem APIs
23
- // that are not available in browser environments.
24
- //
25
- // For browser use cases, the schemas, types, and validation utilities
26
- // are the most commonly needed functionality.
27
- __exportStar(require("./types/units.js"), exports);
28
- __exportStar(require("./types/methods.js"), exports);
29
- __exportStar(require("./types/array_interface.js"), exports);
30
- __exportStar(require("./types/zarr_metadata.js"), exports);
31
- __exportStar(require("./types/ngff_image.js"), exports);
32
- __exportStar(require("./types/multiscales.js"), exports);
33
- __exportStar(require("./schemas/units.js"), exports);
34
- __exportStar(require("./schemas/methods.js"), exports);
35
- __exportStar(require("./schemas/zarr_metadata.js"), exports);
36
- __exportStar(require("./schemas/ngff_image.js"), exports);
37
- __exportStar(require("./schemas/multiscales.js"), exports);
38
- var validation_js_1 = require("./utils/validation.js");
39
- Object.defineProperty(exports, "isValidDimension", { enumerable: true, get: function () { return validation_js_1.isValidDimension; } });
40
- Object.defineProperty(exports, "isValidUnit", { enumerable: true, get: function () { return validation_js_1.isValidUnit; } });
41
- Object.defineProperty(exports, "validateMetadata", { enumerable: true, get: function () { return validation_js_1.validateMetadata; } });
42
- var factory_js_1 = require("./utils/factory.js");
43
- Object.defineProperty(exports, "createAxis", { enumerable: true, get: function () { return factory_js_1.createAxis; } });
44
- Object.defineProperty(exports, "createDataset", { enumerable: true, get: function () { return factory_js_1.createDataset; } });
45
- Object.defineProperty(exports, "createMetadata", { enumerable: true, get: function () { return factory_js_1.createMetadata; } });
46
- Object.defineProperty(exports, "createMultiscales", { enumerable: true, get: function () { return factory_js_1.createMultiscales; } });
47
- Object.defineProperty(exports, "createNgffImage", { enumerable: true, get: function () { return factory_js_1.createNgffImage; } });
48
- var method_metadata_js_1 = require("./utils/method_metadata.js");
49
- Object.defineProperty(exports, "getMethodMetadata", { enumerable: true, get: function () { return method_metadata_js_1.getMethodMetadata; } });
50
- // Browser-compatible processing modules
51
- __exportStar(require("./process/to_multiscales-browser.js"), exports);
@@ -1,10 +0,0 @@
1
- import * as zarr from "zarrita";
2
- import { Multiscales } from "../types/multiscales.js";
3
- export interface FromNgffZarrOptions {
4
- validate?: boolean;
5
- version?: "0.4" | "0.5";
6
- }
7
- export type MemoryStore = Map<string, Uint8Array>;
8
- export declare function fromNgffZarr(store: string | MemoryStore | zarr.FetchStore, options?: FromNgffZarrOptions): Promise<Multiscales>;
9
- export declare function readArrayData(storePath: string, arrayPath: string, selection?: (number | null)[]): Promise<unknown>;
10
- //# sourceMappingURL=from_ngff_zarr.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"from_ngff_zarr.d.ts","sourceRoot":"","sources":["../../src/io/from_ngff_zarr.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAMtD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;CACzB;AAED,MAAM,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAElD,wBAAsB,YAAY,CAEhC,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAAC,UAAU,EAC7C,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,WAAW,CAAC,CA6MtB;AAED,wBAAsB,aAAa,CACjC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,GAC5B,OAAO,CAAC,OAAO,CAAC,CAmClB"}
@@ -1,234 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.fromNgffZarr = fromNgffZarr;
27
- exports.readArrayData = readArrayData;
28
- // SPDX-FileCopyrightText: Copyright (c) Fideus Labs LLC
29
- // SPDX-License-Identifier: MIT
30
- const dntShim = __importStar(require("../_dnt.shims.js"));
31
- const zarr = __importStar(require("zarrita"));
32
- const multiscales_js_1 = require("../types/multiscales.js");
33
- const ngff_image_js_1 = require("../types/ngff_image.js");
34
- const zarr_metadata_js_1 = require("../schemas/zarr_metadata.js");
35
- async function fromNgffZarr(
36
- // Also accepts FileSystemStore, ZipFileStore objects in Node.js/Deno
37
- store, options = {}) {
38
- const validate = options.validate ?? false;
39
- const version = options.version;
40
- try {
41
- // Determine the appropriate store type based on the path
42
- let resolvedStore;
43
- if (store instanceof Map || store instanceof zarr.FetchStore) {
44
- resolvedStore = store;
45
- }
46
- else if (store.startsWith("http://") || store.startsWith("https://")) {
47
- // Use FetchStore for HTTP/HTTPS URLs
48
- resolvedStore = new zarr.FetchStore(store);
49
- }
50
- else {
51
- // For local paths, check if we're in a browser environment
52
- if (typeof dntShim.dntGlobalThis !== "undefined") {
53
- throw new Error("Local file paths are not supported in browser environments. Use HTTP/HTTPS URLs instead.");
54
- }
55
- // Use dynamic import for FileSystemStore, ZipFileStore in Node.js/Deno environments
56
- try {
57
- const { FileSystemStore, ZipFileStore } = await Promise.resolve().then(() => __importStar(require("@zarrita/storage")));
58
- // @ts-ignore: Node/Deno workaround
59
- if (store instanceof FileSystemStore || store instanceof ZipFileStore) {
60
- // @ts-ignore: Node/Deno workaround
61
- resolvedStore = store;
62
- }
63
- else {
64
- // Normalize the path for cross-platform compatibility
65
- const normalizedPath = store.replace(/^\/([A-Za-z]:)/, "$1");
66
- // @ts-ignore: Node/Deno workaround
67
- resolvedStore = new FileSystemStore(normalizedPath);
68
- }
69
- }
70
- catch (error) {
71
- throw new Error(`Failed to load FileSystemStore: ${error}. Use HTTP/HTTPS URLs for browser compatibility.`);
72
- }
73
- }
74
- // Try to use consolidated metadata for better performance
75
- let optimizedStore;
76
- try {
77
- // @ts-ignore: tryWithConsolidated typing
78
- optimizedStore = await zarr.tryWithConsolidated(resolvedStore);
79
- }
80
- catch {
81
- optimizedStore = resolvedStore;
82
- }
83
- const root = await zarr.open(optimizedStore, {
84
- kind: "group",
85
- });
86
- const attrs = root.attrs;
87
- if (!attrs || !attrs.multiscales) {
88
- throw new Error("No multiscales metadata found in Zarr store");
89
- }
90
- const multiscalesArray = attrs
91
- .multiscales;
92
- if (!Array.isArray(multiscalesArray) || multiscalesArray.length === 0) {
93
- throw new Error("No multiscales metadata found in Zarr store");
94
- }
95
- const multiscalesMetadata = multiscalesArray[0];
96
- if (validate) {
97
- const result = zarr_metadata_js_1.MetadataSchema.safeParse(multiscalesMetadata);
98
- if (!result.success) {
99
- throw new Error(`Invalid OME-Zarr metadata: ${result.error.message}`);
100
- }
101
- // Check version compatibility if specified
102
- if (version) {
103
- const metadataWithVersion = multiscalesMetadata;
104
- if (metadataWithVersion.version !== version) {
105
- throw new Error(`Expected OME-Zarr version ${version}, but found ${metadataWithVersion.version || "unknown"}`);
106
- }
107
- }
108
- }
109
- const metadata = multiscalesMetadata;
110
- // Extract omero metadata from root attributes if present
111
- if (attrs.omero) {
112
- const omeroData = attrs.omero;
113
- // Handle backward compatibility for OMERO window metadata
114
- if (omeroData.channels && Array.isArray(omeroData.channels)) {
115
- for (const channel of omeroData.channels) {
116
- if (channel.window && typeof channel.window === "object") {
117
- const window = channel.window;
118
- // Ensure both min/max and start/end are present for compatibility
119
- if (window.min !== undefined && window.max !== undefined) {
120
- // If only min/max present, use them for start/end
121
- if (window.start === undefined) {
122
- window.start = window.min;
123
- }
124
- if (window.end === undefined) {
125
- window.end = window.max;
126
- }
127
- }
128
- else if (window.start !== undefined && window.end !== undefined) {
129
- // If only start/end present, use them for min/max
130
- if (window.min === undefined) {
131
- window.min = window.start;
132
- }
133
- if (window.max === undefined) {
134
- window.max = window.end;
135
- }
136
- }
137
- }
138
- }
139
- }
140
- metadata.omero = omeroData;
141
- }
142
- const images = [];
143
- for (const dataset of metadata.datasets) {
144
- const arrayPath = dataset.path;
145
- const zarrArray = (await zarr.open(root.resolve(arrayPath), {
146
- kind: "array",
147
- }));
148
- // Verify we have an array with the expected properties
149
- if (!zarrArray ||
150
- !("shape" in zarrArray) ||
151
- !("dtype" in zarrArray) ||
152
- !("chunks" in zarrArray)) {
153
- throw new Error(`Invalid zarr array at path ${arrayPath}: missing shape property`);
154
- }
155
- const scale = {};
156
- const translation = {};
157
- for (const transform of dataset.coordinateTransformations) {
158
- if (transform.type === "scale") {
159
- metadata.axes.forEach((axis, i) => {
160
- if (i < transform.scale.length) {
161
- scale[axis.name] = transform.scale[i];
162
- }
163
- });
164
- }
165
- else if (transform.type === "translation") {
166
- metadata.axes.forEach((axis, i) => {
167
- if (i < transform.translation.length) {
168
- translation[axis.name] = transform.translation[i];
169
- }
170
- });
171
- }
172
- }
173
- const dims = metadata.axes.map((axis) => axis.name);
174
- const axesUnits = metadata.axes.reduce((acc, axis) => {
175
- if (axis.unit) {
176
- acc[axis.name] = axis.unit;
177
- }
178
- return acc;
179
- }, {});
180
- const ngffImage = new ngff_image_js_1.NgffImage({
181
- data: zarrArray,
182
- dims,
183
- scale,
184
- translation,
185
- name: metadata.name,
186
- axesUnits: Object.keys(axesUnits).length > 0 ? axesUnits : undefined,
187
- computedCallbacks: undefined,
188
- });
189
- images.push(ngffImage);
190
- }
191
- return new multiscales_js_1.Multiscales({
192
- images,
193
- metadata,
194
- scaleFactors: undefined,
195
- method: undefined,
196
- chunks: undefined,
197
- });
198
- }
199
- catch (error) {
200
- throw new Error(`Failed to read OME-Zarr: ${error instanceof Error ? error.message : String(error)}`);
201
- }
202
- }
203
- async function readArrayData(storePath, arrayPath, selection) {
204
- try {
205
- const store = new zarr.FetchStore(storePath);
206
- const root = zarr.root(store);
207
- // Try to open as zarr v2 first, then v3 if that fails
208
- let zarrArray;
209
- try {
210
- zarrArray = await zarr.open.v2(root.resolve(arrayPath), {
211
- kind: "array",
212
- });
213
- }
214
- catch (v2Error) {
215
- try {
216
- zarrArray = await zarr.open.v3(root.resolve(arrayPath), {
217
- kind: "array",
218
- });
219
- }
220
- catch (v3Error) {
221
- throw new Error(`Failed to open zarr array ${arrayPath} as either v2 or v3 format. v2 error: ${v2Error}. v3 error: ${v3Error}`);
222
- }
223
- }
224
- if (selection) {
225
- return await zarr.get(zarrArray, selection);
226
- }
227
- else {
228
- return await zarr.get(zarrArray);
229
- }
230
- }
231
- catch (error) {
232
- throw new Error(`Failed to read array data: ${error instanceof Error ? error.message : String(error)}`);
233
- }
234
- }
@@ -1,18 +0,0 @@
1
- import type { HCSPlate } from "../types/hcs.js";
2
- export interface FromHcsZarrOptions {
3
- validate?: boolean;
4
- wellCacheSize?: number;
5
- imageCacheSize?: number;
6
- }
7
- export interface ToHcsZarrOptions {
8
- compressionLevel?: number;
9
- }
10
- /**
11
- * Read an HCS plate from an OME-Zarr NGFF store.
12
- */
13
- export declare function fromHcsZarr(store: string | object, options?: FromHcsZarrOptions): HCSPlate;
14
- /**
15
- * Write an HCS plate to an OME-Zarr NGFF store.
16
- */
17
- export declare function toHcsZarr(plate: HCSPlate, store: string | object, _options?: ToHcsZarrOptions): void;
18
- //# sourceMappingURL=hcs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hcs.d.ts","sourceRoot":"","sources":["../../src/io/hcs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAiB,MAAM,iBAAiB,CAAC;AAG/D,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,gBAAgB;IAE/B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,OAAO,GAAE,kBAAuB,GAC/B,QAAQ,CAkCV;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,QAAQ,EACf,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,QAAQ,GAAE,gBAAqB,GAC9B,IAAI,CAaN"}
package/script/io/hcs.js DELETED
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fromHcsZarr = fromHcsZarr;
4
- exports.toHcsZarr = toHcsZarr;
5
- const hcs_js_1 = require("../types/hcs.js");
6
- /**
7
- * Read an HCS plate from an OME-Zarr NGFF store.
8
- */
9
- function fromHcsZarr(store, options = {}) {
10
- const { validate = false, wellCacheSize, imageCacheSize } = options;
11
- if (validate) {
12
- console.warn("HCS validation not yet implemented");
13
- }
14
- if (typeof store !== "string") {
15
- throw new Error("Non-string store types not yet supported");
16
- }
17
- // For now, create a mock implementation
18
- // This will be properly implemented when the zarrita API integration is complete
19
- const plateMetadata = {
20
- columns: [{ name: "1" }, { name: "2" }],
21
- rows: [{ name: "A" }, { name: "B" }],
22
- wells: [
23
- { path: "A/1", rowIndex: 0, columnIndex: 0 },
24
- { path: "A/2", rowIndex: 0, columnIndex: 1 },
25
- { path: "B/1", rowIndex: 1, columnIndex: 0 },
26
- { path: "B/2", rowIndex: 1, columnIndex: 1 },
27
- ],
28
- version: "0.4",
29
- acquisitions: [{ id: 0, name: "Test Acquisition" }],
30
- field_count: 2,
31
- name: "Test Plate",
32
- };
33
- return new hcs_js_1.HCSPlate({
34
- store,
35
- metadata: plateMetadata,
36
- wellCacheSize,
37
- imageCacheSize,
38
- });
39
- }
40
- /**
41
- * Write an HCS plate to an OME-Zarr NGFF store.
42
- */
43
- function toHcsZarr(plate, store, _options = {}) {
44
- if (typeof store !== "string") {
45
- throw new Error("Non-string store types not yet supported");
46
- }
47
- // Mock implementation for now
48
- console.log(`HCS plate structure would be created at ${store}`);
49
- console.log(`Plate: ${plate.name}`);
50
- console.log(`Wells: ${plate.wells.length}`);
51
- console.log(`Rows: ${plate.rows.length}, Columns: ${plate.columns.length}`);
52
- if (plate.acquisitions) {
53
- console.log(`Acquisitions: ${plate.acquisitions.length}`);
54
- }
55
- }
@@ -1,30 +0,0 @@
1
- /**
2
- * Convert ITK-Wasm Image to NgffImage
3
- */
4
- import type { Image } from "itk-wasm";
5
- import { NgffImage } from "../types/ngff_image.js";
6
- export interface ItkImageToNgffImageOptions {
7
- /**
8
- * Whether to add anatomical orientation metadata based on ITK LPS coordinate system
9
- * @default true
10
- */
11
- addAnatomicalOrientation?: boolean;
12
- /**
13
- * Path prefix for the zarr array (e.g., "scale0/", "scale1/")
14
- * @default "image"
15
- */
16
- path?: string;
17
- }
18
- /**
19
- * Convert an ITK-Wasm Image to an NgffImage, preserving spatial metadata.
20
- *
21
- * This function converts ITK-Wasm Image objects to NgffImage format while
22
- * preserving spatial information like spacing, origin, and optionally
23
- * anatomical orientation based on the ITK LPS coordinate system.
24
- *
25
- * @param itkImage - The ITK-Wasm Image to convert
26
- * @param options - Conversion options
27
- * @returns Promise resolving to NgffImage
28
- */
29
- export declare function itkImageToNgffImage(itkImage: Image, options?: ItkImageToNgffImageOptions): Promise<NgffImage>;
30
- //# sourceMappingURL=itk_image_to_ngff_image.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"itk_image_to_ngff_image.d.ts","sourceRoot":"","sources":["../../src/io/itk_image_to_ngff_image.ts"],"names":[],"mappings":"AAEA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAOnD,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAEnC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,KAAK,EACf,OAAO,GAAE,0BAA+B,GACvC,OAAO,CAAC,SAAS,CAAC,CAmHpB"}
@@ -1,153 +0,0 @@
1
- "use strict";
2
- // SPDX-FileCopyrightText: Copyright (c) Fideus Labs LLC
3
- // SPDX-License-Identifier: MIT
4
- /**
5
- * Convert ITK-Wasm Image to NgffImage
6
- */
7
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
- if (k2 === undefined) k2 = k;
9
- var desc = Object.getOwnPropertyDescriptor(m, k);
10
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
- desc = { enumerable: true, get: function() { return m[k]; } };
12
- }
13
- Object.defineProperty(o, k2, desc);
14
- }) : (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- o[k2] = m[k];
17
- }));
18
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
- Object.defineProperty(o, "default", { enumerable: true, value: v });
20
- }) : function(o, v) {
21
- o["default"] = v;
22
- });
23
- var __importStar = (this && this.__importStar) || function (mod) {
24
- if (mod && mod.__esModule) return mod;
25
- var result = {};
26
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
27
- __setModuleDefault(result, mod);
28
- return result;
29
- };
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.itkImageToNgffImage = itkImageToNgffImage;
32
- const zarr = __importStar(require("zarrita"));
33
- const ngff_image_js_1 = require("../types/ngff_image.js");
34
- const rfc4_js_1 = require("../types/rfc4.js");
35
- // Import the get_strides function from zarrita utilities
36
- const zarrita_1 = require("zarrita");
37
- /**
38
- * Convert an ITK-Wasm Image to an NgffImage, preserving spatial metadata.
39
- *
40
- * This function converts ITK-Wasm Image objects to NgffImage format while
41
- * preserving spatial information like spacing, origin, and optionally
42
- * anatomical orientation based on the ITK LPS coordinate system.
43
- *
44
- * @param itkImage - The ITK-Wasm Image to convert
45
- * @param options - Conversion options
46
- * @returns Promise resolving to NgffImage
47
- */
48
- async function itkImageToNgffImage(itkImage, options = {}) {
49
- const { addAnatomicalOrientation = true, path = "image" } = options;
50
- // Extract image properties from ITK-Wasm Image
51
- const _data = itkImage.data;
52
- // ITK stores size in physical space order [x, y, z], but the data buffer is in
53
- // C-order (row-major) which means [z, y, x] indexing. Reverse to match data layout.
54
- const shape = [...itkImage.size].reverse();
55
- const spacing = itkImage.spacing;
56
- const origin = itkImage.origin;
57
- const ndim = shape.length;
58
- // Determine dimension names based on shape and image type
59
- // This logic matches the Python implementation
60
- let dims;
61
- // Check if this is a vector image (multi-component)
62
- const imageType = itkImage.imageType;
63
- const isVector = imageType.components > 1;
64
- if (ndim === 3 && isVector) {
65
- // 2D RGB/vector image: 2D spatial + components
66
- dims = ["y", "x", "c"];
67
- }
68
- else if (ndim < 4) {
69
- // Scalar images up to 3D: take the last ndim spatial dimensions
70
- dims = ["z", "y", "x"].slice(-ndim);
71
- }
72
- else if (ndim < 5) {
73
- // 3D RGB/vector or 4D scalar
74
- if (isVector) {
75
- dims = ["z", "y", "x", "c"];
76
- }
77
- else {
78
- dims = ["t", "z", "y", "x"];
79
- }
80
- }
81
- else if (ndim < 6) {
82
- // 4D RGB/vector
83
- dims = ["t", "z", "y", "x", "c"];
84
- }
85
- else {
86
- throw new Error(`Unsupported number of dimensions: ${ndim}`);
87
- }
88
- // Identify spatial dimensions
89
- const allSpatialDims = new Set(["x", "y", "z"]);
90
- const spatialDims = dims.filter((dim) => allSpatialDims.has(dim));
91
- // Create scale mapping from spacing
92
- // ITK stores spacing/origin in physical space order (x, y, z),
93
- // but we need to map them to array order (z, y, x).
94
- // Reverse the arrays to convert from physical to array order, matching Python implementation.
95
- const scale = {};
96
- const reversedSpacing = spacing.slice().reverse();
97
- spatialDims.forEach((dim, idx) => {
98
- scale[dim] = reversedSpacing[idx];
99
- });
100
- // Create translation mapping from origin
101
- const translation = {};
102
- const reversedOrigin = origin.slice().reverse();
103
- spatialDims.forEach((dim, idx) => {
104
- translation[dim] = reversedOrigin[idx];
105
- });
106
- // Create Zarr array from ITK-Wasm data
107
- const store = new Map();
108
- const root = zarr.root(store);
109
- // Determine appropriate chunk size
110
- const chunkShape = shape.map((s) => Math.min(s, 256));
111
- const zarrArray = await zarr.create(root.resolve(path), {
112
- shape: shape,
113
- chunk_shape: chunkShape,
114
- data_type: imageType.componentType,
115
- fill_value: 0,
116
- });
117
- // Write the ITK-Wasm data to the zarr array
118
- // We use zarrita's set function to write the entire data efficiently
119
- // Create a selection that covers the entire array (null means "all" for each dimension)
120
- const selection = new Array(ndim).fill(null);
121
- // Create a chunk object with the ITK-Wasm data in zarrita format
122
- // ITK-Wasm stores data in column-major order with size [x, y, z],
123
- // which has the same memory layout as C-order (row-major) with shape [z, y, x].
124
- // We reversed the shape above, and now use C-order strides for that reversed shape.
125
- const dataChunk = {
126
- data: itkImage.data,
127
- shape: shape,
128
- stride: (0, zarrita_1._zarrita_internal_get_strides)(shape, "C"), // C-order strides for the reversed shape
129
- };
130
- // Write all data to the zarr array using zarrita's set function
131
- // This handles chunking and encoding automatically
132
- await zarr.set(zarrArray, selection, dataChunk); // Add anatomical orientation if requested
133
- let axesOrientations;
134
- if (addAnatomicalOrientation) {
135
- axesOrientations = {};
136
- for (const dim of spatialDims) {
137
- const orientation = (0, rfc4_js_1.itkLpsToAnatomicalOrientation)(dim);
138
- if (orientation !== undefined) {
139
- axesOrientations[dim] = orientation;
140
- }
141
- }
142
- }
143
- return new ngff_image_js_1.NgffImage({
144
- data: zarrArray,
145
- dims,
146
- scale,
147
- translation,
148
- name: "image",
149
- axesUnits: undefined,
150
- axesOrientations,
151
- computedCallbacks: undefined,
152
- });
153
- }