Пример #1
0
    def getPeaks(self, threshold, margin):

        fx = self.getXVector()

        # Get area, position, height.
        fd_peaks = fdUtil.getPeaks(fx, threshold, margin)
        num_peaks = fd_peaks.shape[0]

        peaks = numpy.zeros((num_peaks, utilC.getNResultsPar()))

        peaks[:, utilC.getXWidthIndex()] = numpy.ones(num_peaks)
        peaks[:, utilC.getYWidthIndex()] = numpy.ones(num_peaks)

        peaks[:, utilC.getXCenterIndex()] = fd_peaks[:, 2]
        peaks[:, utilC.getYCenterIndex()] = fd_peaks[:, 1]

        # Calculate height.
        #
        # FIXME: Typically the starting value for the peak height will be
        #        under-estimated unless a large enough number of FISTA
        #        iterations is performed to completely de-convolve the image.
        #
        h_index = utilC.getHeightIndex()
        #peaks[:,h_index] = fd_peaks[:,0]
        for i in range(num_peaks):
            peaks[i, h_index] = fd_peaks[i, 0] * self.psf_heights[int(
                round(fd_peaks[i, 3]))]

        # Calculate z (0.0 - 1.0).
        peaks[:,
              utilC.getZCenterIndex()] = fd_peaks[:, 3] / (float(fx.shape[2]) -
                                                           1.0)

        # Background term calculation.
        bg_index = utilC.getBackgroundIndex()
        for i in range(num_peaks):
            ix = int(round(fd_peaks[i, 1]))
            iy = int(round(fd_peaks[i, 2]))
            peaks[i, bg_index] = self.background[ix, iy]

        return peaks
Пример #2
0
]

cubic_fit.initializeMultiFit.argtypes = [
    ndpointer(dtype=numpy.float64), ctypes.c_double, ctypes.c_int, ctypes.c_int
]

cubic_fit.newImage.argtypes = [ndpointer(dtype=numpy.float64)]

cubic_fit.newPeaks2D.argtypes = [ndpointer(dtype=numpy.float64), ctypes.c_int]

cubic_fit.newPeaks3D.argtypes = [ndpointer(dtype=numpy.float64), ctypes.c_int]

# Globals
default_tol = 1.0e-6
height_index = utilC.getHeightIndex()
n_results_par = utilC.getNResultsPar()
status_index = utilC.getStatusIndex()
z_index = utilC.getZCenterIndex()


#
# Functions
#
def fSpline2D(x, y):
    return cubic_fit.fSpline2D(x, y)


def fSpline3D(x, y, z):
    return cubic_fit.fSpline3D(x, y, z)

Пример #3
0
# to the average psf
average_psf = numpy.zeros((4*aoi_size,4*aoi_size))
curf = 1
peaks_used = 0
total = 0.0
[dax_x, dax_y, dax_l] = dax_data.filmSize()
while (curf < dax_l) and (peaks_used < min_peaks):

    # Select localizations in current frame & not near the edges.
    mask = (i3_data['fr'] == curf) & (i3_data['x'] > aoi_size) & (i3_data['x'] < (dax_y - aoi_size - 1)) & (i3_data['y'] > aoi_size) & (i3_data['y'] < (dax_x - aoi_size - 1))
    xr = i3_data['x'][mask]
    yr = i3_data['y'][mask]
    ht = i3_data['h'][mask]

    # Remove localizations that are too close to each other.
    in_peaks = numpy.zeros((xr.size,util_c.getNResultsPar()))
    in_peaks[:,util_c.getXCenterIndex()] = xr
    in_peaks[:,util_c.getYCenterIndex()] = yr
    in_peaks[:,util_c.getHeightIndex()] = ht

    out_peaks = util_c.removeNeighbors(in_peaks, aoi_size)

    print curf, in_peaks.shape, out_peaks.shape

    # Use remaining localizations to calculate spline.
    image = dax_data.loadAFrame(curf-1).astype(numpy.float64)

    xr = out_peaks[:,util_c.getXCenterIndex()]
    yr = out_peaks[:,util_c.getYCenterIndex()]
    ht = out_peaks[:,util_c.getHeightIndex()]
Пример #4
0
curf = 1
peaks_used = 0
total = 0.0
[dax_x, dax_y, dax_l] = dax_data.filmSize()
while (curf < dax_l) and (peaks_used < min_peaks):

    # Select localizations in current frame & not near the edges.
    mask = (i3_data['fr'] == curf) & (i3_data['x'] > aoi_size) & (
        i3_data['x'] < (dax_x - aoi_size - 1)) & (i3_data['y'] > aoi_size) & (
            i3_data['y'] < (dax_y - aoi_size - 1))
    xr = i3_data['x'][mask]
    yr = i3_data['y'][mask]
    ht = i3_data['h'][mask]

    # Remove localizations that are too close to each other.
    in_peaks = numpy.zeros((xr.size, util_c.getNResultsPar()))
    in_peaks[:, util_c.getXCenterIndex()] = xr
    in_peaks[:, util_c.getYCenterIndex()] = yr
    in_peaks[:, util_c.getHeightIndex()] = ht

    out_peaks = util_c.removeNeighbors(in_peaks, aoi_size)

    print curf, in_peaks.shape, out_peaks.shape

    # Use remaining localizations to calculate spline.
    image = dax_data.loadAFrame(curf - 1).astype(numpy.float64)

    xr = out_peaks[:, util_c.getXCenterIndex()]
    yr = out_peaks[:, util_c.getYCenterIndex()]
    ht = out_peaks[:, util_c.getHeightIndex()]
Пример #5
0
                             ndpointer(dtype=numpy.float64),
                             c_double, 
                             c_int, 
                             c_int,
                             c_int,
                             c_int]
multi.initializeZParameters.argtypes = [ndpointer(dtype=numpy.float64), 
                                        ndpointer(dtype=numpy.float64),
                                        c_double,
                                        c_double]

# Globals
default_tol = 1.0e-6

peakpar_size = util_c.getNPeakPar()
resultspar_size = util_c.getNResultsPar()


##
# Helper functions.
##
def calcSxSy(wx_params, wy_params, z):
    zx = (z - wx_params[1])/wx_params[2]
    sx = 0.5 * wx_params[0] * math.sqrt(1.0 + zx*zx + wx_params[3]*zx*zx*zx + wx_params[4]*zx*zx*zx*zx)
    zy = (z - wy_params[1])/wy_params[2]
    sy = 0.5 * wy_params[0] * math.sqrt(1.0 + zy*zy + wy_params[3]*zy*zy*zy + wy_params[4]*zy*zy*zy*zy)
    return [sx, sy]

def fitStats(results):
    total = results.shape[0]
    bad = numpy.count_nonzero(results[:,n_params] == 2.0)
Пример #6
0
                                         ctypes.c_int,
                                         ctypes.c_int]

cubic_fit.newImage.argtypes = [ndpointer(dtype=numpy.float64)]

cubic_fit.newPeaks2D.argtypes = [ndpointer(dtype=numpy.float64),
                                 ctypes.c_int]

cubic_fit.newPeaks3D.argtypes = [ndpointer(dtype=numpy.float64),
                                 ctypes.c_int]


# Globals
default_tol = 1.0e-6
height_index = utilC.getHeightIndex()
n_results_par = utilC.getNResultsPar()
status_index = utilC.getStatusIndex()
z_index = utilC.getZCenterIndex()


#
# Functions
#
def fSpline2D(x, y):
    return cubic_fit.fSpline2D(x, y)

def fSpline3D(x, y, z):
    return cubic_fit.fSpline3D(x, y, z)


#
Пример #7
0
                             ndpointer(dtype=numpy.float64),
                             c_double, 
                             c_int, 
                             c_int,
                             c_int,
                             c_int]
multi.initializeZParameters.argtypes = [ndpointer(dtype=numpy.float64), 
                                        ndpointer(dtype=numpy.float64),
                                        c_double,
                                        c_double]

# Globals
default_tol = 1.0e-6

peakpar_size = util_c.getNPeakPar()
resultspar_size = util_c.getNResultsPar()


##
# Helper functions.
##
def calcSxSy(wx_params, wy_params, z):
    zx = (z - wx_params[1])/wx_params[2]
    sx = 0.5 * wx_params[0] * math.sqrt(1.0 + zx*zx + wx_params[3]*zx*zx*zx + wx_params[4]*zx*zx*zx*zx)
    zy = (z - wy_params[1])/wy_params[2]
    sy = 0.5 * wy_params[0] * math.sqrt(1.0 + zy*zy + wy_params[3]*zy*zy*zy + wy_params[4]*zy*zy*zy*zy)
    return [sx, sy]

def fitStats(results):
    total = results.shape[0]
    bad = numpy.count_nonzero(results[:,n_params] == 2.0)