@@ -2,7 +2,14 @@ import { ZarrPixelSource } from '@hms-dbmi/viv';
2
2
import pMap from 'p-map' ;
3
3
import { Group as ZarrGroup , HTTPStore , openGroup , ZarrArray } from 'zarr' ;
4
4
import type { ImageLayerConfig , SourceData } from './state' ;
5
- import { join , loadMultiscales , guessTileSize , range , parseMatrix } from './utils' ;
5
+ import {
6
+ getAttrsOnly ,
7
+ guessTileSize ,
8
+ join ,
9
+ loadMultiscales ,
10
+ parseMatrix ,
11
+ range
12
+ } from './utils' ;
6
13
7
14
export async function loadWell ( config : ImageLayerConfig , grp : ZarrGroup , wellAttrs : Ome . Well ) : Promise < SourceData > {
8
15
// Can filter Well fields by URL query ?acquisition=ID
@@ -119,7 +126,7 @@ export async function loadPlate(config: ImageLayerConfig, grp: ZarrGroup, plateA
119
126
const wellPaths = plateAttrs . wells . map ( ( well ) => well . path ) ;
120
127
121
128
// Use first image as proxy for others.
122
- const wellAttrs = ( await grp . getItem ( wellPaths [ 0 ] ) . then ( ( g ) => g . attrs . asObject ( ) ) ) as Ome . Attrs ;
129
+ const wellAttrs = await getAttrsOnly < { well : Ome . Well } > ( grp , wellPaths [ 0 ] ) ;
123
130
if ( ! ( 'well' in wellAttrs ) ) {
124
131
throw Error ( 'Path for image is not valid, not a well.' ) ;
125
132
}
@@ -134,8 +141,7 @@ export async function loadPlate(config: ImageLayerConfig, grp: ZarrGroup, plateA
134
141
const resolution = datasets [ datasets . length - 1 ] . path ;
135
142
136
143
async function getImgPath ( wellPath :string ) {
137
- // This loads .zattrs for each well but also tries to load .zarray (404) and .zgroup
138
- const wellAttrs = await grp . getItem ( wellPath ) . then ( ( g ) => g . attrs . asObject ( ) ) ;
144
+ const wellAttrs = await getAttrsOnly < { well : Ome . Well } > ( grp , wellPath ) ;
139
145
return join ( wellPath , wellAttrs . well . images [ 0 ] . path ) ;
140
146
}
141
147
const wellImagePaths = await Promise . all ( wellPaths . map ( getImgPath ) ) ;
0 commit comments