Utilities & Helpers
Internal helpers, constants, and the Spekpy wrapper for spectra generation.
Spectra Generation
flexpose.spectra_gen
MissingDependencyError
Bases: ImportError
Raised when an optional dependency is required for a feature
Source code in flexpose/spectra_gen.py
20 21 22 | |
SpectrumGenerator
Source code in flexpose/spectra_gen.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
loop_spectra()
Loop through the specified kV range and generate spectra for each kV
Source code in flexpose/spectra_gen.py
67 68 69 70 71 72 73 74 75 | |
make_spectrum(kv)
Generate the X-ray spectrum for a given kilovoltage (kV)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kv
|
int
|
Kilovoltage for which to generate the spectrum |
required |
Source code in flexpose/spectra_gen.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
Auxiliary Functions
flexpose.auxfuncs
Calibration
Class to perform the calibration of hist to mAs
Source code in flexpose/auxfuncs.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
calc_hist_mas(kv, rng)
Function to calculate the conversion factor of hist to mAs for a given kV Args: kv (int): Tube potential (kV). rng (np.random.Generator): Random number generator. Returns: tuple: (hist to mAs conversion factor, its uncertainty)
Source code in flexpose/auxfuncs.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | |
calc_hist_mas_mp()
Wrapper to parallelize the reference kerma calculations
Source code in flexpose/auxfuncs.py
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
from_dap_to_kerma(dap_values)
This function converts DAP to Air kerma
Source code in flexpose/auxfuncs.py
175 176 177 178 179 180 181 182 183 184 185 186 | |
get_measured_kerma(kv)
This function gets the air kerma from measured values
Source code in flexpose/auxfuncs.py
202 203 204 205 206 207 208 | |
integrate_quantity(quantity, kv, cutoff_energy)
Integrate the DAP over the x-ray spectrum using 1:1 linear interpolation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
quantity
|
ndarray
|
The DAP values corresponding to the energies in the dose table. |
required |
kv
|
int
|
The tube potential (kV) for which to retrieve the x-ray spectrum. |
required |
cutoff_energy
|
float
|
The minimum energy (in eV) to consider in the integration. |
required |
Returns: float: The integrated DAP value.
Source code in flexpose/auxfuncs.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
make_calibration()
Main function to perform the calibrations
Source code in flexpose/auxfuncs.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
quantity_and_sample(rng)
Function to retrieve the DAP values from the dose tables
Source code in flexpose/auxfuncs.py
143 144 145 146 147 148 149 150 151 152 153 154 155 | |
read_spekpy_kerma(kv)
This function reads the nominal air Kerma from Spekpy per mAs at 100 cm
Source code in flexpose/auxfuncs.py
188 189 190 191 192 193 194 195 196 197 198 199 | |
Logger
This class handles the logs that can be called for each class
Source code in flexpose/auxfuncs.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
close_log()
This function closes the current log :return: nothing
Source code in flexpose/auxfuncs.py
113 114 115 116 117 118 119 120 121 | |
info(text)
This function writes a string to a log :return: nothing
Source code in flexpose/auxfuncs.py
123 124 125 126 127 128 | |
init_log()
This function initializes the logger :return: logger object
Source code in flexpose/auxfuncs.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
cut_mtf_zero(freq, mtf)
This function cuts MTF when it reaches 0 to avoid going above the nyquist frequency
Source code in flexpose/auxfuncs.py
68 69 70 71 72 73 74 75 76 77 | |
get_spec_prob(specdata, kv, cutoff_energy=0.0)
Auxiliary function to read the spectrum file based on kv
Source code in flexpose/auxfuncs.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | |
load_json(path)
Auxiliary function to read a json file and return as dictionary
Source code in flexpose/auxfuncs.py
31 32 33 34 35 36 37 38 | |
make_rng(seed)
Function to return a rng based on an input seed
Source code in flexpose/auxfuncs.py
55 56 57 58 59 60 61 62 63 64 65 | |
measure_time(function)
Decorator to measure execution time
Source code in flexpose/auxfuncs.py
42 43 44 45 46 47 48 49 50 51 52 | |
spectral_set_from_json(path, keymap=None, dtype=np.float64)
Reads a JSON file and constructs a SpectralSet.
Source code in flexpose/auxfuncs.py
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 | |