3.10.1.21.1.3. opengate.tests.utility

3.10.1.21.1.3.1. Functions

test_ok([is_ok])

read_stat_file(filename)

print_test(b, s)

assert_stats(stat1, stat2[, tolerance, is_ok])

plot_img_axis(ax, img, label[, axis])

plot_img_z(ax, img, label)

plot_img_y(ax, img, label)

plot_img_x(ax, img, label)

assert_images_properties(info1, info2)

assert_images(ref_filename1, filename2[, stats, ...])

plot_hist(ax, data, label[, bins])

plot_profile(ax, y[, y_spacing, label])

assert_filtered_imagesprofile1D(ref_filter_filename1, ...)

exponential_func(x, a, b)

fit_exponential_decay(data, start, end)

get_new_key_name(key)

get_keys_correspondence(keys)

rel_diff(a, b)

rel_diff_range(a, b)

get_branch(tree, keys, key)

Return a branch whether it is a numpy or a uproot tree

compare_branches(tree1, keys1, tree2, keys2, key1, key2)

Compare with Wasserstein distance

compare_branches_values(b1, b2, key1, key2[, tol, ax, ...])

Compare with Wasserstein distance

compare_trees(tree1, allkeys1, tree2, allkeys2, keys1, ...)

get_default_test_paths(f[, gate_folder, output_folder])

compare_root2(root1, root2, branch1, branch2, keys, ...)

compare_root(root1, root2, branch1, branch2, ...)

compare_root3(root1, root2, branch1, branch2, keys1, ...)

open_root_as_np(root_file, tree_name)

dict_compare(d1, d2)

write_gauss_param_to_file(output_file_pathV, ...[, ...])

get_gauss_param_xy(data, spacing, shape[, filepath, ...])

extract_gauss_param_1D(data, length, spacing[, axis, ...])

plot_gauss_fit(positionVec, dose, fit[, show])

create_position_vector(length, spacing[, centered])

gauss_func(x, A, x0, sigma)

gaussian_fit(positionVec, dose)

read_mhd(filename)

plot2D(twodarray, label[, show])

create_2D_Edep_colorMap(filepath[, show, axis])

compareGaussParamFromFile(sigma, ref[, rel_tol, ...])

compareGaussParamArrays(paramTestV, paramRefV[, ...])

test_weights(expected_ratio, mhd_1, mhd_2[, thresh])

test_tps_spot_size_positions(data, ref, spacing[, ...])

scale_dose(path, scaling[, outpath])

check_dose_grid_geometry(dose_mhd_path, dose_actor)

arangeDx(dx, xV[, includeUB, lb, ub])

interpolate1Dprofile(xV, dV[, dx, interpolMethod])

getRange(xV, dV[, percentLevel])

get_range_from_image(volume, shape, spacing[, axis])

compareRange(volume1, volume2, shape1, shape2, ...[, ...])

get_1D_profile(data, shape, spacing[, axis])

compare_dose_at_points(pointsV, dose1, dose2, shape1, ...)

assert_img_sum(img1, img2[, sum_tolerance])

assert_images_ratio(expected_ratio, mhd_1, mhd_2[, ...])

assert_images_ratio_per_voxel(expected_ratio, mhd_1, mhd_2)

check_diff(value1, value2, tolerance, txt)

check_diff_abs(value1, value2, tolerance, txt)

root_compare_param_tree(filename, tree_name, keys)

root_compare_param(keys, fig)

root_compare4(p1, p2, param)

Compare two root trees.

compare_trees4(p1, p2, param)

get_gpu_mode_for_tests()

return "auto" except if the test runs with macos and github actions

np_img_window_level(img, window_width, window_level)

Clip and rescale the grey level values of the image according to window width/level.

np_img_crop(img, crop_center, crop_width)

np_plot_slice(ax, img, num_slice, window_width, ...[, ...])

np_plot_slice_h_line(ax, hline, crop_center, crop_width)

np_plot_slice_v_line(ax, vline, crop_center, crop_width)

add_colorbar(imshow, window_level, window_width)

np_plot_integrated_profile(ax, img, axis, num_slice, ...)

np_plot_profile_X(ax, img, hline, num_slice, ...)

np_plot_profile_Y(ax, img, vline, num_slice, ...)

np_get_circle_mean_value(img, center, radius)

add_circle(ax, img, crop_center, crop_width, center, ...)

add_border(ax, border_color, border_width)

plot_compare_profile(ref_names, test_names, options)

3.10.1.21.1.3.2. Module Contents

opengate.tests.utility.test_ok(is_ok=False)[source]
opengate.tests.utility.read_stat_file(filename)[source]
opengate.tests.utility.print_test(b, s)[source]
opengate.tests.utility.assert_stats(stat1, stat2, tolerance=0, is_ok=True)[source]
opengate.tests.utility.plot_img_axis(ax, img, label, axis='z')[source]
opengate.tests.utility.plot_img_z(ax, img, label)[source]
opengate.tests.utility.plot_img_y(ax, img, label)[source]
opengate.tests.utility.plot_img_x(ax, img, label)[source]
opengate.tests.utility.assert_images_properties(info1, info2)[source]
opengate.tests.utility.assert_images(ref_filename1, filename2, stats=None, tolerance=0, ignore_value=0, axis='z', fig_name=None, sum_tolerance=5, scaleImageValuesFactor=None)[source]
opengate.tests.utility.plot_hist(ax, data, label, bins=100)[source]
opengate.tests.utility.plot_profile(ax, y, y_spacing=1, label='')[source]
opengate.tests.utility.assert_filtered_imagesprofile1D(ref_filter_filename1, ref_filename1, filename2, stats=None, tolerance=0, ignore_value=0, fig_name=None, sum_tolerance=5, plt_ylim=None)[source]
opengate.tests.utility.exponential_func(x, a, b)[source]
opengate.tests.utility.fit_exponential_decay(data, start, end)[source]
opengate.tests.utility.get_new_key_name(key)[source]
opengate.tests.utility.get_keys_correspondence(keys)[source]
opengate.tests.utility.rel_diff(a, b)[source]
opengate.tests.utility.rel_diff_range(a, b)[source]
opengate.tests.utility.get_branch(tree, keys, key)[source]

Return a branch whether it is a numpy or a uproot tree

opengate.tests.utility.compare_branches(tree1, keys1, tree2, keys2, key1, key2, tol=0.8, scaling1=1, scaling2=1, ax=False, nb_bins=200)[source]

Compare with Wasserstein distance Works well, but not easy to set the tolerance value.

opengate.tests.utility.compare_branches_values(b1, b2, key1, key2, tol=0.8, ax=False, nb_bins=200)[source]

Compare with Wasserstein distance Works well, but not easy to set the tolerance value.

opengate.tests.utility.compare_trees(tree1, allkeys1, tree2, allkeys2, keys1, keys2, tols, scalings1, scalings2, fig=False, nb_bins=200)[source]
opengate.tests.utility.get_default_test_paths(f, gate_folder=None, output_folder=None)[source]
opengate.tests.utility.compare_root2(root1, root2, branch1, branch2, keys, img_filename, n_tol=3)[source]
opengate.tests.utility.compare_root(root1, root2, branch1, branch2, checked_keys, img)[source]
opengate.tests.utility.compare_root3(root1, root2, branch1, branch2, keys1, keys2, tols, scalings1, scalings2, img, hits_tol=6, nb_bins=200)[source]
opengate.tests.utility.open_root_as_np(root_file, tree_name)[source]
opengate.tests.utility.dict_compare(d1, d2)[source]
opengate.tests.utility.write_gauss_param_to_file(output_file_pathV, planePositionsV, saveFig=False)[source]
opengate.tests.utility.get_gauss_param_xy(data, spacing, shape, filepath=None, saveFig=False)[source]
opengate.tests.utility.extract_gauss_param_1D(data, length, spacing, axis=1, createFig=False)[source]
opengate.tests.utility.plot_gauss_fit(positionVec, dose, fit, show=False)[source]
opengate.tests.utility.create_position_vector(length, spacing, centered=True)[source]
opengate.tests.utility.gauss_func(x, A, x0, sigma)[source]
opengate.tests.utility.gaussian_fit(positionVec, dose)[source]
opengate.tests.utility.read_mhd(filename)[source]
opengate.tests.utility.plot2D(twodarray, label, show=False)[source]
opengate.tests.utility.create_2D_Edep_colorMap(filepath, show=False, axis='z')[source]
opengate.tests.utility.compareGaussParamFromFile(sigma, ref, rel_tol=0, abs_tol=0, verb=False)[source]
opengate.tests.utility.compareGaussParamArrays(paramTestV, paramRefV, rel_tol=0, abs_tol=0, verb=False)[source]
opengate.tests.utility.test_weights(expected_ratio, mhd_1, mhd_2, thresh=0.1)[source]
opengate.tests.utility.test_tps_spot_size_positions(data, ref, spacing, thresh=0.1, abs_tol=0.3)[source]
opengate.tests.utility.scale_dose(path, scaling, outpath='')[source]
opengate.tests.utility.check_dose_grid_geometry(dose_mhd_path, dose_actor)[source]
opengate.tests.utility.arangeDx(dx, xV, includeUB=False, lb=[], ub=[])[source]
opengate.tests.utility.interpolate1Dprofile(xV, dV, dx=0.01, interpolMethod='cubic')[source]
opengate.tests.utility.getRange(xV, dV, percentLevel=0.8)[source]
opengate.tests.utility.get_range_from_image(volume, shape, spacing, axis='y')[source]
opengate.tests.utility.compareRange(volume1, volume2, shape1, shape2, spacing1, spacing2, axis1='y', axis2='y', thresh=2.0)[source]
opengate.tests.utility.get_1D_profile(data, shape, spacing, axis='z')[source]
opengate.tests.utility.compare_dose_at_points(pointsV, dose1, dose2, shape1, shape2, spacing1, spacing2, axis1='z', axis2='z', rel_tol=0.03)[source]
opengate.tests.utility.assert_img_sum(img1, img2, sum_tolerance=5)[source]
opengate.tests.utility.assert_images_ratio(expected_ratio, mhd_1, mhd_2, abs_tolerance=0.1, fn_to_apply=None)[source]
opengate.tests.utility.assert_images_ratio_per_voxel(expected_ratio, mhd_1, mhd_2, abs_tolerance=0.1, mhd_is_path=True)[source]
opengate.tests.utility.check_diff(value1, value2, tolerance, txt)[source]
opengate.tests.utility.check_diff_abs(value1, value2, tolerance, txt)[source]
opengate.tests.utility.root_compare_param_tree(filename, tree_name, keys)[source]
opengate.tests.utility.root_compare_param(keys, fig)[source]
opengate.tests.utility.root_compare4(p1, p2, param)[source]

Compare two root trees.

p1 and p2 contain = the root filename, the tree name, a list of branch names (see root_compare_param_tree) Also, each branch can be scaled and clip to a min/max range.

param contains: the tolerance values (for all branches), the fig name, the nb of bins of the histograms, the tolerance for the nb of hits (see root_compare_param)

opengate.tests.utility.compare_trees4(p1, p2, param)[source]
opengate.tests.utility.get_gpu_mode_for_tests()[source]

return “auto” except if the test runs with macos and github actions On macos and github actions, mps is detected but not usable and lead to errors. So we choose “cpu” in such a case

opengate.tests.utility.np_img_window_level(img, window_width, window_level)[source]

Clip and rescale the grey level values of the image according to window width/level. Output image is within the range [0, 1]

3.10.1.21.1.3. Parameters

img an image as a numpy array window_width window_level

3.10.1.21.1.3. Returns the clipped and normalized image (range [0, 1])

opengate.tests.utility.np_img_crop(img, crop_center, crop_width)[source]
opengate.tests.utility.np_plot_slice(ax, img, num_slice, window_width, window_level, crop_center, crop_width, spacing=(1, 1))[source]
opengate.tests.utility.np_plot_slice_h_line(ax, hline, crop_center, crop_width)[source]
opengate.tests.utility.np_plot_slice_v_line(ax, vline, crop_center, crop_width)[source]
opengate.tests.utility.add_colorbar(imshow, window_level, window_width)[source]
opengate.tests.utility.np_plot_integrated_profile(ax, img, axis, num_slice, crop_center, crop_width, label, spacing)[source]
opengate.tests.utility.np_plot_profile_X(ax, img, hline, num_slice, crop_center, crop_width, label, width)[source]
opengate.tests.utility.np_plot_profile_Y(ax, img, vline, num_slice, crop_center, crop_width, label, width)[source]
opengate.tests.utility.np_get_circle_mean_value(img, center, radius)[source]
opengate.tests.utility.add_circle(ax, img, crop_center, crop_width, center, radius)[source]
opengate.tests.utility.add_border(ax, border_color, border_width)[source]
opengate.tests.utility.plot_compare_profile(ref_names, test_names, options)[source]