id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
700
poppy-project/pypot
pypot/kinematics.py
Link.get_transformation_matrix
def get_transformation_matrix(self, theta): """ Computes the homogeneous transformation matrix for this link. """ ct = numpy.cos(theta + self.theta) st = numpy.sin(theta + self.theta) ca = numpy.cos(self.alpha) sa = numpy.sin(self.alpha) return numpy.matrix(((ct, -st * c...
python
def get_transformation_matrix(self, theta): """ Computes the homogeneous transformation matrix for this link. """ ct = numpy.cos(theta + self.theta) st = numpy.sin(theta + self.theta) ca = numpy.cos(self.alpha) sa = numpy.sin(self.alpha) return numpy.matrix(((ct, -st * c...
[ "def", "get_transformation_matrix", "(", "self", ",", "theta", ")", ":", "ct", "=", "numpy", ".", "cos", "(", "theta", "+", "self", ".", "theta", ")", "st", "=", "numpy", ".", "sin", "(", "theta", "+", "self", ".", "theta", ")", "ca", "=", "numpy",...
Computes the homogeneous transformation matrix for this link.
[ "Computes", "the", "homogeneous", "transformation", "matrix", "for", "this", "link", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/kinematics.py#L27-L37
701
poppy-project/pypot
pypot/kinematics.py
Chain.forward_kinematics
def forward_kinematics(self, q): """ Computes the homogeneous transformation matrix of the end effector of the chain. :param vector q: vector of the joint angles (theta 1, theta 2, ..., theta n) """ q = numpy.array(q).flatten() if len(q) != len(self.links): raise V...
python
def forward_kinematics(self, q): """ Computes the homogeneous transformation matrix of the end effector of the chain. :param vector q: vector of the joint angles (theta 1, theta 2, ..., theta n) """ q = numpy.array(q).flatten() if len(q) != len(self.links): raise V...
[ "def", "forward_kinematics", "(", "self", ",", "q", ")", ":", "q", "=", "numpy", ".", "array", "(", "q", ")", ".", "flatten", "(", ")", "if", "len", "(", "q", ")", "!=", "len", "(", "self", ".", "links", ")", ":", "raise", "ValueError", "(", "'...
Computes the homogeneous transformation matrix of the end effector of the chain. :param vector q: vector of the joint angles (theta 1, theta 2, ..., theta n)
[ "Computes", "the", "homogeneous", "transformation", "matrix", "of", "the", "end", "effector", "of", "the", "chain", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/kinematics.py#L51-L73
702
poppy-project/pypot
pypot/kinematics.py
Chain.inverse_kinematics
def inverse_kinematics(self, end_effector_transformation, q=None, max_iter=1000, tolerance=0.05, mask=numpy.ones(6), use_pinv=False): """ Computes the joint angles corresponding to the end effector transf...
python
def inverse_kinematics(self, end_effector_transformation, q=None, max_iter=1000, tolerance=0.05, mask=numpy.ones(6), use_pinv=False): """ Computes the joint angles corresponding to the end effector transf...
[ "def", "inverse_kinematics", "(", "self", ",", "end_effector_transformation", ",", "q", "=", "None", ",", "max_iter", "=", "1000", ",", "tolerance", "=", "0.05", ",", "mask", "=", "numpy", ".", "ones", "(", "6", ")", ",", "use_pinv", "=", "False", ")", ...
Computes the joint angles corresponding to the end effector transformation. :param end_effector_transformation: the end effector homogeneous transformation matrix :param vector q: initial estimate of the joint angles :param int max_iter: maximum number of iteration :param float toleranc...
[ "Computes", "the", "joint", "angles", "corresponding", "to", "the", "end", "effector", "transformation", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/kinematics.py#L75-L122
703
poppy-project/pypot
pypot/dynamixel/__init__.py
_get_available_ports
def _get_available_ports(): """ Tries to find the available serial ports on your system. """ if platform.system() == 'Darwin': return glob.glob('/dev/tty.usb*') elif platform.system() == 'Linux': return glob.glob('/dev/ttyACM*') + glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyAMA*') e...
python
def _get_available_ports(): """ Tries to find the available serial ports on your system. """ if platform.system() == 'Darwin': return glob.glob('/dev/tty.usb*') elif platform.system() == 'Linux': return glob.glob('/dev/ttyACM*') + glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyAMA*') e...
[ "def", "_get_available_ports", "(", ")", ":", "if", "platform", ".", "system", "(", ")", "==", "'Darwin'", ":", "return", "glob", ".", "glob", "(", "'/dev/tty.usb*'", ")", "elif", "platform", ".", "system", "(", ")", "==", "'Linux'", ":", "return", "glob...
Tries to find the available serial ports on your system.
[ "Tries", "to", "find", "the", "available", "serial", "ports", "on", "your", "system", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/__init__.py#L20-L46
704
poppy-project/pypot
pypot/dynamixel/__init__.py
find_port
def find_port(ids, strict=True): """ Find the port with the specified attached motor ids. :param list ids: list of motor ids to find :param bool strict: specify if all ids should be find (when set to False, only half motor must be found) .. warning:: If two (or more) ports are attached to ...
python
def find_port(ids, strict=True): """ Find the port with the specified attached motor ids. :param list ids: list of motor ids to find :param bool strict: specify if all ids should be find (when set to False, only half motor must be found) .. warning:: If two (or more) ports are attached to ...
[ "def", "find_port", "(", "ids", ",", "strict", "=", "True", ")", ":", "ids_founds", "=", "[", "]", "for", "port", "in", "get_available_ports", "(", ")", ":", "for", "DxlIOCls", "in", "(", "DxlIO", ",", "Dxl320IO", ")", ":", "try", ":", "with", "DxlIO...
Find the port with the specified attached motor ids. :param list ids: list of motor ids to find :param bool strict: specify if all ids should be find (when set to False, only half motor must be found) .. warning:: If two (or more) ports are attached to the same list of motor ids the first matc...
[ "Find", "the", "port", "with", "the", "specified", "attached", "motor", "ids", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/__init__.py#L74-L106
705
poppy-project/pypot
pypot/sensor/depth/sonar.py
Sonar._filter
def _filter(self, data): """ Apply a filter to reduce noisy data. Return the median value of a heap of data. """ filtered_data = [] for queue, data in zip(self._raw_data_queues, data): queue.append(data) filtered_data.append(numpy.median(queue)) ...
python
def _filter(self, data): """ Apply a filter to reduce noisy data. Return the median value of a heap of data. """ filtered_data = [] for queue, data in zip(self._raw_data_queues, data): queue.append(data) filtered_data.append(numpy.median(queue)) ...
[ "def", "_filter", "(", "self", ",", "data", ")", ":", "filtered_data", "=", "[", "]", "for", "queue", ",", "data", "in", "zip", "(", "self", ".", "_raw_data_queues", ",", "data", ")", ":", "queue", ".", "append", "(", "data", ")", "filtered_data", "....
Apply a filter to reduce noisy data. Return the median value of a heap of data.
[ "Apply", "a", "filter", "to", "reduce", "noisy", "data", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/sensor/depth/sonar.py#L87-L98
706
poppy-project/pypot
pypot/dynamixel/syncloop.py
MetaDxlController.setup
def setup(self): """ Starts all the synchronization loops. """ [c.start() for c in self.controllers] [c.wait_to_start() for c in self.controllers]
python
def setup(self): """ Starts all the synchronization loops. """ [c.start() for c in self.controllers] [c.wait_to_start() for c in self.controllers]
[ "def", "setup", "(", "self", ")", ":", "[", "c", ".", "start", "(", ")", "for", "c", "in", "self", ".", "controllers", "]", "[", "c", ".", "wait_to_start", "(", ")", "for", "c", "in", "self", ".", "controllers", "]" ]
Starts all the synchronization loops.
[ "Starts", "all", "the", "synchronization", "loops", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/syncloop.py#L20-L23
707
poppy-project/pypot
pypot/creatures/ik.py
IKChain.from_poppy_creature
def from_poppy_creature(cls, poppy, motors, passiv, tip, reversed_motors=[]): """ Creates an kinematic chain from motors of a Poppy Creature. :param poppy: PoppyCreature used :param list motors: list of all motors that composed the kinematic chain ...
python
def from_poppy_creature(cls, poppy, motors, passiv, tip, reversed_motors=[]): """ Creates an kinematic chain from motors of a Poppy Creature. :param poppy: PoppyCreature used :param list motors: list of all motors that composed the kinematic chain ...
[ "def", "from_poppy_creature", "(", "cls", ",", "poppy", ",", "motors", ",", "passiv", ",", "tip", ",", "reversed_motors", "=", "[", "]", ")", ":", "chain_elements", "=", "get_chain_from_joints", "(", "poppy", ".", "urdf_file", ",", "[", "m", ".", "name", ...
Creates an kinematic chain from motors of a Poppy Creature. :param poppy: PoppyCreature used :param list motors: list of all motors that composed the kinematic chain :param list passiv: list of motors which are passiv in the chain (they will not move) :param list tip: [x...
[ "Creates", "an", "kinematic", "chain", "from", "motors", "of", "a", "Poppy", "Creature", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/creatures/ik.py#L14-L48
708
poppy-project/pypot
pypot/creatures/ik.py
IKChain.goto
def goto(self, position, duration, wait=False, accurate=False): """ Goes to a given cartesian position. :param list position: [x, y, z] representing the target position (in meters) :param float duration: move duration :param bool wait: whether to wait for the end of the move...
python
def goto(self, position, duration, wait=False, accurate=False): """ Goes to a given cartesian position. :param list position: [x, y, z] representing the target position (in meters) :param float duration: move duration :param bool wait: whether to wait for the end of the move...
[ "def", "goto", "(", "self", ",", "position", ",", "duration", ",", "wait", "=", "False", ",", "accurate", "=", "False", ")", ":", "if", "len", "(", "position", ")", "!=", "3", ":", "raise", "ValueError", "(", "'Position should be a list [x, y, z]!'", ")", ...
Goes to a given cartesian position. :param list position: [x, y, z] representing the target position (in meters) :param float duration: move duration :param bool wait: whether to wait for the end of the move :param bool accurate: trade-off between accurate solution and c...
[ "Goes", "to", "a", "given", "cartesian", "position", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/creatures/ik.py#L61-L75
709
poppy-project/pypot
pypot/creatures/ik.py
IKChain._goto
def _goto(self, pose, duration, wait, accurate): """ Goes to a given cartesian pose. :param matrix pose: homogeneous matrix representing the target position :param float duration: move duration :param bool wait: whether to wait for the end of the move :param bool...
python
def _goto(self, pose, duration, wait, accurate): """ Goes to a given cartesian pose. :param matrix pose: homogeneous matrix representing the target position :param float duration: move duration :param bool wait: whether to wait for the end of the move :param bool...
[ "def", "_goto", "(", "self", ",", "pose", ",", "duration", ",", "wait", ",", "accurate", ")", ":", "kwargs", "=", "{", "}", "if", "not", "accurate", ":", "kwargs", "[", "'max_iter'", "]", "=", "3", "q0", "=", "self", ".", "convert_to_ik_angles", "(",...
Goes to a given cartesian pose. :param matrix pose: homogeneous matrix representing the target position :param float duration: move duration :param bool wait: whether to wait for the end of the move :param bool accurate: trade-off between accurate solution and computatio...
[ "Goes", "to", "a", "given", "cartesian", "pose", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/creatures/ik.py#L77-L99
710
poppy-project/pypot
pypot/creatures/ik.py
IKChain.convert_to_ik_angles
def convert_to_ik_angles(self, joints): """ Convert from poppy representation to IKPY internal representation. """ if len(joints) != len(self.motors): raise ValueError('Incompatible data, len(joints) should be {}!'.format(len(self.motors))) raw_joints = [(j + m.offset) * (1 if m.dir...
python
def convert_to_ik_angles(self, joints): """ Convert from poppy representation to IKPY internal representation. """ if len(joints) != len(self.motors): raise ValueError('Incompatible data, len(joints) should be {}!'.format(len(self.motors))) raw_joints = [(j + m.offset) * (1 if m.dir...
[ "def", "convert_to_ik_angles", "(", "self", ",", "joints", ")", ":", "if", "len", "(", "joints", ")", "!=", "len", "(", "self", ".", "motors", ")", ":", "raise", "ValueError", "(", "'Incompatible data, len(joints) should be {}!'", ".", "format", "(", "len", ...
Convert from poppy representation to IKPY internal representation.
[ "Convert", "from", "poppy", "representation", "to", "IKPY", "internal", "representation", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/creatures/ik.py#L101-L111
711
poppy-project/pypot
pypot/creatures/ik.py
IKChain.convert_from_ik_angles
def convert_from_ik_angles(self, joints): """ Convert from IKPY internal representation to poppy representation. """ if len(joints) != len(self.motors) + 2: raise ValueError('Incompatible data, len(joints) should be {}!'.format(len(self.motors) + 2)) joints = [rad2deg(j) for j in jo...
python
def convert_from_ik_angles(self, joints): """ Convert from IKPY internal representation to poppy representation. """ if len(joints) != len(self.motors) + 2: raise ValueError('Incompatible data, len(joints) should be {}!'.format(len(self.motors) + 2)) joints = [rad2deg(j) for j in jo...
[ "def", "convert_from_ik_angles", "(", "self", ",", "joints", ")", ":", "if", "len", "(", "joints", ")", "!=", "len", "(", "self", ".", "motors", ")", "+", "2", ":", "raise", "ValueError", "(", "'Incompatible data, len(joints) should be {}!'", ".", "format", ...
Convert from IKPY internal representation to poppy representation.
[ "Convert", "from", "IKPY", "internal", "representation", "to", "poppy", "representation", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/creatures/ik.py#L113-L122
712
poppy-project/pypot
pypot/dynamixel/io/io_320.py
Dxl320IO.factory_reset
def factory_reset(self, ids, except_ids=False, except_baudrate_and_ids=False): """ Reset all motors on the bus to their factory default settings. """ mode = (0x02 if except_baudrate_and_ids else 0x01 if except_ids else 0xFF) for id in ids: try: self....
python
def factory_reset(self, ids, except_ids=False, except_baudrate_and_ids=False): """ Reset all motors on the bus to their factory default settings. """ mode = (0x02 if except_baudrate_and_ids else 0x01 if except_ids else 0xFF) for id in ids: try: self....
[ "def", "factory_reset", "(", "self", ",", "ids", ",", "except_ids", "=", "False", ",", "except_baudrate_and_ids", "=", "False", ")", ":", "mode", "=", "(", "0x02", "if", "except_baudrate_and_ids", "else", "0x01", "if", "except_ids", "else", "0xFF", ")", "for...
Reset all motors on the bus to their factory default settings.
[ "Reset", "all", "motors", "on", "the", "bus", "to", "their", "factory", "default", "settings", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/io_320.py#L32-L43
713
poppy-project/pypot
pypot/primitive/primitive.py
Primitive.stop
def stop(self, wait=True): """ Requests the primitive to stop. """ logger.info("Primitive %s stopped.", self) StoppableThread.stop(self, wait)
python
def stop(self, wait=True): """ Requests the primitive to stop. """ logger.info("Primitive %s stopped.", self) StoppableThread.stop(self, wait)
[ "def", "stop", "(", "self", ",", "wait", "=", "True", ")", ":", "logger", ".", "info", "(", "\"Primitive %s stopped.\"", ",", "self", ")", "StoppableThread", ".", "stop", "(", "self", ",", "wait", ")" ]
Requests the primitive to stop.
[ "Requests", "the", "primitive", "to", "stop", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/primitive/primitive.py#L126-L129
714
poppy-project/pypot
pypot/primitive/primitive.py
LoopPrimitive.recent_update_frequencies
def recent_update_frequencies(self): """ Returns the 10 most recent update frequencies. The given frequencies are computed as short-term frequencies! The 0th element of the list corresponds to the most recent frequency. """ return list(reversed([(1.0 / p) for p in numpy.diff(sel...
python
def recent_update_frequencies(self): """ Returns the 10 most recent update frequencies. The given frequencies are computed as short-term frequencies! The 0th element of the list corresponds to the most recent frequency. """ return list(reversed([(1.0 / p) for p in numpy.diff(sel...
[ "def", "recent_update_frequencies", "(", "self", ")", ":", "return", "list", "(", "reversed", "(", "[", "(", "1.0", "/", "p", ")", "for", "p", "in", "numpy", ".", "diff", "(", "self", ".", "_recent_updates", ")", "]", ")", ")" ]
Returns the 10 most recent update frequencies. The given frequencies are computed as short-term frequencies! The 0th element of the list corresponds to the most recent frequency.
[ "Returns", "the", "10", "most", "recent", "update", "frequencies", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/primitive/primitive.py#L174-L180
715
poppy-project/pypot
pypot/primitive/primitive.py
MockupMotor.goto_position
def goto_position(self, position, duration, control=None, wait=False): """ Automatically sets the goal position and the moving speed to reach the desired position within the duration. """ if control is None: control = self.goto_behavior if control == 'minjerk': goto_min...
python
def goto_position(self, position, duration, control=None, wait=False): """ Automatically sets the goal position and the moving speed to reach the desired position within the duration. """ if control is None: control = self.goto_behavior if control == 'minjerk': goto_min...
[ "def", "goto_position", "(", "self", ",", "position", ",", "duration", ",", "control", "=", "None", ",", "wait", "=", "False", ")", ":", "if", "control", "is", "None", ":", "control", "=", "self", ".", "goto_behavior", "if", "control", "==", "'minjerk'",...
Automatically sets the goal position and the moving speed to reach the desired position within the duration.
[ "Automatically", "sets", "the", "goal", "position", "and", "the", "moving", "speed", "to", "reach", "the", "desired", "position", "within", "the", "duration", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/primitive/primitive.py#L257-L277
716
poppy-project/pypot
pypot/primitive/move.py
MoveRecorder.add_tracked_motors
def add_tracked_motors(self, tracked_motors): """Add new motors to the recording""" new_mockup_motors = map(self.get_mockup_motor, tracked_motors) self.tracked_motors = list(set(self.tracked_motors + new_mockup_motors))
python
def add_tracked_motors(self, tracked_motors): """Add new motors to the recording""" new_mockup_motors = map(self.get_mockup_motor, tracked_motors) self.tracked_motors = list(set(self.tracked_motors + new_mockup_motors))
[ "def", "add_tracked_motors", "(", "self", ",", "tracked_motors", ")", ":", "new_mockup_motors", "=", "map", "(", "self", ".", "get_mockup_motor", ",", "tracked_motors", ")", "self", ".", "tracked_motors", "=", "list", "(", "set", "(", "self", ".", "tracked_mot...
Add new motors to the recording
[ "Add", "new", "motors", "to", "the", "recording" ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/primitive/move.py#L137-L140
717
poppy-project/pypot
pypot/primitive/manager.py
PrimitiveManager.update
def update(self): """ Combined at a predefined frequency the request orders and affect them to the real motors. """ with self.syncing: for m in self._motors: to_set = defaultdict(list) for p in self._prim: for key, val in getattr(p.robot, ...
python
def update(self): """ Combined at a predefined frequency the request orders and affect them to the real motors. """ with self.syncing: for m in self._motors: to_set = defaultdict(list) for p in self._prim: for key, val in getattr(p.robot, ...
[ "def", "update", "(", "self", ")", ":", "with", "self", ".", "syncing", ":", "for", "m", "in", "self", ".", "_motors", ":", "to_set", "=", "defaultdict", "(", "list", ")", "for", "p", "in", "self", ".", "_prim", ":", "for", "key", ",", "val", "in...
Combined at a predefined frequency the request orders and affect them to the real motors.
[ "Combined", "at", "a", "predefined", "frequency", "the", "request", "orders", "and", "affect", "them", "to", "the", "real", "motors", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/primitive/manager.py#L51-L74
718
poppy-project/pypot
pypot/primitive/manager.py
PrimitiveManager.stop
def stop(self): """ Stop the primitive manager. """ for p in self.primitives[:]: p.stop() StoppableLoopThread.stop(self)
python
def stop(self): """ Stop the primitive manager. """ for p in self.primitives[:]: p.stop() StoppableLoopThread.stop(self)
[ "def", "stop", "(", "self", ")", ":", "for", "p", "in", "self", ".", "primitives", "[", ":", "]", ":", "p", ".", "stop", "(", ")", "StoppableLoopThread", ".", "stop", "(", "self", ")" ]
Stop the primitive manager.
[ "Stop", "the", "primitive", "manager", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/primitive/manager.py#L76-L81
719
poppy-project/pypot
pypot/vrep/io.py
VrepIO.load_scene
def load_scene(self, scene_path, start=False): """ Loads a scene on the V-REP server. :param str scene_path: path to a V-REP scene file :param bool start: whether to directly start the simulation after loading the scene .. note:: It is assumed that the scene file is always available on...
python
def load_scene(self, scene_path, start=False): """ Loads a scene on the V-REP server. :param str scene_path: path to a V-REP scene file :param bool start: whether to directly start the simulation after loading the scene .. note:: It is assumed that the scene file is always available on...
[ "def", "load_scene", "(", "self", ",", "scene_path", ",", "start", "=", "False", ")", ":", "self", ".", "stop_simulation", "(", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "scene_path", ")", ":", "raise", "IOError", "(", "\"No such file or d...
Loads a scene on the V-REP server. :param str scene_path: path to a V-REP scene file :param bool start: whether to directly start the simulation after loading the scene .. note:: It is assumed that the scene file is always available on the server side.
[ "Loads", "a", "scene", "on", "the", "V", "-", "REP", "server", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L91-L108
720
poppy-project/pypot
pypot/vrep/io.py
VrepIO.get_motor_position
def get_motor_position(self, motor_name): """ Gets the motor current position. """ return self.call_remote_api('simxGetJointPosition', self.get_object_handle(motor_name), streaming=True)
python
def get_motor_position(self, motor_name): """ Gets the motor current position. """ return self.call_remote_api('simxGetJointPosition', self.get_object_handle(motor_name), streaming=True)
[ "def", "get_motor_position", "(", "self", ",", "motor_name", ")", ":", "return", "self", ".", "call_remote_api", "(", "'simxGetJointPosition'", ",", "self", ".", "get_object_handle", "(", "motor_name", ")", ",", "streaming", "=", "True", ")" ]
Gets the motor current position.
[ "Gets", "the", "motor", "current", "position", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L143-L147
721
poppy-project/pypot
pypot/vrep/io.py
VrepIO.set_motor_position
def set_motor_position(self, motor_name, position): """ Sets the motor target position. """ self.call_remote_api('simxSetJointTargetPosition', self.get_object_handle(motor_name), position, sending=True)
python
def set_motor_position(self, motor_name, position): """ Sets the motor target position. """ self.call_remote_api('simxSetJointTargetPosition', self.get_object_handle(motor_name), position, sending=True)
[ "def", "set_motor_position", "(", "self", ",", "motor_name", ",", "position", ")", ":", "self", ".", "call_remote_api", "(", "'simxSetJointTargetPosition'", ",", "self", ".", "get_object_handle", "(", "motor_name", ")", ",", "position", ",", "sending", "=", "Tru...
Sets the motor target position.
[ "Sets", "the", "motor", "target", "position", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L149-L154
722
poppy-project/pypot
pypot/vrep/io.py
VrepIO.set_motor_force
def set_motor_force(self, motor_name, force): """ Sets the maximum force or torque that a joint can exert. """ self.call_remote_api('simxSetJointForce', self.get_object_handle(motor_name), force, sending=True)
python
def set_motor_force(self, motor_name, force): """ Sets the maximum force or torque that a joint can exert. """ self.call_remote_api('simxSetJointForce', self.get_object_handle(motor_name), force, sending=True)
[ "def", "set_motor_force", "(", "self", ",", "motor_name", ",", "force", ")", ":", "self", ".", "call_remote_api", "(", "'simxSetJointForce'", ",", "self", ".", "get_object_handle", "(", "motor_name", ")", ",", "force", ",", "sending", "=", "True", ")" ]
Sets the maximum force or torque that a joint can exert.
[ "Sets", "the", "maximum", "force", "or", "torque", "that", "a", "joint", "can", "exert", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L162-L167
723
poppy-project/pypot
pypot/vrep/io.py
VrepIO.get_object_position
def get_object_position(self, object_name, relative_to_object=None): """ Gets the object position. """ h = self.get_object_handle(object_name) relative_handle = (-1 if relative_to_object is None else self.get_object_handle(relative_to_object)) return self.call...
python
def get_object_position(self, object_name, relative_to_object=None): """ Gets the object position. """ h = self.get_object_handle(object_name) relative_handle = (-1 if relative_to_object is None else self.get_object_handle(relative_to_object)) return self.call...
[ "def", "get_object_position", "(", "self", ",", "object_name", ",", "relative_to_object", "=", "None", ")", ":", "h", "=", "self", ".", "get_object_handle", "(", "object_name", ")", "relative_handle", "=", "(", "-", "1", "if", "relative_to_object", "is", "None...
Gets the object position.
[ "Gets", "the", "object", "position", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L169-L177
724
poppy-project/pypot
pypot/vrep/io.py
VrepIO.set_object_position
def set_object_position(self, object_name, position=[0, 0, 0]): """ Sets the object position. """ h = self.get_object_handle(object_name) return self.call_remote_api('simxSetObjectPosition', h, -1, position, sending=True)
python
def set_object_position(self, object_name, position=[0, 0, 0]): """ Sets the object position. """ h = self.get_object_handle(object_name) return self.call_remote_api('simxSetObjectPosition', h, -1, position, sending=True)
[ "def", "set_object_position", "(", "self", ",", "object_name", ",", "position", "=", "[", "0", ",", "0", ",", "0", "]", ")", ":", "h", "=", "self", ".", "get_object_handle", "(", "object_name", ")", "return", "self", ".", "call_remote_api", "(", "'simxSe...
Sets the object position.
[ "Sets", "the", "object", "position", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L179-L185
725
poppy-project/pypot
pypot/vrep/io.py
VrepIO.get_object_handle
def get_object_handle(self, obj): """ Gets the vrep object handle. """ if obj not in self._object_handles: self._object_handles[obj] = self._get_object_handle(obj=obj) return self._object_handles[obj]
python
def get_object_handle(self, obj): """ Gets the vrep object handle. """ if obj not in self._object_handles: self._object_handles[obj] = self._get_object_handle(obj=obj) return self._object_handles[obj]
[ "def", "get_object_handle", "(", "self", ",", "obj", ")", ":", "if", "obj", "not", "in", "self", ".", "_object_handles", ":", "self", ".", "_object_handles", "[", "obj", "]", "=", "self", ".", "_get_object_handle", "(", "obj", "=", "obj", ")", "return", ...
Gets the vrep object handle.
[ "Gets", "the", "vrep", "object", "handle", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L200-L205
726
poppy-project/pypot
pypot/vrep/io.py
VrepIO.get_collision_state
def get_collision_state(self, collision_name): """ Gets the collision state. """ return self.call_remote_api('simxReadCollision', self.get_collision_handle(collision_name), streaming=True)
python
def get_collision_state(self, collision_name): """ Gets the collision state. """ return self.call_remote_api('simxReadCollision', self.get_collision_handle(collision_name), streaming=True)
[ "def", "get_collision_state", "(", "self", ",", "collision_name", ")", ":", "return", "self", ".", "call_remote_api", "(", "'simxReadCollision'", ",", "self", ".", "get_collision_handle", "(", "collision_name", ")", ",", "streaming", "=", "True", ")" ]
Gets the collision state.
[ "Gets", "the", "collision", "state", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L207-L211
727
poppy-project/pypot
pypot/vrep/io.py
VrepIO.get_collision_handle
def get_collision_handle(self, collision): """ Gets a vrep collisions handle. """ if collision not in self._object_handles: h = self._get_collision_handle(collision) self._object_handles[collision] = h return self._object_handles[collision]
python
def get_collision_handle(self, collision): """ Gets a vrep collisions handle. """ if collision not in self._object_handles: h = self._get_collision_handle(collision) self._object_handles[collision] = h return self._object_handles[collision]
[ "def", "get_collision_handle", "(", "self", ",", "collision", ")", ":", "if", "collision", "not", "in", "self", ".", "_object_handles", ":", "h", "=", "self", ".", "_get_collision_handle", "(", "collision", ")", "self", ".", "_object_handles", "[", "collision"...
Gets a vrep collisions handle.
[ "Gets", "a", "vrep", "collisions", "handle", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L216-L222
728
poppy-project/pypot
pypot/vrep/io.py
VrepIO.change_object_name
def change_object_name(self, old_name, new_name): """ Change object name """ h = self._get_object_handle(old_name) if old_name in self._object_handles: self._object_handles.pop(old_name) lua_code = "simSetObjectName({}, '{}')".format(h, new_name) self._inject_lua_code...
python
def change_object_name(self, old_name, new_name): """ Change object name """ h = self._get_object_handle(old_name) if old_name in self._object_handles: self._object_handles.pop(old_name) lua_code = "simSetObjectName({}, '{}')".format(h, new_name) self._inject_lua_code...
[ "def", "change_object_name", "(", "self", ",", "old_name", ",", "new_name", ")", ":", "h", "=", "self", ".", "_get_object_handle", "(", "old_name", ")", "if", "old_name", "in", "self", ".", "_object_handles", ":", "self", ".", "_object_handles", ".", "pop", ...
Change object name
[ "Change", "object", "name" ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L255-L261
729
poppy-project/pypot
pypot/vrep/io.py
VrepIO._create_pure_shape
def _create_pure_shape(self, primitive_type, options, sizes, mass, precision): """ Create Pure Shape """ lua_code = "simCreatePureShape({}, {}, {{{}, {}, {}}}, {}, {{{}, {}}})".format( primitive_type, options, sizes[0], sizes[1], sizes[2], mass, precision[0], precision[1]) self._inje...
python
def _create_pure_shape(self, primitive_type, options, sizes, mass, precision): """ Create Pure Shape """ lua_code = "simCreatePureShape({}, {}, {{{}, {}, {}}}, {}, {{{}, {}}})".format( primitive_type, options, sizes[0], sizes[1], sizes[2], mass, precision[0], precision[1]) self._inje...
[ "def", "_create_pure_shape", "(", "self", ",", "primitive_type", ",", "options", ",", "sizes", ",", "mass", ",", "precision", ")", ":", "lua_code", "=", "\"simCreatePureShape({}, {}, {{{}, {}, {}}}, {}, {{{}, {}}})\"", ".", "format", "(", "primitive_type", ",", "optio...
Create Pure Shape
[ "Create", "Pure", "Shape" ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L263-L267
730
poppy-project/pypot
pypot/vrep/io.py
VrepIO._inject_lua_code
def _inject_lua_code(self, lua_code): """ Sends raw lua code and evaluate it wihtout any checking! """ msg = (ctypes.c_ubyte * len(lua_code)).from_buffer_copy(lua_code.encode()) self.call_remote_api('simxWriteStringStream', 'my_lua_code', msg)
python
def _inject_lua_code(self, lua_code): """ Sends raw lua code and evaluate it wihtout any checking! """ msg = (ctypes.c_ubyte * len(lua_code)).from_buffer_copy(lua_code.encode()) self.call_remote_api('simxWriteStringStream', 'my_lua_code', msg)
[ "def", "_inject_lua_code", "(", "self", ",", "lua_code", ")", ":", "msg", "=", "(", "ctypes", ".", "c_ubyte", "*", "len", "(", "lua_code", ")", ")", ".", "from_buffer_copy", "(", "lua_code", ".", "encode", "(", ")", ")", "self", ".", "call_remote_api", ...
Sends raw lua code and evaluate it wihtout any checking!
[ "Sends", "raw", "lua", "code", "and", "evaluate", "it", "wihtout", "any", "checking!" ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L269-L272
731
poppy-project/pypot
pypot/vrep/io.py
VrepIO.call_remote_api
def call_remote_api(self, func_name, *args, **kwargs): """ Calls any remote API func in a thread_safe way. :param str func_name: name of the remote API func to call :param args: args to pass to the remote API call :param kwargs: args to pass to the remote API call .. note:: You...
python
def call_remote_api(self, func_name, *args, **kwargs): """ Calls any remote API func in a thread_safe way. :param str func_name: name of the remote API func to call :param args: args to pass to the remote API call :param kwargs: args to pass to the remote API call .. note:: You...
[ "def", "call_remote_api", "(", "self", ",", "func_name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "f", "=", "getattr", "(", "remote_api", ",", "func_name", ")", "mode", "=", "self", ".", "_extract_mode", "(", "kwargs", ")", "kwargs", "[", ...
Calls any remote API func in a thread_safe way. :param str func_name: name of the remote API func to call :param args: args to pass to the remote API call :param kwargs: args to pass to the remote API call .. note:: You can add an extra keyword to specify if you want to use the streami...
[ "Calls", "any", "remote", "API", "func", "in", "a", "thread_safe", "way", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L274-L361
732
poppy-project/pypot
pypot/server/httpserver.py
HTTPRobotServer.run
def run(self, **kwargs): """ Start the tornado server, run forever""" try: loop = IOLoop() app = self.make_app() app.listen(self.port) loop.start() except socket.error as serr: # Re raise the socket error if not "[Errno 98] Address al...
python
def run(self, **kwargs): """ Start the tornado server, run forever""" try: loop = IOLoop() app = self.make_app() app.listen(self.port) loop.start() except socket.error as serr: # Re raise the socket error if not "[Errno 98] Address al...
[ "def", "run", "(", "self", ",", "*", "*", "kwargs", ")", ":", "try", ":", "loop", "=", "IOLoop", "(", ")", "app", "=", "self", ".", "make_app", "(", ")", "app", ".", "listen", "(", "self", ".", "port", ")", "loop", ".", "start", "(", ")", "ex...
Start the tornado server, run forever
[ "Start", "the", "tornado", "server", "run", "forever" ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/server/httpserver.py#L253-L267
733
poppy-project/pypot
pypot/dynamixel/io/abstract_io.py
AbstractDxlIO.close
def close(self, _force_lock=False): """ Closes the serial communication if opened. """ if not self.closed: with self.__force_lock(_force_lock) or self._serial_lock: self._serial.close() self.__used_ports.remove(self.port) logger.info("Closing port...
python
def close(self, _force_lock=False): """ Closes the serial communication if opened. """ if not self.closed: with self.__force_lock(_force_lock) or self._serial_lock: self._serial.close() self.__used_ports.remove(self.port) logger.info("Closing port...
[ "def", "close", "(", "self", ",", "_force_lock", "=", "False", ")", ":", "if", "not", "self", ".", "closed", ":", "with", "self", ".", "__force_lock", "(", "_force_lock", ")", "or", "self", ".", "_serial_lock", ":", "self", ".", "_serial", ".", "close"...
Closes the serial communication if opened.
[ "Closes", "the", "serial", "communication", "if", "opened", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/abstract_io.py#L145-L155
734
poppy-project/pypot
pypot/dynamixel/io/abstract_io.py
AbstractDxlIO.ping
def ping(self, id): """ Pings the motor with the specified id. .. note:: The motor id should always be included in [0, 253]. 254 is used for broadcast. """ pp = self._protocol.DxlPingPacket(id) try: self._send_packet(pp, error_handler=None) retu...
python
def ping(self, id): """ Pings the motor with the specified id. .. note:: The motor id should always be included in [0, 253]. 254 is used for broadcast. """ pp = self._protocol.DxlPingPacket(id) try: self._send_packet(pp, error_handler=None) retu...
[ "def", "ping", "(", "self", ",", "id", ")", ":", "pp", "=", "self", ".", "_protocol", ".", "DxlPingPacket", "(", "id", ")", "try", ":", "self", ".", "_send_packet", "(", "pp", ",", "error_handler", "=", "None", ")", "return", "True", "except", "DxlTi...
Pings the motor with the specified id. .. note:: The motor id should always be included in [0, 253]. 254 is used for broadcast.
[ "Pings", "the", "motor", "with", "the", "specified", "id", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/abstract_io.py#L205-L217
735
poppy-project/pypot
pypot/dynamixel/io/abstract_io.py
AbstractDxlIO.scan
def scan(self, ids=range(254)): """ Pings all ids within the specified list, by default it finds all the motors connected to the bus. """ return [id for id in ids if self.ping(id)]
python
def scan(self, ids=range(254)): """ Pings all ids within the specified list, by default it finds all the motors connected to the bus. """ return [id for id in ids if self.ping(id)]
[ "def", "scan", "(", "self", ",", "ids", "=", "range", "(", "254", ")", ")", ":", "return", "[", "id", "for", "id", "in", "ids", "if", "self", ".", "ping", "(", "id", ")", "]" ]
Pings all ids within the specified list, by default it finds all the motors connected to the bus.
[ "Pings", "all", "ids", "within", "the", "specified", "list", "by", "default", "it", "finds", "all", "the", "motors", "connected", "to", "the", "bus", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/abstract_io.py#L219-L221
736
poppy-project/pypot
pypot/dynamixel/io/abstract_io.py
AbstractDxlIO.get_model
def get_model(self, ids): """ Gets the model for the specified motors. """ to_get_ids = [i for i in ids if i not in self._known_models] models = [dxl_to_model(m) for m in self._get_model(to_get_ids, convert=False)] self._known_models.update(zip(to_get_ids, models)) return tuple(...
python
def get_model(self, ids): """ Gets the model for the specified motors. """ to_get_ids = [i for i in ids if i not in self._known_models] models = [dxl_to_model(m) for m in self._get_model(to_get_ids, convert=False)] self._known_models.update(zip(to_get_ids, models)) return tuple(...
[ "def", "get_model", "(", "self", ",", "ids", ")", ":", "to_get_ids", "=", "[", "i", "for", "i", "in", "ids", "if", "i", "not", "in", "self", ".", "_known_models", "]", "models", "=", "[", "dxl_to_model", "(", "m", ")", "for", "m", "in", "self", "...
Gets the model for the specified motors.
[ "Gets", "the", "model", "for", "the", "specified", "motors", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/abstract_io.py#L225-L231
737
poppy-project/pypot
pypot/dynamixel/io/abstract_io.py
AbstractDxlIO.change_baudrate
def change_baudrate(self, baudrate_for_ids): """ Changes the baudrate of the specified motors. """ self._change_baudrate(baudrate_for_ids) for motor_id in baudrate_for_ids: if motor_id in self._known_models: del self._known_models[motor_id] if motor_id in...
python
def change_baudrate(self, baudrate_for_ids): """ Changes the baudrate of the specified motors. """ self._change_baudrate(baudrate_for_ids) for motor_id in baudrate_for_ids: if motor_id in self._known_models: del self._known_models[motor_id] if motor_id in...
[ "def", "change_baudrate", "(", "self", ",", "baudrate_for_ids", ")", ":", "self", ".", "_change_baudrate", "(", "baudrate_for_ids", ")", "for", "motor_id", "in", "baudrate_for_ids", ":", "if", "motor_id", "in", "self", ".", "_known_models", ":", "del", "self", ...
Changes the baudrate of the specified motors.
[ "Changes", "the", "baudrate", "of", "the", "specified", "motors", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/abstract_io.py#L252-L260
738
poppy-project/pypot
pypot/dynamixel/io/abstract_io.py
AbstractDxlIO.get_status_return_level
def get_status_return_level(self, ids, **kwargs): """ Gets the status level for the specified motors. """ convert = kwargs['convert'] if 'convert' in kwargs else self._convert srl = [] for id in ids: try: srl.extend(self._get_status_return_level((id, ), ...
python
def get_status_return_level(self, ids, **kwargs): """ Gets the status level for the specified motors. """ convert = kwargs['convert'] if 'convert' in kwargs else self._convert srl = [] for id in ids: try: srl.extend(self._get_status_return_level((id, ), ...
[ "def", "get_status_return_level", "(", "self", ",", "ids", ",", "*", "*", "kwargs", ")", ":", "convert", "=", "kwargs", "[", "'convert'", "]", "if", "'convert'", "in", "kwargs", "else", "self", ".", "_convert", "srl", "=", "[", "]", "for", "id", "in", ...
Gets the status level for the specified motors.
[ "Gets", "the", "status", "level", "for", "the", "specified", "motors", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/abstract_io.py#L262-L280
739
poppy-project/pypot
pypot/dynamixel/io/abstract_io.py
AbstractDxlIO.set_status_return_level
def set_status_return_level(self, srl_for_id, **kwargs): """ Sets status return level to the specified motors. """ convert = kwargs['convert'] if 'convert' in kwargs else self._convert if convert: srl_for_id = dict(zip(srl_for_id.keys(), [('never', '...
python
def set_status_return_level(self, srl_for_id, **kwargs): """ Sets status return level to the specified motors. """ convert = kwargs['convert'] if 'convert' in kwargs else self._convert if convert: srl_for_id = dict(zip(srl_for_id.keys(), [('never', '...
[ "def", "set_status_return_level", "(", "self", ",", "srl_for_id", ",", "*", "*", "kwargs", ")", ":", "convert", "=", "kwargs", "[", "'convert'", "]", "if", "'convert'", "in", "kwargs", "else", "self", ".", "_convert", "if", "convert", ":", "srl_for_id", "=...
Sets status return level to the specified motors.
[ "Sets", "status", "return", "level", "to", "the", "specified", "motors", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/abstract_io.py#L282-L288
740
poppy-project/pypot
pypot/dynamixel/io/abstract_io.py
AbstractDxlIO.switch_led_on
def switch_led_on(self, ids): """ Switches on the LED of the motors with the specified ids. """ self._set_LED(dict(zip(ids, itertools.repeat(True))))
python
def switch_led_on(self, ids): """ Switches on the LED of the motors with the specified ids. """ self._set_LED(dict(zip(ids, itertools.repeat(True))))
[ "def", "switch_led_on", "(", "self", ",", "ids", ")", ":", "self", ".", "_set_LED", "(", "dict", "(", "zip", "(", "ids", ",", "itertools", ".", "repeat", "(", "True", ")", ")", ")", ")" ]
Switches on the LED of the motors with the specified ids.
[ "Switches", "on", "the", "LED", "of", "the", "motors", "with", "the", "specified", "ids", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/abstract_io.py#L290-L292
741
poppy-project/pypot
pypot/dynamixel/io/abstract_io.py
AbstractDxlIO.switch_led_off
def switch_led_off(self, ids): """ Switches off the LED of the motors with the specified ids. """ self._set_LED(dict(zip(ids, itertools.repeat(False))))
python
def switch_led_off(self, ids): """ Switches off the LED of the motors with the specified ids. """ self._set_LED(dict(zip(ids, itertools.repeat(False))))
[ "def", "switch_led_off", "(", "self", ",", "ids", ")", ":", "self", ".", "_set_LED", "(", "dict", "(", "zip", "(", "ids", ",", "itertools", ".", "repeat", "(", "False", ")", ")", ")", ")" ]
Switches off the LED of the motors with the specified ids.
[ "Switches", "off", "the", "LED", "of", "the", "motors", "with", "the", "specified", "ids", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/abstract_io.py#L294-L296
742
poppy-project/pypot
pypot/dynamixel/io/abstract_io.py
AbstractDxlIO.enable_torque
def enable_torque(self, ids): """ Enables torque of the motors with the specified ids. """ self._set_torque_enable(dict(zip(ids, itertools.repeat(True))))
python
def enable_torque(self, ids): """ Enables torque of the motors with the specified ids. """ self._set_torque_enable(dict(zip(ids, itertools.repeat(True))))
[ "def", "enable_torque", "(", "self", ",", "ids", ")", ":", "self", ".", "_set_torque_enable", "(", "dict", "(", "zip", "(", "ids", ",", "itertools", ".", "repeat", "(", "True", ")", ")", ")", ")" ]
Enables torque of the motors with the specified ids.
[ "Enables", "torque", "of", "the", "motors", "with", "the", "specified", "ids", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/abstract_io.py#L298-L300
743
poppy-project/pypot
pypot/dynamixel/io/abstract_io.py
AbstractDxlIO.disable_torque
def disable_torque(self, ids): """ Disables torque of the motors with the specified ids. """ self._set_torque_enable(dict(zip(ids, itertools.repeat(False))))
python
def disable_torque(self, ids): """ Disables torque of the motors with the specified ids. """ self._set_torque_enable(dict(zip(ids, itertools.repeat(False))))
[ "def", "disable_torque", "(", "self", ",", "ids", ")", ":", "self", ".", "_set_torque_enable", "(", "dict", "(", "zip", "(", "ids", ",", "itertools", ".", "repeat", "(", "False", ")", ")", ")", ")" ]
Disables torque of the motors with the specified ids.
[ "Disables", "torque", "of", "the", "motors", "with", "the", "specified", "ids", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/abstract_io.py#L302-L304
744
poppy-project/pypot
pypot/dynamixel/io/abstract_io.py
AbstractDxlIO.get_pid_gain
def get_pid_gain(self, ids, **kwargs): """ Gets the pid gain for the specified motors. """ return tuple([tuple(reversed(t)) for t in self._get_pid_gain(ids, **kwargs)])
python
def get_pid_gain(self, ids, **kwargs): """ Gets the pid gain for the specified motors. """ return tuple([tuple(reversed(t)) for t in self._get_pid_gain(ids, **kwargs)])
[ "def", "get_pid_gain", "(", "self", ",", "ids", ",", "*", "*", "kwargs", ")", ":", "return", "tuple", "(", "[", "tuple", "(", "reversed", "(", "t", ")", ")", "for", "t", "in", "self", ".", "_get_pid_gain", "(", "ids", ",", "*", "*", "kwargs", ")"...
Gets the pid gain for the specified motors.
[ "Gets", "the", "pid", "gain", "for", "the", "specified", "motors", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/abstract_io.py#L306-L308
745
poppy-project/pypot
pypot/dynamixel/io/abstract_io.py
AbstractDxlIO.set_pid_gain
def set_pid_gain(self, pid_for_id, **kwargs): """ Sets the pid gain to the specified motors. """ pid_for_id = dict(itertools.izip(pid_for_id.iterkeys(), [tuple(reversed(t)) for t in pid_for_id.values()])) self._set_pid_gain(pid_for_id, **kwargs)
python
def set_pid_gain(self, pid_for_id, **kwargs): """ Sets the pid gain to the specified motors. """ pid_for_id = dict(itertools.izip(pid_for_id.iterkeys(), [tuple(reversed(t)) for t in pid_for_id.values()])) self._set_pid_gain(pid_for_id, **kwargs)
[ "def", "set_pid_gain", "(", "self", ",", "pid_for_id", ",", "*", "*", "kwargs", ")", ":", "pid_for_id", "=", "dict", "(", "itertools", ".", "izip", "(", "pid_for_id", ".", "iterkeys", "(", ")", ",", "[", "tuple", "(", "reversed", "(", "t", ")", ")", ...
Sets the pid gain to the specified motors.
[ "Sets", "the", "pid", "gain", "to", "the", "specified", "motors", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/abstract_io.py#L310-L314
746
poppy-project/pypot
pypot/dynamixel/io/abstract_io.py
AbstractDxlIO.get_control_table
def get_control_table(self, ids, **kwargs): """ Gets the full control table for the specified motors. ..note:: This function requires the model for each motor to be known. Querring this additional information might add some extra delay. """ error_handler = kwargs['error_handler...
python
def get_control_table(self, ids, **kwargs): """ Gets the full control table for the specified motors. ..note:: This function requires the model for each motor to be known. Querring this additional information might add some extra delay. """ error_handler = kwargs['error_handler...
[ "def", "get_control_table", "(", "self", ",", "ids", ",", "*", "*", "kwargs", ")", ":", "error_handler", "=", "kwargs", "[", "'error_handler'", "]", "if", "(", "'error_handler'", "in", "kwargs", ")", "else", "self", ".", "_error_handler", "convert", "=", "...
Gets the full control table for the specified motors. ..note:: This function requires the model for each motor to be known. Querring this additional information might add some extra delay.
[ "Gets", "the", "full", "control", "table", "for", "the", "specified", "motors", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/abstract_io.py#L318-L350
747
poppy-project/pypot
pypot/robot/config.py
check_motor_eprom_configuration
def check_motor_eprom_configuration(config, dxl_io, motor_names): """ Change the angles limits depanding on the robot configuration ; Check if the return delay time is set to 0. """ changed_angle_limits = {} changed_return_delay_time = {} for name in motor_names: m = config['motors'...
python
def check_motor_eprom_configuration(config, dxl_io, motor_names): """ Change the angles limits depanding on the robot configuration ; Check if the return delay time is set to 0. """ changed_angle_limits = {} changed_return_delay_time = {} for name in motor_names: m = config['motors'...
[ "def", "check_motor_eprom_configuration", "(", "config", ",", "dxl_io", ",", "motor_names", ")", ":", "changed_angle_limits", "=", "{", "}", "changed_return_delay_time", "=", "{", "}", "for", "name", "in", "motor_names", ":", "m", "=", "config", "[", "'motors'",...
Change the angles limits depanding on the robot configuration ; Check if the return delay time is set to 0.
[ "Change", "the", "angles", "limits", "depanding", "on", "the", "robot", "configuration", ";", "Check", "if", "the", "return", "delay", "time", "is", "set", "to", "0", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/robot/config.py#L209-L252
748
icometrix/dicom2nifti
dicom2nifti/compressed_dicom.py
_get_gdcmconv
def _get_gdcmconv(): """ Get the full path to gdcmconv. If not found raise error """ gdcmconv_executable = settings.gdcmconv_path if gdcmconv_executable is None: gdcmconv_executable = _which('gdcmconv') if gdcmconv_executable is None: gdcmconv_executable = _which('gdcmconv.ex...
python
def _get_gdcmconv(): """ Get the full path to gdcmconv. If not found raise error """ gdcmconv_executable = settings.gdcmconv_path if gdcmconv_executable is None: gdcmconv_executable = _which('gdcmconv') if gdcmconv_executable is None: gdcmconv_executable = _which('gdcmconv.ex...
[ "def", "_get_gdcmconv", "(", ")", ":", "gdcmconv_executable", "=", "settings", ".", "gdcmconv_path", "if", "gdcmconv_executable", "is", "None", ":", "gdcmconv_executable", "=", "_which", "(", "'gdcmconv'", ")", "if", "gdcmconv_executable", "is", "None", ":", "gdcm...
Get the full path to gdcmconv. If not found raise error
[ "Get", "the", "full", "path", "to", "gdcmconv", ".", "If", "not", "found", "raise", "error" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/compressed_dicom.py#L41-L55
749
icometrix/dicom2nifti
dicom2nifti/compressed_dicom.py
compress_directory
def compress_directory(dicom_directory): """ This function can be used to convert a folder of jpeg compressed images to an uncompressed ones :param dicom_directory: directory of dicom files to compress """ if _is_compressed(dicom_directory): return logger.info('Compressing dicom files ...
python
def compress_directory(dicom_directory): """ This function can be used to convert a folder of jpeg compressed images to an uncompressed ones :param dicom_directory: directory of dicom files to compress """ if _is_compressed(dicom_directory): return logger.info('Compressing dicom files ...
[ "def", "compress_directory", "(", "dicom_directory", ")", ":", "if", "_is_compressed", "(", "dicom_directory", ")", ":", "return", "logger", ".", "info", "(", "'Compressing dicom files in %s'", "%", "dicom_directory", ")", "for", "root", ",", "_", ",", "files", ...
This function can be used to convert a folder of jpeg compressed images to an uncompressed ones :param dicom_directory: directory of dicom files to compress
[ "This", "function", "can", "be", "used", "to", "convert", "a", "folder", "of", "jpeg", "compressed", "images", "to", "an", "uncompressed", "ones" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/compressed_dicom.py#L58-L71
750
icometrix/dicom2nifti
dicom2nifti/compressed_dicom.py
is_dicom_file
def is_dicom_file(filename): """ Util function to check if file is a dicom file the first 128 bytes are preamble the next 4 bytes should contain DICM otherwise it is not a dicom :param filename: file to check for the DICM header block :type filename: six.string_types :returns: True if it is...
python
def is_dicom_file(filename): """ Util function to check if file is a dicom file the first 128 bytes are preamble the next 4 bytes should contain DICM otherwise it is not a dicom :param filename: file to check for the DICM header block :type filename: six.string_types :returns: True if it is...
[ "def", "is_dicom_file", "(", "filename", ")", ":", "file_stream", "=", "open", "(", "filename", ",", "'rb'", ")", "file_stream", ".", "seek", "(", "128", ")", "data", "=", "file_stream", ".", "read", "(", "4", ")", "file_stream", ".", "close", "(", ")"...
Util function to check if file is a dicom file the first 128 bytes are preamble the next 4 bytes should contain DICM otherwise it is not a dicom :param filename: file to check for the DICM header block :type filename: six.string_types :returns: True if it is a dicom file
[ "Util", "function", "to", "check", "if", "file", "is", "a", "dicom", "file", "the", "first", "128", "bytes", "are", "preamble", "the", "next", "4", "bytes", "should", "contain", "DICM", "otherwise", "it", "is", "not", "a", "dicom" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/compressed_dicom.py#L74-L97
751
icometrix/dicom2nifti
dicom2nifti/compressed_dicom.py
_is_compressed
def _is_compressed(dicom_file, force=False): """ Check if dicoms are compressed or not """ header = pydicom.read_file(dicom_file, defer_size="1 KB", stop_before_pixels=True, force=force) uncompressed_types ...
python
def _is_compressed(dicom_file, force=False): """ Check if dicoms are compressed or not """ header = pydicom.read_file(dicom_file, defer_size="1 KB", stop_before_pixels=True, force=force) uncompressed_types ...
[ "def", "_is_compressed", "(", "dicom_file", ",", "force", "=", "False", ")", ":", "header", "=", "pydicom", ".", "read_file", "(", "dicom_file", ",", "defer_size", "=", "\"1 KB\"", ",", "stop_before_pixels", "=", "True", ",", "force", "=", "force", ")", "u...
Check if dicoms are compressed or not
[ "Check", "if", "dicoms", "are", "compressed", "or", "not" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/compressed_dicom.py#L100-L116
752
icometrix/dicom2nifti
dicom2nifti/compressed_dicom.py
_decompress_dicom
def _decompress_dicom(dicom_file, output_file): """ This function can be used to convert a jpeg compressed image to an uncompressed one for further conversion :param input_file: single dicom file to decompress """ gdcmconv_executable = _get_gdcmconv() subprocess.check_output([gdcmconv_executab...
python
def _decompress_dicom(dicom_file, output_file): """ This function can be used to convert a jpeg compressed image to an uncompressed one for further conversion :param input_file: single dicom file to decompress """ gdcmconv_executable = _get_gdcmconv() subprocess.check_output([gdcmconv_executab...
[ "def", "_decompress_dicom", "(", "dicom_file", ",", "output_file", ")", ":", "gdcmconv_executable", "=", "_get_gdcmconv", "(", ")", "subprocess", ".", "check_output", "(", "[", "gdcmconv_executable", ",", "'-w'", ",", "dicom_file", ",", "output_file", "]", ")" ]
This function can be used to convert a jpeg compressed image to an uncompressed one for further conversion :param input_file: single dicom file to decompress
[ "This", "function", "can", "be", "used", "to", "convert", "a", "jpeg", "compressed", "image", "to", "an", "uncompressed", "one", "for", "further", "conversion" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/compressed_dicom.py#L119-L127
753
icometrix/dicom2nifti
scripts/dicomdiff.py
dicom_diff
def dicom_diff(file1, file2): """ Shows the fields that differ between two DICOM images. Inspired by https://code.google.com/p/pydicom/source/browse/source/dicom/examples/DicomDiff.py """ datasets = compressed_dicom.read_file(file1), compressed_dicom.read_file(file2) rep = [] for dataset in ...
python
def dicom_diff(file1, file2): """ Shows the fields that differ between two DICOM images. Inspired by https://code.google.com/p/pydicom/source/browse/source/dicom/examples/DicomDiff.py """ datasets = compressed_dicom.read_file(file1), compressed_dicom.read_file(file2) rep = [] for dataset in ...
[ "def", "dicom_diff", "(", "file1", ",", "file2", ")", ":", "datasets", "=", "compressed_dicom", ".", "read_file", "(", "file1", ")", ",", "compressed_dicom", ".", "read_file", "(", "file2", ")", "rep", "=", "[", "]", "for", "dataset", "in", "datasets", "...
Shows the fields that differ between two DICOM images. Inspired by https://code.google.com/p/pydicom/source/browse/source/dicom/examples/DicomDiff.py
[ "Shows", "the", "fields", "that", "differ", "between", "two", "DICOM", "images", "." ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/scripts/dicomdiff.py#L14-L32
754
icometrix/dicom2nifti
dicom2nifti/image_volume.py
ImageVolume._get_number_of_slices
def _get_number_of_slices(self, slice_type): """ Get the number of slices in a certain direction """ if slice_type == SliceType.AXIAL: return self.dimensions[self.axial_orientation.normal_component] elif slice_type == SliceType.SAGITTAL: return self.dimens...
python
def _get_number_of_slices(self, slice_type): """ Get the number of slices in a certain direction """ if slice_type == SliceType.AXIAL: return self.dimensions[self.axial_orientation.normal_component] elif slice_type == SliceType.SAGITTAL: return self.dimens...
[ "def", "_get_number_of_slices", "(", "self", ",", "slice_type", ")", ":", "if", "slice_type", "==", "SliceType", ".", "AXIAL", ":", "return", "self", ".", "dimensions", "[", "self", ".", "axial_orientation", ".", "normal_component", "]", "elif", "slice_type", ...
Get the number of slices in a certain direction
[ "Get", "the", "number", "of", "slices", "in", "a", "certain", "direction" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/image_volume.py#L166-L175
755
icometrix/dicom2nifti
dicom2nifti/convert_dicom.py
_get_first_header
def _get_first_header(dicom_directory): """ Function to get the first dicom file form a directory and return the header Useful to determine the type of data to convert :param dicom_directory: directory with dicom files """ # looping over all files for root, _, file_names in os.walk(dicom_di...
python
def _get_first_header(dicom_directory): """ Function to get the first dicom file form a directory and return the header Useful to determine the type of data to convert :param dicom_directory: directory with dicom files """ # looping over all files for root, _, file_names in os.walk(dicom_di...
[ "def", "_get_first_header", "(", "dicom_directory", ")", ":", "# looping over all files", "for", "root", ",", "_", ",", "file_names", "in", "os", ".", "walk", "(", "dicom_directory", ")", ":", "# go over all the files and try to read the dicom header", "for", "file_name...
Function to get the first dicom file form a directory and return the header Useful to determine the type of data to convert :param dicom_directory: directory with dicom files
[ "Function", "to", "get", "the", "first", "dicom", "file", "form", "a", "directory", "and", "return", "the", "header", "Useful", "to", "determine", "the", "type", "of", "data", "to", "convert" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_dicom.py#L196-L216
756
icometrix/dicom2nifti
dicom2nifti/image_reorientation.py
_reorient_3d
def _reorient_3d(image): """ Reorganize the data for a 3d nifti """ # Create empty array where x,y,z correspond to LR (sagittal), PA (coronal), IS (axial) directions and the size # of the array in each direction is the same with the corresponding direction of the input image. new_image = numpy.z...
python
def _reorient_3d(image): """ Reorganize the data for a 3d nifti """ # Create empty array where x,y,z correspond to LR (sagittal), PA (coronal), IS (axial) directions and the size # of the array in each direction is the same with the corresponding direction of the input image. new_image = numpy.z...
[ "def", "_reorient_3d", "(", "image", ")", ":", "# Create empty array where x,y,z correspond to LR (sagittal), PA (coronal), IS (axial) directions and the size", "# of the array in each direction is the same with the corresponding direction of the input image.", "new_image", "=", "numpy", ".", ...
Reorganize the data for a 3d nifti
[ "Reorganize", "the", "data", "for", "a", "3d", "nifti" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/image_reorientation.py#L112-L133
757
icometrix/dicom2nifti
dicom2nifti/convert_philips.py
dicom_to_nifti
def dicom_to_nifti(dicom_input, output_file=None): """ This is the main dicom to nifti conversion fuction for philips images. As input philips images are required. It will then determine the type of images and do the correct conversion Examples: See unit test :param output_file: file path to the o...
python
def dicom_to_nifti(dicom_input, output_file=None): """ This is the main dicom to nifti conversion fuction for philips images. As input philips images are required. It will then determine the type of images and do the correct conversion Examples: See unit test :param output_file: file path to the o...
[ "def", "dicom_to_nifti", "(", "dicom_input", ",", "output_file", "=", "None", ")", ":", "assert", "common", ".", "is_philips", "(", "dicom_input", ")", "if", "common", ".", "is_multiframe_dicom", "(", "dicom_input", ")", ":", "_assert_explicit_vr", "(", "dicom_i...
This is the main dicom to nifti conversion fuction for philips images. As input philips images are required. It will then determine the type of images and do the correct conversion Examples: See unit test :param output_file: file path to the output nifti :param dicom_input: directory with dicom files ...
[ "This", "is", "the", "main", "dicom", "to", "nifti", "conversion", "fuction", "for", "philips", "images", ".", "As", "input", "philips", "images", "are", "required", ".", "It", "will", "then", "determine", "the", "type", "of", "images", "and", "do", "the",...
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_philips.py#L31-L62
758
icometrix/dicom2nifti
dicom2nifti/convert_philips.py
_assert_explicit_vr
def _assert_explicit_vr(dicom_input): """ Assert that explicit vr is used """ if settings.validate_multiframe_implicit: header = dicom_input[0] if header.file_meta[0x0002, 0x0010].value == '1.2.840.10008.1.2': raise ConversionError('IMPLICIT_VR_ENHANCED_DICOM')
python
def _assert_explicit_vr(dicom_input): """ Assert that explicit vr is used """ if settings.validate_multiframe_implicit: header = dicom_input[0] if header.file_meta[0x0002, 0x0010].value == '1.2.840.10008.1.2': raise ConversionError('IMPLICIT_VR_ENHANCED_DICOM')
[ "def", "_assert_explicit_vr", "(", "dicom_input", ")", ":", "if", "settings", ".", "validate_multiframe_implicit", ":", "header", "=", "dicom_input", "[", "0", "]", "if", "header", ".", "file_meta", "[", "0x0002", ",", "0x0010", "]", ".", "value", "==", "'1....
Assert that explicit vr is used
[ "Assert", "that", "explicit", "vr", "is", "used" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_philips.py#L65-L72
759
icometrix/dicom2nifti
dicom2nifti/convert_philips.py
_is_multiframe_4d
def _is_multiframe_4d(dicom_input): """ Use this function to detect if a dicom series is a philips multiframe 4D dataset """ # check if it is multi frame dicom if not common.is_multiframe_dicom(dicom_input): return False header = dicom_input[0] # check if there are multiple stacks ...
python
def _is_multiframe_4d(dicom_input): """ Use this function to detect if a dicom series is a philips multiframe 4D dataset """ # check if it is multi frame dicom if not common.is_multiframe_dicom(dicom_input): return False header = dicom_input[0] # check if there are multiple stacks ...
[ "def", "_is_multiframe_4d", "(", "dicom_input", ")", ":", "# check if it is multi frame dicom", "if", "not", "common", ".", "is_multiframe_dicom", "(", "dicom_input", ")", ":", "return", "False", "header", "=", "dicom_input", "[", "0", "]", "# check if there are multi...
Use this function to detect if a dicom series is a philips multiframe 4D dataset
[ "Use", "this", "function", "to", "detect", "if", "a", "dicom", "series", "is", "a", "philips", "multiframe", "4D", "dataset" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_philips.py#L98-L114
760
icometrix/dicom2nifti
dicom2nifti/convert_philips.py
_is_singleframe_4d
def _is_singleframe_4d(dicom_input): """ Use this function to detect if a dicom series is a philips singleframe 4D dataset """ header = dicom_input[0] # check if there are stack information slice_number_mr_tag = Tag(0x2001, 0x100a) if slice_number_mr_tag not in header: return False ...
python
def _is_singleframe_4d(dicom_input): """ Use this function to detect if a dicom series is a philips singleframe 4D dataset """ header = dicom_input[0] # check if there are stack information slice_number_mr_tag = Tag(0x2001, 0x100a) if slice_number_mr_tag not in header: return False ...
[ "def", "_is_singleframe_4d", "(", "dicom_input", ")", ":", "header", "=", "dicom_input", "[", "0", "]", "# check if there are stack information", "slice_number_mr_tag", "=", "Tag", "(", "0x2001", ",", "0x100a", ")", "if", "slice_number_mr_tag", "not", "in", "header"...
Use this function to detect if a dicom series is a philips singleframe 4D dataset
[ "Use", "this", "function", "to", "detect", "if", "a", "dicom", "series", "is", "a", "philips", "singleframe", "4D", "dataset" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_philips.py#L139-L155
761
icometrix/dicom2nifti
dicom2nifti/convert_philips.py
_is_bval_type_a
def _is_bval_type_a(grouped_dicoms): """ Check if the bvals are stored in the first of 2 currently known ways for single frame dti """ bval_tag = Tag(0x2001, 0x1003) bvec_x_tag = Tag(0x2005, 0x10b0) bvec_y_tag = Tag(0x2005, 0x10b1) bvec_z_tag = Tag(0x2005, 0x10b2) for group in grouped_di...
python
def _is_bval_type_a(grouped_dicoms): """ Check if the bvals are stored in the first of 2 currently known ways for single frame dti """ bval_tag = Tag(0x2001, 0x1003) bvec_x_tag = Tag(0x2005, 0x10b0) bvec_y_tag = Tag(0x2005, 0x10b1) bvec_z_tag = Tag(0x2005, 0x10b2) for group in grouped_di...
[ "def", "_is_bval_type_a", "(", "grouped_dicoms", ")", ":", "bval_tag", "=", "Tag", "(", "0x2001", ",", "0x1003", ")", "bvec_x_tag", "=", "Tag", "(", "0x2005", ",", "0x10b0", ")", "bvec_y_tag", "=", "Tag", "(", "0x2005", ",", "0x10b1", ")", "bvec_z_tag", ...
Check if the bvals are stored in the first of 2 currently known ways for single frame dti
[ "Check", "if", "the", "bvals", "are", "stored", "in", "the", "first", "of", "2", "currently", "known", "ways", "for", "single", "frame", "dti" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_philips.py#L172-L187
762
icometrix/dicom2nifti
dicom2nifti/convert_philips.py
_is_bval_type_b
def _is_bval_type_b(grouped_dicoms): """ Check if the bvals are stored in the second of 2 currently known ways for single frame dti """ bval_tag = Tag(0x0018, 0x9087) bvec_tag = Tag(0x0018, 0x9089) for group in grouped_dicoms: if bvec_tag in group[0] and bval_tag in group[0]: ...
python
def _is_bval_type_b(grouped_dicoms): """ Check if the bvals are stored in the second of 2 currently known ways for single frame dti """ bval_tag = Tag(0x0018, 0x9087) bvec_tag = Tag(0x0018, 0x9089) for group in grouped_dicoms: if bvec_tag in group[0] and bval_tag in group[0]: ...
[ "def", "_is_bval_type_b", "(", "grouped_dicoms", ")", ":", "bval_tag", "=", "Tag", "(", "0x0018", ",", "0x9087", ")", "bvec_tag", "=", "Tag", "(", "0x0018", ",", "0x9089", ")", "for", "group", "in", "grouped_dicoms", ":", "if", "bvec_tag", "in", "group", ...
Check if the bvals are stored in the second of 2 currently known ways for single frame dti
[ "Check", "if", "the", "bvals", "are", "stored", "in", "the", "second", "of", "2", "currently", "known", "ways", "for", "single", "frame", "dti" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_philips.py#L190-L202
763
icometrix/dicom2nifti
dicom2nifti/convert_philips.py
_multiframe_to_nifti
def _multiframe_to_nifti(dicom_input, output_file): """ This function will convert philips 4D or anatomical multiframe series to a nifti """ # Read the multiframe dicom file logger.info('Read dicom file') multiframe_dicom = dicom_input[0] # Create mosaic block logger.info('Creating dat...
python
def _multiframe_to_nifti(dicom_input, output_file): """ This function will convert philips 4D or anatomical multiframe series to a nifti """ # Read the multiframe dicom file logger.info('Read dicom file') multiframe_dicom = dicom_input[0] # Create mosaic block logger.info('Creating dat...
[ "def", "_multiframe_to_nifti", "(", "dicom_input", ",", "output_file", ")", ":", "# Read the multiframe dicom file", "logger", ".", "info", "(", "'Read dicom file'", ")", "multiframe_dicom", "=", "dicom_input", "[", "0", "]", "# Create mosaic block", "logger", ".", "i...
This function will convert philips 4D or anatomical multiframe series to a nifti
[ "This", "function", "will", "convert", "philips", "4D", "or", "anatomical", "multiframe", "series", "to", "a", "nifti" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_philips.py#L216-L268
764
icometrix/dicom2nifti
dicom2nifti/convert_philips.py
_singleframe_to_nifti
def _singleframe_to_nifti(grouped_dicoms, output_file): """ This function will convert a philips singleframe series to a nifti """ # Create mosaic block logger.info('Creating data block') full_block = _singleframe_to_block(grouped_dicoms) logger.info('Creating affine') # Create the nif...
python
def _singleframe_to_nifti(grouped_dicoms, output_file): """ This function will convert a philips singleframe series to a nifti """ # Create mosaic block logger.info('Creating data block') full_block = _singleframe_to_block(grouped_dicoms) logger.info('Creating affine') # Create the nif...
[ "def", "_singleframe_to_nifti", "(", "grouped_dicoms", ",", "output_file", ")", ":", "# Create mosaic block", "logger", ".", "info", "(", "'Creating data block'", ")", "full_block", "=", "_singleframe_to_block", "(", "grouped_dicoms", ")", "logger", ".", "info", "(", ...
This function will convert a philips singleframe series to a nifti
[ "This", "function", "will", "convert", "a", "philips", "singleframe", "series", "to", "a", "nifti" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_philips.py#L271-L322
765
icometrix/dicom2nifti
dicom2nifti/convert_philips.py
_create_affine_multiframe
def _create_affine_multiframe(multiframe_dicom): """ Function to create the affine matrix for a siemens mosaic dataset This will work for siemens dti and 4D if in mosaic format """ first_frame = multiframe_dicom[Tag(0x5200, 0x9230)][0] last_frame = multiframe_dicom[Tag(0x5200, 0x9230)][-1] #...
python
def _create_affine_multiframe(multiframe_dicom): """ Function to create the affine matrix for a siemens mosaic dataset This will work for siemens dti and 4D if in mosaic format """ first_frame = multiframe_dicom[Tag(0x5200, 0x9230)][0] last_frame = multiframe_dicom[Tag(0x5200, 0x9230)][-1] #...
[ "def", "_create_affine_multiframe", "(", "multiframe_dicom", ")", ":", "first_frame", "=", "multiframe_dicom", "[", "Tag", "(", "0x5200", ",", "0x9230", ")", "]", "[", "0", "]", "last_frame", "=", "multiframe_dicom", "[", "Tag", "(", "0x5200", ",", "0x9230", ...
Function to create the affine matrix for a siemens mosaic dataset This will work for siemens dti and 4D if in mosaic format
[ "Function", "to", "create", "the", "affine", "matrix", "for", "a", "siemens", "mosaic", "dataset", "This", "will", "work", "for", "siemens", "dti", "and", "4D", "if", "in", "mosaic", "format" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_philips.py#L393-L419
766
icometrix/dicom2nifti
dicom2nifti/convert_philips.py
_multiframe_to_block
def _multiframe_to_block(multiframe_dicom): """ Generate a full datablock containing all stacks """ # Calculate the amount of stacks and slices in the stack number_of_stack_slices = int(common.get_ss_value(multiframe_dicom[Tag(0x2001, 0x105f)][0][Tag(0x2001, 0x102d)])) number_of_stacks = int(int...
python
def _multiframe_to_block(multiframe_dicom): """ Generate a full datablock containing all stacks """ # Calculate the amount of stacks and slices in the stack number_of_stack_slices = int(common.get_ss_value(multiframe_dicom[Tag(0x2001, 0x105f)][0][Tag(0x2001, 0x102d)])) number_of_stacks = int(int...
[ "def", "_multiframe_to_block", "(", "multiframe_dicom", ")", ":", "# Calculate the amount of stacks and slices in the stack", "number_of_stack_slices", "=", "int", "(", "common", ".", "get_ss_value", "(", "multiframe_dicom", "[", "Tag", "(", "0x2001", ",", "0x105f", ")", ...
Generate a full datablock containing all stacks
[ "Generate", "a", "full", "datablock", "containing", "all", "stacks" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_philips.py#L422-L473
767
icometrix/dicom2nifti
dicom2nifti/convert_philips.py
_fix_diffusion_images
def _fix_diffusion_images(bvals, bvecs, nifti, nifti_file): """ This function will remove the last timepoint from the nifti, bvals and bvecs if the last vector is 0,0,0 This is sometimes added at the end by philips """ # if all zero continue of if the last bvec is not all zero continue if numpy....
python
def _fix_diffusion_images(bvals, bvecs, nifti, nifti_file): """ This function will remove the last timepoint from the nifti, bvals and bvecs if the last vector is 0,0,0 This is sometimes added at the end by philips """ # if all zero continue of if the last bvec is not all zero continue if numpy....
[ "def", "_fix_diffusion_images", "(", "bvals", ",", "bvecs", ",", "nifti", ",", "nifti_file", ")", ":", "# if all zero continue of if the last bvec is not all zero continue", "if", "numpy", ".", "count_nonzero", "(", "bvecs", ")", "==", "0", "or", "not", "numpy", "."...
This function will remove the last timepoint from the nifti, bvals and bvecs if the last vector is 0,0,0 This is sometimes added at the end by philips
[ "This", "function", "will", "remove", "the", "last", "timepoint", "from", "the", "nifti", "bvals", "and", "bvecs", "if", "the", "last", "vector", "is", "0", "0", "0", "This", "is", "sometimes", "added", "at", "the", "end", "by", "philips" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_philips.py#L548-L565
768
icometrix/dicom2nifti
dicom2nifti/convert_generic.py
dicom_to_nifti
def dicom_to_nifti(dicom_input, output_file): """ This function will convert an anatomical dicom series to a nifti Examples: See unit test :param output_file: filepath to the output nifti :param dicom_input: directory with the dicom files for a single scan, or list of read in dicoms """ if...
python
def dicom_to_nifti(dicom_input, output_file): """ This function will convert an anatomical dicom series to a nifti Examples: See unit test :param output_file: filepath to the output nifti :param dicom_input: directory with the dicom files for a single scan, or list of read in dicoms """ if...
[ "def", "dicom_to_nifti", "(", "dicom_input", ",", "output_file", ")", ":", "if", "len", "(", "dicom_input", ")", "<=", "0", ":", "raise", "ConversionError", "(", "'NO_DICOM_FILES_FOUND'", ")", "# remove duplicate slices based on position and data", "dicom_input", "=", ...
This function will convert an anatomical dicom series to a nifti Examples: See unit test :param output_file: filepath to the output nifti :param dicom_input: directory with the dicom files for a single scan, or list of read in dicoms
[ "This", "function", "will", "convert", "an", "anatomical", "dicom", "series", "to", "a", "nifti" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_generic.py#L29-L94
769
icometrix/dicom2nifti
dicom2nifti/convert_generic.py
_convert_slice_incement_inconsistencies
def _convert_slice_incement_inconsistencies(dicom_input): """ If there is slice increment inconsistency detected, for the moment CT images, then split the volumes into subvolumes based on the slice increment and process each volume separately using a space constructed based on the highest resolution increment ...
python
def _convert_slice_incement_inconsistencies(dicom_input): """ If there is slice increment inconsistency detected, for the moment CT images, then split the volumes into subvolumes based on the slice increment and process each volume separately using a space constructed based on the highest resolution increment ...
[ "def", "_convert_slice_incement_inconsistencies", "(", "dicom_input", ")", ":", "# Estimate the \"first\" slice increment based on the 2 first slices", "increment", "=", "numpy", ".", "array", "(", "dicom_input", "[", "0", "]", ".", "ImagePositionPatient", ")", "-", "nump...
If there is slice increment inconsistency detected, for the moment CT images, then split the volumes into subvolumes based on the slice increment and process each volume separately using a space constructed based on the highest resolution increment
[ "If", "there", "is", "slice", "increment", "inconsistency", "detected", "for", "the", "moment", "CT", "images", "then", "split", "the", "volumes", "into", "subvolumes", "based", "on", "the", "slice", "increment", "and", "process", "each", "volume", "separately",...
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_generic.py#L174-L209
770
icometrix/dicom2nifti
dicom2nifti/common.py
is_hitachi
def is_hitachi(dicom_input): """ Use this function to detect if a dicom series is a hitachi dataset :param dicom_input: directory with dicom files for 1 scan of a dicom_header """ # read dicom header header = dicom_input[0] if 'Manufacturer' not in header or 'Modality' not in header: ...
python
def is_hitachi(dicom_input): """ Use this function to detect if a dicom series is a hitachi dataset :param dicom_input: directory with dicom files for 1 scan of a dicom_header """ # read dicom header header = dicom_input[0] if 'Manufacturer' not in header or 'Modality' not in header: ...
[ "def", "is_hitachi", "(", "dicom_input", ")", ":", "# read dicom header", "header", "=", "dicom_input", "[", "0", "]", "if", "'Manufacturer'", "not", "in", "header", "or", "'Modality'", "not", "in", "header", ":", "return", "False", "# we try generic conversion in...
Use this function to detect if a dicom series is a hitachi dataset :param dicom_input: directory with dicom files for 1 scan of a dicom_header
[ "Use", "this", "function", "to", "detect", "if", "a", "dicom", "series", "is", "a", "hitachi", "dataset" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/common.py#L57-L77
771
icometrix/dicom2nifti
dicom2nifti/common.py
is_ge
def is_ge(dicom_input): """ Use this function to detect if a dicom series is a GE dataset :param dicom_input: list with dicom objects """ # read dicom header header = dicom_input[0] if 'Manufacturer' not in header or 'Modality' not in header: return False # we try generic conversi...
python
def is_ge(dicom_input): """ Use this function to detect if a dicom series is a GE dataset :param dicom_input: list with dicom objects """ # read dicom header header = dicom_input[0] if 'Manufacturer' not in header or 'Modality' not in header: return False # we try generic conversi...
[ "def", "is_ge", "(", "dicom_input", ")", ":", "# read dicom header", "header", "=", "dicom_input", "[", "0", "]", "if", "'Manufacturer'", "not", "in", "header", "or", "'Modality'", "not", "in", "header", ":", "return", "False", "# we try generic conversion in thes...
Use this function to detect if a dicom series is a GE dataset :param dicom_input: list with dicom objects
[ "Use", "this", "function", "to", "detect", "if", "a", "dicom", "series", "is", "a", "GE", "dataset" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/common.py#L80-L100
772
icometrix/dicom2nifti
dicom2nifti/common.py
is_philips
def is_philips(dicom_input): """ Use this function to detect if a dicom series is a philips dataset :param dicom_input: directory with dicom files for 1 scan of a dicom_header """ # read dicom header header = dicom_input[0] if 'Manufacturer' not in header or 'Modality' not in header: ...
python
def is_philips(dicom_input): """ Use this function to detect if a dicom series is a philips dataset :param dicom_input: directory with dicom files for 1 scan of a dicom_header """ # read dicom header header = dicom_input[0] if 'Manufacturer' not in header or 'Modality' not in header: ...
[ "def", "is_philips", "(", "dicom_input", ")", ":", "# read dicom header", "header", "=", "dicom_input", "[", "0", "]", "if", "'Manufacturer'", "not", "in", "header", "or", "'Modality'", "not", "in", "header", ":", "return", "False", "# we try generic conversion in...
Use this function to detect if a dicom series is a philips dataset :param dicom_input: directory with dicom files for 1 scan of a dicom_header
[ "Use", "this", "function", "to", "detect", "if", "a", "dicom", "series", "is", "a", "philips", "dataset" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/common.py#L103-L123
773
icometrix/dicom2nifti
dicom2nifti/common.py
is_siemens
def is_siemens(dicom_input): """ Use this function to detect if a dicom series is a siemens dataset :param dicom_input: directory with dicom files for 1 scan """ # read dicom header header = dicom_input[0] # check if manufacturer is Siemens if 'Manufacturer' not in header or 'Modality'...
python
def is_siemens(dicom_input): """ Use this function to detect if a dicom series is a siemens dataset :param dicom_input: directory with dicom files for 1 scan """ # read dicom header header = dicom_input[0] # check if manufacturer is Siemens if 'Manufacturer' not in header or 'Modality'...
[ "def", "is_siemens", "(", "dicom_input", ")", ":", "# read dicom header", "header", "=", "dicom_input", "[", "0", "]", "# check if manufacturer is Siemens", "if", "'Manufacturer'", "not", "in", "header", "or", "'Modality'", "not", "in", "header", ":", "return", "F...
Use this function to detect if a dicom series is a siemens dataset :param dicom_input: directory with dicom files for 1 scan
[ "Use", "this", "function", "to", "detect", "if", "a", "dicom", "series", "is", "a", "siemens", "dataset" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/common.py#L126-L146
774
icometrix/dicom2nifti
dicom2nifti/common.py
_get_slice_pixeldata
def _get_slice_pixeldata(dicom_slice): """ the slice and intercept calculation can cause the slices to have different dtypes we should get the correct dtype that can cover all of them :type dicom_slice: pydicom object :param dicom_slice: slice to get the pixeldata for """ data = dicom_slice...
python
def _get_slice_pixeldata(dicom_slice): """ the slice and intercept calculation can cause the slices to have different dtypes we should get the correct dtype that can cover all of them :type dicom_slice: pydicom object :param dicom_slice: slice to get the pixeldata for """ data = dicom_slice...
[ "def", "_get_slice_pixeldata", "(", "dicom_slice", ")", ":", "data", "=", "dicom_slice", ".", "pixel_array", "# fix overflow issues for signed data where BitsStored is lower than BitsAllocated and PixelReprentation = 1 (signed)", "# for example a hitachi mri scan can have BitsAllocated 16 bu...
the slice and intercept calculation can cause the slices to have different dtypes we should get the correct dtype that can cover all of them :type dicom_slice: pydicom object :param dicom_slice: slice to get the pixeldata for
[ "the", "slice", "and", "intercept", "calculation", "can", "cause", "the", "slices", "to", "have", "different", "dtypes", "we", "should", "get", "the", "correct", "dtype", "that", "can", "cover", "all", "of", "them" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/common.py#L225-L245
775
icometrix/dicom2nifti
dicom2nifti/common.py
set_fd_value
def set_fd_value(tag, value): """ Setters for data that also work with implicit transfersyntax :param value: the value to set on the tag :param tag: the tag to read """ if tag.VR == 'OB' or tag.VR == 'UN': value = struct.pack('d', value) tag.value = value
python
def set_fd_value(tag, value): """ Setters for data that also work with implicit transfersyntax :param value: the value to set on the tag :param tag: the tag to read """ if tag.VR == 'OB' or tag.VR == 'UN': value = struct.pack('d', value) tag.value = value
[ "def", "set_fd_value", "(", "tag", ",", "value", ")", ":", "if", "tag", ".", "VR", "==", "'OB'", "or", "tag", ".", "VR", "==", "'UN'", ":", "value", "=", "struct", ".", "pack", "(", "'d'", ",", "value", ")", "tag", ".", "value", "=", "value" ]
Setters for data that also work with implicit transfersyntax :param value: the value to set on the tag :param tag: the tag to read
[ "Setters", "for", "data", "that", "also", "work", "with", "implicit", "transfersyntax" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/common.py#L309-L318
776
icometrix/dicom2nifti
dicom2nifti/common.py
set_ss_value
def set_ss_value(tag, value): """ Setter for data that also work with implicit transfersyntax :param value: the value to set on the tag :param tag: the tag to read """ if tag.VR == 'OB' or tag.VR == 'UN': value = struct.pack('h', value) tag.value = value
python
def set_ss_value(tag, value): """ Setter for data that also work with implicit transfersyntax :param value: the value to set on the tag :param tag: the tag to read """ if tag.VR == 'OB' or tag.VR == 'UN': value = struct.pack('h', value) tag.value = value
[ "def", "set_ss_value", "(", "tag", ",", "value", ")", ":", "if", "tag", ".", "VR", "==", "'OB'", "or", "tag", ".", "VR", "==", "'UN'", ":", "value", "=", "struct", ".", "pack", "(", "'h'", ",", "value", ")", "tag", ".", "value", "=", "value" ]
Setter for data that also work with implicit transfersyntax :param value: the value to set on the tag :param tag: the tag to read
[ "Setter", "for", "data", "that", "also", "work", "with", "implicit", "transfersyntax" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/common.py#L359-L368
777
icometrix/dicom2nifti
dicom2nifti/common.py
apply_scaling
def apply_scaling(data, dicom_headers): """ Rescale the data based on the RescaleSlope and RescaleOffset Based on the scaling from pydicomseries :param dicom_headers: dicom headers to use to retreive the scaling factors :param data: the input data """ # Apply the rescaling if needed pr...
python
def apply_scaling(data, dicom_headers): """ Rescale the data based on the RescaleSlope and RescaleOffset Based on the scaling from pydicomseries :param dicom_headers: dicom headers to use to retreive the scaling factors :param data: the input data """ # Apply the rescaling if needed pr...
[ "def", "apply_scaling", "(", "data", ",", "dicom_headers", ")", ":", "# Apply the rescaling if needed", "private_scale_slope_tag", "=", "Tag", "(", "0x2005", ",", "0x100E", ")", "private_scale_intercept_tag", "=", "Tag", "(", "0x2005", ",", "0x100D", ")", "if", "'...
Rescale the data based on the RescaleSlope and RescaleOffset Based on the scaling from pydicomseries :param dicom_headers: dicom headers to use to retreive the scaling factors :param data: the input data
[ "Rescale", "the", "data", "based", "on", "the", "RescaleSlope", "and", "RescaleOffset", "Based", "on", "the", "scaling", "from", "pydicomseries" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/common.py#L371-L401
778
icometrix/dicom2nifti
dicom2nifti/common.py
write_bvec_file
def write_bvec_file(bvecs, bvec_file): """ Write an array of bvecs to a bvec file :param bvecs: array with the vectors :param bvec_file: filepath to write to """ if bvec_file is None: return logger.info('Saving BVEC file: %s' % bvec_file) with open(bvec_file, 'w') as text_file: ...
python
def write_bvec_file(bvecs, bvec_file): """ Write an array of bvecs to a bvec file :param bvecs: array with the vectors :param bvec_file: filepath to write to """ if bvec_file is None: return logger.info('Saving BVEC file: %s' % bvec_file) with open(bvec_file, 'w') as text_file: ...
[ "def", "write_bvec_file", "(", "bvecs", ",", "bvec_file", ")", ":", "if", "bvec_file", "is", "None", ":", "return", "logger", ".", "info", "(", "'Saving BVEC file: %s'", "%", "bvec_file", ")", "with", "open", "(", "bvec_file", ",", "'w'", ")", "as", "text_...
Write an array of bvecs to a bvec file :param bvecs: array with the vectors :param bvec_file: filepath to write to
[ "Write", "an", "array", "of", "bvecs", "to", "a", "bvec", "file" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/common.py#L478-L492
779
icometrix/dicom2nifti
dicom2nifti/common.py
write_bval_file
def write_bval_file(bvals, bval_file): """ Write an array of bvals to a bval file :param bvals: array with the values :param bval_file: filepath to write to """ if bval_file is None: return logger.info('Saving BVAL file: %s' % bval_file) with open(bval_file, 'w') as text_file: ...
python
def write_bval_file(bvals, bval_file): """ Write an array of bvals to a bval file :param bvals: array with the values :param bval_file: filepath to write to """ if bval_file is None: return logger.info('Saving BVAL file: %s' % bval_file) with open(bval_file, 'w') as text_file: ...
[ "def", "write_bval_file", "(", "bvals", ",", "bval_file", ")", ":", "if", "bval_file", "is", "None", ":", "return", "logger", ".", "info", "(", "'Saving BVAL file: %s'", "%", "bval_file", ")", "with", "open", "(", "bval_file", ",", "'w'", ")", "as", "text_...
Write an array of bvals to a bval file :param bvals: array with the values :param bval_file: filepath to write to
[ "Write", "an", "array", "of", "bvals", "to", "a", "bval", "file" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/common.py#L495-L507
780
icometrix/dicom2nifti
dicom2nifti/common.py
sort_dicoms
def sort_dicoms(dicoms): """ Sort the dicoms based om the image possition patient :param dicoms: list of dicoms """ # find most significant axis to use during sorting # the original way of sorting (first x than y than z) does not work in certain border situations # where for exampe the X wi...
python
def sort_dicoms(dicoms): """ Sort the dicoms based om the image possition patient :param dicoms: list of dicoms """ # find most significant axis to use during sorting # the original way of sorting (first x than y than z) does not work in certain border situations # where for exampe the X wi...
[ "def", "sort_dicoms", "(", "dicoms", ")", ":", "# find most significant axis to use during sorting", "# the original way of sorting (first x than y than z) does not work in certain border situations", "# where for exampe the X will only slightly change causing the values to remain equal on multiple ...
Sort the dicoms based om the image possition patient :param dicoms: list of dicoms
[ "Sort", "the", "dicoms", "based", "om", "the", "image", "possition", "patient" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/common.py#L614-L635
781
icometrix/dicom2nifti
dicom2nifti/common.py
validate_orientation
def validate_orientation(dicoms): """ Validate that all dicoms have the same orientation :param dicoms: list of dicoms """ first_image_orient1 = numpy.array(dicoms[0].ImageOrientationPatient)[0:3] first_image_orient2 = numpy.array(dicoms[0].ImageOrientationPatient)[3:6] for dicom_ in dicoms...
python
def validate_orientation(dicoms): """ Validate that all dicoms have the same orientation :param dicoms: list of dicoms """ first_image_orient1 = numpy.array(dicoms[0].ImageOrientationPatient)[0:3] first_image_orient2 = numpy.array(dicoms[0].ImageOrientationPatient)[3:6] for dicom_ in dicoms...
[ "def", "validate_orientation", "(", "dicoms", ")", ":", "first_image_orient1", "=", "numpy", ".", "array", "(", "dicoms", "[", "0", "]", ".", "ImageOrientationPatient", ")", "[", "0", ":", "3", "]", "first_image_orient2", "=", "numpy", ".", "array", "(", "...
Validate that all dicoms have the same orientation :param dicoms: list of dicoms
[ "Validate", "that", "all", "dicoms", "have", "the", "same", "orientation" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/common.py#L696-L715
782
icometrix/dicom2nifti
dicom2nifti/common.py
set_tr_te
def set_tr_te(nifti_image, repetition_time, echo_time): """ Set the tr and te in the nifti headers :param echo_time: echo time :param repetition_time: repetition time :param nifti_image: nifti image to set the info to """ # set the repetition time in pixdim nifti_image.header.structarr[...
python
def set_tr_te(nifti_image, repetition_time, echo_time): """ Set the tr and te in the nifti headers :param echo_time: echo time :param repetition_time: repetition time :param nifti_image: nifti image to set the info to """ # set the repetition time in pixdim nifti_image.header.structarr[...
[ "def", "set_tr_te", "(", "nifti_image", ",", "repetition_time", ",", "echo_time", ")", ":", "# set the repetition time in pixdim", "nifti_image", ".", "header", ".", "structarr", "[", "'pixdim'", "]", "[", "4", "]", "=", "repetition_time", "/", "1000.0", "# set tr...
Set the tr and te in the nifti headers :param echo_time: echo time :param repetition_time: repetition time :param nifti_image: nifti image to set the info to
[ "Set", "the", "tr", "and", "te", "in", "the", "nifti", "headers" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/common.py#L718-L732
783
icometrix/dicom2nifti
dicom2nifti/convert_ge.py
dicom_to_nifti
def dicom_to_nifti(dicom_input, output_file=None): """ This is the main dicom to nifti conversion fuction for ge images. As input ge images are required. It will then determine the type of images and do the correct conversion Examples: See unit test :param output_file: the filepath to the output n...
python
def dicom_to_nifti(dicom_input, output_file=None): """ This is the main dicom to nifti conversion fuction for ge images. As input ge images are required. It will then determine the type of images and do the correct conversion Examples: See unit test :param output_file: the filepath to the output n...
[ "def", "dicom_to_nifti", "(", "dicom_input", ",", "output_file", "=", "None", ")", ":", "assert", "common", ".", "is_ge", "(", "dicom_input", ")", "logger", ".", "info", "(", "'Reading and sorting dicom files'", ")", "grouped_dicoms", "=", "_get_grouped_dicoms", "...
This is the main dicom to nifti conversion fuction for ge images. As input ge images are required. It will then determine the type of images and do the correct conversion Examples: See unit test :param output_file: the filepath to the output nifti file :param dicom_input: list with dicom objects
[ "This", "is", "the", "main", "dicom", "to", "nifti", "conversion", "fuction", "for", "ge", "images", ".", "As", "input", "ge", "images", "are", "required", ".", "It", "will", "then", "determine", "the", "type", "of", "images", "and", "do", "the", "correc...
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_ge.py#L32-L52
784
icometrix/dicom2nifti
dicom2nifti/convert_ge.py
_4d_to_nifti
def _4d_to_nifti(grouped_dicoms, output_file): """ This function will convert ge 4d series to a nifti """ # Create mosaic block logger.info('Creating data block') full_block = _get_full_block(grouped_dicoms) logger.info('Creating affine') # Create the nifti header info affine, slic...
python
def _4d_to_nifti(grouped_dicoms, output_file): """ This function will convert ge 4d series to a nifti """ # Create mosaic block logger.info('Creating data block') full_block = _get_full_block(grouped_dicoms) logger.info('Creating affine') # Create the nifti header info affine, slic...
[ "def", "_4d_to_nifti", "(", "grouped_dicoms", ",", "output_file", ")", ":", "# Create mosaic block", "logger", ".", "info", "(", "'Creating data block'", ")", "full_block", "=", "_get_full_block", "(", "grouped_dicoms", ")", "logger", ".", "info", "(", "'Creating af...
This function will convert ge 4d series to a nifti
[ "This", "function", "will", "convert", "ge", "4d", "series", "to", "a", "nifti" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_ge.py#L91-L136
785
icometrix/dicom2nifti
dicom2nifti/convert_hitachi.py
dicom_to_nifti
def dicom_to_nifti(dicom_input, output_file=None): """ This is the main dicom to nifti conversion fuction for hitachi images. As input hitachi images are required. It will then determine the type of images and do the correct conversion Examples: See unit test :param output_file: file path to the o...
python
def dicom_to_nifti(dicom_input, output_file=None): """ This is the main dicom to nifti conversion fuction for hitachi images. As input hitachi images are required. It will then determine the type of images and do the correct conversion Examples: See unit test :param output_file: file path to the o...
[ "def", "dicom_to_nifti", "(", "dicom_input", ",", "output_file", "=", "None", ")", ":", "assert", "common", ".", "is_hitachi", "(", "dicom_input", ")", "# TODO add validations and conversion for DTI and fMRI once testdata is available", "logger", ".", "info", "(", "'Assum...
This is the main dicom to nifti conversion fuction for hitachi images. As input hitachi images are required. It will then determine the type of images and do the correct conversion Examples: See unit test :param output_file: file path to the output nifti :param dicom_input: directory with dicom files ...
[ "This", "is", "the", "main", "dicom", "to", "nifti", "conversion", "fuction", "for", "hitachi", "images", ".", "As", "input", "hitachi", "images", "are", "required", ".", "It", "will", "then", "determine", "the", "type", "of", "images", "and", "do", "the",...
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_hitachi.py#L25-L41
786
icometrix/dicom2nifti
dicom2nifti/convert_siemens.py
dicom_to_nifti
def dicom_to_nifti(dicom_input, output_file=None): """ This is the main dicom to nifti conversion function for ge images. As input ge images are required. It will then determine the type of images and do the correct conversion :param output_file: filepath to the output nifti :param dicom_input: dir...
python
def dicom_to_nifti(dicom_input, output_file=None): """ This is the main dicom to nifti conversion function for ge images. As input ge images are required. It will then determine the type of images and do the correct conversion :param output_file: filepath to the output nifti :param dicom_input: dir...
[ "def", "dicom_to_nifti", "(", "dicom_input", ",", "output_file", "=", "None", ")", ":", "assert", "common", ".", "is_siemens", "(", "dicom_input", ")", "if", "_is_4d", "(", "dicom_input", ")", ":", "logger", ".", "info", "(", "'Found sequence type: MOSAIC 4D'", ...
This is the main dicom to nifti conversion function for ge images. As input ge images are required. It will then determine the type of images and do the correct conversion :param output_file: filepath to the output nifti :param dicom_input: directory with dicom files for 1 scan
[ "This", "is", "the", "main", "dicom", "to", "nifti", "conversion", "function", "for", "ge", "images", ".", "As", "input", "ge", "images", "are", "required", ".", "It", "will", "then", "determine", "the", "type", "of", "images", "and", "do", "the", "corre...
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_siemens.py#L45-L66
787
icometrix/dicom2nifti
dicom2nifti/convert_siemens.py
_get_sorted_mosaics
def _get_sorted_mosaics(dicom_input): """ Search all mosaics in the dicom directory, sort and validate them """ # Order all dicom files by acquisition number sorted_mosaics = sorted(dicom_input, key=lambda x: x.AcquisitionNumber) for index in range(0, len(sorted_mosaics) - 1): # Validat...
python
def _get_sorted_mosaics(dicom_input): """ Search all mosaics in the dicom directory, sort and validate them """ # Order all dicom files by acquisition number sorted_mosaics = sorted(dicom_input, key=lambda x: x.AcquisitionNumber) for index in range(0, len(sorted_mosaics) - 1): # Validat...
[ "def", "_get_sorted_mosaics", "(", "dicom_input", ")", ":", "# Order all dicom files by acquisition number", "sorted_mosaics", "=", "sorted", "(", "dicom_input", ",", "key", "=", "lambda", "x", ":", "x", ".", "AcquisitionNumber", ")", "for", "index", "in", "range", ...
Search all mosaics in the dicom directory, sort and validate them
[ "Search", "all", "mosaics", "in", "the", "dicom", "directory", "sort", "and", "validate", "them" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_siemens.py#L324-L336
788
icometrix/dicom2nifti
dicom2nifti/convert_siemens.py
_mosaic_to_block
def _mosaic_to_block(mosaic): """ Convert a mosaic slice to a block of data by reading the headers, splitting the mosaic and appending """ # get the mosaic type mosaic_type = _get_mosaic_type(mosaic) # get the size of one tile format is 64p*64 or 80*80 or something similar matches = re.find...
python
def _mosaic_to_block(mosaic): """ Convert a mosaic slice to a block of data by reading the headers, splitting the mosaic and appending """ # get the mosaic type mosaic_type = _get_mosaic_type(mosaic) # get the size of one tile format is 64p*64 or 80*80 or something similar matches = re.find...
[ "def", "_mosaic_to_block", "(", "mosaic", ")", ":", "# get the mosaic type", "mosaic_type", "=", "_get_mosaic_type", "(", "mosaic", ")", "# get the size of one tile format is 64p*64 or 80*80 or something similar", "matches", "=", "re", ".", "findall", "(", "r'(\\d+)\\D+(\\d+)...
Convert a mosaic slice to a block of data by reading the headers, splitting the mosaic and appending
[ "Convert", "a", "mosaic", "slice", "to", "a", "block", "of", "data", "by", "reading", "the", "headers", "splitting", "the", "mosaic", "and", "appending" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_siemens.py#L399-L440
789
icometrix/dicom2nifti
dicom2nifti/convert_siemens.py
_create_affine_siemens_mosaic
def _create_affine_siemens_mosaic(dicom_input): """ Function to create the affine matrix for a siemens mosaic dataset This will work for siemens dti and 4d if in mosaic format """ # read dicom series with pds dicom_header = dicom_input[0] # Create affine matrix (http://nipy.sourceforge.net/...
python
def _create_affine_siemens_mosaic(dicom_input): """ Function to create the affine matrix for a siemens mosaic dataset This will work for siemens dti and 4d if in mosaic format """ # read dicom series with pds dicom_header = dicom_input[0] # Create affine matrix (http://nipy.sourceforge.net/...
[ "def", "_create_affine_siemens_mosaic", "(", "dicom_input", ")", ":", "# read dicom series with pds", "dicom_header", "=", "dicom_input", "[", "0", "]", "# Create affine matrix (http://nipy.sourceforge.net/nibabel/dicom/dicom_orientation.html#dicom-slice-affine)", "image_orient1", "=",...
Function to create the affine matrix for a siemens mosaic dataset This will work for siemens dti and 4d if in mosaic format
[ "Function", "to", "create", "the", "affine", "matrix", "for", "a", "siemens", "mosaic", "dataset", "This", "will", "work", "for", "siemens", "dti", "and", "4d", "if", "in", "mosaic", "format" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_siemens.py#L443-L467
790
icometrix/dicom2nifti
dicom2nifti/resample.py
resample_single_nifti
def resample_single_nifti(input_nifti): """ Resample a gantry tilted image in place """ # read the input image input_image = nibabel.load(input_nifti) output_image = resample_nifti_images([input_image]) output_image.to_filename(input_nifti)
python
def resample_single_nifti(input_nifti): """ Resample a gantry tilted image in place """ # read the input image input_image = nibabel.load(input_nifti) output_image = resample_nifti_images([input_image]) output_image.to_filename(input_nifti)
[ "def", "resample_single_nifti", "(", "input_nifti", ")", ":", "# read the input image", "input_image", "=", "nibabel", ".", "load", "(", "input_nifti", ")", "output_image", "=", "resample_nifti_images", "(", "[", "input_image", "]", ")", "output_image", ".", "to_fil...
Resample a gantry tilted image in place
[ "Resample", "a", "gantry", "tilted", "image", "in", "place" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/resample.py#L15-L22
791
icometrix/dicom2nifti
dicom2nifti/convert_dir.py
convert_directory
def convert_directory(dicom_directory, output_folder, compression=True, reorient=True): """ This function will order all dicom files by series and order them one by one :param compression: enable or disable gzip compression :param reorient: reorient the dicoms according to LAS orientation :param ou...
python
def convert_directory(dicom_directory, output_folder, compression=True, reorient=True): """ This function will order all dicom files by series and order them one by one :param compression: enable or disable gzip compression :param reorient: reorient the dicoms according to LAS orientation :param ou...
[ "def", "convert_directory", "(", "dicom_directory", ",", "output_folder", ",", "compression", "=", "True", ",", "reorient", "=", "True", ")", ":", "# sort dicom files by series uid", "dicom_series", "=", "{", "}", "for", "root", ",", "_", ",", "files", "in", "...
This function will order all dicom files by series and order them one by one :param compression: enable or disable gzip compression :param reorient: reorient the dicoms according to LAS orientation :param output_folder: folder to write the nifti files to :param dicom_directory: directory with dicom fil...
[ "This", "function", "will", "order", "all", "dicom", "files", "by", "series", "and", "order", "them", "one", "by", "one" ]
1462ae5dd979fa3f276fe7a78ceb9b028121536f
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_dir.py#L34-L99
792
aegirhall/console-menu
consolemenu/menu_formatter.py
MenuFormatBuilder.clear_data
def clear_data(self): """ Clear menu data from previous menu generation. """ self.__header.title = None self.__header.subtitle = None self.__prologue.text = None self.__epilogue.text = None self.__items_section.items = None
python
def clear_data(self): """ Clear menu data from previous menu generation. """ self.__header.title = None self.__header.subtitle = None self.__prologue.text = None self.__epilogue.text = None self.__items_section.items = None
[ "def", "clear_data", "(", "self", ")", ":", "self", ".", "__header", ".", "title", "=", "None", "self", ".", "__header", ".", "subtitle", "=", "None", "self", ".", "__prologue", ".", "text", "=", "None", "self", ".", "__epilogue", ".", "text", "=", "...
Clear menu data from previous menu generation.
[ "Clear", "menu", "data", "from", "previous", "menu", "generation", "." ]
1a28959d6f1dd6ac79c87b11efd8529d05532422
https://github.com/aegirhall/console-menu/blob/1a28959d6f1dd6ac79c87b11efd8529d05532422/consolemenu/menu_formatter.py#L246-L254
793
aegirhall/console-menu
consolemenu/menu_component.py
MenuComponent.inner_horizontal_border
def inner_horizontal_border(self): """ The complete inner horizontal border section, including the left and right border verticals. Returns: str: The complete inner horizontal border. """ return u"{lm}{lv}{hz}{rv}".format(lm=' ' * self.margins.left, ...
python
def inner_horizontal_border(self): """ The complete inner horizontal border section, including the left and right border verticals. Returns: str: The complete inner horizontal border. """ return u"{lm}{lv}{hz}{rv}".format(lm=' ' * self.margins.left, ...
[ "def", "inner_horizontal_border", "(", "self", ")", ":", "return", "u\"{lm}{lv}{hz}{rv}\"", ".", "format", "(", "lm", "=", "' '", "*", "self", ".", "margins", ".", "left", ",", "lv", "=", "self", ".", "border_style", ".", "outer_vertical_inner_right", ",", "...
The complete inner horizontal border section, including the left and right border verticals. Returns: str: The complete inner horizontal border.
[ "The", "complete", "inner", "horizontal", "border", "section", "including", "the", "left", "and", "right", "border", "verticals", "." ]
1a28959d6f1dd6ac79c87b11efd8529d05532422
https://github.com/aegirhall/console-menu/blob/1a28959d6f1dd6ac79c87b11efd8529d05532422/consolemenu/menu_component.py#L123-L133
794
aegirhall/console-menu
consolemenu/menu_component.py
MenuComponent.outer_horizontal_border_bottom
def outer_horizontal_border_bottom(self): """ The complete outer bottom horizontal border section, including left and right margins. Returns: str: The bottom menu border. """ return u"{lm}{lv}{hz}{rv}".format(lm=' ' * self.margins.left, ...
python
def outer_horizontal_border_bottom(self): """ The complete outer bottom horizontal border section, including left and right margins. Returns: str: The bottom menu border. """ return u"{lm}{lv}{hz}{rv}".format(lm=' ' * self.margins.left, ...
[ "def", "outer_horizontal_border_bottom", "(", "self", ")", ":", "return", "u\"{lm}{lv}{hz}{rv}\"", ".", "format", "(", "lm", "=", "' '", "*", "self", ".", "margins", ".", "left", ",", "lv", "=", "self", ".", "border_style", ".", "bottom_left_corner", ",", "r...
The complete outer bottom horizontal border section, including left and right margins. Returns: str: The bottom menu border.
[ "The", "complete", "outer", "bottom", "horizontal", "border", "section", "including", "left", "and", "right", "margins", "." ]
1a28959d6f1dd6ac79c87b11efd8529d05532422
https://github.com/aegirhall/console-menu/blob/1a28959d6f1dd6ac79c87b11efd8529d05532422/consolemenu/menu_component.py#L145-L155
795
aegirhall/console-menu
consolemenu/menu_component.py
MenuComponent.outer_horizontal_border_top
def outer_horizontal_border_top(self): """ The complete outer top horizontal border section, including left and right margins. Returns: str: The top menu border. """ return u"{lm}{lv}{hz}{rv}".format(lm=' ' * self.margins.left, ...
python
def outer_horizontal_border_top(self): """ The complete outer top horizontal border section, including left and right margins. Returns: str: The top menu border. """ return u"{lm}{lv}{hz}{rv}".format(lm=' ' * self.margins.left, ...
[ "def", "outer_horizontal_border_top", "(", "self", ")", ":", "return", "u\"{lm}{lv}{hz}{rv}\"", ".", "format", "(", "lm", "=", "' '", "*", "self", ".", "margins", ".", "left", ",", "lv", "=", "self", ".", "border_style", ".", "top_left_corner", ",", "rv", ...
The complete outer top horizontal border section, including left and right margins. Returns: str: The top menu border.
[ "The", "complete", "outer", "top", "horizontal", "border", "section", "including", "left", "and", "right", "margins", "." ]
1a28959d6f1dd6ac79c87b11efd8529d05532422
https://github.com/aegirhall/console-menu/blob/1a28959d6f1dd6ac79c87b11efd8529d05532422/consolemenu/menu_component.py#L157-L167
796
aegirhall/console-menu
consolemenu/menu_component.py
MenuComponent.row
def row(self, content='', align='left'): """ A row of the menu, which comprises the left and right verticals plus the given content. Returns: str: A row of this menu component with the specified content. """ return u"{lm}{vert}{cont}{vert}".format(lm=' ' * self.margi...
python
def row(self, content='', align='left'): """ A row of the menu, which comprises the left and right verticals plus the given content. Returns: str: A row of this menu component with the specified content. """ return u"{lm}{vert}{cont}{vert}".format(lm=' ' * self.margi...
[ "def", "row", "(", "self", ",", "content", "=", "''", ",", "align", "=", "'left'", ")", ":", "return", "u\"{lm}{vert}{cont}{vert}\"", ".", "format", "(", "lm", "=", "' '", "*", "self", ".", "margins", ".", "left", ",", "vert", "=", "self", ".", "bord...
A row of the menu, which comprises the left and right verticals plus the given content. Returns: str: A row of this menu component with the specified content.
[ "A", "row", "of", "the", "menu", "which", "comprises", "the", "left", "and", "right", "verticals", "plus", "the", "given", "content", "." ]
1a28959d6f1dd6ac79c87b11efd8529d05532422
https://github.com/aegirhall/console-menu/blob/1a28959d6f1dd6ac79c87b11efd8529d05532422/consolemenu/menu_component.py#L169-L178
797
aegirhall/console-menu
consolemenu/format/menu_borders.py
MenuBorderStyleFactory.create_border
def create_border(self, border_style_type): """ Create a new MenuBorderStyle instance based on the given border style type. Args: border_style_type (int): an integer value from :obj:`MenuBorderStyleType`. Returns: :obj:`MenuBorderStyle`: a new MenuBorderStyle i...
python
def create_border(self, border_style_type): """ Create a new MenuBorderStyle instance based on the given border style type. Args: border_style_type (int): an integer value from :obj:`MenuBorderStyleType`. Returns: :obj:`MenuBorderStyle`: a new MenuBorderStyle i...
[ "def", "create_border", "(", "self", ",", "border_style_type", ")", ":", "if", "border_style_type", "==", "MenuBorderStyleType", ".", "ASCII_BORDER", ":", "return", "self", ".", "create_ascii_border", "(", ")", "elif", "border_style_type", "==", "MenuBorderStyleType",...
Create a new MenuBorderStyle instance based on the given border style type. Args: border_style_type (int): an integer value from :obj:`MenuBorderStyleType`. Returns: :obj:`MenuBorderStyle`: a new MenuBorderStyle instance of the specified style.
[ "Create", "a", "new", "MenuBorderStyle", "instance", "based", "on", "the", "given", "border", "style", "type", "." ]
1a28959d6f1dd6ac79c87b11efd8529d05532422
https://github.com/aegirhall/console-menu/blob/1a28959d6f1dd6ac79c87b11efd8529d05532422/consolemenu/format/menu_borders.py#L352-L378
798
aegirhall/console-menu
consolemenu/format/menu_borders.py
MenuBorderStyleFactory.is_win_python35_or_earlier
def is_win_python35_or_earlier(): """ Convenience method to determine if the current platform is Windows and Python version 3.5 or earlier. Returns: bool: True if the current platform is Windows and the Python interpreter is 3.5 or earlier; False otherwise. """ retu...
python
def is_win_python35_or_earlier(): """ Convenience method to determine if the current platform is Windows and Python version 3.5 or earlier. Returns: bool: True if the current platform is Windows and the Python interpreter is 3.5 or earlier; False otherwise. """ retu...
[ "def", "is_win_python35_or_earlier", "(", ")", ":", "return", "sys", ".", "platform", ".", "startswith", "(", "\"win\"", ")", "and", "sys", ".", "version_info", ".", "major", "<", "3", "or", "(", "sys", ".", "version_info", ".", "major", "==", "3", "and"...
Convenience method to determine if the current platform is Windows and Python version 3.5 or earlier. Returns: bool: True if the current platform is Windows and the Python interpreter is 3.5 or earlier; False otherwise.
[ "Convenience", "method", "to", "determine", "if", "the", "current", "platform", "is", "Windows", "and", "Python", "version", "3", ".", "5", "or", "earlier", "." ]
1a28959d6f1dd6ac79c87b11efd8529d05532422
https://github.com/aegirhall/console-menu/blob/1a28959d6f1dd6ac79c87b11efd8529d05532422/consolemenu/format/menu_borders.py#L454-L463
799
aegirhall/console-menu
consolemenu/items/submenu_item.py
SubmenuItem.set_menu
def set_menu(self, menu): """ Sets the menu of this item. Should be used instead of directly accessing the menu attribute for this class. :param ConsoleMenu menu: the menu """ self.menu = menu self.submenu.parent = menu
python
def set_menu(self, menu): """ Sets the menu of this item. Should be used instead of directly accessing the menu attribute for this class. :param ConsoleMenu menu: the menu """ self.menu = menu self.submenu.parent = menu
[ "def", "set_menu", "(", "self", ",", "menu", ")", ":", "self", ".", "menu", "=", "menu", "self", ".", "submenu", ".", "parent", "=", "menu" ]
Sets the menu of this item. Should be used instead of directly accessing the menu attribute for this class. :param ConsoleMenu menu: the menu
[ "Sets", "the", "menu", "of", "this", "item", ".", "Should", "be", "used", "instead", "of", "directly", "accessing", "the", "menu", "attribute", "for", "this", "class", "." ]
1a28959d6f1dd6ac79c87b11efd8529d05532422
https://github.com/aegirhall/console-menu/blob/1a28959d6f1dd6ac79c87b11efd8529d05532422/consolemenu/items/submenu_item.py#L19-L27