diff --git a/examples/python_files/inf_matrix_sparsification.py b/examples/python_files/inf_matrix_sparsification.py index 7171359..e111031 100644 --- a/examples/python_files/inf_matrix_sparsification.py +++ b/examples/python_files/inf_matrix_sparsification.py @@ -68,7 +68,7 @@ def inf_matrix_sparsification(): beams_full = pp.Beams(data, load_inf_matrix_full=True) # load influence matrix based upon beams and structure set inf_matrix_full = pp.InfluenceMatrix(ct=ct, structs=structs, beams=beams_full, is_full=True) - plan_full = pp.Plan(ct, structs, beams, inf_matrix_full, clinical_criteria) + plan_full = pp.Plan(ct=ct, structs=structs, beams=beams, inf_matrix=inf_matrix_full, clinical_criteria=clinical_criteria) # use the full influence matrix to calculate the dose for the plan obtained by sparse matrix dose_full_1d = plan_full.inf_matrix.A @ (sol_sparse['optimal_intensity'] * plan_full.get_num_of_fractions()) diff --git a/examples/python_files/vmat_global_optimal.py b/examples/python_files/vmat_global_optimal.py index 99427de..a262a4e 100644 --- a/examples/python_files/vmat_global_optimal.py +++ b/examples/python_files/vmat_global_optimal.py @@ -176,7 +176,7 @@ def vmat_optimization(): """ # plot dvh for the structures in the given list. Default dose_1d is in Gy and volume is in relative scale(%). struct_names = ['PTV', 'ESOPHAGUS', 'HEART', 'CORD'] - pp.Visualization.plot_dvh(my_plan, sol=sol, struct_names=struct_names, title=patient_id) + pp.Visualization.plot_dvh(my_plan, sol=sol, struct_names=struct_names, title=data.patient_id) # plot 2d axial slice for the given solution and display the structures contours on the slice pp.Visualization.plot_2d_slice(my_plan=my_plan, sol=sol, slice_num=60, struct_names=['PTV']) diff --git a/examples/python_files/vmat_tps_import.py b/examples/python_files/vmat_tps_import.py index c4d1567..2e1ca91 100644 --- a/examples/python_files/vmat_tps_import.py +++ b/examples/python_files/vmat_tps_import.py @@ -17,29 +17,20 @@ # 5. Comparing the PortPy plan against the TPS plan for validation and analysis # -# In[1]: - - import sys sys.path.append('..') - -# In[8]: - - import portpy.photon as pp import os import matplotlib.pyplot as plt import cvxpy as cp import numpy as np +import pandas as pd # ### 1) Creating a simple IMRT plan (Plan class, Optimization class) # -# In[3]: - - # specify the patient data location. data_dir = r'../data' # Use PortPy DataExplorer class to explore PortPy data @@ -50,10 +41,6 @@ # # display the data of the patient in console or browser. # data.display_patient_metadata() - -# In[9]: - - # Load ct and structure set for the above patient using CT and Structures class ct = pp.CT(data) structs = pp.Structures(data) @@ -88,11 +75,6 @@ my_plan = pp.Plan(ct=ct, structs=structs, beams=beams, inf_matrix=inf_matrix, clinical_criteria=clinical_criteria, arcs=arcs) -# #### Optimize VMAT plan using sequential convex programming - -# In[ ]: - - # Initialize Optimization vmat_opt = pp.VmatScpOptimization(my_plan=my_plan, opt_params=vmat_opt_params) @@ -117,25 +99,14 @@ # 3. Finally, in TPS, execute final dose calculation. # -# In[4]: - - my_plan = pp.load_plan(plan_name='my_plan_vmat.pkl', path=os.path.join(r'C:\temp', data.patient_id)) sol = pp.load_optimal_sol(sol_name='sol_vmat.pkl', path=os.path.join(r'C:\temp', data.patient_id)) - -# In[ ]: - - # create dicom RT Plan file to be imported in TPS out_rt_plan_file = r'C:\Temp\Lung_Patient_3\rt_plan_portpy_vmat.dcm' # change this file directory based upon your needs in_rt_plan_file = r'C:\Temp\Lung_Patient_3\rt_plan_echo_vmat.dcm' # change this directory as per your pp.write_rt_plan_vmat(my_plan=my_plan, in_rt_plan_file=in_rt_plan_file, out_rt_plan_file=out_rt_plan_file) - -# In[7]: - - # get the corresponding tcia collection/subject ID data.get_tcia_metadata() @@ -143,9 +114,6 @@ # ### 3) Exporting the finally calculated dose from the TPS system into PortPy # After the final dose calculation in Eclipse, export the dose in DICOM RT-Dose format using the Eclipse Export module. Then, utilize the following lines of code to convert the exported dose into the PortPy format for visualization or evaluation purposes -# In[10]: - - # Specify the location and name of the DICOM RT Dose file dose_file_name = os.path.join(r'C:\temp', data.patient_id, 'rt_dose_portpy_vmat.dcm') # Convert the DICOM dose into PortPy format @@ -156,20 +124,12 @@ # ### 4) Comparing the PortPy VMAT plan against the TPS plan for validation and analysis # # Finally dose exported from TPS in RT-dose DICOM file can be compared against PortPy dose using full influence matrix -# - -# In[12]: - beams_full = pp.Beams(data, beam_ids=beam_ids, load_inf_matrix_full=True) # load influence matrix based upon beams and structure set inf_matrix_full = pp.InfluenceMatrix(ct=ct, structs=structs, beams=beams_full, is_full=True) dose_full_1d = inf_matrix_full.A @ (sol['optimal_intensity'] * my_plan.get_num_of_fractions()) # calculate dose using full matrix - -# In[13]: - - # Visualize the DVH discrepancy between eclipse dose and dose using full matrix in portpy struct_names = ['PTV', 'ESOPHAGUS', 'HEART', 'CORD', 'LUNGS_NOT_GTV'] fig, ax = plt.subplots(figsize=(12, 8)) @@ -177,10 +137,6 @@ ax = pp.Visualization.plot_dvh(my_plan, dose_1d=ecl_dose_1d, struct_names=struct_names, style='dotted', ax=ax, norm_flag=True) ax.set_title('- PortPy VMAT(Using full matrix) .. Eclipse') plt.show() - - -# In[ ]: - - +print('Done') diff --git a/examples/vmat_scp_tutorial.ipynb b/examples/vmat_scp_tutorial.ipynb index 9f692ce..92d0f10 100644 --- a/examples/vmat_scp_tutorial.ipynb +++ b/examples/vmat_scp_tutorial.ipynb @@ -7,7 +7,7 @@ "source": [ "#