def applyTform_posList(from_pL, c): tform_pL = posList(axis = None) for index,pos in enumerate(from_pL.slicePositions): #print index, pos tform_x = c[1]*pos.x - c[0]*pos.y + c[2] tform_y = c[1]*pos.y + c[0]*pos.x + c[3] #print tform_x, tform_y print "%d (x, y): (%f, %f) --> (%f, %f)" %(index, pos.x, pos.y, tform_x, tform_y) tform_pL.add_position(tform_x,tform_y) return tform_pL
def getPoints(file): # read posList file & get datapoints # return list of points as [[x1,y1],[x2,y2],...] pL = posList(axis = None) pL.add_from_file(file) pt_list = [] for index,pos in enumerate(pL.slicePositions): pt_list.append([pos.x,pos.y]) print ('%d\t[%f,%f]' %(index, pos.x, pos.y)) return pt_list
def __init__(self, parent, config, **kwargs): """keyword the same as standard init function for a FigureCanvas""" self.figure = Figure(figsize=(5, 9)) FigureCanvas.__init__(self, parent, -1, self.figure, **kwargs) self.canvas = self.figure.canvas #format the appearance self.figure.set_facecolor((1,1,1)) self.figure.set_edgecolor((1,1,1)) self.canvas.SetBackgroundColour('white') #add subplots for various things self.subplot = self.figure.add_axes([.05,.5,.92,.5]) self.posone_plot = self.figure.add_axes([.1,.05,.2,.4]) self.postwo_plot = self.figure.add_axes([.37,.05,.2,.4]) self.corrplot = self.figure.add_axes([.65,.05,.25,.4]) #initialize the camera settings and mosaic settings self.cfg=config camera_settings=CameraSettings() camera_settings.load_settings(config) mosaic_settings=MosaicSettings() mosaic_settings.load_settings(config) #setup a blank position list self.posList=posList(self.subplot,mosaic_settings,camera_settings) #start with no MosaicImage self.mosaicImage=None #start with relative_motion on, so that keypress calls shift_selected_curved() of posList self.relative_motion = True #start with no toolbar and no lasso tool self.navtoolbar = None self.lasso = None self.lassoLock=False #make a sin plot just to see that things are working #self.t = arange(0.0,3.0,0.01) #s = sin(2*pi*self.t) #self.subplot.plot(self.t,s) self.canvas.mpl_connect('button_press_event', self.on_press) self.canvas.mpl_connect('button_release_event', self.on_release) self.canvas.mpl_connect('key_press_event', self.on_key)
def savePoints(tform_pt, file): pL = posList(axis = None) pL.save_position_list()
#TkFileDialogExample(root).pack() #root.mainloop() options = {} options['defaultextension'] = '' # couldn't figure out how this works options['filetypes'] = [('csv files', '.csv')] options['initialdir'] = '/Users/SJSmith/Documents/Nick Local/data/ISI-Barrels/Ct1-ISI/R55/Imaging-Sessions' options['initialfile'] = 'posList.csv' #options['parent'] = root #get input pList (ie. original template to be transformed from) options['title'] = 'Select template PositionList file' template_csv = tkFileDialog.askopenfilename(**options) #template_pt = getPoints(template_csv) template_pL = posList(axis = None) template_pL.add_from_file(template_csv) #get target pList (ie. new points from which to calculate transformation) options['title'] = 'Select target PositionList file' options['initialdir'] = os.path.split(template_csv)[0] target_csv = tkFileDialog.askopenfilename(**options) #target_pt = getPoints(target_csv) target_pL = posList(axis = None) target_pL.add_from_file(target_csv) print "Calculating transformation of %s to %s" %(template_csv, target_csv) #calculate coefficients #c = rstTransform(template_pt, target_pt)