def testingParameters(): """ Create a Spliner parameters object for FISTA deconvolution. """ if settings.use_fista: params = parameters.ParametersSplinerFISTA() else: params = parameters.ParametersSplinerSTD() params.setAttr("max_frame", "int", -1) params.setAttr("start_frame", "int", -1) params.setAttr("background_sigma", "float", 8.0) params.setAttr("camera_gain", "float", settings.camera_gain) params.setAttr("camera_offset", "float", settings.camera_offset) params.setAttr("find_max_radius", "int", 15) params.setAttr("iterations", "int", settings.iterations) params.setAttr("pixel_size", "float", settings.pixel_size) params.setAttr("max_z", "float", 1.0) params.setAttr("min_z", "float", -1.0) params.setAttr("no_fitting", "int", 1) params.setAttr("sigma", "float", 1.5) params.setAttr("spline", "filename", "psf.spline") params.setAttr("threshold", "float", 6.0) # FISTA. if settings.use_fista: params.setAttr("use_fista", "int", settings.use_fista) params.setAttr("fista_iterations", "int", 500) params.setAttr("fista_lambda", "float", 20.0) params.setAttr("fista_number_z", "int", 5) params.setAttr("fista_threshold", "float", 500.0) params.setAttr("fista_timestep", "float", 0.1) params.setAttr("rb_radius", "float", 10.0) params.setAttr("rb_sigma", "float", 1.0) # Standard else: params.setAttr("z_value", "float-array", [-0.6, -0.3, 0.0, 0.3, 0.6]) # Don't do tracking. params.setAttr("descriptor", "string", "1") params.setAttr("radius", "float", "0.0") # Don't do drift-correction. params.setAttr("d_scale", "int", 2) params.setAttr("drift_correction", "int", 0) params.setAttr("frame_step", "int", 500) params.setAttr("z_correction", "int", 0) # 'peak_locations' testing. if hasattr(settings, "peak_locations") and (settings.peak_locations is not None): params.setAttr("peak_locations", "filename", settings.peak_locations) return params
def analyze(movie_name, mlist_name, settings_name): parameters = params.ParametersSpliner().initFromFile(settings_name, warnings=False) if (parameters.getAttr("use_fista", 0) != 0): parameters = params.ParametersSplinerFISTA().initFromFile( settings_name) finder = find_peaks_fista.SplinerFISTAFinderFitter(parameters) else: parameters = params.ParametersSplinerSTD().initFromFile(settings_name) finder = find_peaks_std.SplinerFinderFitter(parameters) std_analysis.standardAnalysis(finder, movie_name, mlist_name, parameters)
def analyze(movie_name, mlist_name, settings_name): # Load parameters. parameters = params.ParametersSpliner().initFromFile(settings_name, warnings=False) # Check for v1.0 parameters. if not (parameters.hasAttr("camera_gain") or parameters.hasAttr("camera_calibration")): raise Exception( "Camera parameters are missing. Version 1.0 parameters?") # Create appropriate finding and fitting object. if (parameters.getAttr("use_fista", 0) != 0): parameters = params.ParametersSplinerFISTA().initFromFile( settings_name) finder = find_peaks_fista.initFindAndFit(parameters) else: parameters = params.ParametersSplinerSTD().initFromFile(settings_name) finder = find_peaks_std.initFindAndFit(parameters) # Create appropriate reader. if parameters.hasAttr("camera_offset"): frame_reader = analysisIO.FrameReaderStd(movie_file=movie_name, parameters=parameters) else: frame_reader = analysisIO.FrameReaderSCMOS(movie_file=movie_name, parameters=parameters) # Create movie reader (uses frame reader). movie_reader = analysisIO.MovieReader(frame_reader=frame_reader, parameters=parameters) # Create localization file writer. data_writer = analysisIO.DataWriterHDF5(data_file=mlist_name, parameters=parameters, sa_type="Spliner") std_analysis.standardAnalysis(finder, movie_reader, data_writer, parameters)
import storm_analysis.rolling_ball_bgr.rolling_ball as rollingBall import storm_analysis.sa_library.datareader as datareader import storm_analysis.sa_library.daxwriter as daxwriter import storm_analysis.sa_library.parameters as params import storm_analysis.sa_library.writeinsight3 as writeinsight3 import storm_analysis.wavelet_bgr.wavelet_bgr as waveletBGR import fista_decon_utilities_c as fdUtil if (len(sys.argv) != 4): print("usage: <movie, input> <parameters_file, input> <decon, output>") exit() # Load parameters parameters = params.ParametersSplinerFISTA().initFromFile(sys.argv[2]) # Open movie and load the first frame. movie_data = datareader.inferReader(sys.argv[1]) [x_size, y_size, z_size] = movie_data.filmSize() image = movie_data.loadAFrame(0) - parameters.getAttr("baseline") image = image.astype(numpy.float) # Do FISTA deconvolution. fdecon = FISTADecon(image.shape, parameters.getAttr("spline"), parameters.getAttr("fista_number_z"), parameters.getAttr("fista_timestep"), upsample=parameters.getAttr("fista_upsample")) if 0:
import storm_analysis.spliner.spline_to_psf as splineToPSF import storm_analysis.wavelet_bgr.wavelet_bgr as waveletBGR parser = argparse.ArgumentParser(description = 'FISTA deconvolution - Beck and Teboulle, SIAM J. Imaging Sciences, 2009') parser.add_argument('--movie', dest='movie', type=str, required=True, help = "The name of the movie to deconvolve, can be .dax, .tiff or .spe format.") parser.add_argument('--xml', dest='settings', type=str, required=True, help = "The name of the settings xml file.") parser.add_argument('--output', dest='output', type=str, required=True, help = "The name of the .tif file to save the results in.") args = parser.parse_args() # Load parameters parameters = params.ParametersSplinerFISTA().initFromFile(args.settings) # Open movie and load the first frame. movie_data = datareader.inferReader(args.movie) [x_size, y_size, z_size] = movie_data.filmSize() image = (movie_data.loadAFrame(0) - parameters.getAttr("camera_offset"))/parameters.getAttr("camera_gain") image = image.astype(numpy.float) # Load spline. psf_object = splineToPSF.loadSpline(parameters.getAttr("spline")) # Do FISTA deconvolution. fdecon = FISTADecon(image.shape, psf_object, parameters.getAttr("fista_number_z"), parameters.getAttr("fista_timestep"))