@fideus-labs/ngff-zarr 0.0.1
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.
- package/LICENSE +10 -0
- package/README.md +73 -0
- package/esm/_dnt.shims.d.ts +2 -0
- package/esm/_dnt.shims.d.ts.map +1 -0
- package/esm/_dnt.shims.js +57 -0
- package/esm/io/from_ngff_zarr.d.ts +7 -0
- package/esm/io/from_ngff_zarr.d.ts.map +1 -0
- package/esm/io/from_ngff_zarr.js +140 -0
- package/esm/io/to_ngff_zarr.d.ts +9 -0
- package/esm/io/to_ngff_zarr.d.ts.map +1 -0
- package/esm/io/to_ngff_zarr.js +57 -0
- package/esm/mod.d.ts +17 -0
- package/esm/mod.d.ts.map +1 -0
- package/esm/mod.js +16 -0
- package/esm/package.json +3 -0
- package/esm/schemas/lazy_array.d.ts +8 -0
- package/esm/schemas/lazy_array.d.ts.map +1 -0
- package/esm/schemas/lazy_array.js +7 -0
- package/esm/schemas/methods.d.ts +3 -0
- package/esm/schemas/methods.d.ts.map +1 -0
- package/esm/schemas/methods.js +6 -0
- package/esm/schemas/multiscales.d.ts +4 -0
- package/esm/schemas/multiscales.d.ts.map +1 -0
- package/esm/schemas/multiscales.js +19 -0
- package/esm/schemas/ngff_image.d.ts +13 -0
- package/esm/schemas/ngff_image.d.ts.map +1 -0
- package/esm/schemas/ngff_image.js +12 -0
- package/esm/schemas/units.d.ts +13 -0
- package/esm/schemas/units.d.ts.map +1 -0
- package/esm/schemas/units.js +75 -0
- package/esm/schemas/zarr_metadata.d.ts +49 -0
- package/esm/schemas/zarr_metadata.d.ts.map +1 -0
- package/esm/schemas/zarr_metadata.js +47 -0
- package/esm/types/lazy_array.d.ts +18 -0
- package/esm/types/lazy_array.d.ts.map +1 -0
- package/esm/types/lazy_array.js +27 -0
- package/esm/types/methods.d.ts +7 -0
- package/esm/types/methods.d.ts.map +1 -0
- package/esm/types/methods.js +7 -0
- package/esm/types/multiscales.d.ts +21 -0
- package/esm/types/multiscales.d.ts.map +1 -0
- package/esm/types/multiscales.js +34 -0
- package/esm/types/ngff_image.d.ts +24 -0
- package/esm/types/ngff_image.d.ts.map +1 -0
- package/esm/types/ngff_image.js +32 -0
- package/esm/types/units.d.ts +12 -0
- package/esm/types/units.d.ts.map +1 -0
- package/esm/types/units.js +61 -0
- package/esm/types/zarr_metadata.d.ts +49 -0
- package/esm/types/zarr_metadata.d.ts.map +1 -0
- package/esm/types/zarr_metadata.js +14 -0
- package/esm/utils/factory.d.ts +13 -0
- package/esm/utils/factory.d.ts.map +1 -0
- package/esm/utils/factory.js +67 -0
- package/esm/utils/validation.d.ts +6 -0
- package/esm/utils/validation.d.ts.map +1 -0
- package/esm/utils/validation.js +72 -0
- package/package.json +47 -0
- package/script/_dnt.shims.d.ts +2 -0
- package/script/_dnt.shims.d.ts.map +1 -0
- package/script/_dnt.shims.js +60 -0
- package/script/io/from_ngff_zarr.d.ts +7 -0
- package/script/io/from_ngff_zarr.d.ts.map +1 -0
- package/script/io/from_ngff_zarr.js +167 -0
- package/script/io/to_ngff_zarr.d.ts +9 -0
- package/script/io/to_ngff_zarr.d.ts.map +1 -0
- package/script/io/to_ngff_zarr.js +83 -0
- package/script/mod.d.ts +17 -0
- package/script/mod.d.ts.map +1 -0
- package/script/mod.js +41 -0
- package/script/package.json +3 -0
- package/script/schemas/lazy_array.d.ts +8 -0
- package/script/schemas/lazy_array.d.ts.map +1 -0
- package/script/schemas/lazy_array.js +10 -0
- package/script/schemas/methods.d.ts +3 -0
- package/script/schemas/methods.d.ts.map +1 -0
- package/script/schemas/methods.js +9 -0
- package/script/schemas/multiscales.d.ts +4 -0
- package/script/schemas/multiscales.d.ts.map +1 -0
- package/script/schemas/multiscales.js +22 -0
- package/script/schemas/ngff_image.d.ts +13 -0
- package/script/schemas/ngff_image.d.ts.map +1 -0
- package/script/schemas/ngff_image.js +15 -0
- package/script/schemas/units.d.ts +13 -0
- package/script/schemas/units.d.ts.map +1 -0
- package/script/schemas/units.js +78 -0
- package/script/schemas/zarr_metadata.d.ts +49 -0
- package/script/schemas/zarr_metadata.d.ts.map +1 -0
- package/script/schemas/zarr_metadata.js +50 -0
- package/script/types/lazy_array.d.ts +18 -0
- package/script/types/lazy_array.d.ts.map +1 -0
- package/script/types/lazy_array.js +31 -0
- package/script/types/methods.d.ts +7 -0
- package/script/types/methods.d.ts.map +1 -0
- package/script/types/methods.js +10 -0
- package/script/types/multiscales.d.ts +21 -0
- package/script/types/multiscales.d.ts.map +1 -0
- package/script/types/multiscales.js +38 -0
- package/script/types/ngff_image.d.ts +24 -0
- package/script/types/ngff_image.d.ts.map +1 -0
- package/script/types/ngff_image.js +36 -0
- package/script/types/units.d.ts +12 -0
- package/script/types/units.d.ts.map +1 -0
- package/script/types/units.js +66 -0
- package/script/types/zarr_metadata.d.ts +49 -0
- package/script/types/zarr_metadata.d.ts.map +1 -0
- package/script/types/zarr_metadata.js +20 -0
- package/script/utils/factory.d.ts +13 -0
- package/script/utils/factory.d.ts.map +1 -0
- package/script/utils/factory.js +76 -0
- package/script/utils/validation.d.ts +6 -0
- package/script/utils/validation.d.ts.map +1 -0
- package/script/utils/validation.js +78 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AxesTypeSchema, SupportedDimsSchema, UnitsSchema } from "./units.js";
|
|
3
|
+
export declare const AxisSchema: z.ZodObject<{
|
|
4
|
+
name: typeof SupportedDimsSchema;
|
|
5
|
+
type: typeof AxesTypeSchema;
|
|
6
|
+
unit: z.ZodOptional<typeof UnitsSchema>;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const IdentitySchema: z.ZodObject<{
|
|
9
|
+
type: z.ZodLiteral<"identity">;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const ScaleSchema: z.ZodObject<{
|
|
12
|
+
scale: z.ZodArray<z.ZodNumber>;
|
|
13
|
+
type: z.ZodLiteral<"scale">;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const TranslationSchema: z.ZodObject<{
|
|
16
|
+
translation: z.ZodArray<z.ZodNumber>;
|
|
17
|
+
type: z.ZodLiteral<"translation">;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const TransformSchema: z.ZodUnion<[
|
|
20
|
+
typeof ScaleSchema,
|
|
21
|
+
typeof TranslationSchema
|
|
22
|
+
]>;
|
|
23
|
+
export declare const DatasetSchema: z.ZodObject<{
|
|
24
|
+
path: z.ZodString;
|
|
25
|
+
coordinateTransformations: z.ZodArray<typeof TransformSchema>;
|
|
26
|
+
}>;
|
|
27
|
+
export declare const OmeroWindowSchema: z.ZodObject<{
|
|
28
|
+
min: z.ZodNumber;
|
|
29
|
+
max: z.ZodNumber;
|
|
30
|
+
start: z.ZodNumber;
|
|
31
|
+
end: z.ZodNumber;
|
|
32
|
+
}>;
|
|
33
|
+
export declare const OmeroChannelSchema: z.ZodObject<{
|
|
34
|
+
color: z.ZodString;
|
|
35
|
+
window: typeof OmeroWindowSchema;
|
|
36
|
+
label: z.ZodOptional<z.ZodString>;
|
|
37
|
+
}>;
|
|
38
|
+
export declare const OmeroSchema: z.ZodObject<{
|
|
39
|
+
channels: z.ZodArray<typeof OmeroChannelSchema>;
|
|
40
|
+
}>;
|
|
41
|
+
export declare const MetadataSchema: z.ZodObject<{
|
|
42
|
+
axes: z.ZodArray<typeof AxisSchema>;
|
|
43
|
+
datasets: z.ZodArray<typeof DatasetSchema>;
|
|
44
|
+
coordinateTransformations: z.ZodOptional<z.ZodArray<typeof TransformSchema>>;
|
|
45
|
+
omero: z.ZodOptional<typeof OmeroSchema>;
|
|
46
|
+
name: z.ZodDefault<z.ZodString>;
|
|
47
|
+
version: z.ZodDefault<z.ZodString>;
|
|
48
|
+
}>;
|
|
49
|
+
//# sourceMappingURL=zarr_metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zarr_metadata.d.ts","sourceRoot":"","sources":["../../src/schemas/zarr_metadata.ts"],"names":[],"mappings":"AAA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4
|
+
name: SupportedDimsSchema,
|
|
5
|
+
type: AxesTypeSchema,
|
|
6
|
+
unit: UnitsSchema.optional(),
|
|
7
|
+
});
|
|
8
|
+
export const IdentitySchema = z.object({
|
|
9
|
+
type: z.literal("identity"),
|
|
10
|
+
});
|
|
11
|
+
export const ScaleSchema = z.object({
|
|
12
|
+
scale: z.array(z.number()),
|
|
13
|
+
type: z.literal("scale"),
|
|
14
|
+
});
|
|
15
|
+
export const TranslationSchema = z.object({
|
|
16
|
+
translation: z.array(z.number()),
|
|
17
|
+
type: z.literal("translation"),
|
|
18
|
+
});
|
|
19
|
+
export const TransformSchema = z.union([ScaleSchema, TranslationSchema]);
|
|
20
|
+
export const DatasetSchema = z.object({
|
|
21
|
+
path: z.string(),
|
|
22
|
+
coordinateTransformations: z.array(TransformSchema),
|
|
23
|
+
});
|
|
24
|
+
export const OmeroWindowSchema = z.object({
|
|
25
|
+
min: z.number(),
|
|
26
|
+
max: z.number(),
|
|
27
|
+
start: z.number(),
|
|
28
|
+
end: z.number(),
|
|
29
|
+
});
|
|
30
|
+
export const OmeroChannelSchema = z.object({
|
|
31
|
+
color: z.string().regex(/^[0-9A-Fa-f]{6}$/, {
|
|
32
|
+
message: "Color must be 6 hex digits",
|
|
33
|
+
}),
|
|
34
|
+
window: OmeroWindowSchema,
|
|
35
|
+
label: z.string().optional(),
|
|
36
|
+
});
|
|
37
|
+
export const OmeroSchema = z.object({
|
|
38
|
+
channels: z.array(OmeroChannelSchema),
|
|
39
|
+
});
|
|
40
|
+
export const MetadataSchema = z.object({
|
|
41
|
+
axes: z.array(AxisSchema),
|
|
42
|
+
datasets: z.array(DatasetSchema),
|
|
43
|
+
coordinateTransformations: z.array(TransformSchema).optional(),
|
|
44
|
+
omero: OmeroSchema.optional(),
|
|
45
|
+
name: z.string().default("image"),
|
|
46
|
+
version: z.string().default("0.4"),
|
|
47
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface LazyArrayMetadata {
|
|
2
|
+
shape: number[];
|
|
3
|
+
dtype: string;
|
|
4
|
+
chunks: number[][];
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class LazyArray {
|
|
8
|
+
readonly shape: number[];
|
|
9
|
+
readonly dtype: string;
|
|
10
|
+
readonly chunks: number[][];
|
|
11
|
+
readonly name: string;
|
|
12
|
+
constructor(metadata: LazyArrayMetadata);
|
|
13
|
+
get ndim(): number;
|
|
14
|
+
get size(): number;
|
|
15
|
+
get chunksize(): number[];
|
|
16
|
+
toString(): string;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=lazy_array.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy_array.d.ts","sourceRoot":"","sources":["../../src/types/lazy_array.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,SAAS;IACpB,SAAgB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChC,SAAgB,KAAK,EAAE,MAAM,CAAC;IAC9B,SAAgB,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;IACnC,SAAgB,IAAI,EAAE,MAAM,CAAC;gBAEjB,QAAQ,EAAE,iBAAiB;IAOvC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,SAAS,IAAI,MAAM,EAAE,CAExB;IAED,QAAQ,IAAI,MAAM;CAUnB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export class LazyArray {
|
|
2
|
+
shape;
|
|
3
|
+
dtype;
|
|
4
|
+
chunks;
|
|
5
|
+
name;
|
|
6
|
+
constructor(metadata) {
|
|
7
|
+
this.shape = [...metadata.shape];
|
|
8
|
+
this.dtype = metadata.dtype;
|
|
9
|
+
this.chunks = metadata.chunks.map((chunk) => [...chunk]);
|
|
10
|
+
this.name = metadata.name;
|
|
11
|
+
}
|
|
12
|
+
get ndim() {
|
|
13
|
+
return this.shape.length;
|
|
14
|
+
}
|
|
15
|
+
get size() {
|
|
16
|
+
return this.shape.reduce((acc, dim) => acc * dim, 1);
|
|
17
|
+
}
|
|
18
|
+
get chunksize() {
|
|
19
|
+
return this.chunks[0] || [];
|
|
20
|
+
}
|
|
21
|
+
toString() {
|
|
22
|
+
const chunkStr = this.chunksize.length > 0
|
|
23
|
+
? `chunksize=(${this.chunksize.join(", ")})`
|
|
24
|
+
: "chunksize=()";
|
|
25
|
+
return `LazyArray(name=${this.name}, shape=(${this.shape.join(", ")}), dtype=${this.dtype}, ${chunkStr}, chunktype=TypedArray)`;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"methods.d.ts","sourceRoot":"","sources":["../../src/types/methods.ts"],"names":[],"mappings":"AAAA,oBAAY,OAAO;IACjB,gBAAgB,qBAAqB;IACrC,kBAAkB,uBAAuB;IACzC,mBAAmB,wBAAwB;CAC5C;AAED,eAAO,MAAM,aAAa,EAAE,OAAO,EAA2B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var Methods;
|
|
2
|
+
(function (Methods) {
|
|
3
|
+
Methods["ITKWASM_GAUSSIAN"] = "itkwasm_gaussian";
|
|
4
|
+
Methods["ITKWASM_BIN_SHRINK"] = "itkwasm_bin_shrink";
|
|
5
|
+
Methods["ITKWASM_LABEL_IMAGE"] = "itkwasm_label_image";
|
|
6
|
+
})(Methods || (Methods = {}));
|
|
7
|
+
export const methodsValues = Object.values(Methods);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { NgffImage } from "./ngff_image.js";
|
|
2
|
+
import type { Metadata } from "./zarr_metadata.js";
|
|
3
|
+
import type { Methods } from "./methods.js";
|
|
4
|
+
export type ChunkSpec = number | number[] | number[][] | Record<string, number | number[] | undefined>;
|
|
5
|
+
export interface MultiscalesOptions {
|
|
6
|
+
images: NgffImage[];
|
|
7
|
+
metadata: Metadata;
|
|
8
|
+
scaleFactors: (Record<string, number> | number)[] | undefined;
|
|
9
|
+
method: Methods | undefined;
|
|
10
|
+
chunks: ChunkSpec | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare class Multiscales {
|
|
13
|
+
readonly images: NgffImage[];
|
|
14
|
+
readonly metadata: Metadata;
|
|
15
|
+
readonly scaleFactors: (Record<string, number> | number)[] | undefined;
|
|
16
|
+
readonly method: Methods | undefined;
|
|
17
|
+
readonly chunks: ChunkSpec | undefined;
|
|
18
|
+
constructor(options: MultiscalesOptions);
|
|
19
|
+
toString(): string;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=multiscales.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiscales.d.ts","sourceRoot":"","sources":["../../src/types/multiscales.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,EAAE,GACR,MAAM,EAAE,EAAE,GACV,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;AAElD,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC;IACnB,YAAY,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,EAAE,GAAG,SAAS,CAAC;IAC9D,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC;CAC/B;AAED,qBAAa,WAAW;IACtB,SAAgB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpC,SAAgB,QAAQ,EAAE,QAAQ,CAAC;IACnC,SAAgB,YAAY,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,EAAE,GAAG,SAAS,CAAC;IAC9E,SAAgB,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5C,SAAgB,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC;gBAElC,OAAO,EAAE,kBAAkB;IAUvC,QAAQ,IAAI,MAAM;CAwBnB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export class Multiscales {
|
|
2
|
+
images;
|
|
3
|
+
metadata;
|
|
4
|
+
scaleFactors;
|
|
5
|
+
method;
|
|
6
|
+
chunks;
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.images = [...options.images];
|
|
9
|
+
this.metadata = { ...options.metadata };
|
|
10
|
+
this.scaleFactors = options.scaleFactors
|
|
11
|
+
? [...options.scaleFactors]
|
|
12
|
+
: undefined;
|
|
13
|
+
this.method = options.method;
|
|
14
|
+
this.chunks = options.chunks;
|
|
15
|
+
}
|
|
16
|
+
toString() {
|
|
17
|
+
const imagesStr = this.images
|
|
18
|
+
.map((img, _i) => ` ${img.toString().replace(/\n/g, "\n ")}`)
|
|
19
|
+
.join(",\n");
|
|
20
|
+
const metadataStr = JSON.stringify(this.metadata, null, 4)
|
|
21
|
+
.split("\n")
|
|
22
|
+
.map((line) => ` ${line}`)
|
|
23
|
+
.join("\n");
|
|
24
|
+
return `Multiscales(
|
|
25
|
+
images=[
|
|
26
|
+
${imagesStr}
|
|
27
|
+
],
|
|
28
|
+
metadata=${metadataStr},
|
|
29
|
+
scale_factors=${JSON.stringify(this.scaleFactors)},
|
|
30
|
+
method=${this.method ? `Methods.${this.method.toUpperCase()}` : "undefined"},
|
|
31
|
+
chunks=${JSON.stringify(this.chunks)}
|
|
32
|
+
)`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { LazyArray } from "./lazy_array.js";
|
|
2
|
+
import type { Units } from "./units.js";
|
|
3
|
+
export type ComputedCallback = () => void;
|
|
4
|
+
export interface NgffImageOptions {
|
|
5
|
+
data: LazyArray;
|
|
6
|
+
dims: string[];
|
|
7
|
+
scale: Record<string, number>;
|
|
8
|
+
translation: Record<string, number>;
|
|
9
|
+
name: string | undefined;
|
|
10
|
+
axesUnits: Record<string, Units> | undefined;
|
|
11
|
+
computedCallbacks: ComputedCallback[] | undefined;
|
|
12
|
+
}
|
|
13
|
+
export declare class NgffImage {
|
|
14
|
+
readonly data: LazyArray;
|
|
15
|
+
readonly dims: string[];
|
|
16
|
+
readonly scale: Record<string, number>;
|
|
17
|
+
readonly translation: Record<string, number>;
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly axesUnits: Record<string, Units> | undefined;
|
|
20
|
+
readonly computedCallbacks: ComputedCallback[];
|
|
21
|
+
constructor(options: NgffImageOptions);
|
|
22
|
+
toString(): string;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=ngff_image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngff_image.d.ts","sourceRoot":"","sources":["../../src/types/ngff_image.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC;AAE1C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,SAAS,CAAC;IAC7C,iBAAiB,EAAE,gBAAgB,EAAE,GAAG,SAAS,CAAC;CACnD;AAED,qBAAa,SAAS;IACpB,SAAgB,IAAI,EAAE,SAAS,CAAC;IAChC,SAAgB,IAAI,EAAE,MAAM,EAAE,CAAC;IAC/B,SAAgB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,SAAgB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpD,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,SAAS,CAAC;IAC7D,SAAgB,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;gBAE1C,OAAO,EAAE,gBAAgB;IAUrC,QAAQ,IAAI,MAAM;CAcnB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export class NgffImage {
|
|
2
|
+
data;
|
|
3
|
+
dims;
|
|
4
|
+
scale;
|
|
5
|
+
translation;
|
|
6
|
+
name;
|
|
7
|
+
axesUnits;
|
|
8
|
+
computedCallbacks;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.data = options.data;
|
|
11
|
+
this.dims = [...options.dims];
|
|
12
|
+
this.scale = { ...options.scale };
|
|
13
|
+
this.translation = { ...options.translation };
|
|
14
|
+
this.name = options.name ?? "image";
|
|
15
|
+
this.axesUnits = options.axesUnits ? { ...options.axesUnits } : undefined;
|
|
16
|
+
this.computedCallbacks = [...(options.computedCallbacks ?? [])];
|
|
17
|
+
}
|
|
18
|
+
toString() {
|
|
19
|
+
const axesUnitsStr = this.axesUnits
|
|
20
|
+
? JSON.stringify(this.axesUnits)
|
|
21
|
+
: "None";
|
|
22
|
+
return `NgffImage(
|
|
23
|
+
data=${this.data.toString()},
|
|
24
|
+
dims=[${this.dims.map((d) => `'${d}'`).join(", ")}],
|
|
25
|
+
scale=${JSON.stringify(this.scale)},
|
|
26
|
+
translation=${JSON.stringify(this.translation)},
|
|
27
|
+
name='${this.name}',
|
|
28
|
+
axes_units=${axesUnitsStr},
|
|
29
|
+
computed_callbacks=[${this.computedCallbacks.length} callbacks]
|
|
30
|
+
)`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type SupportedDims = "c" | "x" | "y" | "z" | "t";
|
|
2
|
+
export type SpatialDims = "x" | "y" | "z";
|
|
3
|
+
export type AxesType = "time" | "space" | "channel";
|
|
4
|
+
export type SpaceUnits = "angstrom" | "attometer" | "centimeter" | "decimeter" | "exameter" | "femtometer" | "foot" | "gigameter" | "hectometer" | "inch" | "kilometer" | "megameter" | "meter" | "micrometer" | "mile" | "millimeter" | "nanometer" | "parsec" | "petameter" | "picometer" | "terameter" | "yard" | "yoctometer" | "yottameter" | "zeptometer" | "zettameter";
|
|
5
|
+
export type TimeUnits = "attosecond" | "centisecond" | "day" | "decisecond" | "exasecond" | "femtosecond" | "gigasecond" | "hectosecond" | "hour" | "kilosecond" | "megasecond" | "microsecond" | "millisecond" | "minute" | "nanosecond" | "petasecond" | "picosecond" | "second" | "terasecond" | "yoctosecond" | "yottasecond" | "zeptosecond" | "zettasecond";
|
|
6
|
+
export type Units = SpaceUnits | TimeUnits;
|
|
7
|
+
export declare const supportedDims: SupportedDims[];
|
|
8
|
+
export declare const spaceUnits: SpaceUnits[];
|
|
9
|
+
export declare const timeUnits: TimeUnits[];
|
|
10
|
+
export declare function isDimensionSupported(dim: string): dim is SupportedDims;
|
|
11
|
+
export declare function isUnitSupported(unit: string): unit is Units;
|
|
12
|
+
//# sourceMappingURL=units.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"units.d.ts","sourceRoot":"","sources":["../../src/types/units.ts"],"names":[],"mappings":"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|
|
1
|
+
export const supportedDims = ["x", "y", "z", "c", "t"];
|
|
2
|
+
export const spaceUnits = [
|
|
3
|
+
"angstrom",
|
|
4
|
+
"attometer",
|
|
5
|
+
"centimeter",
|
|
6
|
+
"decimeter",
|
|
7
|
+
"exameter",
|
|
8
|
+
"femtometer",
|
|
9
|
+
"foot",
|
|
10
|
+
"gigameter",
|
|
11
|
+
"hectometer",
|
|
12
|
+
"inch",
|
|
13
|
+
"kilometer",
|
|
14
|
+
"megameter",
|
|
15
|
+
"meter",
|
|
16
|
+
"micrometer",
|
|
17
|
+
"mile",
|
|
18
|
+
"millimeter",
|
|
19
|
+
"nanometer",
|
|
20
|
+
"parsec",
|
|
21
|
+
"petameter",
|
|
22
|
+
"picometer",
|
|
23
|
+
"terameter",
|
|
24
|
+
"yard",
|
|
25
|
+
"yoctometer",
|
|
26
|
+
"yottameter",
|
|
27
|
+
"zeptometer",
|
|
28
|
+
"zettameter",
|
|
29
|
+
];
|
|
30
|
+
export const timeUnits = [
|
|
31
|
+
"attosecond",
|
|
32
|
+
"centisecond",
|
|
33
|
+
"day",
|
|
34
|
+
"decisecond",
|
|
35
|
+
"exasecond",
|
|
36
|
+
"femtosecond",
|
|
37
|
+
"gigasecond",
|
|
38
|
+
"hectosecond",
|
|
39
|
+
"hour",
|
|
40
|
+
"kilosecond",
|
|
41
|
+
"megasecond",
|
|
42
|
+
"microsecond",
|
|
43
|
+
"millisecond",
|
|
44
|
+
"minute",
|
|
45
|
+
"nanosecond",
|
|
46
|
+
"petasecond",
|
|
47
|
+
"picosecond",
|
|
48
|
+
"second",
|
|
49
|
+
"terasecond",
|
|
50
|
+
"yoctosecond",
|
|
51
|
+
"yottasecond",
|
|
52
|
+
"zeptosecond",
|
|
53
|
+
"zettasecond",
|
|
54
|
+
];
|
|
55
|
+
export function isDimensionSupported(dim) {
|
|
56
|
+
return supportedDims.includes(dim);
|
|
57
|
+
}
|
|
58
|
+
export function isUnitSupported(unit) {
|
|
59
|
+
return (timeUnits.includes(unit) ||
|
|
60
|
+
spaceUnits.includes(unit));
|
|
61
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { AxesType, SupportedDims, Units } from "./units.js";
|
|
2
|
+
export interface Axis {
|
|
3
|
+
name: SupportedDims;
|
|
4
|
+
type: AxesType;
|
|
5
|
+
unit: Units | undefined;
|
|
6
|
+
}
|
|
7
|
+
export interface Identity {
|
|
8
|
+
type: "identity";
|
|
9
|
+
}
|
|
10
|
+
export interface Scale {
|
|
11
|
+
scale: number[];
|
|
12
|
+
type: "scale";
|
|
13
|
+
}
|
|
14
|
+
export interface Translation {
|
|
15
|
+
translation: number[];
|
|
16
|
+
type: "translation";
|
|
17
|
+
}
|
|
18
|
+
export type Transform = Scale | Translation;
|
|
19
|
+
export interface Dataset {
|
|
20
|
+
path: string;
|
|
21
|
+
coordinateTransformations: Transform[];
|
|
22
|
+
}
|
|
23
|
+
export interface OmeroWindow {
|
|
24
|
+
min: number;
|
|
25
|
+
max: number;
|
|
26
|
+
start: number;
|
|
27
|
+
end: number;
|
|
28
|
+
}
|
|
29
|
+
export interface OmeroChannel {
|
|
30
|
+
color: string;
|
|
31
|
+
window: OmeroWindow;
|
|
32
|
+
label: string | undefined;
|
|
33
|
+
}
|
|
34
|
+
export interface Omero {
|
|
35
|
+
channels: OmeroChannel[];
|
|
36
|
+
}
|
|
37
|
+
export interface Metadata {
|
|
38
|
+
axes: Axis[];
|
|
39
|
+
datasets: Dataset[];
|
|
40
|
+
coordinateTransformations: Transform[] | undefined;
|
|
41
|
+
omero: Omero | undefined;
|
|
42
|
+
name: string;
|
|
43
|
+
version: string;
|
|
44
|
+
}
|
|
45
|
+
export declare function validateColor(color: string): void;
|
|
46
|
+
export declare function createScale(scale: number[]): Scale;
|
|
47
|
+
export declare function createTranslation(translation: number[]): Translation;
|
|
48
|
+
export declare function createIdentity(): Identity;
|
|
49
|
+
//# sourceMappingURL=zarr_metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|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S,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAMjD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,CAElD;AAED,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,WAAW,CAEpE;AAED,wBAAgB,cAAc,IAAI,QAAQ,CAEzC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function validateColor(color) {
|
|
2
|
+
if (!/^[0-9A-Fa-f]{6}$/.test(color)) {
|
|
3
|
+
throw new Error(`Invalid color '${color}'. Must be 6 hex digits.`);
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
export function createScale(scale) {
|
|
7
|
+
return { scale: [...scale], type: "scale" };
|
|
8
|
+
}
|
|
9
|
+
export function createTranslation(translation) {
|
|
10
|
+
return { translation: [...translation], type: "translation" };
|
|
11
|
+
}
|
|
12
|
+
export function createIdentity() {
|
|
13
|
+
return { type: "identity" };
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NgffImage } from "../types/ngff_image.js";
|
|
2
|
+
import { Multiscales } from "../types/multiscales.js";
|
|
3
|
+
import type { Axis, Dataset, Metadata, Scale, Translation } from "../types/zarr_metadata.js";
|
|
4
|
+
import type { AxesType, SupportedDims, Units } from "../types/units.js";
|
|
5
|
+
import type { Methods } from "../types/methods.js";
|
|
6
|
+
export declare function createNgffImage(_data: ArrayBuffer | number[], shape: number[], dtype: string, dims: string[], scale: Record<string, number>, translation: Record<string, number>, name?: string): NgffImage;
|
|
7
|
+
export declare function createAxis(name: SupportedDims, type: AxesType, unit?: Units): Axis;
|
|
8
|
+
export declare function createScale(scale: number[]): Scale;
|
|
9
|
+
export declare function createTranslation(translation: number[]): Translation;
|
|
10
|
+
export declare function createDataset(path: string, scale: number[], translation: number[]): Dataset;
|
|
11
|
+
export declare function createMetadata(axes: Axis[], datasets: Dataset[], name?: string, version?: string): Metadata;
|
|
12
|
+
export declare function createMultiscales(images: NgffImage[], metadata: Metadata, scaleFactors?: (Record<string, number> | number)[], method?: Methods): Multiscales;
|
|
13
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/utils/factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EACV,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,KAAK,EACL,WAAW,EACZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,wBAAgB,eAAe,CAC7B,KAAK,EAAE,WAAW,GAAG,MAAM,EAAE,EAC7B,KAAK,EAAE,MAAM,EAAE,EACf,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,IAAI,SAAU,GACb,SAAS,CAiBX;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,aAAa,EACnB,IAAI,EAAE,QAAQ,EACd,IAAI,CAAC,EAAE,KAAK,GACX,IAAI,CAMN;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,CAKlD;AAED,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,WAAW,CAKpE;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EAAE,EACf,WAAW,EAAE,MAAM,EAAE,GACpB,OAAO,CAQT;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,IAAI,EAAE,EACZ,QAAQ,EAAE,OAAO,EAAE,EACnB,IAAI,SAAU,EACd,OAAO,SAAQ,GACd,QAAQ,CASV;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,EAAE,EACnB,QAAQ,EAAE,QAAQ,EAClB,YAAY,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,EAAE,EAClD,MAAM,CAAC,EAAE,OAAO,GACf,WAAW,CAQb"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { LazyArray } from "../types/lazy_array.js";
|
|
2
|
+
import { NgffImage } from "../types/ngff_image.js";
|
|
3
|
+
import { Multiscales } from "../types/multiscales.js";
|
|
4
|
+
export function createNgffImage(_data, shape, dtype, dims, scale, translation, name = "image") {
|
|
5
|
+
const lazyArray = new LazyArray({
|
|
6
|
+
shape,
|
|
7
|
+
dtype,
|
|
8
|
+
chunks: [shape],
|
|
9
|
+
name,
|
|
10
|
+
});
|
|
11
|
+
return new NgffImage({
|
|
12
|
+
data: lazyArray,
|
|
13
|
+
dims,
|
|
14
|
+
scale,
|
|
15
|
+
translation,
|
|
16
|
+
name,
|
|
17
|
+
axesUnits: undefined,
|
|
18
|
+
computedCallbacks: undefined,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export function createAxis(name, type, unit) {
|
|
22
|
+
return {
|
|
23
|
+
name,
|
|
24
|
+
type,
|
|
25
|
+
unit: unit || undefined,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function createScale(scale) {
|
|
29
|
+
return {
|
|
30
|
+
scale: [...scale],
|
|
31
|
+
type: "scale",
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export function createTranslation(translation) {
|
|
35
|
+
return {
|
|
36
|
+
translation: [...translation],
|
|
37
|
+
type: "translation",
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export function createDataset(path, scale, translation) {
|
|
41
|
+
return {
|
|
42
|
+
path,
|
|
43
|
+
coordinateTransformations: [
|
|
44
|
+
createScale(scale),
|
|
45
|
+
createTranslation(translation),
|
|
46
|
+
],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export function createMetadata(axes, datasets, name = "image", version = "0.4") {
|
|
50
|
+
return {
|
|
51
|
+
axes: [...axes],
|
|
52
|
+
datasets: [...datasets],
|
|
53
|
+
coordinateTransformations: undefined,
|
|
54
|
+
omero: undefined,
|
|
55
|
+
name,
|
|
56
|
+
version,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export function createMultiscales(images, metadata, scaleFactors, method) {
|
|
60
|
+
return new Multiscales({
|
|
61
|
+
images: [...images],
|
|
62
|
+
metadata,
|
|
63
|
+
scaleFactors: scaleFactors || undefined,
|
|
64
|
+
method: method || undefined,
|
|
65
|
+
chunks: undefined,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Metadata } from "../types/zarr_metadata.js";
|
|
2
|
+
export declare function validateMetadata(metadata: unknown): Metadata;
|
|
3
|
+
export declare function validateColor(color: string): void;
|
|
4
|
+
export declare function isValidDimension(dim: string): boolean;
|
|
5
|
+
export declare function isValidUnit(unit: string): boolean;
|
|
6
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAG1D,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,CAQ5D;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAIjD;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAErD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAyDjD"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { MetadataSchema } from "../schemas/zarr_metadata.js";
|
|
2
|
+
export function validateMetadata(metadata) {
|
|
3
|
+
const result = MetadataSchema.safeParse(metadata);
|
|
4
|
+
if (!result.success) {
|
|
5
|
+
throw new Error(`Invalid metadata: ${result.error.message}`);
|
|
6
|
+
}
|
|
7
|
+
return result.data;
|
|
8
|
+
}
|
|
9
|
+
export function validateColor(color) {
|
|
10
|
+
if (!/^[0-9A-Fa-f]{6}$/.test(color)) {
|
|
11
|
+
throw new Error(`Invalid color '${color}'. Must be 6 hex digits.`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function isValidDimension(dim) {
|
|
15
|
+
return ["c", "x", "y", "z", "t"].includes(dim);
|
|
16
|
+
}
|
|
17
|
+
export function isValidUnit(unit) {
|
|
18
|
+
const timeUnits = [
|
|
19
|
+
"attosecond",
|
|
20
|
+
"centisecond",
|
|
21
|
+
"day",
|
|
22
|
+
"decisecond",
|
|
23
|
+
"exasecond",
|
|
24
|
+
"femtosecond",
|
|
25
|
+
"gigasecond",
|
|
26
|
+
"hectosecond",
|
|
27
|
+
"hour",
|
|
28
|
+
"kilosecond",
|
|
29
|
+
"megasecond",
|
|
30
|
+
"microsecond",
|
|
31
|
+
"millisecond",
|
|
32
|
+
"minute",
|
|
33
|
+
"nanosecond",
|
|
34
|
+
"petasecond",
|
|
35
|
+
"picosecond",
|
|
36
|
+
"second",
|
|
37
|
+
"terasecond",
|
|
38
|
+
"yoctosecond",
|
|
39
|
+
"yottasecond",
|
|
40
|
+
"zeptosecond",
|
|
41
|
+
"zettasecond",
|
|
42
|
+
];
|
|
43
|
+
const spaceUnits = [
|
|
44
|
+
"angstrom",
|
|
45
|
+
"attometer",
|
|
46
|
+
"centimeter",
|
|
47
|
+
"decimeter",
|
|
48
|
+
"exameter",
|
|
49
|
+
"femtometer",
|
|
50
|
+
"foot",
|
|
51
|
+
"gigameter",
|
|
52
|
+
"hectometer",
|
|
53
|
+
"inch",
|
|
54
|
+
"kilometer",
|
|
55
|
+
"megameter",
|
|
56
|
+
"meter",
|
|
57
|
+
"micrometer",
|
|
58
|
+
"mile",
|
|
59
|
+
"millimeter",
|
|
60
|
+
"nanometer",
|
|
61
|
+
"parsec",
|
|
62
|
+
"petameter",
|
|
63
|
+
"picometer",
|
|
64
|
+
"terameter",
|
|
65
|
+
"yard",
|
|
66
|
+
"yoctometer",
|
|
67
|
+
"yottameter",
|
|
68
|
+
"zeptometer",
|
|
69
|
+
"zettameter",
|
|
70
|
+
];
|
|
71
|
+
return timeUnits.includes(unit) || spaceUnits.includes(unit);
|
|
72
|
+
}
|