.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/run_view_clearcontrol_dataset.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_view_clearcontrol_dataset.py: Viewing Clear Control ===================== Example of opening a Clear Control dataset and viewing with napari. Usage: $ python view_clearcontrol_dataset.py If the dataset path is not provided, it creates a mock dataset of random integers. .. GENERATED FROM PYTHON SOURCE LINES 16-17 Setup .. GENERATED FROM PYTHON SOURCE LINES 17-27 .. code-block:: Python import sys import tempfile import time from iohub.clearcontrol import ( ClearControlFOV, create_mock_clear_control_dataset, ) .. GENERATED FROM PYTHON SOURCE LINES 28-30 Parse optional Clear Control dataset path. Mock dataset is created if dataset path is not provided. .. GENERATED FROM PYTHON SOURCE LINES 30-38 .. code-block:: Python if len(sys.argv) < 2: print("Loading mock random noise dataset ...") path = f"{tempfile.gettempdir()}/dataset.cc" create_mock_clear_control_dataset(path) else: path = sys.argv[1] .. rst-class:: sphx-glr-script-out .. code-block:: none Loading mock random noise dataset ... .. GENERATED FROM PYTHON SOURCE LINES 39-40 Open Clear Control dataset. .. GENERATED FROM PYTHON SOURCE LINES 40-45 .. code-block:: Python s = time.time() cc = ClearControlFOV(path, cache=True) print("init time (secs)", time.time() - s) .. rst-class:: sphx-glr-script-out .. code-block:: none init time (secs) 9.5367431640625e-05 .. GENERATED FROM PYTHON SOURCE LINES 46-47 Time load time of a single volume. .. GENERATED FROM PYTHON SOURCE LINES 47-53 .. code-block:: Python s = time.time() cc[0, 0] print("single volume load time (secs)", time.time() - s) .. rst-class:: sphx-glr-script-out .. code-block:: none single volume load time (secs) 0.002139568328857422 .. GENERATED FROM PYTHON SOURCE LINES 54-55 Load dataset using napari .. GENERATED FROM PYTHON SOURCE LINES 55-67 .. code-block:: Python if __name__ == "__main__": try: import napari s = time.time() napari.view_image(cc) print("napari load time (secs)", time.time() - s) napari.run() except ModuleNotFoundError: pass .. _sphx_glr_download_auto_examples_run_view_clearcontrol_dataset.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: run_view_clearcontrol_dataset.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: run_view_clearcontrol_dataset.py `