Пример #1
0
#import astigmaticPSF as PSF
import dhPSF as PSF

if (len(sys.argv) != 5):
    print "usage: <dax> <bin> <frames> <num_objects>"
    exit()

# Peak height.
intensity = 500.0

# Image size.
x_size = 256
y_size = 256

dax_data = daxwriter.DaxWriter(sys.argv[1], x_size, y_size)
i3_data = writeinsight3.I3Writer(sys.argv[2])
num_frames = int(sys.argv[3])
num_objects = int(sys.argv[4])

for i in range(num_frames):
    print "Generating frame:", i

    # Generate locations
    x_vals = numpy.zeros(num_objects)
    y_vals = numpy.zeros(num_objects)
    z_vals = numpy.zeros(num_objects)
    h_vals = numpy.ones(num_objects) * intensity

    for j in range(num_objects):

        # Random locations.
Пример #2
0
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 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):

            # Set up the 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 and fit the peaks.
            [peaks, residual] = find_peaks.analyzeImage(image)

            # 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()
        find_peaks.cleanUp()
        return 0

    except KeyboardInterrupt:
        print "Analysis stopped."
        i3data.close()
        find_peaks.cleanUp()
        return 1
Пример #3
0
    # Save results.
    fx = fdecon.getXVector()
    print numpy.min(fx), numpy.max(fx)
    decon_data = daxwriter.DaxWriter(sys.argv[3], fx.shape[0], fx.shape[1])
    for i in range(fx.shape[2]):
        decon_data.addFrame(fx[:, :, i])
    decon_data.close()

    # Find peaks in the decon data.
    peaks = fdecon.getPeaks(parameters.fista_threshold, 5)

    zci = utilC.getZCenterIndex()
    z_min, z_max = fdecon.getZRange()
    peaks[:, zci] = 1.0e-3 * ((z_max - z_min) * peaks[:, zci] + z_min)

    i3_writer = writeinsight3.I3Writer(sys.argv[3][:-4] + "_flist.bin")
    i3_writer.addMultiFitMolecules(peaks, x_size, y_size, 1,
                                   parameters.pixel_size)
    i3_writer.close()

#
# The MIT License
#
# Copyright (c) 2016 Zhuang Lab, Harvard University
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
Пример #4
0
#
# Create a test .bin file for evaluating RCC correction.
#
# Hazen 10/14
#

import numpy
import sys

import sa_library.writeinsight3 as writeinsight3

if (len(sys.argv) != 2):
    print "usage: <out.bin>"
    exit()

i3_out = writeinsight3.I3Writer(sys.argv[1])
n_locs = 100

def addMol(x,y,frame):
    x += numpy.random.normal(scale = 0.05, size = n_locs)
    y += numpy.random.normal(scale = 0.05, size = n_locs)
    i3_out.addMoleculesWithXYFrame(x,y,i)

x1 = 255.0 * numpy.random.uniform(size = n_locs)
y1 = 255.0 * numpy.random.uniform(size = n_locs)

x2 = 255.0 * numpy.random.uniform(size = n_locs)
y2 = 255.0 * numpy.random.uniform(size = n_locs)

dx = 0.0
dy = 0.0
Пример #5
0
# Setup
#
src_directory = os.path.dirname(__file__)

if (len(sys.argv) != 5):
    print "usage: cs_analysis <dax_file> <params_file> <hres_file> <bin_file>"
    exit()

movie_data = datareader.inferReader(sys.argv[1])

#
# FIXME:
#
# This should also start at the same frame as hres in the event of a restart.
#
i3_file = writeinsight3.I3Writer(sys.argv[4])

params = parameters.Parameters(sys.argv[2])

#
# Load the a matrix and setup the homotopy image analysis class.
#
a_mat_file = params.a_matrix

print "Using A matrix file:", a_mat_file
a_mat = setup_A_matrix.loadAMatrix(a_mat_file)

image = movie_data.loadAFrame(0)
htia = homotopy_imagea_c.HomotopyIA(a_mat, params.epsilon, image.shape)

#