/** Test of evaluateAt method, of class ParameterisedGroup. */ @Test public void testEvaluateAt() throws ParameterException { System.out.println("--- testEvaluateAt..."); // SegmentLocation loc1 = new PostSynapticTerminalLocation(d2.getSegmentId(), 0.5f); assertEquals(0.5, pg1.evaluateAt(cell, d2, 0.5f), 0); assertEquals(15, pg2.evaluateAt(cell, d2, 0.5f), 0); //////// assertEquals(15, pg5.evaluateAt(cell, loc1), 0); // SegmentLocation loc2 = new PostSynapticTerminalLocation(d3.getSegmentId(), 0.5f); assertEquals(5d / 6d, pg1.evaluateAt(cell, d3, 0.5f), 1e-7); assertEquals(25, pg2.evaluateAt(cell, d3, 0.5f), 0); assertEquals(0.5, pg3.evaluateAt(cell, d3, 0.5f), 0); assertEquals(0, pg4.evaluateAt(cell, d3, 0), 0); assertEquals(5, pg4.evaluateAt(cell, d3, 0.5f), 0); SegmentLocation sl1 = new SegmentLocation(d3.getSegmentId(), 0.5f); assertEquals( 25, pg5.evaluateAt(cell, cell.getSegmentWithId(sl1.getSegmentId()), sl1.getFractAlong()), 0); assertEquals(30, pg5.evaluateAt(cell, d3, 1), 0); GenesisCompartmentalisation g = new GenesisCompartmentalisation(); Cell gCell = g.getCompartmentalisation(cell); System.out.println(CellTopologyHelper.printDetails(cell, null)); System.out.println( "Changed from morph: " + cell.getMorphSummary() + ", to morph: " + gCell.getMorphSummary()); System.out.println("getSegmentMapper: " + g.getSegmentMapper()); System.out.println(CellTopologyHelper.printDetails(gCell, null)); SegmentLocation sl1_g = g.getSegmentMapper().mapSegmentLocation(sl1); System.out.println("Mapped: " + sl1 + " to " + sl1_g); assertEquals( 25, pg5.evaluateAt(gCell, gCell.getSegmentWithId(sl1_g.getSegmentId()), sl1_g.getFractAlong()), 0); }
public static void main(String[] args) { RectangularBox rb = new RectangularBox(); System.out.println("Created: " + rb); Point3f p = new Point3f(95, 18f, 98); System.out.println("Moved: " + rb.getTranslatedRegion(new Vector3f(p))); System.out.println("Sphere around: " + RectangularBox.getEnclosingSphere(rb)); SimpleCell cell = new SimpleCell("fff"); Vector3f origLoc = new Vector3f(cell.getFirstSomaSegment().getStartPointPosition()); origLoc.scale(-1); CellTopologyHelper.translateAllPositions(cell, origLoc); System.out.println("Cell: " + CellTopologyHelper.printShortDetails(cell)); System.out.println("Is point: " + p + " in region: " + rb.isCellWithinRegion(p, cell, true)); }
protected Point3f generateNextPosition() throws CellPackingException { Point3f proposedPoint = null; logger.logComment( "---- Generating next position. positionsAlreadyTaken.size() = " + getNumPosAlreadyTaken()); float minXLoc, minYLoc, minZLoc, maxXLoc, maxYLoc, maxZLoc; if (mustBeCompletelyInsideRegion()) { // limit the extent for possible location of soma centre to box which // will preclude soma wall impacting region boundary. minXLoc = myRegion.getLowestXValue() - CellTopologyHelper.getMinXExtent(myCell, true, false); minYLoc = myRegion.getLowestYValue() - CellTopologyHelper.getMinYExtent(myCell, true, false); minZLoc = myRegion.getLowestZValue() - CellTopologyHelper.getMinZExtent(myCell, true, false); maxXLoc = myRegion.getHighestXValue() - CellTopologyHelper.getMaxXExtent(myCell, true, false); maxYLoc = myRegion.getHighestYValue() - CellTopologyHelper.getMaxYExtent(myCell, true, false); maxZLoc = myRegion.getHighestZValue() - CellTopologyHelper.getMaxZExtent(myCell, true, false); } else { // in this case the soma centre can be anywhere inside the region.. minXLoc = myRegion.getLowestXValue(); minYLoc = myRegion.getLowestYValue(); minZLoc = myRegion.getLowestZValue(); maxXLoc = myRegion.getHighestXValue(); maxYLoc = myRegion.getHighestYValue(); maxZLoc = myRegion.getHighestZValue(); } Point3f startPoint = new Point3f(minXLoc, minYLoc, minZLoc); logger.logComment("minXLoc: " + minXLoc + ", maxXLoc: " + maxXLoc); if (maxXLoc - minXLoc < 0 || maxYLoc - minYLoc < 0 || maxZLoc - minZLoc < 0) { throw new CellPackingException("Diameter of cell is smaller than region"); } if (getNumPosAlreadyTaken() >= getNumberCells()) { throw new CellPackingException("All cells successfully placed"); } if (getNumberCells() == 0) { throw new CellPackingException("Cell number set to zero!!"); } else if (getNumberCells() == 1) { if (parameterList[DIMENSION_PARAM].value == DIMENSION_PARAM_X) { proposedPoint = new Point3f((minXLoc + maxXLoc) / 2, minYLoc, minZLoc); } else if (parameterList[DIMENSION_PARAM].value == DIMENSION_PARAM_Y) { proposedPoint = new Point3f(minXLoc, (minYLoc + maxYLoc) / 2, minZLoc); } else if (parameterList[DIMENSION_PARAM].value == DIMENSION_PARAM_Z) { proposedPoint = new Point3f(minXLoc, minYLoc, (minZLoc + maxZLoc) / 2); } } else { // Point3f lastPositionedPoint = getLastPosTaken(); if (parameterList[DIMENSION_PARAM].value == DIMENSION_PARAM_X) { float distanceApart = (maxXLoc - minXLoc) / (getNumberCells() - 1); proposedPoint = new Point3f(startPoint); proposedPoint.add(new Point3f(distanceApart * numProposedPoints, 0, 0)); logger.logComment( "Placing one of " + getNumberCells() + " cells in x dim..." + distanceApart + " apart, new: " + proposedPoint + ", already proposed: " + numProposedPoints); if (proposedPoint.x > maxXLoc) throw new CellPackingException("Reached end of x dimension"); } else if (parameterList[DIMENSION_PARAM].value == DIMENSION_PARAM_Y) { logger.logComment("Placing cell in y dim..."); float distanceApart = (maxYLoc - minYLoc) / (getNumberCells() - 1); proposedPoint = new Point3f(startPoint); proposedPoint.add(new Point3f(0, distanceApart * numProposedPoints, 0)); if (proposedPoint.y > maxYLoc) throw new CellPackingException("Reached end of y dimension"); } else if (parameterList[DIMENSION_PARAM].value == DIMENSION_PARAM_Z) { logger.logComment("Placing cell in z dim..."); float distanceApart = (maxZLoc - minZLoc) / (getNumberCells() - 1); proposedPoint = new Point3f(startPoint); proposedPoint.add(new Point3f(0, 0, distanceApart * numProposedPoints)); if (proposedPoint.z > maxZLoc) throw new CellPackingException("Reached end of z dimension"); } if (proposedPoint == null) throw new CellPackingException("Cannot successfully place cell."); } // lastProposedPoint = new Point3d(proposedPoint); numProposedPoints++; return new Point3f(proposedPoint); }
public static void main(String[] args) { GolgiCell g = new GolgiCell("Test golgi"); System.out.println(CellTopologyHelper.printDetails(g, null)); }