Scattering Module
Direction
Bases: Enum
Source code in pytissueoptics/rayscattering/display/utils/direction.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |
axis
property
Returns an integer between 0 and 2 representing the x, y, or z axis, ignoring direction sign.
EnergyLogger
Bases: Logger
Source code in pytissueoptics/rayscattering/energyLogging/energyLogger.py
22 23 24 25 26 27 28 29 30 31 32 33 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 76 77 78 79 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 129 130 131 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 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 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 | |
nDataPoints
property
Overwrites the Logger method to return the total number of data points logged, including the ones discarded.
__init__(scene, filepath=None, keep3D=True, views=ViewGroup.ALL, defaultViewEnergyType=EnergyType.DEPOSITION, defaultBinSize=0.01, infiniteLimits=((-5, 5), (-5, 5), (-5, 5)))
Log the energy deposited by scattering photons as well as the energy that crossed surfaces. Every interaction
is linked to a specific solid and surface of the scene when applicable. This EnergyLogger has to be given to
a Source instance when propagating.
:param scene: The scene is required to auto-initialize the 2D views correctly. Even if keep3D is True, the
scene may be used later to correctly create and display the 2D views.
:param filepath: (Optional) Load the logger from the given file. When saving, the file will be overwritten.
:param keep3D: (Default to True) If False, logged datapoints are automatically binned to predefined 2D views
and the 3D data is discarded. This allows for a lightweight logger alternative. If True, the 3D data is
kept and the 2D views are only computed later if displayed.
:param views: The 2D views to track, particularly used when keep3D is set to False. Can be a ViewGroup flag
or a list of View2D. Default to ViewGroup.ALL which includes the 3 default XYZ projections for the
whole scene as well as for each solid, and a projection of each surface in the direction of the surface
normal for both the energy entering and leaving the surface. When keep3D is False, ViewGroup.All is
required to allow calculation of the detailed report for absorbance and transmittance. When keep3D is
True, the 2D views data is only computed when displayed, so it is equivalent to setting views to None.
:param defaultBinSize: The default bin size to use when binning the 3D data to 2D views. In the same physical
units as the scene. Custom bin sizes can be specified in each View2D.
:param infiniteLimits: The default limits to use for the 2D views when the scene is infinite (has no solids).
Source code in pytissueoptics/rayscattering/energyLogging/energyLogger.py
25 26 27 28 29 30 31 32 33 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 | |
export(exportName)
Export the raw 3D data points to a CSV file, along with the scene information to a JSON file.
The data file
Two types of interactions are logged: scattering and surface crossings. In the first case, the energy will be the delta energy deposited at the point and the surface index will be -1. In the second case, the energy will be the total photon energy when crossing the surface, either as positive if leaving the surface (along the normal) or as negative if entering the surface.
The scene information will be saved in a JSON file named
Source code in pytissueoptics/rayscattering/energyLogging/energyLogger.py
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | |
filter(detectedBy)
Keeps only the data points from photons detected by one of the specified detector(s).
Source code in pytissueoptics/rayscattering/energyLogging/energyLogger.py
322 323 324 325 326 327 328 329 330 | |
getDataPoints(key, energyType=EnergyType.DEPOSITION)
All 3D data points recorded for this InteractionKey (not binned). Array of shape (n, 4) where the second axis is (value, x, y, z). The value can be the energy deposited, the fluence rate, or the energy that crossed the surface.
:param key: Filtering the data by solidLabel and surfaceLabel. :param energyType: The type of volumetric energy to return when no surfaceLabel is given.
:return: The data points (value, x, y, z) for the given solidLabel and surfaceLabel. If a surfaceLabel is given, the value corresponds to the energy that crossed the surface (positive when in the direction of the normal). If only a solidLabel is given, the value corresponds to the volumetric EnergyType at that point.
Source code in pytissueoptics/rayscattering/energyLogging/energyLogger.py
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | |
getFiltered(detectedBy)
Returns a new logger with only data from photons detected by one of the specified detector(s).
Source code in pytissueoptics/rayscattering/energyLogging/energyLogger.py
332 333 334 335 336 337 338 339 | |
logDataPointArray(array, key)
Used internally by Source when propagating photons. Overwrites the Logger method to automatically bin the
data to 2D views if 3D data is being discarded.
Source code in pytissueoptics/rayscattering/energyLogging/energyLogger.py
226 227 228 229 230 231 232 233 234 235 236 | |
EnergyType
Bases: Enum
Type of volumetric energy: either as the deposited energy in the solid (absorption) or as the fluence rate.
Source code in pytissueoptics/rayscattering/energyLogging/energyType.py
4 5 6 7 8 9 10 | |
PointCloudStyle
3D display configuration for solid and surface point clouds.
Visibility attributes
solidLabel (Optional[str]): Only show the point cloud specific to a single solid. surfaceLabel (Optional[str]): Only show the point cloud specific to a single surface of the solid. showSolidPoints (bool): Show the point clouds of the solids. showSurfacePointsLeaving (bool): Show energy that left the surface (direction with surface normal). showSurfacePointsEntering (bool): Show energy that entered the surface (direction opposite to surface normal). energyType (EnergyType): Type of energy to show for volumetric datapoints (deposition or fluence).
Other attributes
showPointsAsSpheres (bool): Show the points as spheres or as dots. Dots require less memory.
pointSize (float): Reference diameter of the points in the point cloud when drawn as spheres.
scaleWithValue (bool): Scale the points with their value. A value of 1 yields the pointSize.
colormap (str): The name of the colormap to use for the point cloud.
reverseColormap (bool): Reverse the colormap.
surfacePointSize (float): Same as pointSize, but for the surface points.
surfaceScaleWithValue (bool): Same as scaleWithValue but for the surface points.
surfaceColormap (str): Same as colormap but for the surface points.
surfaceReverseColormap (bool): Same as reverseColormap but for the surface points.
Source code in pytissueoptics/rayscattering/display/viewer.py
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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
ScatteringScene
Bases: Scene
Source code in pytissueoptics/rayscattering/scatteringScene.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
getEstimatedIPP(weightThreshold)
Get the estimated number of interactions per photon. This gross estimation is done by assuming an infinite medium of mean scene albedo. Used as a starting point for the OpenCL kernel optimization.
Source code in pytissueoptics/rayscattering/scatteringScene.py
34 35 36 37 38 39 40 41 42 | |
Stats
Source code in pytissueoptics/rayscattering/statistics/statistics.py
27 28 29 30 31 32 33 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 76 77 78 79 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 129 130 131 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 | |
getTransmittance(solidLabel, surfaceLabel=None, useTotalEnergy=False)
Uses local energy input for the desired solid by default. Specify 'useTotalEnergy' = True to compare instead with total input energy of the scene.
Source code in pytissueoptics/rayscattering/statistics/statistics.py
204 205 206 207 208 209 210 211 212 213 214 215 216 | |
ViewGroup
Bases: Flag
A ViewGroup is a bit Flag representing a group of 2D views. They can be combined with the | operator (bitwise OR).
It has two different usages
- Specify which default views to create when initializing an EnergyLogger, particularly when
keep3Dis False. - Specify which views to show during visualization.
In the first use case, the default views created are three 2D projections of the whole scene (SCENE) or of each solid (SOLIDS) in every XYZ direction.
Except for surface groups, where the default views created include a single 2D projection in the direction of the surface normal.
SURFACES_ENTERING specifies the energy that entered the surface (energy direction opposite to the surface normal).
Source code in pytissueoptics/rayscattering/display/views/view2D.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
Visibility
Bases: Flag
A Visibility is a bit Flag representing what to show inside a 3D visualization. They can be combined with the |
operator (bitwise OR). AUTO will automatically switch to DEFAULT_3D if 3D data is present, else DEFAULT_2D.
Source code in pytissueoptics/rayscattering/display/viewer.py
22 23 24 25 26 27 28 29 30 31 32 33 34 | |