@@ -137,10 +137,34 @@ def illumination_correction(
137
137
if not newzarrurl .endswith ("/" ):
138
138
newzarrurl += "/"
139
139
140
- # Hard-coded values for the image size
141
- # FIXME can we parse this from somewhere?
142
- img_size_y = 2160
143
- img_size_x = 2560
140
+ # Read FOV ROIs
141
+ FOV_ROI_table = ad .read_zarr (f"{ zarrurl } tables/FOV_ROI_table" )
142
+
143
+ # Read pixel sizes from zattrs file
144
+ pixel_sizes_zyx = extract_zyx_pixel_sizes_from_zattrs (zarrurl + ".zattrs" )
145
+
146
+ # Create list of indices for 3D FOVs spanning the entire Z direction
147
+ list_indices = convert_ROI_table_to_indices (
148
+ FOV_ROI_table ,
149
+ level = 0 ,
150
+ coarsening_xy = coarsening_xy ,
151
+ pixel_sizes_zyx = pixel_sizes_zyx ,
152
+ )
153
+
154
+ # Extract image size from FOV-ROI indices
155
+ # Note: this works at level=0, where FOVs should all be of the exact same
156
+ # size (in pixels)
157
+ ref_img_size = None
158
+ for indices in list_indices :
159
+ img_size = (indices [3 ] - indices [2 ], indices [5 ] - indices [4 ])
160
+ if ref_img_size is None :
161
+ ref_img_size = img_size
162
+ else :
163
+ if img_size != ref_img_size :
164
+ raise Exception (
165
+ "ERROR: inconsistent image sizes in list_indices"
166
+ )
167
+ img_size_y , img_size_x = img_size [:]
144
168
145
169
# Load paths of correction matrices
146
170
with open (path_dict_corr , "r" ) as jsonfile :
@@ -193,20 +217,6 @@ def illumination_correction(
193
217
f"Error in illumination_correction, chunks_x: { chunks_x } "
194
218
)
195
219
196
- # Read FOV ROIs
197
- FOV_ROI_table = ad .read_zarr (f"{ zarrurl } tables/FOV_ROI_table" )
198
-
199
- # Read pixel sizes from zattrs file
200
- pixel_sizes_zyx = extract_zyx_pixel_sizes_from_zattrs (zarrurl + ".zattrs" )
201
-
202
- # Create list of indices for 3D FOVs spanning the entire Z direction
203
- list_indices = convert_ROI_table_to_indices (
204
- FOV_ROI_table ,
205
- level = 0 ,
206
- coarsening_xy = coarsening_xy ,
207
- pixel_sizes_zyx = pixel_sizes_zyx ,
208
- )
209
-
210
220
# Create the final list of single-Z-layer FOVs
211
221
list_indices = split_3D_indices_into_z_layers (list_indices )
212
222
0 commit comments