.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/run_create_pyramid.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_run_create_pyramid.py: Multiscale Pyramid Creation ============================ Create and compute a multiscale pyramid for efficient visualization. .. GENERATED FROM PYTHON SOURCE LINES 7-38 .. rst-class:: sphx-glr-script-out .. code-block:: none Original data shape: (1, 2, 32, 256, 256) Pyramid levels: Level 0: (1, 2, 32, 256, 256), scale=[1.0, 1.0, 1.0] Level 1: (1, 2, 16, 128, 128), scale=[2.0, 2.0, 2.0] Level 2: (1, 2, 8, 64, 64), scale=[4.0, 4.0, 4.0] | .. code-block:: Python import os from tempfile import TemporaryDirectory import numpy as np from iohub import open_ome_zarr # Create temporary directory and sample data tmp_dir = TemporaryDirectory() store_path = os.path.join(tmp_dir.name, "pyramid.zarr") data = np.random.randint(0, 255, size=(1, 2, 32, 256, 256), dtype=np.uint16) print(f"Original data shape: {data.shape}\n") # Create position with data and compute pyramid with open_ome_zarr( store_path, layout="fov", mode="a", channel_names=["DAPI", "GFP"] ) as position: # Create full resolution image position.create_image("0", data) # Fill pyramid with downsampled data position.compute_pyramid(levels=3, method="mean") # Print results print("Pyramid levels:") for level in range(3): level_array = position[str(level)] scale = position.get_effective_scale(str(level)) print(f" Level {level}: {level_array.shape}, scale={scale[-3:]}") .. _sphx_glr_download_auto_examples_run_create_pyramid.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: run_create_pyramid.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: run_create_pyramid.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: run_create_pyramid.zip `