diff --git a/MANIFEST.in b/MANIFEST.in index 7da24ba5bf..2f0746981b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,7 @@ global-include *.mac global-include *.md global-include *.bs +global-include *.sh recursive-include opengate/contrib * recursive-include opengate/tests/src/gate/gate_test* * recursive-include opengate/tests/output_ref * diff --git a/opengate/tests/src/advanced_tests/linacs/Dockerfile_opengate_vip b/opengate/tests/src/advanced_tests/linacs/Dockerfile_opengate_vip new file mode 100644 index 0000000000..9e93df168d --- /dev/null +++ b/opengate/tests/src/advanced_tests/linacs/Dockerfile_opengate_vip @@ -0,0 +1,27 @@ + +#Docker for opengate_core +#systemctl start docker +#login: docker login +#build: docker build -t tbaudier/opengate_castor_ci -f Dockerfile_opengate_vip. +#push: docker push tbaudier/opengate_vip +#run: docker run --rm -v $(Pipeline.Workspace):/home tbaudier/opengate_vip /home/.github/workflows/vip/run_linac_test.sh +#interactive: docker run -ti --rm -v $PWD:/home quay.io/pypa/manylinux_2_34_x86_64 /bin/bash + +FROM quay.io/pypa/manylinux_2_34_x86_64 +MAINTAINER Thomas Baudier +#Install packages +RUN yum install -y wget \ + && /opt/python/cp312-cp312/bin/pip install opengate \ + && export PATH=/opt/python/cp312-cp312/bin:$PATH \ + && opengate_info \ + && cd /opt/python/cp312-cp312/lib/python3.12/site-packages/opengate/tests/src/advanced_tests/linacs/ \ + && wget http://www.creatis.insa-lyon.fr/~baudier/data_advanced_test_linac.zip \ + && unzip data_advanced_test_linac.zip \ + && rm -f data_advanced_test_linac.zip \ + && mkdir output \ + && chmod a+rwX -R /opt/python/cp312-cp312/lib/python3.12/site-packages/opengate \ + && /opt/python/cp312-cp312/bin/pip install "pymedphys[tests]==0.41.0" + +# docker commit +# docker tag tbaudier/opengate_vip:0.1.1 +# docker run --rm tbaudier/opengate_vip:0.1.1 /opt/python/cp312-cp312/lib/python3.12/site-packages/opengate/tests/src/advanced_tests/linacs/run_linac_test.sh diff --git a/opengate/tests/src/advanced_tests/linacs/README b/opengate/tests/src/advanced_tests/linacs/README index 426943a2a7..a563569251 100644 --- a/opengate/tests/src/advanced_tests/linacs/README +++ b/opengate/tests/src/advanced_tests/linacs/README @@ -1,4 +1,7 @@ +#Test for a linac +#We use that test on VIP + wget http://www.creatis.insa-lyon.fr/~baudier/data_advanced_test_linac.zip unzip data_advanced_test_linac.zip rm -f data_advanced_test_linac.zip @@ -6,6 +9,6 @@ mkdir output python run_vmat_mc.py --json_name data_advanced_test_linac/header.json python normalize_dose.py --path data_advanced_test_linac -python comparison_deposited_dose_mc_tps.py --path data_advanced_test_linac data_advanced_test_linac --path_output output +python comparison_deposited_dose_mc_tps.py --path data_advanced_test_linac --path_output output -For the moment the test in comparison_deposited_dose_MC_TPS is a gamma index of 2%/2mm with 0.6 (60%) of passing rate between the gate dose and the TPS. Maybe chage the RAM for VIP +#For the moment the test in comparison_deposited_dose_MC_TPS is a gamma index of 2%/2mm with 0.7 (70%) of passing rate between the gate dose and the TPS. Maybe chage the RAM for VIP diff --git a/opengate/tests/src/advanced_tests/linacs/comparison_deposited_dose_mc_tps.py b/opengate/tests/src/advanced_tests/linacs/comparison_deposited_dose_mc_tps.py index 98b1c30be6..806a5373a1 100755 --- a/opengate/tests/src/advanced_tests/linacs/comparison_deposited_dose_mc_tps.py +++ b/opengate/tests/src/advanced_tests/linacs/comparison_deposited_dose_mc_tps.py @@ -3,6 +3,7 @@ import os from pathlib import Path + import click import itk import matplotlib.colors as mcolors @@ -192,7 +193,8 @@ def gamma_index_comparison(path, path_output): "max_gamma": 1.5, "random_subset": None, "local_gamma": True, - "ram_available": 40 * 2**29, # 40 * 1/2 GB + "ram_available": 7 * 2**30, # < 8 GB + "interp_algo": "scipy", } gamma = pymedphys.gamma( @@ -204,6 +206,7 @@ def gamma_index_comparison(path, path_output): ) valid_gamma = gamma[~np.isnan(gamma)] pass_ratio = np.sum(valid_gamma <= 1) / len(valid_gamma) + print("pass ration: " + str(pass_ratio)) height = 20 width = height / 2 @@ -257,7 +260,7 @@ def gamma_index_comparison(path, path_output): ax1[1].set(ylabel="Y position [mm]", xlabel="X position [mm]") ax1[0].axes.get_xaxis().set_visible(False) fig1.savefig(f"{path_output}/MC_vs_TPS_dose.pdf") - is_ok = pass_ratio > 0.6 + is_ok = pass_ratio > 0.70 utility.test_ok(is_ok) diff --git a/opengate/tests/src/advanced_tests/linacs/run_linac_test.sh b/opengate/tests/src/advanced_tests/linacs/run_linac_test.sh new file mode 100755 index 0000000000..3ac5847c3d --- /dev/null +++ b/opengate/tests/src/advanced_tests/linacs/run_linac_test.sh @@ -0,0 +1,7 @@ + +#!/bin/bash +cd /opt/python/cp312-cp312/lib/python3.12/site-packages/opengate/tests/src/advanced_tests/linacs/ +export PATH=/opt/python/cp312-cp312/bin:$PATH +python run_vmat_mc.py --json_name data_advanced_test_linac/header.json +python normalize_dose.py --path data_advanced_test_linac +python comparison_deposited_dose_mc_tps.py --path data_advanced_test_linac --path_output output > output/output.log 2>&1 diff --git a/opengate/tests/src/advanced_tests/linacs/vmat_mc_helpers.py b/opengate/tests/src/advanced_tests/linacs/vmat_mc_helpers.py index 8f572d91ef..35a015fb5e 100644 --- a/opengate/tests/src/advanced_tests/linacs/vmat_mc_helpers.py +++ b/opengate/tests/src/advanced_tests/linacs/vmat_mc_helpers.py @@ -1,9 +1,11 @@ +import itk +import numpy as np + import opengate as gate -from opengate.tests import utility -from opengate.contrib.linacs import elektaversa as versa +from opengate import utility as ut from opengate.contrib.linacs import dicomrtplan as rtplan -import numpy as np -import itk +from opengate.contrib.linacs import elektaversa as versa +from opengate.tests import utility def information_img_patient(path_img=None, open_img=True, img=None): @@ -90,8 +92,8 @@ def add_patient_image( patient.image = path_image + img patient.mother = name patient.material = "G4_AIR" # material used by default - f1 = paths.data / "Schneider2000MaterialsTable.txt" - f2 = paths.data / "Schneider2000DensitiesTable.txt" + f1 = ut.get_data_folder() / "Schneider2000MaterialsTable.txt" + f2 = ut.get_data_folder() / "Schneider2000DensitiesTable.txt" tol = 0.05 * gcm3 patient.voxel_materials, materials = ( gate.geometry.materials.HounsfieldUnit_to_material(sim, tol, f1, f2)