API#
GUI_tool module#
- relative_dose_1d.GUI_tool.plot(D_ref, D_eval)#
A function to show a graphical user interface (GUI) to showing 1D dose profiles, gamma analysis and dose difference. Data has to be in 2 columns, corresponding to positions and dose values, respectively.
- Parameters:
D_ref (ndarray,) – Reference dose profile represented by a (M, 2) numpy array.
D_eva (ndarray,) – Dose profile to be evaluated, represented by a (N, 2) numpy array.
- Return type:
A GUI showing dose profiles, gamma analysis and dose difference.
Examples
>>> from relative_dose_1d.GUI_tool import plot >>> from relative_dose_1d.tools import build_from_array_and_step >>> import numpy as np
>>> a = np.array([0,1,2,3,4,5,6,7,8,9,10]) >>> b = a + np.random.random_sample((11,))
>>> A = build_from_array_and_step(a, 1) >>> B = build_from_array_and_step(b, 1)
>>> w = plot(A,B)
Tools module#
- relative_dose_1d.tools.text_to_list(file_name)#
Convert a text file to a python list. Each element of the list represents a line from the text file.
- Parameters:
file_name (string) – Text file name
- Returns:
Loaded data as a list.
- Return type:
list
- relative_dose_1d.tools.identify_format(data_list)#
Identify text format.
- Parameters:
data_list (list) – Each element of the list represents a line from the text file.
- Returns:
‘varian’ for w2CAD format, identified by the ‘$’ character at the beginning of the file.
’ptw’ for mcc fromat, identified by the word ‘BEGIN_SCAN_DATA’.
’just_numbers’ for data without headers.
’text_file’ for other formats.
- Return type:
string
- relative_dose_1d.tools.get_data(file_name, start_word=None, end_word=None, delta=None)#
Get and normalize data from a text-file (file that is structured as a sequence of lines). Since w2CAD and mcc formats are automatically detected, it is not necessary to specify start/end words in such cases.
- Parameters:
file_name (string) – Name of the file
start_word (string) – Word to identify the beginning of the data
end_word (string) – Word to identify the end of the data
delta (float) – Displacement in mm to define the started point
- Returns:
Data as a Numpy object
- Return type:
ndarray
- relative_dose_1d.tools.build_from_array_and_step(array, step)#
Create a new array with the same length but with an additional axis. The first column represents the physical positions of the given values. The second column is a normalization of the given array. The positions are builded with evenly step spacing starting from zero.
- Parameters:
array (ndarrya,) – Numpy 1D array with the profile values
step (float,) – The spacing between samples
- Returns:
A new array with shape (M,2), where M is the shape of the array.
- Return type:
array, ndarray
Examples
>>> y = np.array([2,4,6,8,10]) >>> A = build_from_array_and_step(y, 0.5) [ [0.0, 2] [0.5, 4] [1.0, 6] [1.5, 8] [2.0, 10]]
>>> y = np.arange(6) >>> B = build_from_array_and_step(y, 3) [ [0, 0] [3, 1] [6, 2] [9, 3] [12, 4]]
- relative_dose_1d.tools.gamma_1D(ref, eval, dose_t=3, dist_t=2, dose_threshold=0, interpol=1)#
1-dimensional gamma index calculation. Dose profiles have to be normalized (0-100%).
- Parameters:
ref (ndarray,) – Reference dose profile represented by a (M, 2) numpy array.
eva (ndarray,) – Dose profile to be evaluated, represented by a (N, 2) numpy array.
dose_t (float, default = 3) – Dose tolerance [%].
dist_t (float, default = 2) – Distance to agreement [mm].
dose_threshold (float, default = 0) – Dose threshold [%]. Any point in the distribution with a dose value less than the threshold is going to be excluded from the analysis.
interpol (float, default = 1) – Number of interpolated points to generate between each two consecutive points in “eval” data.
- Returns:
gamma distribution, gamma percent and number of evaluated points
- Return type:
ndarray, float