def export(runs,sortby,flipper,minmon=16): data = load(runs) keys = data.keys() if sortby is None: values = [""] else: values = set([x[sortby] for x in keys]) base = basedir + "%04i/" % runs[-1] for value in values: ups = [x for x in keys if x[flipper][0] != '-' and (sortby is None or x[sortby] == value)] downs = [x for x in keys if x[flipper][0] == '-' and (sortby is None or x[sortby] == value)] if ups != []: Combiner.save(base+value+"up.pel", minmon, ups, data) if downs != []: Combiner.save(base+value+"down.pel", minmon, downs, data)
def onSave(self,event): #Combine each flipper current dlg = wx.FileDialog(self,"Save PEL file",wildcard="PEL file|*.pel", style=wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) if dlg.ShowModal()!=wx.ID_OK: return outfile = dlg.GetPath() minmon = float(self.monctrl.GetValue())#Monitor cutoff for live beam index = self.currentbox.GetSelections() keys = [eval(self.currentbox.GetItems()[i]) for i in index] Combiner.save(outfile,minmon,keys,self.runsets)
def Combiner(self): print "Assigning scores to evidence..." assignscore.AssignScore(self.periodicity_output2gff3,self.weightPeriod) assignscore.AssignScore(self.naivepred_output2gff3,self.weightNaive) assignscore.AssignScore(self.gtf2gff3_rnaoutput,self.weightRNA) print "Combining evidence..." results = Combiner.combine(self.periodicity_output2gff3,self.naivepred_output2gff3,self.gtf2gff3_rnaoutput,self.glimmer_predict2gff3) self.outputgff3 = self.genomeinput[:-len(".fasta")]+".gff3" print "Writing results..." assignscore.writeResults2gff3(results,self.outputgff3,self.seqname_fasta,self.seqname_Combiner)
def onLoad(self,event): """Combine the manifests""" paths = self.listbox.GetItems() runsets = Combiner.load(paths) currents = set(runsets.keys()) for current in currents: self.currentbox.Insert(str(current),0) self.runsets = runsets
def export(runs,minmon=16): data = load(runs) keys = data.keys() base = basedir + "%04i/" % runs[-1] #phase(2) controls the cryo-flipper and sample(3) controls the #v-coil flipper # #w -> all flippers on #x -> cryo flipper on #y -> solenoid flipper on #z -> all flippers off w = [k for k in keys if float(k[2])<0 and float(k[3])<0] y = [k for k in keys if float(k[2])<0 and float(k[3])>0] x = [k for k in keys if float(k[2])>0 and float(k[3])<0] z = [k for k in keys if float(k[2])>0 and float(k[3])>0] print w print x print y print z if w != []: Combiner.save(base+"w_new.pel", minmon, w, data) if x != []: Combiner.save(base+"x_new.pel", minmon, x, data) if y != []: Combiner.save(base+"y_new.pel", minmon, y, data) if z != []: Combiner.save(base+"z_new.pel", minmon, z, data)
def two_flipper(runs, flipper1, flipper2, minmon, current, \ watch="2"): data = load(runs,current) keys = data.keys() values = [""] base = basedir + "SESAME_%i/" % runs[-1] for value in values: if type(value) is not str: value = normalize_name(value) upup = [x for x in keys if x[flipper1] < 0 and x[flipper2] < 0 \ and x[choices[watch]]==current] updown = [x for x in keys if x[flipper1] < 0 and x[flipper2] > 0 \ and x[choices[watch]]==current] downup = [x for x in keys if x[flipper1] > 0 and x[flipper2] < 0 \ and x[choices[watch]]==current] downdown = [x for x in keys if x[flipper1] > 0 and x[flipper2] > 0 \ and x[choices[watch]]==current] if filter is not None: value = "" #Don't put values on files when we're only running a single export if upup != []: print "-------------- Up/Up state --------------" Combiner.save(base+value+"upup_current=" + str(current), minmon, upup, data) if updown != []: print "-------------- Up/Down state --------------" Combiner.save(base+value+"updown_current=" + str(current), minmon, updown, data) if downup != []: print "-------------- Down/Up state --------------" Combiner.save(base+value+"downup_current=" + str(current), minmon, downup, data) if downdown != []: print "-------------- Down/Down state --------------" Combiner.save(base+value+"downdown_current=" + str(current), minmon, downdown, data) if [upup,updown,downup,downdown]==[[],[],[],[]]: print("No data to write")
def export(runs,sortby=None,flipper=0,minmon=8,current=None,\ filter=None,watch=None): data = load(runs,current) keys = data.keys() print keys # if sortby is None: values = [""] else: if filter is None: values = set([x[sortby] for x in keys]) else: values = [filter] # base = basedir + "SESAME_%i/" % runs[-1] # for value in values: if type(value) is not str: value = normalize_name(value) ups = [x for x in keys if (flipper is None or x[flipper] < 0) \ and (watch is None or x[choices[watch]]==current) \ and (sortby is None or normalize_name(x[sortby]) == value)] downs = [x for x in keys if (flipper is not None and x[flipper] > 0) \ and (watch is None or x[choices[watch]]==current) \ and (sortby is None or normalize_name(x[sortby]) == value)] sames = [x for x in keys if (flipper is not None and x[flipper] == 0) \ and (watch is None or x[choices[watch]]==current) \ and (sortby is None or normalize_name(x[sortby]) == value)] # if filter is not None: value = "" #Don't put values on files when we're only running a single export # if current==None: titleend="" else: titleend="_current="+str(current) # if ups == [] and downs == []: Combiner.save(base+value+"Combined"+titleend, 0, sames, data) if ups != []: print "-------------- Up state --------------" Combiner.save(base+value+"up"+titleend, minmon, ups, data) if downs != []: print "-------------- Down state --------------" Combiner.save(base+value+"down"+titleend, minmon, downs, data)
def main(): #calib = calibration.calibration(visualtion=True) base_dataset_path = os.path.join(os.getcwd(), "datasets", "test_lab6") file_name = os.path.join(base_dataset_path, "imageData.txt") image_directory = base_dataset_path drone_location = os.path.join(base_dataset_path, "drone_postion.txt") write_img_dir_path = os.path.join(base_dataset_path, "results") all_images, data_matrix = util.importData(file_name, drone_location, image_directory) all_images = all_images[:12] data_matrix = data_matrix[:12] # for i in range(0,3): # all_images[i] = all_images[i][::10, ::10, :] #all_imgs_undistorted = calib.calibrate(all_images) # stitcher = cv2.createStitcher() if imutils.is_cv3() else cv2.Stitcher_create() # (status, stitched) = stitcher.stitch(all_images) my_combiner = Combiner.Combiner(all_images, data_matrix) result = my_combiner.createMosaic() util.display("RESULT", result) if not os.path.exists(write_img_dir_path): os.makedirs(write_img_dir_path) cv2.imwrite(os.path.join(write_img_dir_path, "finalResult3.png"), result)
if os.path.isdir('results') == True: os.rename('results', 'results - ' + str(now)) os.mkdir('results') fileName = "datasets/imageData.txt" imageDirectory = "datasets/images/" print("Creating Temp Directory") if os.path.isdir('temp') == True: shutil.rmtree('temp', ignore_errors=False, onerror=None) os.mkdir('temp') print("Copying Images to Temp Directory") allImages, dataMatrix = util.importData(fileName, imageDirectory) # Perspective.changePerspective(allImages, dataMatrix) print("Sitiching Images") start = time.time() result = Combiner.combine() end = time.time() util.display("RESULT", result, 4000000) cv2.imwrite("results/final_result.jpg", result) print("Time --->>>>>", end - start) print("Done. Find your final image in results folder as final_result.jpg")
def load(runs): paths = [basedir + "%04i/Manifest.xml" % run for run in runs] return Combiner.load(paths)
''' Driver script. Execute this to perform the mosaic procedure. ''' import utilities as util import Combiner import cv2 fileName = "datasets/imageData.txt" imageDirectory = "datasets/images/" allImages, dataMatrix = util.importData(fileName, imageDirectory) myCombiner = Combiner.Combiner(allImages, dataMatrix) result = myCombiner.createMosaic() util.display("RESULT", result) cv2.imwrite("results/finalResult.png", result)
def load(runs,current=None): paths = [basedir + "SESAME_%i/SESAME_%i_runinfo.xml" % (run,run) for run in runs] return Combiner.load(paths,current)