|
8 | 8 | from typing import List, Union, Tuple
|
9 | 9 | from IPython.display import display, HTML
|
10 | 10 | from IPython.lib import backgroundjobs as bg
|
11 |
| -from ngff_zarr import from_ngff_zarr, to_ngff_image, NgffImage |
| 11 | +from ngff_zarr import ( |
| 12 | + from_ngff_zarr, |
| 13 | + to_ngff_image, |
| 14 | + Multiscales, |
| 15 | + NgffImage |
| 16 | +) |
12 | 17 | import uuid
|
13 | 18 |
|
14 | 19 | from ._method_types import deferred_methods
|
@@ -434,6 +439,30 @@ async def get_roi_image(self, scale: int = -1, name: str = 'Image') -> NgffImage
|
434 | 439 | )
|
435 | 440 | raise ValueError(f'No image data found for {name}.')
|
436 | 441 |
|
| 442 | + @fetch_value |
| 443 | + async def get_roi_multiscale(self, name: str = 'Image') -> Multiscales: |
| 444 | + """Build and return a new Multiscales NgffImage for the ROI. |
| 445 | +
|
| 446 | + :param name: Name of the loaded image data to use. 'Image', the |
| 447 | + default, selects the first loaded image. |
| 448 | + :type name: str |
| 449 | +
|
| 450 | + :return: roi_multiscales |
| 451 | + :rtype: Multiscales NgffImage |
| 452 | + """ |
| 453 | + if store := self.stores.get(name): |
| 454 | + multiscales = from_ngff_zarr(store) |
| 455 | + scales = range(len(multiscales.images)) |
| 456 | + images = [await self.get_roi_image(s) for s in scales] |
| 457 | + return Multiscales( |
| 458 | + images=images, |
| 459 | + metadata=multiscales.metadata, |
| 460 | + scale_factors=multiscales.scale_factors, |
| 461 | + method=multiscales.method, |
| 462 | + chunks=multiscales.chunks |
| 463 | + ) |
| 464 | + raise ValueError(f'No image data found for {name}.') |
| 465 | + |
437 | 466 | @fetch_value
|
438 | 467 | async def get_roi_region(self):
|
439 | 468 | """Get the current region of interest in world / physical space.
|
|
0 commit comments