def move_mouse(self, x, y, z): mouse = (x,y,z) if self.cursor_outside_image_dimensions(mouse): return self.info_panel.mouse = tuple(map(lambda x:truncate(x, 2), mouse)) self.info_panel.mouse_ras = self.map_cursor(mouse, self.current_affine) self.info_panel.mouse_tkr = self.map_cursor(mouse, self.current_tkr_affine) self.info_panel.mouse_intensity = truncate( self.current_image[x,y,z], 3)
def move_cursor(self, x, y, z, suppress_cursor=False, suppress_ras=False, suppress_tkr=False): #it doesnt seem necessary for the instance variable cursor to exist #at all but this code isn't broken cursor = x,y,z if self.cursor_outside_image_dimensions(cursor): print ('Cursor %.2f %.2f %.2f outside image dimensions, doing ' 'nothing'%(x,y,z)) return self.cursor = cursor xy_cut, xz_cut, yz_cut = self.cut_data(self.current_image, self.cursor) print 'clicked on point %.2f %.2f %.2f'%(x,y,z) self.xy_plane.data.set_data('imagedata', xy_cut) self.xz_plane.data.set_data('imagedata', xz_cut) self.yz_plane.data.set_data('imagedata', yz_cut) self.xy_plane.data.set_data('cursor_x', np.array((x,))) self.xy_plane.data.set_data('cursor_y', np.array((y,))) self.xz_plane.data.set_data('cursor_x', np.array((x,))) self.xz_plane.data.set_data('cursor_z', np.array((z,))) self.yz_plane.data.set_data('cursor_y', np.array((y,))) self.yz_plane.data.set_data('cursor_z', np.array((z,))) if not suppress_cursor: self.info_panel.cursor = tuple( map(lambda x:truncate(x, 2), self.cursor)) if not suppress_ras: self.info_panel.cursor_ras = self.map_cursor(self.cursor, self.current_affine) if not suppress_tkr: self.info_panel.cursor_tkr = self.map_cursor(self.cursor, self.current_tkr_affine) self.info_panel.cursor_intensity = truncate( self.current_image[x,y,z],3) image_name = self.currently_showing.name if image_name in self.pins: for pin in self.pins[image_name]: px, py, pz, pcolor = self.pins[image_name][pin] self.drop_pin(px,py,pz, name=pin, color=pcolor) self.untrack_cursor_event = True
def map_cursor(self, cursor, affine, invert=False): x,y,z = cursor aff_to_use = np.linalg.inv(affine) if invert else affine mcursor, = apply_affine([cursor], aff_to_use) return tuple(map(lambda x: truncate(x, 2), mcursor))