Skip to content

Commit

Permalink
FIX: default orientation for directional leads
Browse files Browse the repository at this point in the history
The marker orientation is in YZ-plane for zero angle
  • Loading branch information
Konstantin Butenko committed Feb 7, 2024
1 parent 3604c53 commit 5bf8de7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
9 changes: 7 additions & 2 deletions leaddbsinterface/lead_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,13 @@ def get_rot_z(self, index_side: int):
Always recalculated from the other settings
*IMPORTANT*: it is actually not native but scrf!
"""
head_nat = self.get_head_nat()[index_side, :]
y = self.get_y_mark_nat()[index_side, :] - head_nat

if self.get_est_in_temp():
head_MNI = self.get_head_mni()[index_side, :]
y = self.get_y_mark_mni()[index_side, :] - head_MNI
else:
head_nat = self.get_head_nat()[index_side, :]
y = self.get_y_mark_nat()[index_side, :] - head_nat
y_postop = y / np.linalg.norm(y)
phi = np.arctan2(-y_postop[0], y_postop[1])
return phi * 180.0 / np.pi
Expand Down
6 changes: 4 additions & 2 deletions ossdbs/electrodes/abbott_stjude.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ def __contact_directed(self) -> netgen.libngpy._NgOCC.TopoDS_Shape:
radius = self._parameters.lead_diameter * 0.5
height = self._parameters.contact_length
body = occ.Cylinder(p=point, d=self._direction, r=radius, h=height)
new_direction = tuple(np.cross(self.__direction_2(), self._direction))
#new_direction = tuple(np.cross(self.__direction_2(), self._direction))
# tilted y-vector marker is in YZ-plane and orthogonal to _direction
new_direction = tuple([0, self._direction[2], -1 * self._direction[1]])
eraser = occ.HalfSpace(p=point, n=new_direction)
delta = 15
angle = 30 + delta
Expand Down Expand Up @@ -277,7 +279,7 @@ def __contact_directed(self) -> netgen.libngpy._NgOCC.TopoDS_Shape:
or np.isclose(edge.center.y, radius / 2)
):
edge.name = "min z"
contact = contact.Rotate(axis, angle)
contact = contact.Rotate(axis, -1*angle)
# TODO check that the starting axis of the contacts
# are correct according to the documentation
return contact
Expand Down
6 changes: 4 additions & 2 deletions ossdbs/electrodes/boston_scientific_vercise.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ def __contact_directed(self) -> netgen.libngpy._NgOCC.TopoDS_Shape:
radius = self._parameters.lead_diameter * 0.5
height = self._parameters.contact_length
body = occ.Cylinder(p=point, d=self._direction, r=radius, h=height)
new_direction = tuple(np.cross(self.__direction_2(), self._direction))
#new_direction = tuple(np.cross(self.__direction_2(), self._direction))
# tilted y-vector marker is in YZ-plane and orthogonal to _direction
new_direction = tuple([0, self._direction[2], -1 * self._direction[1]])
eraser = occ.HalfSpace(p=point, n=new_direction)
delta = 15
angle = 30 + delta
Expand Down Expand Up @@ -190,7 +192,7 @@ def __contact_directed(self) -> netgen.libngpy._NgOCC.TopoDS_Shape:

# TODO check that the starting axis of the contacts
# are correct according to the documentation
contact = contact.Rotate(axis, angle)
contact = contact.Rotate(axis, -1*angle)

return contact

Expand Down
6 changes: 4 additions & 2 deletions ossdbs/electrodes/medtronic.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ def __contact_directed(self) -> netgen.libngpy._NgOCC.TopoDS_Shape:
radius = self._parameters.lead_diameter * 0.5
height = self._parameters.contact_length
body = occ.Cylinder(p=point, d=self._direction, r=radius, h=height)
new_direction = tuple(np.cross(self.__direction_2(), self._direction))
#new_direction = tuple(np.cross(self.__direction_2(), self._direction))
# tilted y-vector marker is in YZ-plane and orthogonal to _direction
new_direction = tuple([0, self._direction[2], -1 * self._direction[1]])
eraser = occ.HalfSpace(p=point, n=new_direction)
delta = 15
angle = 30 + delta
Expand Down Expand Up @@ -262,7 +264,7 @@ def __contact_directed(self) -> netgen.libngpy._NgOCC.TopoDS_Shape:
elif cond_z_min and not (cond_x or cond_y):
edge.name = "min z"
# Reseting position so that 0 deg lies in the middle of contact
contact = contact.Rotate(axis, angle)
contact = contact.Rotate(axis, -1*angle)
# TODO check that the starting axis of the contacts
# are correct according to the documentation

Expand Down

0 comments on commit 5bf8de7

Please sign in to comment.