@@ -2,7 +2,7 @@ import * as zarr from "zarrita";
22import { Multiscales } from "../types/multiscales.ts" ;
33import { NgffImage } from "../types/ngff_image.ts" ;
44import type { Metadata } from "../types/zarr_metadata.ts" ;
5- import { DaskArray } from "../types/dask_array .ts" ;
5+ import { LazyArray } from "../types/lazy_array .ts" ;
66import { MetadataSchema } from "../schemas/zarr_metadata.ts" ;
77
88export interface ZarrReaderOptions {
@@ -18,37 +18,38 @@ export class ZarrReader {
1818
1919 async fromNgffZarr (
2020 storePath : string ,
21- options : ZarrReaderOptions = { } ,
21+ options : ZarrReaderOptions = { }
2222 ) : Promise < Multiscales > {
2323 const validate = options . validate ?? this . validate ;
2424
2525 try {
2626 const store = new zarr . FetchStore ( storePath ) ;
2727 const root = zarr . root ( store ) ;
28-
28+
2929 // Try to use consolidated metadata for better performance
3030 let consolidatedRoot ;
3131 try {
3232 consolidatedRoot = await zarr . tryWithConsolidated ( store ) ;
3333 } catch {
3434 consolidatedRoot = store ;
3535 }
36-
37- const group = await zarr . open ( zarr . root ( consolidatedRoot ) , { kind : "group" } ) ;
36+
37+ const group = await zarr . open ( zarr . root ( consolidatedRoot ) , {
38+ kind : "group" ,
39+ } ) ;
3840 const attrs = group . attrs as unknown ;
3941
4042 if ( ! attrs || ! ( attrs as Record < string , unknown > ) . multiscales ) {
4143 throw new Error ( "No multiscales metadata found in Zarr store" ) ;
4244 }
4345
44- const multiscalesMetadata = ( attrs as Record < string , unknown > ) . multiscales ?. [ 0 ] as unknown ;
46+ const multiscalesMetadata = ( attrs as Record < string , unknown > )
47+ . multiscales ?. [ 0 ] as unknown ;
4548
4649 if ( validate ) {
4750 const result = MetadataSchema . safeParse ( multiscalesMetadata ) ;
4851 if ( ! result . success ) {
49- throw new Error (
50- `Invalid OME-Zarr metadata: ${ result . error . message } ` ,
51- ) ;
52+ throw new Error ( `Invalid OME-Zarr metadata: ${ result . error . message } ` ) ;
5253 }
5354 }
5455
@@ -61,7 +62,7 @@ export class ZarrReader {
6162 kind : "array" ,
6263 } ) ;
6364
64- const daskArray = new DaskArray ( {
65+ const lazyArray = new LazyArray ( {
6566 shape : zarrArray . shape ,
6667 dtype : zarrArray . dtype ,
6768 chunks : [ zarrArray . chunks ] ,
@@ -96,7 +97,7 @@ export class ZarrReader {
9697 } , { } as Record < string , string > ) ;
9798
9899 const ngffImage = new NgffImage ( {
99- data : daskArray ,
100+ data : lazyArray ,
100101 dims,
101102 scale,
102103 translation,
@@ -119,15 +120,15 @@ export class ZarrReader {
119120 throw new Error (
120121 `Failed to read OME-Zarr: ${
121122 error instanceof Error ? error . message : String ( error )
122- } `,
123+ } `
123124 ) ;
124125 }
125126 }
126127
127128 async readArrayData (
128129 storePath : string ,
129130 arrayPath : string ,
130- selection ?: unknown [ ] ,
131+ selection ?: unknown [ ]
131132 ) : Promise < unknown > {
132133 try {
133134 const store = new zarr . FetchStore ( storePath ) ;
@@ -145,7 +146,7 @@ export class ZarrReader {
145146 throw new Error (
146147 `Failed to read array data: ${
147148 error instanceof Error ? error . message : String ( error )
148- } `,
149+ } `
149150 ) ;
150151 }
151152 }
0 commit comments