Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -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 *
Expand Down
27 changes: 27 additions & 0 deletions opengate/tests/src/advanced_tests/linacs/Dockerfile_opengate_vip
Original file line number Diff line number Diff line change
@@ -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 <thomas.baudier@creatis.insa-lyon.fr>
#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 <container_name>
# docker tag <image_id> 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
7 changes: 5 additions & 2 deletions opengate/tests/src/advanced_tests/linacs/README
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@

#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
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import os
from pathlib import Path

import click
import itk
import matplotlib.colors as mcolors
Expand Down Expand Up @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -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)


Expand Down
7 changes: 7 additions & 0 deletions opengate/tests/src/advanced_tests/linacs/run_linac_test.sh
Original file line number Diff line number Diff line change
@@ -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
14 changes: 8 additions & 6 deletions opengate/tests/src/advanced_tests/linacs/vmat_mc_helpers.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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)
Expand Down
Loading