{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# imports\n", "import pathlib\n", "from tqdm.notebook import tqdm\n", "import napari\n", "import dask.array as da\n", "from coda_visual.datasets.raw_hamamatsu_file import RawHamamatsuFile" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "RAW_IMAGE_DIR = pathlib.Path().resolve().parent.parent / \"sample_dataset\" / \"20x files\"\n", "raw_image_list = sorted(list(RAW_IMAGE_DIR.glob(\"*.ndpi\")), key=lambda x: x.name)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "LOW_RES_LEVEL = 5" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "largest_layer_width = 0.\n", "largest_layer_height = 0.\n", "for fp in raw_image_list:\n", " hamamatsu_file = RawHamamatsuFile(fp)\n", " level_width, level_height = hamamatsu_file.openslide_slide.level_dimensions[LOW_RES_LEVEL]\n", " if level_width>largest_layer_width:\n", " largest_layer_width = level_width\n", " if level_height>largest_layer_height:\n", " largest_layer_height = level_height" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "ad5d890426524863ac49fbb21140a8bb", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Loading images...: 0%| | 0/150 [00:00" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "viewer = napari.Viewer()\n", "viewer.add_image(\n", " layer_images,\n", " name=\"dataset\",\n", " contrast_limits=[0, 255],\n", " rgb=True,\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "coda-visual", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.15" } }, "nbformat": 4, "nbformat_minor": 2 }