Commit ce117592 authored by Dominique Piche's avatar Dominique Piche

add Util doc

parent d1fc1593
......@@ -3,8 +3,6 @@ import pytg43
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
# TODO : doc
def get_spherical_coordinates(x, y, z):
r = np.sqrt((x**2 + y**2 + z**2))
theta = np.arccos(z/r) * 180 / np.pi
......
......@@ -75,11 +75,11 @@ Moves the robot to its initial position (every joint at 0°)
**MecaRobot.start_tracking**()
Writes the tool reference frame position in the *tracking_data.txt* file every time the robot stops moving during a linear, square of cube sequence.
Writes the tool reference frame position in the *Data/tracking_data.txt* file every time the robot stops moving during a linear, square of cube sequence.
**MecaRobot.stop_tracking**()
Stops tracking the tool reference frame position and closes *tracking_data.txt* file.
Stops tracking the tool reference frame position and closes *Data/tracking_data.txt* file.
**MecaRobot.get_TRF_pose**()
......@@ -93,7 +93,7 @@ Returns:
**MecaRobot.linear_sequence**(*direction_vector, total_distance, step, delay=0, do_clear_buffer=True*)
Moves the tool reference frame linearly along an axis by steps. For instance, using linear_sequence(np.array([1,0,0]), 50, 1) will move the robot along the x-axis for 50 mm with 1 mm steps. If the user is tracking, there will be 50 new entries in the *tracking_data.txt* file (after every step). In its default position, the robot is in a singularity, which means it has to move elsewhere using the MovePose or MoveJoints command prior to a linear sequence.
Moves the tool reference frame linearly along an axis by steps. For instance, using linear_sequence(np.array([1,0,0]), 50, 1) will move the robot along the x-axis for 50 mm with 1 mm steps. If the user is tracking, there will be 50 new entries in the *Data/tracking_data.txt* file (after every step). In its default position, the robot is in a singularity, which means it has to move elsewhere using the MovePose or MoveJoints command prior to a linear sequence.
The program waits for an end of movement response from the robot before tracking the data. The buffer is cleared to ensure the EOM responses are not from earlier movements. This step can be skipped to save about 2 seconds by setting do_clear_buffer to False if the user is certain the buffer is empty.
......@@ -201,7 +201,7 @@ Parameters:
Clears the socket buffer if the robot is in tracking mode and do_clear_buffer is True.
### MecaRobotForDosimetry
This class inherits from the MecaRobot class and adapts it for scintillation dosimetry. It keeps track of each scintillators' position in relation to the source. The lowest scintillator is set as the tool reference frame (TRF), which means that the movement commands will send the lowest scintillator to the specified position. For each scintillator, two files will be created : one containing the scintillator's position relative to the source (scintillator_x_position_relative_to_source.txt) and one containing the scintillator's absolute distance to the source (scintillator_x_distance_to_source.txt). A file containing the time (time.txt) will be created as well.
This class inherits from the MecaRobot class and adapts it for scintillation dosimetry. It keeps track of each scintillators' position in relation to the source. The lowest scintillator is set as the tool reference frame (TRF), which means that the movement commands will send the lowest scintillator to the specified position. For each scintillator, two files will be created : one containing the scintillator's position relative to the source (*Data/scintillator_x_position_relative_to_source.txt*) and one containing the scintillator's absolute distance to the source (*Data/scintillator_x_distance_to_source.txt*). A file containing the time (*Data/time.txt*) will be created as well.
**MecaRobotForDosimetry**(*ip="192.168.0.100", port=10000, simulation_mode=False, enable_log=False, scintillators_positions=np.array([[0,0,0]]), source_position=np.array([0,0,0])*)
......@@ -282,10 +282,35 @@ Parameters:
Clears the socket buffer if the robot is in tracking mode and do_clear_buffer is True.
### Util
This file contains some useful functions which relate to the data acquired with the robot.
**export_tg_43_dose_rate**(*show_figure=False, seed_name='Flexisource'*)
Reads the scintillators' positions in the *Data* folder and writes in a file (*Data/scintillator_x_tg43_dose_rate.txt*) the dose rates corresponding to every dwell position of every scintillator calculated using the TG-43 formalism (pytg43 module).
Parameters:
- **show_figure : *bool***
Plots the dose rate for each scintillator.
- **seed_name : *str***
Brachytherapy seed used for the measurements. Implemented seeds are `'Flexisource'`, `'MBDCA'`, `'MicroSelectronV2'` or `'SelectSeed'`.
**export_trajectory_graph**(*show_figure=False*)
Reads the scintillators' positions in the *Data* folder and exports an image (*Data/trajectory_scint_x.png*) of the robot trajectory graph.
Parameters:
- **show_figure : *bool***
Shows the plots of each scintillator's trajectory.
**export_list_of_commands**()
Reads the *log.txt* file and writes in a file *Data/list_of_movement_commands.txt* every movement command that was sent to the robot. These can then be copy and pasted into the web interface to recreate an old sequence for which the *log.txt* file was saved.
<!--stackedit_data:
eyJoaXN0b3J5IjpbMjA3OTM1MzUxLDE3MDc3MjM1MjMsLTIwNj
Y4MTcwLC0yMTMzMDc2OTk3LDE2OTgzOTU4NzMsMTM4ODQxMjc4
MCwxMDM5MTQ3MTAzLC0yMDM0ODAxNTE5LC0xNjY5MjA3MjYyLD
IxMDI0ODQ2OTUsLTExMDQ5MTYwNjFdfQ==
-->
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment