def zFitting(mol_list_filename, parameters): if(parameters.orientation == "inverted"): wx_str = map(str, params.getWidthParams(parameters, "y")) wy_str = map(str, params.getWidthParams(parameters, "x")) else: wx_str = map(str, params.getWidthParams(parameters, "x")) wy_str = map(str, params.getWidthParams(parameters, "y")) proc_params = [src_dir + "fitz", mol_list_filename, str(parameters.cutoff)] + wx_str + wy_str subprocess.call(proc_params)
def zFitting(mol_list_filename, parameters): if (parameters.orientation == "inverted"): wx_str = map(str, params.getWidthParams(parameters, "y")) wy_str = map(str, params.getWidthParams(parameters, "x")) else: wx_str = map(str, params.getWidthParams(parameters, "x")) wy_str = map(str, params.getWidthParams(parameters, "y")) proc_params = [ src_dir + "fitz", mol_list_filename, str(parameters.cutoff) ] + wx_str + wy_str subprocess.call(proc_params)
def peakFinding(find_peaks, movie_file, mlist_file, parameters): # open files for input & output movie_data = datareader.inferReader(movie_file) [movie_x,movie_y,movie_l] = movie_data.filmSize() # if the i3 file already exists, read it in, # write it out & start the analysis from the # end. total_peaks = 0 if(os.path.exists(mlist_file)): print "Found", mlist_file i3data_in = readinsight3.loadI3File(mlist_file) try: curf = int(numpy.max(i3data_in['fr'])) except ValueError: curf = 0 print " Starting analysis at frame:", curf i3data = writeinsight3.I3Writer(mlist_file) if (curf > 0): i3data.addMolecules(i3data_in) total_peaks = i3data_in['x'].size else: curf = 0 i3data = writeinsight3.I3Writer(mlist_file) # process parameters if (parameters.model == "Z"): wx_params = params.getWidthParams(parameters, "x", for_mu_Zfit = True) wy_params = params.getWidthParams(parameters, "y", for_mu_Zfit = True) [min_z, max_z] = params.getZRange(parameters) if(parameters.orientation == "inverted"): find_peaks.initZParams(wx_params, wy_params, min_z, max_z) else: find_peaks.initZParams(wy_params, wx_params, min_z, max_z) if hasattr(parameters, "start_frame"): if (parameters.start_frame>=curf) and (parameters.start_frame<movie_l): curf = parameters.start_frame if hasattr(parameters, "max_frame"): if (parameters.max_frame>0) and (parameters.max_frame<movie_l): movie_l = parameters.max_frame # analyze the movie # catch keyboard interrupts & "gracefully" exit. try: while(curf<movie_l): #for j in range(l): # setup analysis image = movie_data.loadAFrame(curf) - parameters.baseline mask = (image < 1.0) if (numpy.sum(mask) > 0): print " Removing negative values in frame", curf image[mask] = 1.0 # Find the peaks. finder = find_peaks.Finder(image, parameters) [peaks, residual] = finder.analyzeImage() # Save the peaks. if (type(peaks) == type(numpy.array([]))): # remove unconverged peaks peaks = find_peaks.getConvergedPeaks(peaks) # save results if(parameters.orientation == "inverted"): i3data.addMultiFitMolecules(peaks, movie_x, movie_y, curf+1, parameters.pixel_size, inverted = True) else: i3data.addMultiFitMolecules(peaks, movie_x, movie_y, curf+1, parameters.pixel_size, inverted = False) total_peaks += peaks.shape[0] print "Frame:", curf, peaks.shape[0], total_peaks else: print "Frame:", curf, 0, total_peaks curf += 1 print "" i3data.close() return 0 except KeyboardInterrupt: print "Analysis stopped." i3data.close() return 1