@@ -113,33 +113,43 @@ export async function loadZarrForPanel(zarrUrl) {
113113 "00FFFF" ,
114114 "FFFFFF" ,
115115 ] ;
116- let channels = omero ?. channels ;
116+ let chs = omero ?. channels ;
117117 let indices = { } ;
118118 if ( axesNames . includes ( "z" ) ) {
119119 indices [ "z" ] = defaultZ ;
120120 }
121- if ( ! channels ) {
121+ // placeholder minmax values
122+ let minMaxs = _ . range ( sizeC ) . map ( ( idx ) => [ 0 , 255 ] ) ;
123+ let minMaxProvided = chs && chs . every ( ( ch ) => ch . window && ch . window . min != undefined && ch . window . max != undefined ) ;
124+ if ( ! minMaxProvided ) {
122125 // load smallest array to get min/max values for every channel
123126 let slices = omezarr . getSlices ( _ . range ( sizeC ) , arr . shape , axesNames , indices , shapes [ 0 ] ) ;
124127 let promises = slices . map ( ( chSlice ) => zarr . get ( arr , chSlice ) ) ;
125128 let ndChunks = await Promise . all ( promises ) ;
126129
127- channels = _ . range ( sizeC ) . map ( ( idx ) => {
128- let mm = omezarr . getMinMaxValues ( ndChunks [ idx ] ) ;
129- return {
130- label : "Ch" + idx ,
131- active : true ,
132- color : default_colors [ idx ] ,
133- window : {
134- min : mm [ 0 ] ,
135- max : mm [ 1 ] ,
136- start : mm [ 0 ] ,
137- end : mm [ 1 ] ,
138- } ,
139- } ;
130+ minMaxs = _ . range ( sizeC ) . map ( ( idx ) => {
131+ return omezarr . getMinMaxValues ( ndChunks [ idx ] ) ;
140132 } ) ;
141133 }
142134
135+ // use channel metadata if provided, otherwise default values or values from smallest array
136+ let channels = _ . range ( sizeC ) . map ( ( idx ) => {
137+ let ch = chs ? chs [ idx ] : null ;
138+ let mm = [ ch ?. window ?. min ?? minMaxs [ idx ] [ 0 ] , ch ?. window ?. max ?? minMaxs [ idx ] [ 1 ] ] ;
139+
140+ return {
141+ label : ch ?. label || "Ch" + idx ,
142+ active : ch ?. active !== undefined ? ch . active : true ,
143+ color : ch ?. color || default_colors [ idx ] ,
144+ window : {
145+ min : mm [ 0 ] ,
146+ max : mm [ 1 ] ,
147+ start : ch ?. window ?. start || mm [ 0 ] ,
148+ end : ch ?. window ?. end || mm [ 1 ] ,
149+ } ,
150+ } ;
151+ } ) ;
152+
143153 let deltaT = [ ] ;
144154 if ( axesNames . includes ( "t" ) ) {
145155 // if we have time units...
0 commit comments