Exemple #1
0
def plot_bleb_evolution(ts, prop_to_plots, title):
    """Plot evolution of a given bleb property over time"""
    title = title.replace("\u00B5", "u")
    plt = Plot((title + " against time"), "Time", title)
    plt.add("line", ts, prop_to_plots)
    plt.show()
    plot_data = [(t, d) for t, d in zip(ts, prop_to_plots)]
    return plt.getImagePlus(), plot_data
Exemple #2
0
    def createAngleTable(self, roi):
        polygon = roi.getPolygon()
        xPoints = polygon.xpoints
        yPoints = polygon.ypoints

        nPoints = polygon.npoints
        table = ResultsTable()
        firstAngle = Math.atan2(yPoints[0], xPoints[0])
        plot = Plot(str(roi.getName()) + " Angle", "--", "angle")

        angles = []
        derivative = []
        derivativeSign = []
        posDerivative = 0
        negDerivative = 0

        for i in range(nPoints):
            x = xPoints[i]
            y = yPoints[i]
            angle = Math.atan2(y, x)

            angles.append(angle - firstAngle)
            if i == 0:
                continue

            derivative.append(angle - angles[-2])
            derivativeSign.append(Math.signum(derivative[-1]))
            if derivativeSign[-1] > 0:
                posDerivative = posDerivative + 1
            else:
                negDerivative = negDerivative + 1

        maxSign = max(posDerivative, negDerivative)
        minSign = min(posDerivative, negDerivative)

        print("--" + str(roi.getName()))
        signRatio = float(minSign) / float(maxSign)
        print("Min Sign = " + str(minSign))
        print("Max Sign = " + str(maxSign))
        print("Sign Ratio = " + str(signRatio))
        plot.add("filled", derivativeSign)
        plot.show()

        if signRatio < 1.1:
            # table.show(str( roi.getName())+" Angle")
            return True
        return False
from ij.gui import Plot
from java.awt import Color
import jarray
import os

# start clean
IJ.run("Close All")

# create example data arrays
xa = [1, 2, 3, 4]
ya = [3, 3.5, 4, 4.5]

# convert to java array
jxa = jarray.array(xa, 'd')
jya = jarray.array(ya, 'd')

# Create filled plot
plt = Plot("Line plot", "X", "Y")
plt.setLimits(0, 5, 0, 5)
plt.setFrameSize(600, 300)
plt.setColor("blue", "#ccccff")

# the circles are small. Can't figure out how to make
# them larger... These 2 calls are equivalent...
# plt.addPoints(jxa,jya, Plot.CIRCLE)
plt.add("circles", jxa, jya)
plt.setColor(Color.RED)
plt.setLineWidth(1)
plt.drawLine(0.0, 2.5, 4.0, 4.5)
plt.setXYLabels("X", "Y")
plt.show()
Exemple #4
0
# Find the best linear fit of mean gray level vs camera exposure
cf = CurveFitter(exposures, list(levels))
cf.doFit(CurveFitter.STRAIGHT_LINE)
fitParams = cf.getParams()
slope = fitParams[1]
intercept = fitParams[0]
rSqr = cf.getRSquared()

print("slope=", slope, " ; intercept=", intercept, " ; rSquared=", rSqr)

# Plot the data and the regression line
newPlotFlags = Plot.TRIANGLE + Plot.X_GRID + Plot.X_NUMBERS + Plot.Y_GRID + Plot.Y_NUMBERS
newPlot = Plot("DARK NOISE", "EXPOSURE, ms", "MEAN GRAY LEVEL", newPlotFlags)
newPlot.setLineWidth(2)
newPlot.setColor("red")
newPlot.add("triangle", exposures, list(levels))
newPlot.setLineWidth(1)
newPlot.setColor("black")
newPlot.drawLine(exposures[0], cf.f(exposures[0]), exposures[-1],
                 cf.f(exposures[-1]))
newPlot.setColor("blue")
newPlot.setFontSize(20)
newPlot.addText("y = a+bx", 100.0, 13000.0)
newPlot.addText("a = " + str(round(intercept, 2)), 100.0, 12250.0)
newPlot.addText("b = " + str(round(slope, 2)), 100.0, 11500.0)
newPlot.addText("R squared = " + str(round(rSqr, 3)), 100.0, 10750.0)
newPlot.show()

# Place the plot data into a ResultsTable
rt = newPlot.getResultsTable()
rt.show("Dark Noise Results")
Exemple #5
0
from ij.gui import Plot
from math import sin, cos, radians

# title, X label, Y label
plot = Plot("My data", "time", "value")

# Series 1
plot.setColor("blue")
plot.add("circle", [50 + sin(radians(i * 5)) * 50 for i in xrange(100)])

# Series 2
plot.setColor("magenta")
plot.add("diamond", [50 + cos(radians(i * 5)) * 50 for i in xrange(100)])

# Series 3
plot.setColor("black")
plot.add("line", [50 + cos(-1.0 + radians(i * 5)) * 50 for i in xrange(100)])

plot.show()
from ij.gui import Plot
from math import sin, radians
plot = Plot("My data", "time", "value")
plot.setColor("blue")
plot.add("circle", [sin(radians(i)) for i in xrange(1000)])
plot.show()
Exemple #7
0
stack_crop = stack.crop(x_val, y_val, 0, width, height, NSlices)

time1 = timeit.default_timer()
print roi
print stack
print stack_crop

modal_vals = []

for idx in range(0, stack_crop.size()):
    #Determine Mode of each Slice
    sel_frame = stack_crop.getProcessor(idx + 1)  #1-based indexing
    frame_hist = sel_frame.getHistogram()
    hist_set = sorted(set(frame_hist))
    modal_count = hist_set[-1]
    modal_val = frame_hist.index(modal_count)
    if modal_val == 0:
        modal_count = hist_set[-2]
        modal_val = frame_hist.index(modal_count)
    modal_vals.append(modal_val)
    if idx % 1000 == 0:
        print(idx, timeit.default_timer() - time1)

print sorted(set(modal_vals))
print timeit.default_timer() - time1

final_plot = Plot("Modal Values", "Stack", "Value")
final_plot.add("line", modal_vals)
final_plot.show()

print timeit.default_timer() - time1