Skip to content

Commit d249702

Browse files
committed
Version 1.1.1:
Dose calculation for custom patient. Update eclipse_photon_dose_calculation.ipynb Add docstring in clinical criteria. Add more methods to data explorer for accessing data from hugging face. Add unit test Remove redundant max constraints from optimization.py
1 parent ae60f54 commit d249702

File tree

8 files changed

+367
-94
lines changed

8 files changed

+367
-94
lines changed

examples/eclipse_photon_dose_calculation.ipynb

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
"---\n",
1616
"\n",
1717
"### **1. Download the Photon Dose Calculation Module**\n",
18-
"Download the required module from Varian's GitHub repository: [Photon Dose Calculation Module](https://github.com/Varian-MedicalAffairsAppliedSolutions/MAAS-DoseInfluenceMatrix/tree/main) **Note:** This repository is currently not public. Please allow it sometime to become public\n",
19-
"\n",
18+
"Download the required module from Varian's GitHub repository under release tab: [CalculateInfluenceMatrix](https://github.com/Varian-MedicalAffairsAppliedSolutions/MAAS-DoseInfluenceMatrix/tree/main) \n",
2019
"\n",
2120
"### **2. Prepare Your Plan in Eclipse**\n",
2221
"Before running dose calculation, you must set up your plan correctly in Eclipse.\n",
@@ -46,15 +45,15 @@
4645
"For users unfamiliar with command-line scripting, the plugin provides a **graphical interface** for dose calculation.\n",
4746
"\n",
4847
"##### **Steps:**\n",
49-
"1. Navigate to the [Plugin Directory](https://github.com/Varian-MedicalAffairsAppliedSolutions/MAAS-DoseInfluenceMatrix/tree/main/PhotonDoseCalc/Plugin/bin/Release) in photon dose calculation module \n",
48+
"1. Navigate to the release [tab](https://github.com/Varian-MedicalAffairsAppliedSolutions/MAAS-DoseInfluenceMatrix/releases) tab for dose calculation module and download the latest version of CalculateInfluenceMatrix \n",
5049
"2. Modify the config file: \n",
51-
" - Edit [PhotonInfluenceMatrixCalcPlugin.esapi.config](https://github.com/Varian-MedicalAffairsAppliedSolutions/MAAS-DoseInfluenceMatrix/blob/main/PhotonDoseCalc/Source_C%23/bin/release/PhotonInfluenceMatrixCalcPlugin.esapi.config). \n",
52-
" - Set `OutputRootFolder` to your preferred output directory. You can also modify `BeamletSizeX` and `BeamletSizeY` for choosing the beamlet size in X and Y direction. Please modify the `EclipseVolumeDoseCalcModel` based on your dose calculation version available at your institution.\n",
50+
" - Edit CalculateInfluenceMatrix.esapi.dll.config. \n",
51+
" - Set `Photon_OutputRootFolder` to your preferred output directory. You can also modify `BeamletSizeX` and `BeamletSizeY` for choosing the beamlet size in X and Y direction. Please modify the `Photon_EclipseVolumeDoseCalcModel` based on your dose calculation version available at your institution.\n",
5352
"3. In Eclipse:\n",
5453
" - Open your patient plan (e.g., **PortPy_Plan**). \n",
5554
" - Navigate to **Tools → Scripts → Change Folder**. \n",
56-
" - Change the path to downloaded [Plugin Directory](https://github.com/Varian-MedicalAffairsAppliedSolutions/MAAS-DoseInfluenceMatrix/tree/main/PhotonDoseCalc/Plugin/bin/Release) and click **Open**. \n",
57-
" - Select **PhotonInfluenceMatrixCalcPlugin.esapi.dll** and click **Run**\n",
55+
" - Change the path to downloaded folder from release and click **Open**. \n",
56+
" - Select **CalculateInfluenceMatrix.esapi.dll** and click **Run**\n",
5857
" - (Optional) Add the plugin to **Favorites** for quicker access. \n",
5958
"\n",
6059
"**Output:** PortPy-compatible data will be saved in the `OutputRootFolder` specified in the config file.\n",
@@ -64,14 +63,14 @@
6463
"For users comfortable with command-line execution.\n",
6564
"\n",
6665
"##### **Steps:**\n",
67-
"1. Navigate to the [Executable Directory](https://github.com/Varian-MedicalAffairsAppliedSolutions/MAAS-DoseInfluenceMatrix/tree/main/PhotonDoseCalc/Source_C%23/bin/release). \n",
66+
"1. Navigate to the release [tab](https://github.com/Varian-MedicalAffairsAppliedSolutions/MAAS-DoseInfluenceMatrix/releases) tab for dose calculation module and download the latest version of CalculateInfluenceMatrix. \n",
6867
"2. Modify the config file:\n",
69-
" - Edit [PhotonInfluenceMatrixCalc.exe.config](https://github.com/Varian-MedicalAffairsAppliedSolutions/MAAS-DoseInfluenceMatrix/blob/main/PhotonDoseCalc/Source_C%23/bin/release/PhotonInfluenceMatrixCalc.exe.config). \n",
70-
" - Set `OutputRootFolder` to your preferred output directory. You can also modify `BeamletSizeX` and `BeamletSizeY` for choosing the beamlet size in X and Y direction. Please modify the `EclipseVolumeDoseCalcModel` based on your dose calculation version available at your institution.\n",
68+
" - Edit CalculateInfluenceMatrix.exe.config. \n",
69+
" - Set `Photon_OutputRootFolder` to your preferred output directory. You can also modify `Photon_BeamletSizeX` and `Photon_BeamletSizeY` for choosing the beamlet size in X and Y direction. Please modify the `Photon_EclipseVolumeDoseCalcModel` based on your dose calculation version available at your institution.\n",
7170
" \n",
7271
"3. Run the following command in a terminal or command prompt: \n",
7372
" ```bash\n",
74-
" PhotonInfluenceMatrixCalc.exe <patient_mrn> <course_name> <plan_name>"
73+
" CalculateInfluenceMatrix.exe <patient_mrn> <course_name> <plan_name>"
7574
]
7675
},
7776
{

examples/python_files/1_basic_tutorial.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ def basic_tutorial():
5959
data_dir = r'../../data'
6060
data = pp.DataExplorer(data_dir=data_dir)
6161
# OR
62-
# data = pp.DataExplorer(hf_repo_id="PortPy-Project/PortPy_Dataset")
62+
# data = pp.DataExplorer(hf_repo_id="PortPy-Project/PortPy_Dataset", local_download_dir='your_local_directory')
6363

6464
# display the existing patients in console or browser.
6565
data.display_list_of_patients()
6666

6767
# pick a patient from the existing patient list to get detailed info (e.g., beam angles, structures).
6868
data.patient_id = 'Lung_Phantom_Patient_1'
6969

70-
# download patient data with planner beams from hugging face
70+
# download patient data with planner beams from hugging face. Run it only once for the initial run to download the data. Skip it for next run
7171
# data.filter_and_download_hf_dataset()
7272

7373
# display the data of the patient in console or browser.

portpy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
__version__ = "1.1.0"
1+
__version__ = "1.1.1"
22

33
from portpy import photon

portpy/photon/clinical_criteria.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import TYPE_CHECKING, Union
77
if TYPE_CHECKING:
88
from portpy.photon.plan import Plan
9+
from portpy.photon.influence_matrix import InfluenceMatrix
910
from copy import deepcopy
1011
import numpy as np
1112

@@ -288,7 +289,34 @@ def get_dvh_table(self, my_plan: Plan, constraint_list: list = None, opt_params:
288289
return self.dvh_table
289290

290291

291-
def get_low_dose_vox_ind(self, my_plan: Plan, dose: np.ndarray):
292+
def get_low_dose_vox_ind(self, my_plan: Plan, dose: np.ndarray, inf_matrix: InfluenceMatrix):
293+
"""
294+
Identifies and stores the indices of low-dose voxels for each DVH constraint or goal.
295+
296+
For each row in the DVH table, the method:
297+
- Retrieves the relevant structure name, dose threshold, and volume percentage.
298+
- Adjusts the volume percentage based on the fraction of the volume in the dose calculation box.
299+
- Sorts the structure's voxels based on dose values (ascending).
300+
- Accumulates voxel volumes until the specified volume percentage is reached.
301+
- Marks these as low-dose voxels and stores them in the `low_dose_voxels` column.
302+
303+
Parameters
304+
----------
305+
my_plan : Plan
306+
The treatment plan object that includes the influence matrix.
307+
dose : np.ndarray
308+
A 1D array representing the dose values for all optimization voxels.
309+
inf_matrix : InfluenceMatrix, optional
310+
The influence matrix that provides voxel-related metadata. If not provided,
311+
it defaults to `my_plan.inf_matrix`.
312+
313+
Returns
314+
-------
315+
pd.DataFrame
316+
Updated DVH table with a new column `low_dose_voxels` indicating voxel indices
317+
in each structure that received the lowest doses contributing up to the specified
318+
volume percentage.
319+
"""
292320
dvh_table = self.dvh_table
293321
inf_matrix = my_plan.inf_matrix
294322
for ind in dvh_table.index:

0 commit comments

Comments
 (0)