dosimetry:userguide:thinknode
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
dosimetry:userguide:thinknode [2015/09/25 12:07] – [thinknode_worker] dpatenaude | dosimetry:userguide:thinknode [2021/07/29 18:23] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 6: | Line 6: | ||
====== Python ====== | ====== Python ====== | ||
+ | Please refer to the [[https:// | ||
===== Python: Overview ===== | ===== Python: Overview ===== | ||
Line 152: | Line 153: | ||
# Get IAM ids | # Get IAM ids | ||
iam = thinknode.authenticate(thinknode.read_config(' | iam = thinknode.authenticate(thinknode.read_config(' | ||
- | |||
- | def make_grid(corner, | ||
- | ... | ||
- | |||
- | def make_water_phantom(corner, | ||
- | return \ | ||
- | thinknode.function(" | ||
- | [ | ||
- | make_grid(corner, | ||
- | thinknode.value(1), | ||
- | thinknode.value(" | ||
- | ]) | ||
def make_dose_points(pointCount): | def make_dose_points(pointCount): | ||
Line 213: | Line 202: | ||
thinknode.function(" | thinknode.function(" | ||
[ | [ | ||
- | | + | |
thinknode.value(make_dose_points(181)), | thinknode.value(make_dose_points(181)), | ||
beam_geometry, | beam_geometry, | ||
- | make_grid([-75, | + | |
make_layers(2270.0, | make_layers(2270.0, | ||
compute_aperture(), | compute_aperture(), | ||
Line 230: | Line 219: | ||
==== rt_types ==== | ==== rt_types ==== | ||
- | The // | + | The // |
Each data type detailed in the [[http:// | Each data type detailed in the [[http:// | ||
- | Below you will see as snippet from the rt_types module that shows the class for the //polyset// rt_type along with its default | + | Below you will see a snippet from the rt_types module that shows the class for the //polyset// rt_type along with its default |
<code python> | <code python> | ||
Line 283: | Line 272: | ||
</ | </ | ||
- | * **Interdependence: | + | * **Interdependence: |
- | * **// | + | * **// |
- | * **// | + | * **// |
- | Below is an example usage of getting a thinknode dose image (image_3d data type in the astroid manifest) and turning it into a rt_types image_3d data type, then using that data type to output the image as a VTK graphics file: | + | Below is an example usage of getting a thinknode dose image (image_3d data type in the astroid manifest) and turning it into a rt_types image_3d data type, so that it can be expanded and then used to output the image into a VTK graphics file: |
<code python> | <code python> | ||
Line 303: | Line 292: | ||
The // | The // | ||
- | Refer to the [[https:// | + | Refer to the [[https:// |
<code python> | <code python> | ||
Line 312: | Line 301: | ||
def authenticate(config): | def authenticate(config): | ||
- | # Send calculation request to thinknode and wait for the calculation to perform. Caches locally calculation results so if the same calculation is performed again, the calculation | + | # Send calculation request to thinknode and wait for the calculation to perform. Caches locally calculation results so if the same |
+ | # calculation is performed again, the calculation | ||
# does not have to be repeatedly pulled from thinknode. Saves one calculation time and bandwidth. | # does not have to be repeatedly pulled from thinknode. Saves one calculation time and bandwidth. | ||
# note: see post_calculation if you just want the calculation ID and don't need to wait for the calculation to finish or get results | # note: see post_calculation if you just want the calculation ID and don't need to wait for the calculation to finish or get results | ||
Line 337: | Line 327: | ||
+ | </ | ||
+ | |||
+ | ==== dosimetry_worker ==== | ||
+ | The dosimetry_worker module provides high-level functions for building data types and calculation requests for common dosimetry tasks. This library is constantly growing as more routine tasks are programmed in python. | ||
+ | |||
+ | Refer to the [[https:// | ||
+ | |||
+ | - Aperture creation (using structures/ | ||
+ | - Dose comparison | ||
+ | - Grid creation | ||
+ | - Image creation | ||
+ | - PBS Spot functions | ||
+ | |||
+ | |||
+ | ==== vtk_worker ==== | ||
+ | The VTK worker provides a means to write out common rt_types to a vtk file format ([[http:// | ||
+ | |||
+ | Below is an example of turning a dose image_3d into a vtk file for visualization in Paraview: | ||
+ | |||
+ | <code python> | ||
+ | def dose_to_vtk(dose_id): | ||
+ | img_data = json.loads(thinknode.get_immutable(iam, | ||
+ | |||
+ | img = rt_types.image_3d() | ||
+ | img.from_json(img_data) | ||
+ | img2 = img.expand_data() | ||
+ | |||
+ | vtk.write_vtk_image3(' | ||
</ | </ | ||
==== decimal_logging ==== | ==== decimal_logging ==== | ||
- | The // | + | The // |
The following settings are available in the decimal_logging.py file: | The following settings are available in the decimal_logging.py file: | ||
Line 347: | Line 365: | ||
**display_types: | **display_types: | ||
**log_file: ** sets the logfile name and location | **log_file: ** sets the logfile name and location | ||
+ | |||
+ | === Debugging === | ||
+ | |||
+ | When debugging, use the dl.debug() function and set the //isDebug// flag in the decimal_logging library to True. This toggles on the output for each of the dl.debug calls. By default we keep debugging off, but it can be turned on as needed. | ||
+ | |||
+ | === Other Flags === | ||
+ | |||
The following image shows the logging settings for each message type as: | The following image shows the logging settings for each message type as: | ||
Line 354: | Line 379: | ||
{{ dosimetry: | {{ dosimetry: | ||
+ | |||
+ | === File Logging === | ||
+ | |||
+ | The decimal_logging library also provides simple file logging. The // | ||
+ | |||
+ | * log(message) | ||
+ | * log_debug_data(message, | ||
+ | * log_data(data) | ||
+ | |||
---- | ---- | ||
<WRAP center 10%>// | <WRAP center 10%>// | ||
<WRAP center 40%> | <WRAP center 40%> |
dosimetry/userguide/thinknode.1443182874.txt.gz · Last modified: 2021/07/29 18:21 (external edit)