def addMoleculesWithXYAFrame(self, x, y, pa, frame):
     i3data = i3dtype.createDefaultI3Data(x.size)
     i3dtype.posSet(i3data, 'x', x)
     i3dtype.posSet(i3data, 'y', y)
     i3dtype.setI3Field(i3data, 'a', pa)
     i3dtype.setI3Field(i3data, 'fr', frame)
     self.addMolecules(i3data)
Beispiel #2
0
    def addDAOSTORMMolecules(self, frame, xc, yc, br, be, msky, niter, sharp, chi, err):
        #
        # DAOSTORM -> Insight3 format mapping.
        #
        # xc - xcenter
        # yc - ycenter
        # br - brightness -> peak height
        # be - brightness error (?) -> peak area
        # msky - background -> peak background
        # niter - fit iterations
        # sharp - sharpness (?) -> peak angle
        # chi - fit quality -> peak width
        # err - error flag -> link
        #

        i3data = i3dtype.createDefaultI3Data(xc.size)
        i3dtype.posSet(i3data, 'x', xc)
        i3dtype.posSet(i3data, 'y', yc)
        i3dtype.setI3Field(i3data, 'h', br)
        i3dtype.setI3Field(i3data, 'a', be)
        i3dtype.setI3Field(i3data, 'bg', msky)
        i3dtype.setI3Field(i3data, 'fi', niter)
        i3dtype.setI3Field(i3data, 'phi', sharp)
        i3dtype.setI3Field(i3data, 'w', chi)
        i3dtype.setI3Field(i3data, 'lk', err)

        self.addMolecules(i3data)
Beispiel #3
0
 def addMoleculesWithXYICat(self, x, y, pi, cat):
     i3data = i3dtype.createDefaultI3Data(x.size)
     i3dtype.posSet(i3data, 'x', x)
     i3dtype.posSet(i3data, 'y', y)
     i3dtype.setI3Field(i3data, 'i', pi)
     i3dtype.setI3Field(i3data, 'c', cat)
     self.addMolecules(i3data)
Beispiel #4
0
    def addDAOSTORMMolecules(self, frame, xc, yc, br, be, msky, niter, sharp,
                             chi, err):
        #
        # DAOSTORM -> Insight3 format mapping.
        #
        # xc - xcenter
        # yc - ycenter
        # br - brightness -> peak height
        # be - brightness error (?) -> peak area
        # msky - background -> peak background
        # niter - fit iterations
        # sharp - sharpness (?) -> peak angle
        # chi - fit quality -> peak width
        # err - error flag -> link
        #

        i3data = i3dtype.createDefaultI3Data(xc.size)
        i3dtype.posSet(i3data, 'x', xc)
        i3dtype.posSet(i3data, 'y', yc)
        i3dtype.setI3Field(i3data, 'h', br)
        i3dtype.setI3Field(i3data, 'a', be)
        i3dtype.setI3Field(i3data, 'bg', msky)
        i3dtype.setI3Field(i3data, 'fi', niter)
        i3dtype.setI3Field(i3data, 'phi', sharp)
        i3dtype.setI3Field(i3data, 'w', chi)
        i3dtype.setI3Field(i3data, 'lk', err)

        self.addMolecules(i3data)
Beispiel #5
0
 def addMoleculesWithXYAFrame(self, x, y, pa, frame):
     i3data = i3dtype.createDefaultI3Data(x.size)
     i3dtype.posSet(i3data, 'x', x)
     i3dtype.posSet(i3data, 'y', y)
     i3dtype.setI3Field(i3data, 'a', pa)
     i3dtype.setI3Field(i3data, 'fr', frame)
     self.addMolecules(i3data)
    def addDAOSTORMMolecules(self, frame, xc, yc, br, be, msky, niter, sharp, chi, err):
        """
        This is for localizations identified by the original DAOSTORM
        algorithm, not the 3D-DAOSTORM algorithm.
        
        DAOSTORM -> Insight3 format mapping.
        
        xc - xcenter
        yc - ycenter
        br - brightness -> peak height
        be - brightness error (?) -> peak area
        msky - background -> peak background
        niter - fit iterations
        sharp - sharpness (?) -> peak angle
        chi - fit quality -> peak width
        err - error flag -> link
        """

        i3data = i3dtype.createDefaultI3Data(xc.size)
        i3dtype.posSet(i3data, 'x', xc)
        i3dtype.posSet(i3data, 'y', yc)
        i3dtype.setI3Field(i3data, 'h', br)
        i3dtype.setI3Field(i3data, 'a', be)
        i3dtype.setI3Field(i3data, 'bg', msky)
        i3dtype.setI3Field(i3data, 'fi', niter)
        i3dtype.setI3Field(i3data, 'phi', sharp)
        i3dtype.setI3Field(i3data, 'w', chi)
        i3dtype.setI3Field(i3data, 'lk', err)

        self.addMolecules(i3data)
    def addDAOSTORMMolecules(self, frame, xc, yc, br, be, msky, niter, sharp,
                             chi, err):
        """
        This is for localizations identified by the original DAOSTORM
        algorithm, not the 3D-DAOSTORM algorithm.
        
        DAOSTORM -> Insight3 format mapping.
        
        xc - xcenter
        yc - ycenter
        br - brightness -> peak height
        be - brightness error (?) -> peak area
        msky - background -> peak background
        niter - fit iterations
        sharp - sharpness (?) -> peak angle
        chi - fit quality -> peak width
        err - error flag -> link
        """

        i3data = i3dtype.createDefaultI3Data(xc.size)
        i3dtype.posSet(i3data, 'x', xc)
        i3dtype.posSet(i3data, 'y', yc)
        i3dtype.setI3Field(i3data, 'h', br)
        i3dtype.setI3Field(i3data, 'a', be)
        i3dtype.setI3Field(i3data, 'bg', msky)
        i3dtype.setI3Field(i3data, 'fi', niter)
        i3dtype.setI3Field(i3data, 'phi', sharp)
        i3dtype.setI3Field(i3data, 'w', chi)
        i3dtype.setI3Field(i3data, 'lk', err)

        self.addMolecules(i3data)
Beispiel #8
0
 def addMoleculesWithXYCatF(self, x, y, cat,f):
     i3data = i3dtype.createDefaultI3Data(x.size)
     i3dtype.posSet(i3data, 'x', x)
     i3dtype.posSet(i3data, 'y', y)
     i3dtype.setI3Field(i3data, 'c', cat)
     i3dtype.setI3Field(i3data, 'fr', f)
     self.addMolecules(i3data)
 def addMoleculesWithXYICat(self, x, y, pi, cat):
     i3data = i3dtype.createDefaultI3Data(x.size)
     i3dtype.posSet(i3data, 'x', x)
     i3dtype.posSet(i3data, 'y', y)
     i3dtype.setI3Field(i3data, 'i', pi)
     i3dtype.setI3Field(i3data, 'c', cat)
     self.addMolecules(i3data)
 def addMoleculesWithXYCatF(self, x, y, cat, f):
     i3data = i3dtype.createDefaultI3Data(x.size)
     i3dtype.posSet(i3data, 'x', x)
     i3dtype.posSet(i3data, 'y', y)
     i3dtype.setI3Field(i3data, 'c', cat)
     i3dtype.setI3Field(i3data, 'fr', f)
     self.addMolecules(i3data)
 def addMoleculesWithXYIWFrame(self, x, y, pi, width, frame):
     i3data = i3dtype.createDefaultI3Data(x.size)
     i3dtype.posSet(i3data, 'x', x)
     i3dtype.posSet(i3data, 'y', y)
     i3dtype.setI3Field(i3data, 'i', pi)
     i3dtype.setI3Field(i3data, 'w', width)
     i3dtype.setI3Field(i3data, 'fr', frame)
     self.addMolecules(i3data)
Beispiel #12
0
 def addMoleculesWithXYIWFrame(self, x, y, pi, width, frame):
     i3data = i3dtype.createDefaultI3Data(x.size)
     i3dtype.posSet(i3data, 'x', x)
     i3dtype.posSet(i3data, 'y', y)
     i3dtype.setI3Field(i3data, 'i', pi)
     i3dtype.setI3Field(i3data, 'w', width)
     i3dtype.setI3Field(i3data, 'fr', frame)
     self.addMolecules(i3data)
Beispiel #13
0
def test_i3dtype_3():
    """
    Test creation and setting with a scalar.
    """
    i3_locs = i3dtype.createDefaultI3Data(10)
    i3dtype.posSet(i3_locs, 'x', 10.0)

    for i in range(10):
        assert(abs(i3_locs["x"][i] - 10.0) < 1.0e-6)
        assert(abs(i3_locs["xc"][i] - 10.0) < 1.0e-6)
Beispiel #14
0
def test_i3dtype_2():
    """
    Test creation and setting position with an array.
    """
    i3_locs = i3dtype.createDefaultI3Data(10)
    i3dtype.posSet(i3_locs, 'x', numpy.arange(10))

    for i in range(10):
        assert(abs(i3_locs["x"][i] - i) < 1.0e-6)
        assert(abs(i3_locs["xc"][i] - i) < 1.0e-6)
Beispiel #15
0
def test_write_read_1():
    """
    Test writing and reading.
    """
    bin_name = storm_analysis.getPathOutputTest("test_insight3io.bin")

    i3_locs = i3dtype.createDefaultI3Data(10)
    i3dtype.posSet(i3_locs, 'x', 10.0)

    with writeinsight3.I3Writer(bin_name) as i3:
        i3.addMolecules(i3_locs)

    i3_in = readinsight3.loadI3File(bin_name, verbose = False)
    assert(numpy.allclose(i3_locs['x'], i3_in['x']))
Beispiel #16
0
def test_write_read_3():
    """
    Test I3Reader on an empty file.
    """
    bin_name = storm_analysis.getPathOutputTest("test_insight3io.bin")

    i3_locs = i3dtype.createDefaultI3Data(10)
    i3dtype.posSet(i3_locs, 'x', 10.0)

    with writeinsight3.I3Writer(bin_name) as i3:
        pass

    i3_reader = readinsight3.I3Reader(bin_name)

    # Read localizations.
    i3_in = i3_reader.nextBlock()
    assert(i3_in is False)
 def addMoleculesWithXYZI(self, x, y, z, pi):
     i3data = i3dtype.createDefaultI3Data(x.size)
     i3dtype.posSet(i3data, 'x', x)
     i3dtype.posSet(i3data, 'y', y)
     i3dtype.posSet(i3data, 'z', z)
     i3dtype.setI3Field(i3data, 'i', pi)
     self.addMolecules(i3data)
Beispiel #18
0
 def addMoleculesWithXYZI(self, x, y, z, pi):
     i3data = i3dtype.createDefaultI3Data(x.size)
     i3dtype.posSet(i3data, 'x', x)
     i3dtype.posSet(i3data, 'y', y)
     i3dtype.posSet(i3data, 'z', z)
     i3dtype.setI3Field(i3data, 'i', pi)
     self.addMolecules(i3data)
Beispiel #19
0
def test_write_read_2():
    """
    Test I3Reader.
    """
    bin_name = storm_analysis.getPathOutputTest("test_insight3io.bin")

    i3_locs = i3dtype.createDefaultI3Data(10)
    i3dtype.posSet(i3_locs, 'x', 10.0)

    with writeinsight3.I3Writer(bin_name) as i3:
        i3.addMolecules(i3_locs)

    i3_reader = readinsight3.I3Reader(bin_name)

    # Read localizations.
    i3_in = i3_reader.nextBlock()
    assert(numpy.allclose(i3_locs['x'], i3_in['x']))
    assert(i3_in is not False)

    # This should return False because there are no more localizations.
    i3_in = i3_reader.nextBlock()
    assert(i3_in is False)
Beispiel #20
0
 def addMoleculesWithXYZICatFrame(self, x, y, z, pi, cat, f):
     i3data = i3dtype.createDefaultI3Data(x.size)
     i3dtype.posSet(i3data, 'x', x)
     i3dtype.posSet(i3data, 'y', y)
     i3dtype.posSet(i3data, 'z', z)
     i3dtype.setI3Field(i3data, 'i', pi)
     i3dtype.setI3Field(i3data, 'c', cat)
     i3dtype.setI3Field(i3data, 'fr', f)
     self.addMolecules(i3data)
 def addMoleculesWithXYZICatFrame(self, x, y, z, pi, cat, f):
     i3data = i3dtype.createDefaultI3Data(x.size)
     i3dtype.posSet(i3data, 'x', x)
     i3dtype.posSet(i3data, 'y', y)
     i3dtype.posSet(i3data, 'z', z)
     i3dtype.setI3Field(i3data, 'i', pi)
     i3dtype.setI3Field(i3data, 'c', cat)
     i3dtype.setI3Field(i3data, 'fr', f)
     self.addMolecules(i3data)
Beispiel #22
0
    def drift(self, frame_number, i3_data):

        # Check that frame number is in range.
        if (frame_number >= self.drift_data.shape[0]):
            frame_number = self.drift_data.shape[0] - 1

        dx = self.drift_data[frame_number, 0]
        dy = self.drift_data[frame_number, 1]
        dz = self.drift_data[frame_number, 2]

        i3dtype.posSet(i3_data, "x", i3_data["x"] + dx)
        i3dtype.posSet(i3_data, "y", i3_data["y"] + dy)
        i3dtype.posSet(i3_data, "z", i3_data["z"] + dz)
Beispiel #23
0
    def addMultiFitMolecules(self,
                             molecules,
                             x_size,
                             y_size,
                             frame,
                             nm_per_pixel,
                             inverted=False):
        n_molecules = molecules.shape[0]

        h = molecules[:, 0]
        if inverted:
            xc = y_size - molecules[:, 1]
            yc = x_size - molecules[:, 3]
            wx = 2.0 * molecules[:, 2] * nm_per_pixel
            wy = 2.0 * molecules[:, 4] * nm_per_pixel
        else:
            xc = molecules[:, 3] + 1
            yc = molecules[:, 1] + 1
            wx = 2.0 * molecules[:, 4] * nm_per_pixel
            wy = 2.0 * molecules[:, 2] * nm_per_pixel

        bg = molecules[:, 5]
        zc = molecules[:,
                       6] * 1000.0  # fitting is done in um, insight works in nm
        st = numpy.round(molecules[:, 7])
        err = molecules[:, 8]

        # calculate peak area, which is saved in the "a" field.
        parea = 2.0 * 3.14159 * h * molecules[:, 2] * molecules[:, 4]

        ax = wy / wx
        ww = numpy.sqrt(wx * wy)

        i3data = i3dtype.createDefaultI3Data(xc.size)
        i3dtype.posSet(i3data, 'x', xc)
        i3dtype.posSet(i3data, 'y', yc)
        i3dtype.posSet(i3data, 'z', zc)
        i3dtype.setI3Field(i3data, 'h', h)
        i3dtype.setI3Field(i3data, 'bg', bg)
        i3dtype.setI3Field(i3data, 'fi', st)
        i3dtype.setI3Field(i3data, 'a', parea)
        i3dtype.setI3Field(i3data, 'w', ww)
        i3dtype.setI3Field(i3data, 'ax', ax)
        i3dtype.setI3Field(i3data, 'fr', frame)
        i3dtype.setI3Field(i3data, 'i', err)
        self.addMolecules(i3data)
Beispiel #24
0
def test_i3dtype_1():
    """
    Test conversion to and from the fitter format.
    """
    x_size = 100
    y_size = 100
    frame = 10
    nm_per_pixel = 100.0
    
    data_in = i3dtype.createDefaultI3Data(10)
    i3dtype.posSet(data_in, 'x', numpy.arange(10))
    i3dtype.posSet(data_in, 'y', numpy.arange(10) + 30.0)
    i3dtype.posSet(data_in, 'z', numpy.arange(10) + 60.0)
    i3dtype.setI3Field(data_in, 'fr', frame)

    peaks = i3dtype.convertToMultiFit(data_in, frame, nm_per_pixel)
    data_out = i3dtype.createFromMultiFit(peaks, frame, nm_per_pixel)

    fields = ['x', 'ax', 'w']
    for i in range(10):
        for field in fields:
            assert(abs(data_in[field][i] - data_out[field][i]) < 1.0e-6)
 def addMoleculesWithXY(self, x, y):
     i3data = i3dtype.createDefaultI3Data(x.size)
     i3dtype.posSet(i3data, 'x', x)
     i3dtype.posSet(i3data, 'y', y)
     self.addMolecules(i3data)
Beispiel #26
0
cx = numpy.random.uniform(low = 20.0, high = 236.0, size = clusters)
cy = numpy.random.uniform(low = 20.0, high = 236.0, size = clusters)
cz = numpy.random.uniform(low = -300.0, high = 300.0, size = clusters)

with writeinsight3.I3Writer("../data/test_clustering_list.bin") as i3_fp:
    for i in range(length):
        
        if((i % 500) == 0):
            print("Creating frame", i)

        on = (numpy.random.uniform(size = clusters) < p_on)
        number_on = numpy.count_nonzero(on)

        x = cx + numpy.random.normal(scale = 0.5, size = clusters)
        y = cy + numpy.random.normal(scale = 0.5, size = clusters)
        z = cz + numpy.random.normal(scale = 50.0, size = clusters)

        # Add background
        x = numpy.concatenate((x[on], numpy.random.uniform(high = 256.0, size = background)))
        y = numpy.concatenate((y[on], numpy.random.uniform(high = 256.0, size = background)))
        z = numpy.concatenate((z[on], numpy.random.uniform(low = -500.0, high = 500.0, size = background)))
        
        i3d = i3dtype.createDefaultI3Data(number_on + background)
        i3dtype.posSet(i3d, "x", x)
        i3dtype.posSet(i3d, "y", y)
        i3dtype.posSet(i3d, "z", z)
        i3dtype.setI3Field(i3d, "fr", i+1)

        i3_fp.addMolecules(i3d)
cy = numpy.random.uniform(low = 20.0, high = 236.0, size = clusters)
cz = numpy.random.uniform(low = -300.0, high = 300.0, size = clusters)

with open("../data/test_drift.txt", "w") as drift_fp:
    with writeinsight3.I3Writer("../data/test_drift_mlist.bin") as i3_fp:
        for i in range(length):
        
            if((i % 500) == 0):
                print("Creating frame", i)

            drift_x = i * dx
            drift_y = i * dy
            drift_z = i * dz

            drift_fp.write("{0:0d}\t{1:.3f}\t{2:.3f}\t{3:.3f}\n".format(i+1, drift_x, drift_y, drift_z))
            
            on = (numpy.random.uniform(size = clusters) < p_on)
            number_on = numpy.count_nonzero(on)

            x = cx + drift_x + numpy.random.normal(scale = 0.5, size = clusters)
            y = cy + drift_y + numpy.random.normal(scale = 0.5, size = clusters)
            z = cz + drift_z + numpy.random.normal(scale = 50.0, size = clusters)
            
            i3d = i3dtype.createDefaultI3Data(number_on)
            i3dtype.posSet(i3d, "x", x[on])
            i3dtype.posSet(i3d, "y", y[on])
            i3dtype.posSet(i3d, "z", z[on])
            i3dtype.setI3Field(i3d, "fr", i+1)

            i3_fp.addMolecules(i3d)
Beispiel #28
0
                    help="The total number of localizations.")
parser.add_argument('--match',
                    dest='match',
                    type=float,
                    required=True,
                    help="The fraction of localizations that match.")

args = parser.parse_args()

im_size = 512

# Create matching points.
total_match = int(args.total * args.match)
m_data = i3dtype.createDefaultI3Data(total_match)

i3dtype.posSet(m_data, "x", numpy.random.uniform(high=im_size,
                                                 size=total_match))
i3dtype.posSet(m_data, "y", numpy.random.uniform(high=im_size,
                                                 size=total_match))

# Create noise 1.
total_noise = args.total - total_match
n1_data = i3dtype.createDefaultI3Data(total_noise)

i3dtype.posSet(n1_data, "x",
               numpy.random.uniform(high=im_size, size=total_noise))
i3dtype.posSet(n1_data, "y",
               numpy.random.uniform(high=im_size, size=total_noise))

# Create noise 2.
n2_data = i3dtype.createDefaultI3Data(total_noise)
parser = argparse.ArgumentParser(description = 'Generate test data for Micrometry')

parser.add_argument('--total', dest='total', type=int, required=True,
                    help = "The total number of localizations.")
parser.add_argument('--match', dest='match', type=float, required=True,
                    help = "The fraction of localizations that match.")

args = parser.parse_args()

im_size = 512

# Create matching points.
total_match = int(args.total * args.match)
m_data = i3dtype.createDefaultI3Data(total_match)

i3dtype.posSet(m_data, "x", numpy.random.uniform(high = im_size, size = total_match))
i3dtype.posSet(m_data, "y", numpy.random.uniform(high = im_size, size = total_match))

# Create noise 1.
total_noise = args.total - total_match
n1_data = i3dtype.createDefaultI3Data(total_noise)

i3dtype.posSet(n1_data, "x", numpy.random.uniform(high = im_size, size = total_noise))
i3dtype.posSet(n1_data, "y", numpy.random.uniform(high = im_size, size = total_noise))

# Create noise 2.
n2_data = i3dtype.createDefaultI3Data(total_noise)

i3dtype.posSet(n2_data, "x", numpy.random.uniform(high = im_size, size = total_noise))
i3dtype.posSet(n2_data, "y", numpy.random.uniform(high = im_size, size = total_noise))
    # Load x,y locations.
    i3_in = readinsight3.loadI3File(args.i3bin)

    xi = i3_in["x"]
    yi = i3_in["y"]

    # Map to back channel 0 if necessary.
    if (args.channel != 0):
        xt_name = str(args.channel) + "_0_x"
        yt_name = str(args.channel) + "_0_y"
        [xi, yi] = mapXYLocations(xi, yi, mappings[xt_name], mappings[yt_name])

    for i in range(8):
        if (i == 0):
            i3dtype.posSet(i3_in, "x", xi)
            i3dtype.posSet(i3_in, "y", yi)
        else:
            xt_name = "0_" + str(i) + "_x"
            yt_name = "0_" + str(i) + "_y"
            if xt_name in mappings:
                [xf, yf] = mapXYLocations(xi, yi, mappings[xt_name],
                                          mappings[yt_name])
                i3dtype.posSet(i3_in, "x", xf)
                i3dtype.posSet(i3_in, "y", yf)
            else:
                break

        i3_out_name = basename + "_mapb_c" + str(i) + ".bin"
        with writeinsight3.I3Writer(i3_out_name) as i3w:
            i3w.addMolecules(i3_in)
Beispiel #31
0
    # Save the image.
    dax_data.addFrame(image)

    # Save the molecule locations.
    a_vals = PSF.PSFIntegral(z_vals, h_vals)
    
    ax = numpy.ones(num_objects)
    ww = 2.0 * 160.0 * numpy.ones(num_objects)
    if (PSF.psf_type == "astigmatic"):
        sx_vals = objects[:,3]
        sy_vals = objects[:,4]
        ax = sy_vals/sx_vals
        ww = 2.0*160.0*numpy.sqrt(sx_vals*sy_vals)
        
    mols = i3dtype.createDefaultI3Data(num_objects)
    i3dtype.posSet(mols, 'x', x_vals + 1.0)
    i3dtype.posSet(mols, 'y', y_vals + 1.0)
    i3dtype.posSet(mols, 'z', z_vals)
    i3dtype.setI3Field(mols, 'a', a_vals)
    i3dtype.setI3Field(mols, 'h', h_vals)
    i3dtype.setI3Field(mols, 'w', ww)
    i3dtype.setI3Field(mols, 'ax', ax)
    i3dtype.setI3Field(mols, 'fr', i+1)
    i3_data.addMolecules(mols)

dax_data.close()
i3_data.close()


#
# The MIT License
Beispiel #32
0
#z_planes = [-250.0, 250.0]
#z_planes = [-750.0, -250.0, 250.0, 750.0]
z_value = -500.0

# Load emitter locations.
i3_locs = readinsight3.loadI3File("emitters.bin")

if False:
    i3_locs = i3_locs[0]

# Make a bin file with emitter locations for each frame.
with writeinsight3.I3Writer("test_olist.bin") as i3w:
    for i in range(frames):
        i3_temp = i3_locs.copy()
        i3dtype.setI3Field(i3_temp, "fr", i + 1)
        i3dtype.posSet(i3_temp, "z", z_value)
        i3w.addMolecules(i3_temp)

# Load channel to channel mapping file.
with open("map.map", 'rb') as fp:
    mappings = pickle.load(fp)

# Create bin files for each plane.
for i, z_plane in enumerate(z_planes):
    cx = mappings["0_" + str(i) + "_x"]
    cy = mappings["0_" + str(i) + "_y"]
    i3_temp = i3_locs.copy()
    xi = i3_temp["x"]
    yi = i3_temp["y"]
    xf = cx[0] + cx[1] * xi + cx[2] * yi
    yf = cy[0] + cy[1] * xi + cy[2] * yi
Beispiel #33
0
 def addMoleculesWithXY(self, x, y):
     i3data = i3dtype.createDefaultI3Data(x.size)
     i3dtype.posSet(i3data, 'x', x)
     i3dtype.posSet(i3data, 'y', y)
     self.addMolecules(i3data)
Beispiel #34
0
    # Save the image.
    dax_data.addFrame(image)

    # Save the molecule locations.
    a_vals = PSF.PSFIntegral(z_vals, h_vals)
    
    ax = numpy.ones(num_objects)
    ww = 2.0 * 160.0 * numpy.ones(num_objects)
    if (PSF.psf_type == "astigmatic"):
        sx_vals = objects[:,3]
        sy_vals = objects[:,4]
        ax = sy_vals/sx_vals
        ww = 2.0*160.0*numpy.sqrt(sx_vals*sy_vals)
        
    mols = i3dtype.createDefaultI3Data(num_objects)
    i3dtype.posSet(mols, 'x', x_vals + 1.0)
    i3dtype.posSet(mols, 'y', y_vals + 1.0)
    i3dtype.posSet(mols, 'z', z_vals)
    i3dtype.setI3Field(mols, 'a', a_vals)
    i3dtype.setI3Field(mols, 'h', h_vals)
    i3dtype.setI3Field(mols, 'w', ww)
    i3dtype.setI3Field(mols, 'ax', ax)
    i3dtype.setI3Field(mols, 'fr', i+1)
    i3_data.addMolecules(mols)

dax_data.close()
i3_data.close()


#
# The MIT License
Beispiel #35
0
zp = None
for clc in cl_centers:

    if xp is None:
        xp = numpy.random.normal(scale=args.dev, size=args.nlocs) + clc[0]
        yp = numpy.random.normal(scale=args.dev, size=args.nlocs) + clc[1]

        # Z is in nm, we'll assume a 100nm pixel size.
        zp = numpy.random.normal(scale=args.dev * 100.0,
                                 size=args.nlocs) + clc[2]
    else:
        xp = numpy.append(
            xp,
            numpy.random.normal(scale=args.dev, size=args.nlocs) + clc[0])
        yp = numpy.append(
            yp,
            numpy.random.normal(scale=args.dev, size=args.nlocs) + clc[1])
        zp = numpy.append(
            zp,
            numpy.random.normal(scale=args.dev * 100.0, size=args.nlocs) +
            clc[2])

# Create a molecule list structure & save it.
i3data = i3dtype.createDefaultI3Data(args.ncl * args.nlocs)
i3dtype.posSet(i3data, "x", xp)
i3dtype.posSet(i3data, "y", yp)
i3dtype.posSet(i3data, "z", zp)

with writeinsight3.I3Writer(args.i3bin) as i3w:
    i3w.addMolecules(i3data)