plt.ylim(*ylim) if show_legend: plt.legend(loc='best') if save is True: save = prefix + "_MS{}D.pdf".format('A' if ang else '') if save: print "saving to", save plt.savefig(save) if show: plt.show() return [fig] + fig.get_axes() + [taus] + [msd, msd_err] if errorbars else [msd] if __name__=='__main__': helpy.save_log_entry(absprefix, 'argv') meta = helpy.load_meta(absprefix) if args.load: datapath = absprefix+'_CORNER'*args.corner+'_POSITIONS.txt' helpy.txt_to_npz(datapath, verbose=True, compress=True) if args.orient or args.track: print 'NOTICE: not tracking, only converting file from txt to npz' print ' please run again without `-l` to track/orient' sys.exit() if args.track or args.orient: from scipy.spatial import cKDTree as KDTree if args.track != args.orient and helpy.bool_input("Would you like to " "simultaneously track and find orientations? (It's faster)\n"): args.track = args.orient = True if args.orient: pdata, cdata = helpy.load_data(absprefix, 'position corner') else: pdata = helpy.load_data(absprefix, 'position') pfsets = helpy.splitter(pdata, ret_dict=True)
eax.set_xlim(0, 1) eax.set_xticks(np.arange(0, 1.1, .1)) eax.set_xticklabels(map('.{:d}'.format, np.arange(10)) + ['1']) eax.legend(loc='best', fontsize='small') areas = point[:, 5].astype(int) amin, amax = size['min_area'], size['max_area'] s = np.ceil(hist_bin_auto(areas)) bins = np.arange(amin, amax+s, s) label = "{} area ({} - {})".format(dot, amin, amax) aax.hist(areas, bins, alpha=0.5, color='g', label=label) aax.axvline(size['min_area'], c='g', lw=2) aax.set_xlim(0, bins[-1]) aax.legend(loc='best', fontsize='small') if args.save: print savenotice(dot, out, ext) np.savetxt(out+ext, point, header=hfmt.format(**size), delimiter=' ', fmt=txtfmt) helpy.txt_to_npz(out+ext, verbose=args.verbose, compress=args.gz) if args.save: from shutil import copy copy(first, prefix+'_'+os.path.basename(first)) helpy.save_meta(prefix, meta, path_to_tiffs=os.path.abspath(filepattern), first_frame=os.path.abspath(first), detect_thresh=args.thresh, detect_removed=args.remove) if args.plot: fig.savefig(prefix+'_SEGMENTSTATS.pdf') elif args.plot: plt.show()
areas = point[:, 5].astype(int) amin, amax = size['min_area'], size['max_area'] s = np.ceil(hist_bin_auto(areas)) bins = np.arange(amin, amax + s, s) label = "{} area ({} - {})".format(dot, amin, amax) aax.hist(areas, bins, alpha=0.5, color='g', label=label) aax.axvline(size['min_area'], c='g', lw=2) aax.set_xlim(0, bins[-1]) aax.legend(loc='best', fontsize='small') if args.save: print savenotice(dot, out, ext) np.savetxt(out + ext, point, header=hfmt.format(**size), delimiter=' ', fmt=txtfmt) helpy.txt_to_npz(out + ext, verbose=args.verbose, compress=args.gz) if args.save: from shutil import copy copy(first, prefix + '_' + os.path.basename(first)) helpy.save_meta(prefix, meta, path_to_tiffs=os.path.abspath(filepattern), first_frame=os.path.abspath(first), detect_thresh=args.thresh, detect_removed=args.remove) if args.plot: fig.savefig(prefix + '_SEGMENTSTATS.pdf') elif args.plot: plt.show()
pts, labels, convolved = find_particles(image, keep=True, **size['center']) filebase = os.path.splitext(os.path.basename(file_name))[0] imbase = os.path.join(imdir, filebase) imprefix = imbase plot_positions(pts, labels, convolved, centers, **size['center']) savename = file_name.split('.')[0] savename += '.png' savename = os.path.join(imdir, savename) plot_check(image, centers, savename) if args.save: from shutil import copy copy(first, prefix + '_' + os.path.basename(first)) savenotice = "Saving {} positions to {}{{{},.npz}}".format hfmt = ( 'Kern {kern:.2f}, Min area {min_area:d}, ' 'Max area {max_area:d}, Max eccen {max_ecc:.2f}\n' 'Frame X Y Label Eccen Area Orientation' ) txtfmt = ['%6d', '%7.3f', '%7.3f', '%4d', '%1.3f', '%5d', '%1.3f'] ext = '.txt' + '.gz' print(savenotice('center', output, ext)) np.savetxt(output + ext, ret_points, header=hfmt.format(**size['center']), delimiter=' ', fmt=txtfmt) helpy.txt_to_npz(output + ext, verbose=False, compress=True)