File |
Line |
com/github/celldynamics/quimp/Outline.java |
292 |
com/github/celldynamics/quimp/Outline.java |
397 |
double lastPlacement;
double currentDis;
Vert oldHead = head;
Vert v1 = oldHead;
// new, higher res outline
head = new Vert(v1.getX(), v1.getY(), v1.getTrackNum());
head.setHead(true);
head.setIntPoint(oldHead.isIntPoint(), oldHead.intsectID);
head.setNext(head);
head.setPrev(head);
head.gCoord = 0.;
head.coord = 0.;
nextTrackNumber = oldHead.getTrackNum() + 1;
POINTS = 1;
double coorSpaceing = 1.0 / numVerts;
// System.out.println("coord: " + CoorSpaceing);
double currentCoor = coorSpaceing;
Vert temp;
Vert newV;
newV = head;
int numVertsInserted = 1; // the head
ExtendedVector2d uedge;
ExtendedVector2d edge;
ExtendedVector2d placementVector;
do {
Vert v2 = v1.getNext();
lastPlacement = 0.0;
currentDis = 0.0;
edge = ExtendedVector2d.vecP2P(v1.getPoint(), v2.getPoint());
// edge.print("edge");
uedge = ExtendedVector2d.unitVector(v1.getPoint(), v2.getPoint());
// uEdge.print("uEdge");
if (edge.length() == 0) { // points on top of one another, move on
v1 = v1.getNext();
continue;
}
while (true) {
placementVector = new ExtendedVector2d(uedge.getX(), uedge.getY());
// double mult = (density + currentDis) - remaining;
// System.out.println("mult "+mult);
// placementVector.print("before Mult");
placementVector.multiply((density + currentDis) - remaining);
// placementVector.print("\tafter Mult");
if (placementVector.length() <= edge.length() && numVertsInserted < numVerts) { // if
currentDis = placementVector.length();
lastPlacement = currentDis;
remaining = 0;
placementVector.addVec(v1.getPoint());
temp = insertVert(newV);
temp.setX(placementVector.getX());
temp.setY(placementVector.getY());
temp.gCoord = currentCoor;
temp.coord = currentCoor;
newV = temp;
numVertsInserted++;
currentCoor += coorSpaceing;
} else {
if (v2.isHead()) {
break; // stop it douplicating the head node if it also an intpoint
}
if (v2.isIntPoint()) {
temp = insertVert(newV);
temp.setX(v2.getX());
temp.setY(v2.getY());
temp.setIntPoint(true, v2.intsectID);
newV = temp;
}
remaining = edge.length() - lastPlacement + remaining;
break;
}
}
v1 = v1.getNext();
} while (!v1.isHead());
oldHead = null;
// LOGGER.trace("head =[" + getHead().getX() + "," + getHead().getY() + "]");
}
/**
* Evenly spaces a new vertices around the outline by following vectors between verts.
*
* @param numVerts numVerts
*/
public void setResolutionN(double numVerts) { |
File |
Line |
com/github/celldynamics/quimp/plugin/protanalysis/TrackVisualisation.java |
563 |
com/github/celldynamics/quimp/plugin/protanalysis/TrackVisualisation.java |
633 |
public void addTrackingMaximaToImage(STmap mapCell, TrackCollection trackCollection) {
double[][] x = mapCell.getxMap(); // temporary x and y coordinates for given cell
double[][] y = mapCell.getyMap();
// these are raw coordinates of tracking lines extracted from List<PolygonRoi> pL
ArrayList<float[]> xcoorda = new ArrayList<>();
ArrayList<float[]> ycoorda = new ArrayList<>();
int al = 0;
// iterate over tracks
Iterator<Track> it = trackCollection.iteratorTrack();
while (it.hasNext()) {
Track track = it.next();
Polygon polyR = track.asPolygon();
// we need to sort tracking line points according to frames where they appear in
// first convert poygon to list of Point2i object
List<Point> plR =
TrackMapAnalyser.polygon2Point2i(new ArrayList<Polygon>(Arrays.asList(polyR)));
// then sort this list according y-coordinate (frame)
Collections.sort(plR, new ListPoint2iComparator());
// convert to polygon again but now it is sorted along frames
Polygon plRsorted = TrackMapAnalyser.point2i2Polygon(plR);
// create store for tracking line coordinates
xcoorda.add(new float[plRsorted.npoints]);
ycoorda.add(new float[plRsorted.npoints]);
// counter of invalid vertexes. According to TrackMap#trackForward last points can
// be -1 when user provided longer time span than available. (last in term of time)
int invalidVertex = 0;
// decode frame,outline to x,y
for (int f = 0; f < plRsorted.npoints; f++) {
// -1 stands for points that are outside of range - assured by TrackMap.class
if (plRsorted.ypoints[f] < 0 || plRsorted.xpoints[f] < 0) {
invalidVertex++; // count bad points
continue;
}
xcoorda.get(al)[f] = (float) x[plRsorted.xpoints[f]][plRsorted.ypoints[f]];
ycoorda.get(al)[f] = (float) y[plRsorted.xpoints[f]][plRsorted.ypoints[f]];
}
// now xcoorda,yccora keep coordinates of aL track, it is time to plot
// iterate over points in sorted polygon (one track line) even indexes stand for
// backward tracking, odd for forward tracking lines Some last points can be skipped
// here (sorting does not influence this because last points means last in term of
// time)
for (int f = 0; f < plRsorted.npoints - invalidVertex; f++) {
// x/ycoorda keep all points of tracking lines but PolygonRoi constructor allow
// to define how many first of them we take. This allows us to add points
// together with frames - in result the line grows as frames rise. After
// sorting, first points are those on lower frames
// set colors (remember about backward/forward order)
PolygonRoi polyRoi = GraphicsElements.getCircle(xcoorda.get(al)[f], ycoorda.get(al)[f], |
File |
Line |
com/github/celldynamics/quimp/Snake.java |
630 |
com/github/celldynamics/quimp/Snake.java |
696 |
for (int i = 0; i < interval; i++) {
if (nodeB.isHead()) {
cutHead = true;
}
state = ExtendedVector2d.segmentIntersection(nodeA.getX(), nodeA.getY(),
nodeA.getNext().getX(), nodeA.getNext().getY(), nodeB.getX(), nodeB.getY(),
nodeB.getNext().getX(), nodeB.getNext().getY(), intersect);
if (state == 1) {
// System.out.println("CutLoops: cut out a loop");
newN = this.insertNode(nodeA);
newN.setX(intersect[0]);
newN.setY(intersect[1]);
newN.setNext(nodeB.getNext());
nodeB.getNext().setPrev(newN);
newN.updateNormale(BOA_.qState.segParam.expandSnake);
nodeB.getNext().updateNormale(BOA_.qState.segParam.expandSnake); |
File |
Line |
com/github/celldynamics/quimp/plugin/protanalysis/ActionTrackPoints.java |
180 |
com/github/celldynamics/quimp/plugin/protanalysis/ActionTrackPoints.java |
275 |
HashMap<Integer, List<Point2D>> tmpSelected = new HashMap<>();
for (PointCoords p : ui.getModel().selected) {
int tmpIndex = MapCoordConverter.findPointIndex(stMap[p.cellNo].getxMap()[p.frame],
stMap[p.cellNo].getyMap()[p.frame], p.point.getX(), p.point.getY(), Double.MAX_VALUE);
if (tmpIndex >= 0) {
// if no cell in HashMap - create
if (tmpSelected.get(p.cellNo) == null) {
tmpSelected.put(p.cellNo, new ArrayList<Point2D>());
}
// add point to the cell
tmpSelected.get(p.cellNo).add(new Point2D.Double(p.frame, tmpIndex));
}
}
logger.trace("Added " + tmpSelected.size() + " points"); |
File |
Line |
com/github/celldynamics/quimp/plugin/protanalysis/TrackVisualisation.java |
384 |
com/github/celldynamics/quimp/plugin/protanalysis/TrackVisualisation.java |
498 |
public Image(String name, ImageProcessor imp) {
super(name, imp);
}
/**
* Plot unrelated points on image (static).
*
* @param mapCell source of coordinate maps
* @param points list of points to plot in coordinates (index,frame)
* @param color color of point
* @param radius radius of point
*/
public void addCirclesToImage(STmap mapCell, Polygon points, Color color, double radius) {
double[][] x = mapCell.getxMap();
double[][] y = mapCell.getyMap();
int[] indexes = points.ypoints;
int[] frames = points.xpoints;
for (int n = 0; n < points.npoints; n++) {
// decode frame,outline to screen coordinates
if (frames[n] < 0 || indexes[n] < 0) {
continue;
}
double xcoord = x[frames[n]][indexes[n]]; // screen coordinate of
double ycoord = y[frames[n]][indexes[n]]; // (frame,index) point
plotCircle(xcoord, ycoord, color, radius); |
File |
Line |
com/github/celldynamics/quimp/plugin/randomwalk/RandomWalkView.java |
1446 |
com/github/celldynamics/quimp/plugin/randomwalk/RandomWalkView.java |
1545 |
.createTitledBorder(BorderFactory.createLineBorder(Color.ORANGE), "Seed build"));
dynPanel.setLayout(new BorderLayout());
((BorderLayout) dynPanel.getLayout()).setVgap(2);
// middle buttons
JPanel seedBuildPanel = new JPanel();
seedBuildPanel.setLayout(new GridLayout(2, 1, 2, 2));
JPanel seedBuildPanelButtons = new JPanel();
seedBuildPanelButtons.setLayout(new GridBagLayout());
GridBagConstraints constrProc = new GridBagConstraints();
constrProc.gridx = 0;
constrProc.gridy = 0;
constrProc.weightx = 1;
constrProc.weighty = 1;
constrProc.fill = GridBagConstraints.HORIZONTAL;
// constrProc.insets = new Insets(1, 1, 1, 1);
seedBuildPanelButtons.add(bnClone, constrProc);
constrProc.gridx = 1;
constrProc.weightx = 1;
constrProc.fill = GridBagConstraints.HORIZONTAL;
// constrProc.insets = new Insets(1, 2, 1, 2);
seedBuildPanelButtons.add(bnFore, constrProc); |
File |
Line |
com/github/celldynamics/quimp/Constrictor.java |
302 |
com/github/celldynamics/quimp/Constrictor.java |
356 |
for (int si = 0; si < nestSize; si++) {
// if (nest.getHandler(si).isSnakeHandlerFrozen()) {
// continue;
// }
snakeA = nest.getHandler(si).getLiveSnake();
if (!snakeA.alive || frame < nest.getHandler(si).getStartFrame()) {
continue;
}
for (int sj = si + 1; sj < nestSize; sj++) {
snakeB = nest.getHandler(sj).getLiveSnake();
if (!snakeB.alive || frame < nest.getHandler(si).getStartFrame()) {
continue;
}
// proximity is computed for centroids, this is limit below we test for contact.
// if snake is big enough it can be not tested even if interact with other
if (prox[si][sj] > BOA_.qState.boap.proximity) {
continue; // snakes far away, assume no chance that they will interact
}
freezeProx(snakeA, snakeB);
}
} |
File |
Line |
com/github/celldynamics/quimp/geom/filters/OutlineProcessor.java |
58 |
com/github/celldynamics/quimp/geom/filters/OutlineProcessor.java |
88 |
pp.smoothMean(window, iters);
List<Point2d> p = pp.getList();
Iterator<?> it = outline.iterator();
Iterator<Point2d> itl = p.iterator();
while (it.hasNext() && itl.hasNext()) {
PointsList<?> n = (PointsList<?>) it.next();
ExtendedVector2d v = n.getPoint();
Point2d pr = itl.next();
v.x = pr.x;
v.y = pr.y;
}
outline.calcCentroid();
outline.updateNormals(true);
outline.setPositions();
return this;
}
/**
* Apply running median filter to Shape.
*
* <p>Do not create new Shape but modify nodes of existing one. Compute
* {@link Shape#calcCentroid()}, {@link Shape#updateNormals(boolean)} and
* {@link Shape#setPositions()}. Normals are updated inwards.
*
* @param window size of filter window, must be uneven
* @param iters number of smoothing iterations
* @return reference to this object. Allows chaining
*/
public OutlineProcessor<T> runningMedian(int window, int iters) { |
File |
Line |
com/github/celldynamics/quimp/SnakeHandler.java |
283 |
com/github/celldynamics/quimp/SnakeHandler.java |
305 |
PrintWriter pw = new PrintWriter(new FileWriter(old), true); // auto flush
for (int i = 0; i < finalSnakes.length; i++) {
if (finalSnakes[i] == null) {
break;
}
if (i != 0) {
pw.print("\n");
} // no new line at top
pw.print(finalSnakes[i].getNumPoints());
Node n = finalSnakes[i].getHead();
do {
pw.print("\n" + IJ.d2s(n.getX(), 6));
pw.print("\n" + IJ.d2s(n.getY(), 6)); |
File |
Line |
com/github/celldynamics/quimp/plugin/randomwalk/ProbabilityMaps.java |
42 |
com/github/celldynamics/quimp/plugin/randomwalk/ProbabilityMaps.java |
74 |
public double[][][] convertTo3dMatrix(Object key) {
List<RealMatrix> maps = get(key);
// Can be null if points not found
if (maps == null || maps.isEmpty()) {
return null;
}
// assume all maps have the same resolution
int width = maps.get(0).getColumnDimension();
int height = maps.get(0).getRowDimension();
int depth = maps.size();
for (int i = 1; i < depth; i++) {
RealMatrix tmp = maps.get(i);
if (tmp.getRowDimension() != height || tmp.getColumnDimension() != width) {
throw new IllegalArgumentException("All maps must have the same resoultion");
}
} |
File |
Line |
com/github/celldynamics/quimp/Snake.java |
387 |
com/github/celldynamics/quimp/Snake.java |
415 |
private void intializePolygonDirect(final FloatPolygon p) throws BoaException {
// System.out.println("poly direct");
head = new Node(0); // make a dummy head node for list initialization
POINTS = 1;
FROZEN = 0;
head.setPrev(head); // link head to itself
head.setNext(head);
head.setHead(true);
Node node;
for (int i = 0; i < p.npoints; i++) {
node = new Node((double) p.xpoints[i], (double) p.ypoints[i], nextTrackNumber++);
addPoint(node);
}
removeNode(head); // remove dummy head node
setPositions();
this.makeAntiClockwise();
updateNormals(BOA_.qState.segParam.expandSnake);
} |
File |
Line |
com/github/celldynamics/quimp/utils/graphics/svg/SVGplotter.java |
93 |
com/github/celldynamics/quimp/utils/graphics/svg/SVGplotter.java |
144 |
int miny = (int) Math.floor(oh.minCoor.getY()) - 10;
int minx = (int) Math.floor(oh.minCoor.getX()) - 10;
int maxy = (int) Math.ceil(oh.maxCoor.getY()) + 10;
int maxx = (int) Math.ceil(oh.maxCoor.getX()) + 10;
int width = maxx - minx;
int height = maxy - miny;
try {
BufferedOutputStream out = new BufferedOutputStream(
new FileOutputStream(outFile.getAbsolutePath() + FileExtensions.motvecimageFileExt)); |
File |
Line |
com/github/celldynamics/quimp/plugin/protanalysis/ActionTrackPoints.java |
149 |
com/github/celldynamics/quimp/plugin/protanalysis/ActionTrackPoints.java |
207 |
visStackDynamic.circleRadius = options.circleRadius;
HashMap<Integer, List<Point2D>> tmpSelected = extractPoints(stMap);
// plot - iterate over cells (keys) and plot all points
for (Map.Entry<Integer, List<Point2D>> entry : tmpSelected.entrySet()) {
Integer cellNo = entry.getKey(); // cell number
List<Point2D> points = entry.getValue(); // users points
MaximaFinder mf = new MaximaFinder(ui.getImagePlus().getProcessor());
mf.setMaxima(points);
TrackCollection trackCollection = getTracks(stMap, cellNo, mf);
if (options.chbShowPoint.booleanValue()) { |
File |
Line |
com/github/celldynamics/quimp/plugin/randomwalk/RandomWalkSegmentation.java |
1675 |
com/github/celldynamics/quimp/plugin/randomwalk/RandomWalkSegmentation.java |
1733 |
com/github/celldynamics/quimp/plugin/randomwalk/RandomWalkSegmentation.java |
1904 |
com/github/celldynamics/quimp/plugin/randomwalk/RandomWalkSegmentation.java |
1964 |
public MatrixDotProduct(RealMatrix m) {
this.matrix = m;
}
/*
* (non-Javadoc)
*
* @see org.apache.commons.math3.linear.RealMatrixChangingVisitor#end()
*/
@Override
public double end() {
return 0;
}
/*
* (non-Javadoc)
*
* @see org.apache.commons.math3.linear.RealMatrixChangingVisitor#start(int, int, int, int, int,
* int)
*/
@Override
public void start(int arg0, int arg1, int arg2, int arg3, int arg4, int arg5) {
if (matrix.getColumnDimension() != arg1 || matrix.getRowDimension() != arg0) {
throw new MatrixDimensionMismatchException(matrix.getRowDimension(),
matrix.getColumnDimension(), arg0, arg1);
}
}
/*
* (non-Javadoc)
*
* @see org.apache.commons.math3.linear.RealMatrixChangingVisitor#visit(int, int, double)
*/
@Override
public double visit(int arg0, int arg1, double arg2) {
return arg2 * matrix.getEntry(arg0, arg1); |
File |
Line |
com/github/celldynamics/quimp/BOA_.java |
1240 |
com/github/celldynamics/quimp/BOA_.java |
1268 |
double max, double step, int columns) {
SpinnerNumberModel model = new SpinnerNumberModel(d, min, max, step);
JSpinner spinner = new JSpinner(model);
((JSpinner.DefaultEditor) spinner.getEditor()).getTextField().setColumns(columns);
spinner.addChangeListener(this);
Panel p = new Panel();
p.setLayout(new FlowLayout(FlowLayout.RIGHT));
Label label = new Label(s);
p.add(label);
p.add(spinner);
mp.add(p);
return spinner;
}
/**
* Helper method for creating spinner in UI with integer values.
*
* @param s Label of spinner (added on its left side)
* @param mp Reference of panel where spinner is located
* @param d The current vale of model
* @param min The first number in sequence
* @param max The last number in sequence
* @param step The difference between numbers in sequence
* @param columns The number of columns preferred for display
* @return Reference to created spinner
*/
private JSpinner addIntSpinner(final String s, final Container mp, int d, int min, int max, |
File |
Line |
com/github/celldynamics/quimp/Test_QuimP.java |
185 |
com/github/celldynamics/quimp/Test_QuimP.java |
192 |
System.out.println("\nLines parallel and overlap");
System.out.println("close all;plot([" + a.getX() + "," + b.getX() + "],[" + a.getY() + ","
+ b.getY() + "],'-ob');"); // matlab output
System.out.println("hold on; plot([" + c.getX() + "," + d.getX() + "],[" + c.getY() + ","
+ d.getY() + "],'-or');");
System.out.println("plot(" + intersect[0] + "," + intersect[1] + ", 'og');");
} else if (state == 1) { |
File |
Line |
com/github/celldynamics/quimp/plugin/ecmm/Sector.java |
95 |
com/github/celldynamics/quimp/plugin/ecmm/Sector.java |
159 |
}
}
Vert v = migCharges.getHead();
ExtendedVector2d normal;
do {
normal = new ExtendedVector2d(v.getNormal().getX(), v.getNormal().getY());
normal.multiply(outerNormal * ECMp.w);
v.getPoint().addVec(normal);
v = v.getNext();
} while (!v.isHead());
if (ECMp.chargeDensity != -1) {
migCharges.setResolution(ECMp.chargeDensity);
tarCharges.setResolution(ECMp.chargeDensity);
} |
File |
Line |
com/github/celldynamics/quimp/geom/MapTracker.java |
90 |
com/github/celldynamics/quimp/geom/MapTracker.java |
114 |
double[] diffC = rowDiff(p, rowAdd(+1, coordMap[i - 1]));
double[] minDiffA = QuimPArrayUtils.minArrayIndexElement(diffA);
double[] minDiffB = QuimPArrayUtils.minArrayIndexElement(diffB);
double[] minDiffC = QuimPArrayUtils.minArrayIndexElement(diffC);
// copy min values to array
minV[0] = minDiffA[0];
minV[1] = minDiffB[0];
minV[2] = minDiffC[0];
minI[0] = minDiffA[1];
minI[1] = minDiffB[1];
minI[2] = minDiffC[1];
double[] minMinV = QuimPArrayUtils.minArrayIndexElement(minV); |