@@ -323,71 +323,3 @@ def get_val_stats(sample_values: list[float]) -> dict[str, float]:
323
323
"iqr" : float (scipy .stats .iqr (sample_values )),
324
324
}
325
325
return meta_row
326
-
327
-
328
- def mp_sample_im_pixels (
329
- fn_args : list [tuple [Any , ...]], workers : int
330
- ) -> list [list [Any ]]:
331
- """Read and compute statistics of images with multiprocessing.
332
-
333
- Parameters
334
- ----------
335
- fn_args : list[tuple[Any, ...]]
336
- List with tuples of function arguments.
337
- workers : int
338
- Max number of workers.
339
-
340
- Returns
341
- -------
342
- list[list[Any]]
343
- List of paths and corresponding returned df from get_im_stats.
344
- """
345
- with ProcessPoolExecutor (workers ) as ex :
346
- # can't use map directly as it works only with single arg functions
347
- res = ex .map (sample_im_pixels , * zip (* fn_args ))
348
- return list (map (list , zip (* list (res ))))
349
-
350
-
351
- def sample_im_pixels (
352
- position : ngff .Position ,
353
- grid_spacing : int ,
354
- channel : int ,
355
- ) -> tuple [ngff .Position , NDArray ]:
356
- # TODO move out of mp utils into normalization utils
357
- """Read and compute statistics of images for each point in a grid.
358
-
359
- Grid spacing determines distance in pixels between grid points
360
- for rows and cols. By default, samples from every time position and every z-depth,
361
- and assumes that the data in the zarr store is stored in [T,C,Z,Y,X] format,
362
- for time, channel, z, y, x.
363
-
364
- Parameters
365
- ----------
366
- position : ngff.Position
367
- NGFF position node object.
368
- grid_spacing : int
369
- Spacing of sampling grid in x and y.
370
- channel : int
371
- Channel to sample from.
372
-
373
- Returns
374
- -------
375
- tuple[ngff.Position, NDArray]
376
- Position and array with intensity data for each grid point.
377
- """
378
- image_zarr = position .data
379
-
380
- all_sample_values = []
381
- all_time_indices = list (range (image_zarr .shape [0 ]))
382
- all_z_indices = list (range (image_zarr .shape [2 ]))
383
-
384
- for time_index in all_time_indices :
385
- for z_index in all_z_indices :
386
- image_slice = image_zarr [time_index , channel , z_index , :, :]
387
- _ , _ , sample_values = image_utils .grid_sample_pixel_values (
388
- image_slice , grid_spacing
389
- )
390
- all_sample_values .append (sample_values )
391
- sample_values = np .stack (all_sample_values , 0 ).flatten ()
392
-
393
- return position , sample_values
0 commit comments