def calc_seg_coords(self, morph_seg_coords): """Update the segment coordinates (after rotations) for individual cells""" phi_y = self._node.rotation_angle_yaxis phi_z = self._node.rotation_angle_zaxis phi_x = self._node.rotation_angle_xaxis # Rotate cell # TODO: Rotations should follow as described in sonata (https://github.com/AllenInstitute/sonata/blob/master/docs/SONATA_DEVELOPER_GUIDE.md). # Need someone with graphics experience to check they are being done correctly (I'm not sure atm). RotX = utils.rotation_matrix([1, 0, 0], phi_x) RotY = utils.rotation_matrix( [0, 1, 0], phi_y) # rotate segments around yaxis normal to pia RotZ = utils.rotation_matrix( [0, 0, 1], -phi_z) # rotate segments around zaxis to get a proper orientation RotXYZ = np.dot(RotX, RotY.dot(RotZ)) # rotated coordinates around z axis first then shift relative to the soma self._seg_coords['p0'] = self._pos_soma + np.dot( RotXYZ, morph_seg_coords['p0']) self._seg_coords['p1'] = self._pos_soma + np.dot( RotXYZ, morph_seg_coords['p1']) self._seg_coords['p05'] = self._pos_soma + np.dot( RotXYZ, morph_seg_coords['p05']) self._seg_coords['d0'] = morph_seg_coords['d0'] self._seg_coords['d1'] = morph_seg_coords['d1']
def calc_seg_coords(self, morph_seg_coords): """Calculate segment coordinates for individual cells""" phi_y = self._props['rotation_angle_yaxis'] phi_z = self._props['rotation_angle_zaxis'] RotY = utils.rotation_matrix([0, 1, 0], phi_y) # rotate segments around yaxis normal to pia RotZ = utils.rotation_matrix([0, 0, 1], -phi_z) # rotate segments around zaxis to get a proper orientation RotYZ = RotY.dot(RotZ) # rotated coordinates around z axis first then shift relative to the soma self._seg_coords['p0'] = self._pos_soma + np.dot(RotYZ, morph_seg_coords['p0']) self._seg_coords['p1'] = self._pos_soma + np.dot(RotYZ, morph_seg_coords['p1'])
def rotate_the_electrodes(self): for el in range(self.elnsites): phi_x = self.elrot[el][0] phi_y = self.elrot[el][1] phi_z = self.elrot[el][2] rot_x = rotation_matrix([1, 0, 0], phi_x) rot_y = rotation_matrix([0, 1, 0], phi_y) rot_z = rotation_matrix([0, 0, 1], phi_z) rot_xy = rot_x.dot(rot_y) rot_xyz = rot_xy.dot(rot_z) new_mesh = np.dot(rot_xyz, self.el_mesh[el]) self.el_mesh[el] = new_mesh