Skip to content

Commit 6047a5d

Browse files
committed
updates
1 parent 4c3d64d commit 6047a5d

1 file changed

Lines changed: 25 additions & 8 deletions

File tree

_sources/projects/Project_02_Radiotherapy.ipynb

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"metadata": {},
1313
"source": [
1414
"<div>\n",
15-
"<img src=\"https://raw.githubusercontent.com/illinois-mlp/MachineLearningForPhysics/main/img/Project_Radiotherapy-overview.jpg\" width=600></img>\n",
15+
"<img src=\"..\\img\\Radiotherapy-overview.jpg\" width=600>\n",
1616
"</div>"
1717
]
1818
},
@@ -53,6 +53,14 @@
5353
"* https://github.com/ababier/open-kbp"
5454
]
5555
},
56+
{
57+
"cell_type": "markdown",
58+
"metadata": {},
59+
"source": [
60+
"Link to data\n",
61+
"* https://github.com/ababier/open-kbp"
62+
]
63+
},
5664
{
5765
"cell_type": "markdown",
5866
"metadata": {},
@@ -74,10 +82,9 @@
7482
"X-rays attenuate exponentially upon entering the body by the Beer-Lambert Law. \n",
7583
"\n",
7684
"$$\n",
77-
"\n",
78-
"I(x) = I_0 \\, e^{-\\mu x}\n",
79-
"\n",
85+
"I(x) = I_0 e^{-\\mu x}\n",
8086
"$$\n",
87+
"\n",
8188
"$$\n",
8289
"\\begin{aligned}\n",
8390
"x & : \\text{Depth in the body} \\\\\n",
@@ -140,7 +147,7 @@
140147
"cell_type": "markdown",
141148
"metadata": {},
142149
"source": [
143-
"Download `openkbp_patient_data.zip` from File URLS above. Unzip it and upload the folder to your Google Colab (`/content/..`) or local directory. Note that you will need to adjust `base_path` to lead to your uploaded folder.\n",
150+
"Run the cell below and unzip the contents of `openkbp_patient_data` into a folder. It should be present in Colab's (`/content/..`) or local directory. Note that you will need to adjust `base_path` to lead to this folder.\n",
144151
"\n",
145152
"Each patient hosts the following three files: \n",
146153
"`ct.csv` - 3D grayscale CT scan of patient anatomy composed of 2D slices. Each voxel represents how much X-ray is absorbed by the tissue in Hounsfield Units (HU) \n",
@@ -150,6 +157,16 @@
150157
"These are currently flattened 1D rows. The cell below converts the csv files into 3D volumes [64, 128, 128] where each point represents an intensity (for the ct scan) or binary value (for ptv & spinal cord). Add a line to the for loop that stacks `ct`, `ptv`, and `spine` into a single tensor. What's the final shape of this tensor? Draw an analogy to an RGB image."
151158
]
152159
},
160+
{
161+
"cell_type": "code",
162+
"execution_count": null,
163+
"metadata": {},
164+
"outputs": [],
165+
"source": [
166+
"!wget https://github.com/florilegium7/Physics-informed-DQN-Radiotherapy/releases/download/v1.0/openkbp_patient_data.zip\n",
167+
"!unzip patient_data.zip"
168+
]
169+
},
153170
{
154171
"cell_type": "code",
155172
"execution_count": null,
@@ -160,7 +177,7 @@
160177
"import pandas as pd\n",
161178
"import os\n",
162179
"\n",
163-
"base_path = 'openkbp_patient_data' #adjust this (e.g. /content/openkbp_patient_data)\n",
180+
"base_path = 'openkbp_patient_data' #you may adjust this (e.g. /content/openkbp_patient_data)\n",
164181
"\n",
165182
"patient_ids = [\"patient_1\", \"patient_2\", \"patient_3\",\"patient_5\",\"patient_7\",\"patient_9\", \"patient_10\", \"patient_12\" , \"patient_14\", \"patient_16\"]\n",
166183
"patient_tensors = []\n",
@@ -368,12 +385,12 @@
368385
"source": [
369386
"We'd like to inject a physics loss that encodes the actual attenuation and radiation dose delivery of the beam, rewarding correct dose distribution between the spine and tumor. We need to upgrade our simple Q-learning method into a Deep-Q Network (DQN). This should only require simple structural changes (refer to our reinforcement learning [notebook](https://illinois-mlp.github.io/MachineLearningForPhysics/_sources/lectures/ReinforcementLearning.html)). Typically, these would use a Bellman loss. With our new physics-loss it should resemble:\n",
370387
"$$\n",
371-
"\\mathcal{L}_{\\text{Total}} = \\mathcal{L}_{\\text{Bellman}} + \\lambda_{\\text{Physics}} \\mathcal{L}_{\\text{Physics}}\n",
388+
"L_{\\text{Total}} = L_{\\text{Bellman}} + \\lambda_{\\text{Physics}} L_{\\text{Physics}}\n",
372389
"$$\n",
373390
"\n",
374391
"The physics loss takes the following form: \n",
375392
"$$\n",
376-
"\\mathcal{L}_{\\text{Physics}} =\n",
393+
"L_{\\text{Physics}} =\n",
377394
"\\lambda_{\\text{PTV}} \\cdot \\text{Underdose}_{\\text{PTV}} +\n",
378395
"\\lambda_{\\text{Spine}} \\cdot \\text{Overdose}_{\\text{Spine}}\n",
379396
"$$\n",

0 commit comments

Comments
 (0)