diff --git a/examples/integrations/itk/IDC_Seg_Primer_Examples.ipynb b/examples/integrations/itk/IDC_Seg_Primer_Examples.ipynb index 2093a0ed..64c62de9 100644 --- a/examples/integrations/itk/IDC_Seg_Primer_Examples.ipynb +++ b/examples/integrations/itk/IDC_Seg_Primer_Examples.ipynb @@ -33,12 +33,12 @@ "source": [ "import sys\n", "\n", - "!{sys.executable} -m pip install -q pooch itk-io \"itkwidgets[all]>=1.0a49\" pydicom pydicom-seg numpy" + "!{sys.executable} -m pip install -q itk-io \"itkwidgets[all]>=1.0a53\" idc-index itkwasm-dicom" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "id": "4120f9bf-e7f3-48a1-ab14-ce57b4d95621", "metadata": { "id": "4120f9bf-e7f3-48a1-ab14-ce57b4d95621", @@ -46,13 +46,14 @@ }, "outputs": [], "source": [ - "import itk\n", - "import pooch\n", "from pathlib import Path\n", - "from itkwidgets import view\n", - "import pydicom\n", - "import pydicom_seg # Pydicom-Seg is a layer on top of pydicom that handles DICOM SEG objects.# Read the DICOM SEG object using pydicom and pydicom_seg.\n", - "import numpy as np" + "\n", + "import itk\n", + "from itkwasm_dicom import read_segmentation\n", + "import numpy as np\n", + "from rich import print\n", + "\n", + "from itkwidgets import view" ] }, { @@ -90,147 +91,458 @@ ] }, { - "cell_type": "markdown", - "id": "5253b70b-4b64-4e12-bdcd-e8401e9710b4", - "metadata": {}, + "cell_type": "code", + "execution_count": 2, + "id": "5a8af240-84fb-4293-b983-b15081b91631", + "metadata": { + "tags": [] + }, + "outputs": [], "source": [ - "#### If you are running on a Mac machine, uncomment the appropriate line in the cell below and run:" + "ct_dicom_series_uid = '1.2.840.113654.2.55.247854884634057477137769379611681725965'\n", + "seg_dicom_series_uid = '1.2.276.0.7230010.3.1.3.481034752.249602.1661572065.734219'" ] }, { "cell_type": "code", - "execution_count": 3, - "id": "1beba815-ea88-45f0-9dae-84038a13ba3d", - "metadata": {}, + "execution_count": 4, + "id": "aOnyE_7hllIl", + "metadata": { + "id": "aOnyE_7hllIl", + "tags": [] + }, "outputs": [], "source": [ - "# if not Path('./s5cmd').exists():\n", - "# !wget https://github.com/peak/s5cmd/releases/download/v2.0.0-beta.2/s5cmd_2.0.0-beta.2_macOS-64bit.tar.gz && tar zxf s5cmd_2.0.0-beta.2_macOS-64bit.tar.gz" + "%%capture\n", + "# CT series downloaded from IDC, NLST collection (https://doi.org/10.7937/TCIA.HMQ8-J677)\n", + "!idc download {ct_dicom_series_uid}\n", + "\n", + "# segmentation of this series downloaded from IDC, from nnU-Net-BPR-Annotations (https://doi.org/10.5281/zenodo.7539035)\n", + "!idc download {seg_dicom_series_uid}" ] }, { - "cell_type": "markdown", - "id": "7e0e9c22-9d4b-4a8b-8935-74fd4d322dfd", - "metadata": {}, + "cell_type": "code", + "execution_count": 3, + "id": "f75f4325-fe02-4d30-875e-ae9282e3930a", + "metadata": { + "tags": [] + }, + "outputs": [], "source": [ - "#### If you are running on a Windows machine, uncomment the cell below and run:" + "images_dir = Path('nlst') / '100147' / '1.2.840.113654.2.55.133032926508606330165457723341736723804'\n", + "ct_dir = images_dir / 'CT_1.2.840.113654.2.55.247854884634057477137769379611681725965'\n", + "seg_dir = images_dir / 'SEG_1.2.276.0.7230010.3.1.3.481034752.249602.1661572065.734219'" ] }, { "cell_type": "code", "execution_count": 4, - "id": "c214d4f2-b6fc-4e02-963f-1738ce02957e", - "metadata": {}, + "id": "RJzY1NUmneKZ", + "metadata": { + "id": "RJzY1NUmneKZ", + "tags": [] + }, "outputs": [], "source": [ - "# if not Path('./s5cmd').exists():\n", - "# !wget https://github.com/peak/s5cmd/releases/download/v2.0.0-beta.2/s5cmd_2.0.0-beta.2_Windows-64bit.zip && tar -xf s5cmd_2.0.0-beta.2_Windows-64bit.zip" - ] - }, - { - "cell_type": "markdown", - "id": "7a85c749-5ece-4121-97e6-3ac7dac1b62a", - "metadata": {}, - "source": [ - "#### For Linux machines, Colab, SageMaker, Binder or other platforms use the following installation:" + "ct_image = itk.imread(ct_dir)" ] }, { "cell_type": "code", - "execution_count": 5, - "id": "0bbe6f14-a34e-4280-bc21-7343a78af88b", - "metadata": {}, + "execution_count": 25, + "id": "0e588f46-01b4-4ae4-886b-63742d59984d", + "metadata": { + "tags": [] + }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "--2023-05-25 14:18:24-- https://github.com/peak/s5cmd/releases/download/v2.0.0/s5cmd_2.0.0_Linux-64bit.tar.gz\n", - "Resolving github.com (github.com)... 140.82.113.3\n", - "Connecting to github.com (github.com)|140.82.113.3|:443... connected.\n", - "HTTP request sent, awaiting response... 302 Found\n", - "Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/73909333/2e177ae0-614f-48ba-92fd-04cf9bf41529?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230525%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230525T181825Z&X-Amz-Expires=300&X-Amz-Signature=4327982d7fc3e663e05504d6f396f1bb67a31dfce4e3fce9fdaa939e35094d2d&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=73909333&response-content-disposition=attachment%3B%20filename%3Ds5cmd_2.0.0_Linux-64bit.tar.gz&response-content-type=application%2Foctet-stream [following]\n", - "--2023-05-25 14:18:24-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/73909333/2e177ae0-614f-48ba-92fd-04cf9bf41529?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230525%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230525T181825Z&X-Amz-Expires=300&X-Amz-Signature=4327982d7fc3e663e05504d6f396f1bb67a31dfce4e3fce9fdaa939e35094d2d&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=73909333&response-content-disposition=attachment%3B%20filename%3Ds5cmd_2.0.0_Linux-64bit.tar.gz&response-content-type=application%2Foctet-stream\n", - "Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.109.133, 185.199.108.133, 185.199.111.133, ...\n", - "Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.109.133|:443... connected.\n", - "HTTP request sent, awaiting response... 200 OK\n", - "Length: 4276789 (4.1M) [application/octet-stream]\n", - "Saving to: ‘s5cmd_2.0.0_Linux-64bit.tar.gz’\n", - "\n", - "s5cmd_2.0.0_Linux-6 100%[===================>] 4.08M 22.3MB/s in 0.2s \n", - "\n", - "2023-05-25 14:18:25 (22.3 MB/s) - ‘s5cmd_2.0.0_Linux-64bit.tar.gz’ saved [4276789/4276789]\n", - "\n" + "Row direction: 1 0 0\n", + "Col direction: 0 -1 0\n", + "Z direction: 0 0 -1\n", + "Total frames: 265\n", + "Total frames with unique IPP: 109\n", + "Total overlapping frames: 94\n", + "Origin: [-177.3, 168.34, 3.81]\n", + "Slice extent: 270\n", + "Slice spacing: 2.5\n", + "Image Orientation Patient set to : 1, 0, 0, 0, -1, 0\n", + "Identified 1 groups of non-overlapping segments\n" ] } ], "source": [ - "if not Path('./s5cmd').exists():\n", - " !wget https://github.com/peak/s5cmd/releases/download/v2.0.0/s5cmd_2.0.0_Linux-64bit.tar.gz && tar zxf s5cmd_2.0.0_Linux-64bit.tar.gz" + "seg_image, seg_info = read_segmentation(seg_dir / \"6c8744b0-5dd7-4730-bef7-1ab465ec2337.dcm\")" ] }, { "cell_type": "code", - "execution_count": 6, - "id": "aOnyE_7hllIl", + "execution_count": 7, + "id": "699aa2d9-c7bf-42df-880e-4b0d6eb21ae0", "metadata": { - "id": "aOnyE_7hllIl", "tags": [] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
{\n",
+       "    'BodyPartExamined': 'CHEST',\n",
+       "    'ClinicalTrialCoordinatingCenterName': 'dcmqi',\n",
+       "    'ClinicalTrialSeriesID': '0',\n",
+       "    'ClinicalTrialTimePointID': '1',\n",
+       "    'ContentCreatorName': 'IDC',\n",
+       "    'InstanceNumber': '1',\n",
+       "    'SeriesDescription': '3d_fullres-tta_nnU-Net_Segmentation',\n",
+       "    'SeriesNumber': '42',\n",
+       "    'segmentAttributes': [\n",
+       "        [\n",
+       "            {\n",
+       "                'SegmentAlgorithmName': '3d_fullres-tta_nnU-Net',\n",
+       "                'SegmentAlgorithmType': 'AUTOMATIC',\n",
+       "                'SegmentDescription': '',\n",
+       "                'SegmentLabel': 'Esophagus',\n",
+       "                'SegmentedPropertyCategoryCodeSequence': {\n",
+       "                    'CodeMeaning': 'Anatomical Structure',\n",
+       "                    'CodeValue': '123037004',\n",
+       "                    'CodingSchemeDesignator': 'SCT'\n",
+       "                },\n",
+       "                'SegmentedPropertyTypeCodeSequence': {\n",
+       "                    'CodeMeaning': 'Esophagus',\n",
+       "                    'CodeValue': '32849002',\n",
+       "                    'CodingSchemeDesignator': 'SCT'\n",
+       "                },\n",
+       "                'labelID': 1,\n",
+       "                'recommendedDisplayRGBValue': [26, 113, 217]\n",
+       "            },\n",
+       "            {\n",
+       "                'SegmentAlgorithmName': '3d_fullres-tta_nnU-Net',\n",
+       "                'SegmentAlgorithmType': 'AUTOMATIC',\n",
+       "                'SegmentDescription': '',\n",
+       "                'SegmentLabel': 'Heart',\n",
+       "                'SegmentedPropertyCategoryCodeSequence': {\n",
+       "                    'CodeMeaning': 'Anatomical Structure',\n",
+       "                    'CodeValue': '123037004',\n",
+       "                    'CodingSchemeDesignator': 'SCT'\n",
+       "                },\n",
+       "                'SegmentedPropertyTypeCodeSequence': {\n",
+       "                    'CodeMeaning': 'Heart',\n",
+       "                    'CodeValue': '80891009',\n",
+       "                    'CodingSchemeDesignator': 'SCT'\n",
+       "                },\n",
+       "                'labelID': 2,\n",
+       "                'recommendedDisplayRGBValue': [5, 183, 61]\n",
+       "            },\n",
+       "            {\n",
+       "                'SegmentAlgorithmName': '3d_fullres-tta_nnU-Net',\n",
+       "                'SegmentAlgorithmType': 'AUTOMATIC',\n",
+       "                'SegmentDescription': '',\n",
+       "                'SegmentLabel': 'Trachea',\n",
+       "                'SegmentedPropertyCategoryCodeSequence': {\n",
+       "                    'CodeMeaning': 'Anatomical Structure',\n",
+       "                    'CodeValue': '123037004',\n",
+       "                    'CodingSchemeDesignator': 'SCT'\n",
+       "                },\n",
+       "                'SegmentedPropertyTypeCodeSequence': {\n",
+       "                    'CodeMeaning': 'Trachea',\n",
+       "                    'CodeValue': '44567001',\n",
+       "                    'CodingSchemeDesignator': 'SCT'\n",
+       "                },\n",
+       "                'labelID': 3,\n",
+       "                'recommendedDisplayRGBValue': [226, 62, 62]\n",
+       "            },\n",
+       "            {\n",
+       "                'SegmentAlgorithmName': '3d_fullres-tta_nnU-Net',\n",
+       "                'SegmentAlgorithmType': 'AUTOMATIC',\n",
+       "                'SegmentDescription': '',\n",
+       "                'SegmentLabel': 'Aorta',\n",
+       "                'SegmentedPropertyCategoryCodeSequence': {\n",
+       "                    'CodeMeaning': 'Anatomical Structure',\n",
+       "                    'CodeValue': '123037004',\n",
+       "                    'CodingSchemeDesignator': 'SCT'\n",
+       "                },\n",
+       "                'SegmentedPropertyTypeCodeSequence': {\n",
+       "                    'CodeMeaning': 'Aorta',\n",
+       "                    'CodeValue': '15825003',\n",
+       "                    'CodingSchemeDesignator': 'SCT'\n",
+       "                },\n",
+       "                'labelID': 4,\n",
+       "                'recommendedDisplayRGBValue': [250, 194, 39]\n",
+       "            }\n",
+       "        ]\n",
+       "    ]\n",
+       "}\n",
+       "
\n" + ], + "text/plain": [ + "\u001b[1m{\u001b[0m\n", + " \u001b[32m'BodyPartExamined'\u001b[0m: \u001b[32m'CHEST'\u001b[0m,\n", + " \u001b[32m'ClinicalTrialCoordinatingCenterName'\u001b[0m: \u001b[32m'dcmqi'\u001b[0m,\n", + " \u001b[32m'ClinicalTrialSeriesID'\u001b[0m: \u001b[32m'0'\u001b[0m,\n", + " \u001b[32m'ClinicalTrialTimePointID'\u001b[0m: \u001b[32m'1'\u001b[0m,\n", + " \u001b[32m'ContentCreatorName'\u001b[0m: \u001b[32m'IDC'\u001b[0m,\n", + " \u001b[32m'InstanceNumber'\u001b[0m: \u001b[32m'1'\u001b[0m,\n", + " \u001b[32m'SeriesDescription'\u001b[0m: \u001b[32m'3d_fullres-tta_nnU-Net_Segmentation'\u001b[0m,\n", + " \u001b[32m'SeriesNumber'\u001b[0m: \u001b[32m'42'\u001b[0m,\n", + " \u001b[32m'segmentAttributes'\u001b[0m: \u001b[1m[\u001b[0m\n", + " \u001b[1m[\u001b[0m\n", + " \u001b[1m{\u001b[0m\n", + " \u001b[32m'SegmentAlgorithmName'\u001b[0m: \u001b[32m'3d_fullres-tta_nnU-Net'\u001b[0m,\n", + " \u001b[32m'SegmentAlgorithmType'\u001b[0m: \u001b[32m'AUTOMATIC'\u001b[0m,\n", + " \u001b[32m'SegmentDescription'\u001b[0m: \u001b[32m''\u001b[0m,\n", + " \u001b[32m'SegmentLabel'\u001b[0m: \u001b[32m'Esophagus'\u001b[0m,\n", + " \u001b[32m'SegmentedPropertyCategoryCodeSequence'\u001b[0m: \u001b[1m{\u001b[0m\n", + " \u001b[32m'CodeMeaning'\u001b[0m: \u001b[32m'Anatomical Structure'\u001b[0m,\n", + " \u001b[32m'CodeValue'\u001b[0m: \u001b[32m'123037004'\u001b[0m,\n", + " \u001b[32m'CodingSchemeDesignator'\u001b[0m: \u001b[32m'SCT'\u001b[0m\n", + " \u001b[1m}\u001b[0m,\n", + " \u001b[32m'SegmentedPropertyTypeCodeSequence'\u001b[0m: \u001b[1m{\u001b[0m\n", + " \u001b[32m'CodeMeaning'\u001b[0m: \u001b[32m'Esophagus'\u001b[0m,\n", + " \u001b[32m'CodeValue'\u001b[0m: \u001b[32m'32849002'\u001b[0m,\n", + " \u001b[32m'CodingSchemeDesignator'\u001b[0m: \u001b[32m'SCT'\u001b[0m\n", + " \u001b[1m}\u001b[0m,\n", + " \u001b[32m'labelID'\u001b[0m: \u001b[1;36m1\u001b[0m,\n", + " \u001b[32m'recommendedDisplayRGBValue'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1;36m26\u001b[0m, \u001b[1;36m113\u001b[0m, \u001b[1;36m217\u001b[0m\u001b[1m]\u001b[0m\n", + " \u001b[1m}\u001b[0m,\n", + " \u001b[1m{\u001b[0m\n", + " \u001b[32m'SegmentAlgorithmName'\u001b[0m: \u001b[32m'3d_fullres-tta_nnU-Net'\u001b[0m,\n", + " \u001b[32m'SegmentAlgorithmType'\u001b[0m: \u001b[32m'AUTOMATIC'\u001b[0m,\n", + " \u001b[32m'SegmentDescription'\u001b[0m: \u001b[32m''\u001b[0m,\n", + " \u001b[32m'SegmentLabel'\u001b[0m: \u001b[32m'Heart'\u001b[0m,\n", + " \u001b[32m'SegmentedPropertyCategoryCodeSequence'\u001b[0m: \u001b[1m{\u001b[0m\n", + " \u001b[32m'CodeMeaning'\u001b[0m: \u001b[32m'Anatomical Structure'\u001b[0m,\n", + " \u001b[32m'CodeValue'\u001b[0m: \u001b[32m'123037004'\u001b[0m,\n", + " \u001b[32m'CodingSchemeDesignator'\u001b[0m: \u001b[32m'SCT'\u001b[0m\n", + " \u001b[1m}\u001b[0m,\n", + " \u001b[32m'SegmentedPropertyTypeCodeSequence'\u001b[0m: \u001b[1m{\u001b[0m\n", + " \u001b[32m'CodeMeaning'\u001b[0m: \u001b[32m'Heart'\u001b[0m,\n", + " \u001b[32m'CodeValue'\u001b[0m: \u001b[32m'80891009'\u001b[0m,\n", + " \u001b[32m'CodingSchemeDesignator'\u001b[0m: \u001b[32m'SCT'\u001b[0m\n", + " \u001b[1m}\u001b[0m,\n", + " \u001b[32m'labelID'\u001b[0m: \u001b[1;36m2\u001b[0m,\n", + " \u001b[32m'recommendedDisplayRGBValue'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1;36m5\u001b[0m, \u001b[1;36m183\u001b[0m, \u001b[1;36m61\u001b[0m\u001b[1m]\u001b[0m\n", + " \u001b[1m}\u001b[0m,\n", + " \u001b[1m{\u001b[0m\n", + " \u001b[32m'SegmentAlgorithmName'\u001b[0m: \u001b[32m'3d_fullres-tta_nnU-Net'\u001b[0m,\n", + " \u001b[32m'SegmentAlgorithmType'\u001b[0m: \u001b[32m'AUTOMATIC'\u001b[0m,\n", + " \u001b[32m'SegmentDescription'\u001b[0m: \u001b[32m''\u001b[0m,\n", + " \u001b[32m'SegmentLabel'\u001b[0m: \u001b[32m'Trachea'\u001b[0m,\n", + " \u001b[32m'SegmentedPropertyCategoryCodeSequence'\u001b[0m: \u001b[1m{\u001b[0m\n", + " \u001b[32m'CodeMeaning'\u001b[0m: \u001b[32m'Anatomical Structure'\u001b[0m,\n", + " \u001b[32m'CodeValue'\u001b[0m: \u001b[32m'123037004'\u001b[0m,\n", + " \u001b[32m'CodingSchemeDesignator'\u001b[0m: \u001b[32m'SCT'\u001b[0m\n", + " \u001b[1m}\u001b[0m,\n", + " \u001b[32m'SegmentedPropertyTypeCodeSequence'\u001b[0m: \u001b[1m{\u001b[0m\n", + " \u001b[32m'CodeMeaning'\u001b[0m: \u001b[32m'Trachea'\u001b[0m,\n", + " \u001b[32m'CodeValue'\u001b[0m: \u001b[32m'44567001'\u001b[0m,\n", + " \u001b[32m'CodingSchemeDesignator'\u001b[0m: \u001b[32m'SCT'\u001b[0m\n", + " \u001b[1m}\u001b[0m,\n", + " \u001b[32m'labelID'\u001b[0m: \u001b[1;36m3\u001b[0m,\n", + " \u001b[32m'recommendedDisplayRGBValue'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1;36m226\u001b[0m, \u001b[1;36m62\u001b[0m, \u001b[1;36m62\u001b[0m\u001b[1m]\u001b[0m\n", + " \u001b[1m}\u001b[0m,\n", + " \u001b[1m{\u001b[0m\n", + " \u001b[32m'SegmentAlgorithmName'\u001b[0m: \u001b[32m'3d_fullres-tta_nnU-Net'\u001b[0m,\n", + " \u001b[32m'SegmentAlgorithmType'\u001b[0m: \u001b[32m'AUTOMATIC'\u001b[0m,\n", + " \u001b[32m'SegmentDescription'\u001b[0m: \u001b[32m''\u001b[0m,\n", + " \u001b[32m'SegmentLabel'\u001b[0m: \u001b[32m'Aorta'\u001b[0m,\n", + " \u001b[32m'SegmentedPropertyCategoryCodeSequence'\u001b[0m: \u001b[1m{\u001b[0m\n", + " \u001b[32m'CodeMeaning'\u001b[0m: \u001b[32m'Anatomical Structure'\u001b[0m,\n", + " \u001b[32m'CodeValue'\u001b[0m: \u001b[32m'123037004'\u001b[0m,\n", + " \u001b[32m'CodingSchemeDesignator'\u001b[0m: \u001b[32m'SCT'\u001b[0m\n", + " \u001b[1m}\u001b[0m,\n", + " \u001b[32m'SegmentedPropertyTypeCodeSequence'\u001b[0m: \u001b[1m{\u001b[0m\n", + " \u001b[32m'CodeMeaning'\u001b[0m: \u001b[32m'Aorta'\u001b[0m,\n", + " \u001b[32m'CodeValue'\u001b[0m: \u001b[32m'15825003'\u001b[0m,\n", + " \u001b[32m'CodingSchemeDesignator'\u001b[0m: \u001b[32m'SCT'\u001b[0m\n", + " \u001b[1m}\u001b[0m,\n", + " \u001b[32m'labelID'\u001b[0m: \u001b[1;36m4\u001b[0m,\n", + " \u001b[32m'recommendedDisplayRGBValue'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1;36m250\u001b[0m, \u001b[1;36m194\u001b[0m, \u001b[1;36m39\u001b[0m\u001b[1m]\u001b[0m\n", + " \u001b[1m}\u001b[0m\n", + " \u001b[1m]\u001b[0m\n", + " \u001b[1m]\u001b[0m\n", + "\u001b[1m}\u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ - "%%capture\n", - "# CT series downloaded from IDC, NLST collection (https://doi.org/10.7937/TCIA.HMQ8-J677)\n", - "!./s5cmd --no-sign-request --endpoint-url https://storage.googleapis.com cp s3://public-datasets-idc/865da32b-cea7-4e6d-b4fe-9731bf08b3d2/* CT_DICOM_series\n", - "\n", - "# segmentation of this series downloaded from IDC, from nnU-Net-BPR-Annotations (https://doi.org/10.5281/zenodo.7539035)\n", - "!./s5cmd --no-sign-request --endpoint-url https://storage.googleapis.com cp s3://public-datasets-idc/3a0c03fe-3d17-48dc-9b8d-f64f5302e0a4/* SEG_DICOM_series" + "print(seg_info)" ] }, { "cell_type": "code", - "execution_count": 5, - "id": "RJzY1NUmneKZ", + "execution_count": 26, + "id": "264e1ce0-dd11-4197-a033-574d601cab50", "metadata": { - "id": "RJzY1NUmneKZ", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 567 + }, + "id": "264e1ce0-dd11-4197-a033-574d601cab50", + "outputId": "0dd9122e-599b-47ac-83ec-e2af41f1657e", "tags": [] }, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/javascript": [ + "window.connectPlugin && window.connectPlugin(\"52f4fea9-6a18-48e8-bff1-4edacb82e340\")" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "segthor_viewer = view(ct_image, label_image=seg_image)" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "id": "de4dfee3-1f5e-41d4-a599-02d1d9cbdf0e", + "metadata": { + "tags": [ + "skip-execution" + ] + }, "outputs": [], "source": [ - "ct_image = itk.imread(\"CT_DICOM_series\")" + "segthor_viewer.set_image_color_range([-1260, 2385])\n", + "segthor_viewer.set_label_image_blend(0.90)\n", + "segthor_viewer.set_image_gradient_opacity(0.45)\n", + "segthor_viewer.set_image_gradient_opacity_scale(0.55)" ] }, { "cell_type": "code", - "execution_count": 7, - "id": "0e588f46-01b4-4ae4-886b-63742d59984d", + "execution_count": 10, + "id": "ddeb5876-41cc-4b4b-8979-2ec0ace6ea20", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/javascript": [ + "window.connectPlugin && window.connectPlugin(\"52f4fea9-6a18-48e8-bff1-4edacb82e340\")" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "view(seg_image)" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "id": "7d4c4971-9dc5-41c1-beeb-45c9519bc185", "metadata": { "tags": [] }, "outputs": [], "source": [ - "seg_dicom = pydicom.dcmread(\"./SEG_DICOM_series/6c8744b0-5dd7-4730-bef7-1ab465ec2337.dcm\")\n", - "seg_reader = pydicom_seg.MultiClassReader()\n", - "seg_obj = seg_reader.read(seg_dicom)\n", - "\n", - "# Convert the DICOM SEG object into an itk image, with correct voxel origin, spacing, and directions in physical space.\n", - "seg_image = itk.image_from_array(seg_obj.data.astype(np.float32))\n", - "seg_image.SetOrigin(ct_image.GetOrigin())\n", - "seg_image.SetSpacing(ct_image.GetSpacing())\n", - "seg_image.SetDirection(ct_image.GetDirection())" + "seg_image\n", + "seg_image.origin = list(itk.origin(ct_image))\n", + "seg_image.spacing = list(itk.spacing(ct_image))\n", + "seg_image.direction = itk.array_from_matrix(ct_image.GetDirection())" ] }, { "cell_type": "code", - "execution_count": 8, - "id": "264e1ce0-dd11-4197-a033-574d601cab50", + "execution_count": 23, + "id": "3b9cf723-058d-47b0-befa-69aa8d656556", "metadata": { - "colab": { - "base_uri": "https://localhost:8080/", - "height": 567 - }, - "id": "264e1ce0-dd11-4197-a033-574d601cab50", - "outputId": "0dd9122e-599b-47ac-83ec-e2af41f1657e", "tags": [] }, "outputs": [ @@ -238,11 +550,11 @@ "data": { "text/html": [ "\n", - " \n", + " \n", " \n", @@ -258,7 +570,7 @@ { "data": { "application/javascript": [ - "window.connectPlugin && window.connectPlugin(\"7a4d3388-37d8-410f-9cd2-0f4c8cb74f46\")" + "window.connectPlugin && window.connectPlugin(\"52f4fea9-6a18-48e8-bff1-4edacb82e340\")" ], "text/plain": [ "" @@ -270,7 +582,7 @@ { "data": { "text/html": [ - "
" + "
" ], "text/plain": [ "" @@ -286,23 +598,296 @@ }, { "cell_type": "code", - "execution_count": 9, - "id": "de4dfee3-1f5e-41d4-a599-02d1d9cbdf0e", - "metadata": { "tags": ["skip-execution"] }, - "outputs": [], + "execution_count": 10, + "id": "3f3b109f-5307-48f5-afd6-dfd19622640b", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
Image(\n",
+       "    imageType=ImageType(dimension=3, componentType='int16', pixelType='Scalar', components=1),\n",
+       "    name='',\n",
+       "    origin=[-177.300003, 168.339722, 3.80999756],\n",
+       "    spacing=[0.660156, 0.660156, 2.5],\n",
+       "    direction=array([[ 1.,  0.,  0.],\n",
+       "       [ 0., -1.,  0.],\n",
+       "       [ 0.,  0., -1.]]),\n",
+       "    size=[512, 512, 109],\n",
+       "    metadata=[],\n",
+       "    data=array([[[0, 0, 0, ..., 0, 0, 0],\n",
+       "        [0, 0, 0, ..., 0, 0, 0],\n",
+       "        [0, 0, 0, ..., 0, 0, 0],\n",
+       "        ...,\n",
+       "        [0, 0, 0, ..., 0, 0, 0],\n",
+       "        [0, 0, 0, ..., 0, 0, 0],\n",
+       "        [0, 0, 0, ..., 0, 0, 0]],\n",
+       "\n",
+       "       [[0, 0, 0, ..., 0, 0, 0],\n",
+       "        [0, 0, 0, ..., 0, 0, 0],\n",
+       "        [0, 0, 0, ..., 0, 0, 0],\n",
+       "        ...,\n",
+       "        [0, 0, 0, ..., 0, 0, 0],\n",
+       "        [0, 0, 0, ..., 0, 0, 0],\n",
+       "        [0, 0, 0, ..., 0, 0, 0]],\n",
+       "\n",
+       "       [[0, 0, 0, ..., 0, 0, 0],\n",
+       "        [0, 0, 0, ..., 0, 0, 0],\n",
+       "        [0, 0, 0, ..., 0, 0, 0],\n",
+       "        ...,\n",
+       "        [0, 0, 0, ..., 0, 0, 0],\n",
+       "        [0, 0, 0, ..., 0, 0, 0],\n",
+       "        [0, 0, 0, ..., 0, 0, 0]],\n",
+       "\n",
+       "       ...,\n",
+       "\n",
+       "       [[0, 0, 0, ..., 0, 0, 0],\n",
+       "        [0, 0, 0, ..., 0, 0, 0],\n",
+       "        [0, 0, 0, ..., 0, 0, 0],\n",
+       "        ...,\n",
+       "        [0, 0, 0, ..., 0, 0, 0],\n",
+       "        [0, 0, 0, ..., 0, 0, 0],\n",
+       "        [0, 0, 0, ..., 0, 0, 0]],\n",
+       "\n",
+       "       [[0, 0, 0, ..., 0, 0, 0],\n",
+       "        [0, 0, 0, ..., 0, 0, 0],\n",
+       "        [0, 0, 0, ..., 0, 0, 0],\n",
+       "        ...,\n",
+       "        [0, 0, 0, ..., 0, 0, 0],\n",
+       "        [0, 0, 0, ..., 0, 0, 0],\n",
+       "        [0, 0, 0, ..., 0, 0, 0]],\n",
+       "\n",
+       "       [[0, 0, 0, ..., 0, 0, 0],\n",
+       "        [0, 0, 0, ..., 0, 0, 0],\n",
+       "        [0, 0, 0, ..., 0, 0, 0],\n",
+       "        ...,\n",
+       "        [0, 0, 0, ..., 0, 0, 0],\n",
+       "        [0, 0, 0, ..., 0, 0, 0],\n",
+       "        [0, 0, 0, ..., 0, 0, 0]]], dtype=int16),\n",
+       "    bufferedRegion={'index': [0, 0, 0], 'size': [512, 512, 109]}\n",
+       ")\n",
+       "
\n" + ], + "text/plain": [ + "\u001b[1;35mImage\u001b[0m\u001b[1m(\u001b[0m\n", + " \u001b[33mimageType\u001b[0m=\u001b[1;35mImageType\u001b[0m\u001b[1m(\u001b[0m\u001b[33mdimension\u001b[0m=\u001b[1;36m3\u001b[0m, \u001b[33mcomponentType\u001b[0m=\u001b[32m'int16'\u001b[0m, \u001b[33mpixelType\u001b[0m=\u001b[32m'Scalar'\u001b[0m, \u001b[33mcomponents\u001b[0m=\u001b[1;36m1\u001b[0m\u001b[1m)\u001b[0m,\n", + " \u001b[33mname\u001b[0m=\u001b[32m''\u001b[0m,\n", + " \u001b[33morigin\u001b[0m=\u001b[1m[\u001b[0m\u001b[1;36m-177.300003\u001b[0m, \u001b[1;36m168.339722\u001b[0m, \u001b[1;36m3.80999756\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[33mspacing\u001b[0m=\u001b[1m[\u001b[0m\u001b[1;36m0.660156\u001b[0m, \u001b[1;36m0.660156\u001b[0m, \u001b[1;36m2.5\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[33mdirection\u001b[0m=\u001b[1;35marray\u001b[0m\u001b[1m(\u001b[0m\u001b[1m[\u001b[0m\u001b[1m[\u001b[0m \u001b[1;36m1\u001b[0m., \u001b[1;36m0\u001b[0m., \u001b[1;36m0\u001b[0m.\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m \u001b[1;36m0\u001b[0m., \u001b[1;36m-1\u001b[0m., \u001b[1;36m0\u001b[0m.\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m \u001b[1;36m0\u001b[0m., \u001b[1;36m0\u001b[0m., \u001b[1;36m-1\u001b[0m.\u001b[1m]\u001b[0m\u001b[1m]\u001b[0m\u001b[1m)\u001b[0m,\n", + " \u001b[33msize\u001b[0m=\u001b[1m[\u001b[0m\u001b[1;36m512\u001b[0m, \u001b[1;36m512\u001b[0m, \u001b[1;36m109\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[33mmetadata\u001b[0m=\u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[33mdata\u001b[0m=\u001b[1;35marray\u001b[0m\u001b[1m(\u001b[0m\u001b[1m[\u001b[0m\u001b[1m[\u001b[0m\u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[33m...\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m\u001b[1m]\u001b[0m,\n", + "\n", + " \u001b[1m[\u001b[0m\u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[33m...\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m\u001b[1m]\u001b[0m,\n", + "\n", + " \u001b[1m[\u001b[0m\u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[33m...\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m\u001b[1m]\u001b[0m,\n", + "\n", + " \u001b[33m...\u001b[0m,\n", + "\n", + " \u001b[1m[\u001b[0m\u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[33m...\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m\u001b[1m]\u001b[0m,\n", + "\n", + " \u001b[1m[\u001b[0m\u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[33m...\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m\u001b[1m]\u001b[0m,\n", + "\n", + " \u001b[1m[\u001b[0m\u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[33m...\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[33m...\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m\u001b[1m]\u001b[0m\u001b[1m]\u001b[0m, \u001b[33mdtype\u001b[0m=\u001b[35mint16\u001b[0m\u001b[1m)\u001b[0m,\n", + " \u001b[33mbufferedRegion\u001b[0m=\u001b[1m{\u001b[0m\u001b[32m'index'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m, \u001b[1;36m0\u001b[0m\u001b[1m]\u001b[0m, \u001b[32m'size'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1;36m512\u001b[0m, \u001b[1;36m512\u001b[0m, \u001b[1;36m109\u001b[0m\u001b[1m]\u001b[0m\u001b[1m}\u001b[0m\n", + "\u001b[1m)\u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ - "segthor_viewer.set_image_color_range([-1260, 2385])\n", - "segthor_viewer.set_label_image_blend(0.90)\n", - "segthor_viewer.set_image_gradient_opacity(0.45)\n", - "segthor_viewer.set_image_gradient_opacity_scale(0.55)" + "print(seg_image)" ] }, { - "cell_type": "markdown", - "id": "05608a80-fbe3-4adb-81b9-b9f92695c5c1", + "cell_type": "code", + "execution_count": 11, + "id": "aaea5b0c-bf96-4af1-a932-30e29c360cc6", "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
Image (0x5e4d0e90b850)\n",
+       "  RTTI typeinfo:   itk::Image<int, 3u>\n",
+       "  Reference Count: 1\n",
+       "  Modified Time: 22467\n",
+       "  Debug: Off\n",
+       "  Object Name: \n",
+       "  Observers: \n",
+       "    none\n",
+       "  Source: (none)\n",
+       "  Source output name: (none)\n",
+       "  Release Data: Off\n",
+       "  Data Released: False\n",
+       "  Global Release Data: Off\n",
+       "  PipelineMTime: 294\n",
+       "  UpdateMTime: 22466\n",
+       "  RealTimeStamp: 0 seconds \n",
+       "  LargestPossibleRegion: \n",
+       "    Dimension: 3\n",
+       "    Index: [0, 0, 0]\n",
+       "    Size: [512, 512, 110]\n",
+       "  BufferedRegion: \n",
+       "    Dimension: 3\n",
+       "    Index: [0, 0, 0]\n",
+       "    Size: [512, 512, 110]\n",
+       "  RequestedRegion: \n",
+       "    Dimension: 3\n",
+       "    Index: [0, 0, 0]\n",
+       "    Size: [512, 512, 110]\n",
+       "  Spacing: [0.660156, 0.660156, 2.5]\n",
+       "  Origin: [-177.3, -169, -268.69]\n",
+       "  Direction: \n",
+       "1 0 0\n",
+       "0 1 0\n",
+       "0 0 1\n",
+       "\n",
+       "  IndexToPointMatrix: \n",
+       "0.660156 0 0\n",
+       "0 0.660156 0\n",
+       "0 0 2.5\n",
+       "\n",
+       "  PointToIndexMatrix: \n",
+       "1.51479 0 0\n",
+       "0 1.51479 0\n",
+       "0 0 0.4\n",
+       "\n",
+       "  Inverse Direction: \n",
+       "1 0 0\n",
+       "0 1 0\n",
+       "0 0 1\n",
+       "\n",
+       "  PixelContainer: \n",
+       "    ImportImageContainer (0x5e4d0e79edd0)\n",
+       "      RTTI typeinfo:   itk::ImportImageContainer<unsigned long, int>\n",
+       "      Reference Count: 1\n",
+       "      Modified Time: 683\n",
+       "      Debug: Off\n",
+       "      Object Name: \n",
+       "      Observers: \n",
+       "        none\n",
+       "      Pointer: 0x7fd392400010\n",
+       "      Container manages memory: true\n",
+       "      Size: 28835840\n",
+       "      Capacity: 28835840\n",
+       "\n",
+       "
\n" + ], + "text/plain": [ + "Image \u001b[1m(\u001b[0m\u001b[1;36m0x5e4d0e90b850\u001b[0m\u001b[1m)\u001b[0m\n", + " RTTI typeinfo: itk::Image\u001b[1m<\u001b[0m\u001b[1;95mint\u001b[0m\u001b[39m, 3u>\u001b[0m\n", + "\u001b[39m Reference Count: \u001b[0m\u001b[1;36m1\u001b[0m\n", + "\u001b[39m Modified Time: \u001b[0m\u001b[1;36m22467\u001b[0m\n", + "\u001b[39m Debug: Off\u001b[0m\n", + "\u001b[39m Object Name: \u001b[0m\n", + "\u001b[39m Observers: \u001b[0m\n", + "\u001b[39m none\u001b[0m\n", + "\u001b[39m Source: \u001b[0m\u001b[1;39m(\u001b[0m\u001b[39mnone\u001b[0m\u001b[1;39m)\u001b[0m\n", + "\u001b[39m Source output name: \u001b[0m\u001b[1;39m(\u001b[0m\u001b[39mnone\u001b[0m\u001b[1;39m)\u001b[0m\n", + "\u001b[39m Release Data: Off\u001b[0m\n", + "\u001b[39m Data Released: \u001b[0m\u001b[3;91mFalse\u001b[0m\n", + "\u001b[39m Global Release Data: Off\u001b[0m\n", + "\u001b[39m PipelineMTime: \u001b[0m\u001b[1;36m294\u001b[0m\n", + "\u001b[39m UpdateMTime: \u001b[0m\u001b[1;36m22466\u001b[0m\n", + "\u001b[39m RealTimeStamp: \u001b[0m\u001b[1;36m0\u001b[0m\u001b[39m seconds \u001b[0m\n", + "\u001b[39m LargestPossibleRegion: \u001b[0m\n", + "\u001b[39m Dimension: \u001b[0m\u001b[1;36m3\u001b[0m\n", + "\u001b[39m Index: \u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[39m, \u001b[0m\u001b[1;36m0\u001b[0m\u001b[39m, \u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;39m]\u001b[0m\n", + "\u001b[39m Size: \u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;36m512\u001b[0m\u001b[39m, \u001b[0m\u001b[1;36m512\u001b[0m\u001b[39m, \u001b[0m\u001b[1;36m110\u001b[0m\u001b[1;39m]\u001b[0m\n", + "\u001b[39m BufferedRegion: \u001b[0m\n", + "\u001b[39m Dimension: \u001b[0m\u001b[1;36m3\u001b[0m\n", + "\u001b[39m Index: \u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[39m, \u001b[0m\u001b[1;36m0\u001b[0m\u001b[39m, \u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;39m]\u001b[0m\n", + "\u001b[39m Size: \u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;36m512\u001b[0m\u001b[39m, \u001b[0m\u001b[1;36m512\u001b[0m\u001b[39m, \u001b[0m\u001b[1;36m110\u001b[0m\u001b[1;39m]\u001b[0m\n", + "\u001b[39m RequestedRegion: \u001b[0m\n", + "\u001b[39m Dimension: \u001b[0m\u001b[1;36m3\u001b[0m\n", + "\u001b[39m Index: \u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[39m, \u001b[0m\u001b[1;36m0\u001b[0m\u001b[39m, \u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;39m]\u001b[0m\n", + "\u001b[39m Size: \u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;36m512\u001b[0m\u001b[39m, \u001b[0m\u001b[1;36m512\u001b[0m\u001b[39m, \u001b[0m\u001b[1;36m110\u001b[0m\u001b[1;39m]\u001b[0m\n", + "\u001b[39m Spacing: \u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;36m0.660156\u001b[0m\u001b[39m, \u001b[0m\u001b[1;36m0.660156\u001b[0m\u001b[39m, \u001b[0m\u001b[1;36m2.5\u001b[0m\u001b[1;39m]\u001b[0m\n", + "\u001b[39m Origin: \u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;36m-177.3\u001b[0m\u001b[39m, \u001b[0m\u001b[1;36m-169\u001b[0m\u001b[39m, \u001b[0m\u001b[1;36m-268.69\u001b[0m\u001b[1;39m]\u001b[0m\n", + "\u001b[39m Direction: \u001b[0m\n", + "\u001b[1;36m1\u001b[0m\u001b[39m \u001b[0m\u001b[1;36m0\u001b[0m\u001b[39m \u001b[0m\u001b[1;36m0\u001b[0m\n", + "\u001b[1;36m0\u001b[0m\u001b[39m \u001b[0m\u001b[1;36m1\u001b[0m\u001b[39m \u001b[0m\u001b[1;36m0\u001b[0m\n", + "\u001b[1;36m0\u001b[0m\u001b[39m \u001b[0m\u001b[1;36m0\u001b[0m\u001b[39m \u001b[0m\u001b[1;36m1\u001b[0m\n", + "\n", + "\u001b[39m IndexToPointMatrix: \u001b[0m\n", + "\u001b[1;36m0.660156\u001b[0m\u001b[39m \u001b[0m\u001b[1;36m0\u001b[0m\u001b[39m \u001b[0m\u001b[1;36m0\u001b[0m\n", + "\u001b[1;36m0\u001b[0m\u001b[39m \u001b[0m\u001b[1;36m0.660156\u001b[0m\u001b[39m \u001b[0m\u001b[1;36m0\u001b[0m\n", + "\u001b[1;36m0\u001b[0m\u001b[39m \u001b[0m\u001b[1;36m0\u001b[0m\u001b[39m \u001b[0m\u001b[1;36m2.5\u001b[0m\n", + "\n", + "\u001b[39m PointToIndexMatrix: \u001b[0m\n", + "\u001b[1;36m1.51479\u001b[0m\u001b[39m \u001b[0m\u001b[1;36m0\u001b[0m\u001b[39m \u001b[0m\u001b[1;36m0\u001b[0m\n", + "\u001b[1;36m0\u001b[0m\u001b[39m \u001b[0m\u001b[1;36m1.51479\u001b[0m\u001b[39m \u001b[0m\u001b[1;36m0\u001b[0m\n", + "\u001b[1;36m0\u001b[0m\u001b[39m \u001b[0m\u001b[1;36m0\u001b[0m\u001b[39m \u001b[0m\u001b[1;36m0.4\u001b[0m\n", + "\n", + "\u001b[39m Inverse Direction: \u001b[0m\n", + "\u001b[1;36m1\u001b[0m\u001b[39m \u001b[0m\u001b[1;36m0\u001b[0m\u001b[39m \u001b[0m\u001b[1;36m0\u001b[0m\n", + "\u001b[1;36m0\u001b[0m\u001b[39m \u001b[0m\u001b[1;36m1\u001b[0m\u001b[39m \u001b[0m\u001b[1;36m0\u001b[0m\n", + "\u001b[1;36m0\u001b[0m\u001b[39m \u001b[0m\u001b[1;36m0\u001b[0m\u001b[39m \u001b[0m\u001b[1;36m1\u001b[0m\n", + "\n", + "\u001b[39m PixelContainer: \u001b[0m\n", + "\u001b[39m ImportImageContainer \u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;36m0x5e4d0e79edd0\u001b[0m\u001b[1;39m)\u001b[0m\n", + "\u001b[39m RTTI typeinfo: itk::ImportImageContainer\u001b[0m\n", + " Reference Count: \u001b[1;36m1\u001b[0m\n", + " Modified Time: \u001b[1;36m683\u001b[0m\n", + " Debug: Off\n", + " Object Name: \n", + " Observers: \n", + " none\n", + " Pointer: \u001b[1;36m0x7fd392400010\u001b[0m\n", + " Container manages memory: true\n", + " Size: \u001b[1;36m28835840\u001b[0m\n", + " Capacity: \u001b[1;36m28835840\u001b[0m\n", + "\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ - "## Head MRA" + "print(ct_image)" ] }, { @@ -317,9 +902,13 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "id": "03988ee1-90eb-4e75-99af-2c56d932fad9", - "metadata": { "tags": ["skip-execution"] }, + "metadata": { + "tags": [ + "skip-execution" + ] + }, "outputs": [], "source": [ "head_image_file = pooch.retrieve('https://data.kitware.com/api/v1/file/61b61cd74acac99f42a7ec84/download',\n", @@ -330,19 +919,23 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 16, "id": "091d4d0e-fdc5-4034-b6a5-a4d7350b98d5", - "metadata": { "tags": ["skip-execution"] }, + "metadata": { + "tags": [ + "skip-execution" + ] + }, "outputs": [ { "data": { "text/html": [ "\n", - " \n", + " \n", " \n", @@ -358,7 +951,7 @@ { "data": { "application/javascript": [ - "window.connectPlugin && window.connectPlugin(\"7a4d3388-37d8-410f-9cd2-0f4c8cb74f46\")" + "window.connectPlugin && window.connectPlugin(\"379402b6-f2f0-4950-9de8-882fc45c5249\")" ], "text/plain": [ "" @@ -370,7 +963,7 @@ { "data": { "text/html": [ - "
" + "
" ], "text/plain": [ "" @@ -383,14 +976,6 @@ "source": [ "head_viewer = view(head_image)" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "0f4633af-fd01-4ab5-8202-3fb642276040", - "metadata": { "tags": ["skip-execution"] }, - "outputs": [], - "source": [] } ], "metadata": { @@ -412,7 +997,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.10" + "version": "3.11.8" } }, "nbformat": 4,