public void Update(Tissue t) { var _context = new ApplicationDbContext(); _context.Entry(t).State = EntityState.Modified; _context.SaveChanges(); }
public override void SetupSimulation() { logFrequency = 1; nbCellTypes = 3; nbOfSimulationSteps = 10; //* popSize = 148; popMaxSize = 343; Tissue t1 = new Tissue(25, 125, new Cylinder34(new Vector(.5f, .5f, .5f))); Tissue t2 = new Tissue(98, popMaxSize, new Cylinder34(new Vector(.5f, 1f, .5f))); Tissue t3 = new Tissue(25, 125, new Cylinder34(new Vector(.5f, .5f, .5f))); List <Tissue> tissueList = new List <Tissue>() { t1, t2, t3 }; cellPopulation = new CellPopulation(popSize, popMaxSize, tissueList, true); //Helper.SetNCubedInN(125); //t1.PositionCells(false); //Helper.SetNCubedInN(popMaxSize); //t2.PositionCells(false, new Vector(0, t1.reference.y + t1.mesh.innerRadius.y + t2.mesh.innerRadius.y, 0)); Helper.SetNCubedInN(popMaxSize); t2.PositionCells(false); Helper.SetNCubedInN(125); t1.PositionCells(false, new Vector(0, t2.reference.y - 4 * t2.mesh.innerRadius.y - t1.mesh.innerRadius.y, 0)); Helper.SetNCubedInN(125); t3.PositionCells(false, new Vector(0, t2.reference.y + t3.mesh.innerRadius.y, 0)); //*/ nbCellTypes = tissueList.Count; }
public void Insert(Tissue t) { var _context = new DataContext(); _context.Tissues.Add(t); _context.SaveChanges(); }
public void Delete(Tissue t) { var _context = new ApplicationDbContext(); _context.Tissues.Remove(t); _context.SaveChanges(); }
public AStar(VG.Map.Tissue t) { this.map = t; nodeGrid = new AStarNode[200][]; openSet = new bool[200][]; closedSet= new bool[200][]; cacheable = new bool[200][]; for (int i = 0; i < 200; i++) { nodeGrid[i] = new AStarNode[200]; openSet[i] = new bool[200]; closedSet[i] = new bool[200]; cacheable[i] = new bool[200]; } // prepare cacheable set EntityCollection aznCol = map.get_EntitiesByType(EntityEnum.AZN); for (int i = 0; i < aznCol.Count; i++) cacheable[aznCol[i].X][aznCol[i].Y] = true; EntityCollection hpCol = map.get_EntitiesByType(EntityEnum.HoshimiPoint); for (int i = 0; i < hpCol.Count; i++) cacheable[hpCol[i].X][hpCol[i].Y] = true; //cache PierreIP cacheable[Global.MYAI.PierreTeamInjectionPoint.X][Global.MYAI.PierreTeamInjectionPoint.Y] = true; cache = new System.Collections.Hashtable( (hpCol.Count * hpCol.Count) + (aznCol.Count * aznCol.Count) ); aznCol = null; // garbage-collected hpCol = null; }
public void Delete(Tissue t) { var _context = new DataContext(); _context.Tissues.Remove(t); _context.SaveChanges(); }
public void validate_spectral_generation_of_OpticalProperties_with_tissue() { var scatterer = new IntralipidScatterer(0.01); var fatAbsorber = new ChromophoreAbsorber(ChromophoreType.Fat, 0.01); var waterAbsorber = new ChromophoreAbsorber(ChromophoreType.H2O, 0.99); var _twoLayerSDAForwardSolver = new TwoLayerSDAForwardSolver(); var _oneLayerPointSourceForwardSolver = new PointSourceSDAForwardSolver(); var n = 1.4; var wvs = new DoubleRange(650, 1000, 36).AsEnumerable().ToArray(); var rho = 10; var tissue = new Tissue( new IChromophoreAbsorber[] { fatAbsorber, waterAbsorber }, scatterer, "test_tissue", n); var ops = wvs.Select(wv => tissue.GetOpticalProperties(wv)).ToArray(); var fs = new PointSourceSDAForwardSolver(); var reflectanceVsWavelength = fs.ROfRho(ops, rho); Assert.NotNull(reflectanceVsWavelength); Assert.AreEqual(reflectanceVsWavelength.Length, wvs.Length); // check that change in scattering changes the reflectance Assert.IsTrue(reflectanceVsWavelength[0] != reflectanceVsWavelength[1]); // check that change in absorption changes the reflectance Assert.IsTrue(reflectanceVsWavelength[1] != reflectanceVsWavelength[2]); }
public void validate_ROfFxAndFt_With_Wavelength() { // used values for tissue=liver var scatterer = new PowerLawScatterer(0.84, 0.55); var hbAbsorber = new ChromophoreAbsorber(ChromophoreType.Hb, 66); var hbo2Absorber = new ChromophoreAbsorber(ChromophoreType.HbO2, 124); var fatAbsorber = new ChromophoreAbsorber(ChromophoreType.Fat, 0.02); var waterAbsorber = new ChromophoreAbsorber(ChromophoreType.H2O, 0.87); var n = 1.4; var wvs = new double[] { 650, 700 }; var fxs = new double[] { 0.0, 0.5 }; var fts = new double[] { 0.0, 0.50 }; var tissue = new Tissue( new IChromophoreAbsorber[] { hbAbsorber, hbo2Absorber, fatAbsorber, waterAbsorber }, scatterer, "test_tissue", n); var ops = wvs.Select(wv => tissue.GetOpticalProperties(wv)).ToArray(); var fs = new DistributedPointSourceSDAForwardSolver(); var rVsWavelength = fs.ROfFxAndFt(ops, fxs, fts); // return from ROfFxAndFt is new double[ops.Length * fxs.Length * fts.Length]; // order is: (ops0,fxs0,fts0), (ops0,fxs0,ts1)...(ops0,fxs0,ftsnt-1) // (ops0,fxs1,fts0), (ops0,fxs1,ts1)...(ops0,fxs1,ftsnt-1) // ... // (ops0,fxsnf-1,fts0),.................(ops0,fxsnf-1,ftsnt-1) // ... repeat above with ops1... // [0] -> ops0=650, fx0=0.0, fts0=0.0 Assert.IsTrue(Math.Abs(rVsWavelength[0].Real - 1.890007) < 0.000001); // API match Assert.IsTrue(Math.Abs(rVsWavelength[0].Imaginary - 0.0) < 0.000001); // API match // [1] -> ops0=650, fx0=0.0, fts1=0.5 Assert.IsTrue(Math.Abs(rVsWavelength[1].Real - 1.888160) < 0.000001); Assert.IsTrue(Math.Abs(rVsWavelength[1].Imaginary + 0.045122) < 0.000001); // [2] -> ops0=650, fx1=0.5, fts0=0.0 Assert.IsTrue(Math.Abs(rVsWavelength[2].Real - 0.562537) < 0.000001); // API match Assert.IsTrue(Math.Abs(rVsWavelength[2].Imaginary - 0.0) < 0.000001); // API match // [3] -> ops0=650, fx1=0.5, fts1=0.5 Assert.IsTrue(Math.Abs(rVsWavelength[3].Real - 0.562543) < 0.000001); Assert.IsTrue(Math.Abs(rVsWavelength[3].Imaginary + 0.000799) < 0.000001); // [4] -> ops1=700, fx0=0.0, fts0=0.0 Assert.IsTrue(Math.Abs(rVsWavelength[4].Real - 2.118427) < 0.000001); // API match Assert.IsTrue(Math.Abs(rVsWavelength[4].Imaginary - 0.0) < 0.000001); // API match // [5] -> ops1=700, fx0=0.0, fts1=0.5 Assert.IsTrue(Math.Abs(rVsWavelength[5].Real - 2.113377) < 0.000001); Assert.IsTrue(Math.Abs(rVsWavelength[5].Imaginary + 0.071758) < 0.000001); // [6] -> ops1=700, fx1=0.5, fts0=0.0 Assert.IsTrue(Math.Abs(rVsWavelength[6].Real - 0.543539) < 0.000001); // API match Assert.IsTrue(Math.Abs(rVsWavelength[6].Imaginary - 0.0) < 0.000001); // API match // [7] -> ops1=700, fx1=0.5, fts1=0.5 Assert.IsTrue(Math.Abs(rVsWavelength[7].Real - 0.543546) < 0.000001); Assert.IsTrue(Math.Abs(rVsWavelength[7].Imaginary + 0.000651) < 0.000001); }
public void validate_ROfRhoAndFt_With_Wavelength() { // used values for tissue=liver var scatterer = new PowerLawScatterer(0.84, 0.55); var hbAbsorber = new ChromophoreAbsorber(ChromophoreType.Hb, 66); var hbo2Absorber = new ChromophoreAbsorber(ChromophoreType.HbO2, 124); var fatAbsorber = new ChromophoreAbsorber(ChromophoreType.Fat, 0.02); var waterAbsorber = new ChromophoreAbsorber(ChromophoreType.H2O, 0.87); var n = 1.4; var wvs = new double[] { 650, 700 }; var rhos = new double[] { 0.5, 1.625 }; var fts = new double[] { 0.0, 0.50 }; var tissue = new Tissue( new IChromophoreAbsorber[] { hbAbsorber, hbo2Absorber, fatAbsorber, waterAbsorber }, scatterer, "test_tissue", n); var ops = wvs.Select(wv => tissue.GetOpticalProperties(wv)).ToArray(); var fs = new PointSourceSDAForwardSolver(); var rVsWavelength = fs.ROfRhoAndFt(ops, rhos, fts); // return from ROfRhoAndFt is new double[ops.Length * rhos.Length * fts.Length]; // order is: (ops0,rhos0,fts0), (ops0,rhos0,fts1)...(ops0,rhos0,ftsnt-1) // (ops0,rhos1,fts0), (ops0,rhos1,fts1)...(ops0,rhos1,ftsnt-1) // ... // (ops0,rhosnr-1,fts0),.................(ops0,rhosnr-1,ftsnt-1) // ... repeat above with ops1... // [0] -> ops0=650, rho0=0.5, fts0=0.0 Assert.IsTrue(Math.Abs(rVsWavelength[0].Real - 0.037575) < 0.000001); Assert.IsTrue(Math.Abs(rVsWavelength[0].Imaginary - 0.0) < 0.000001); // [1] -> ops0=650, rho0=0.5, fts1=0.5 Assert.IsTrue(Math.Abs(rVsWavelength[1].Real - 0.037511) < 0.000001); Assert.IsTrue(Math.Abs(rVsWavelength[1].Imaginary + 0.001200) < 0.000001); // [2] -> ops0=650, rho1=1.635, fts0=0.0 Assert.IsTrue(Math.Abs(rVsWavelength[2].Real - 0.009306) < 0.000001); Assert.IsTrue(Math.Abs(rVsWavelength[2].Imaginary - 0.0) < 0.000001); // [3] -> ops0=650, rho1=1.635, fts1=0.5 Assert.IsTrue(Math.Abs(rVsWavelength[3].Real - 0.009255) < 0.000001); Assert.IsTrue(Math.Abs(rVsWavelength[3].Imaginary + 0.000674) < 0.000001); // [4] -> ops1=700, rho0=0.5, fts0=0.0 Assert.IsTrue(Math.Abs(rVsWavelength[4].Real - 0.036425) < 0.000001); Assert.IsTrue(Math.Abs(rVsWavelength[4].Imaginary - 0.0) < 0.000001); // [5] -> ops1=700, rho0=0.5, fts1=0.5 Assert.IsTrue(Math.Abs(rVsWavelength[5].Real - 0.036310) < 0.000001); Assert.IsTrue(Math.Abs(rVsWavelength[5].Imaginary + 0.001446) < 0.000001); // [6] -> ops1=700, rho1=1.635, fts0=0.0 Assert.IsTrue(Math.Abs(rVsWavelength[6].Real - 0.010657) < 0.000001); Assert.IsTrue(Math.Abs(rVsWavelength[6].Imaginary - 0.0) < 0.000001); // [7] -> ops1=700, rho1=1.635, fts1=0.5 Assert.IsTrue(Math.Abs(rVsWavelength[7].Real - 0.010558) < 0.000001); Assert.IsTrue(Math.Abs(rVsWavelength[7].Imaginary + 0.000929) < 0.000001); }
public void validate_ROfFxAndTime_With_Wavelength() { // used values for tissue=liver var scatterer = new PowerLawScatterer(0.84, 0.55); var hbAbsorber = new ChromophoreAbsorber(ChromophoreType.Hb, 66); var hbo2Absorber = new ChromophoreAbsorber(ChromophoreType.HbO2, 124); var fatAbsorber = new ChromophoreAbsorber(ChromophoreType.Fat, 0.02); var waterAbsorber = new ChromophoreAbsorber(ChromophoreType.H2O, 0.87); var n = 1.4; var wvs = new double[] { 650, 700 }; var fxs = new double[] { 0.0, 0.5 }; var times = new double[] { 0.05, 0.10 }; var tissue = new Tissue( new IChromophoreAbsorber[] { hbAbsorber, hbo2Absorber, fatAbsorber, waterAbsorber }, scatterer, "test_tissue", n); var ops = wvs.Select(wv => tissue.GetOpticalProperties(wv)).ToArray(); var rVsWavelength = ComputationFactory.ComputeReflectance( new DistributedPointSourceSDAForwardSolver(), SolutionDomainType.ROfFxAndTime, ForwardAnalysisType.R, new object[] { ops, fxs, times }); // return from ROfFxAndTime is new double[ops.Length * fxs.Length * ts.Length]; // order is: (ops0,fxs0,ts0), (ops0,fxs0,ts1)...(ops0,fxs0,tsnt-1) // (ops0,fxs1,ts0), (ops0,fxs1,ts1)...(ops0,fxs1,tsnt-1) // ... // (ops0,fxsnf-1,ts0),................(ops0,fxsnf-1,tsnt-1) // ... repeat above with ops1... // [0] -> ops0=650, fx0=0.0, ts0=0.05 Assert.IsTrue(Math.Abs(rVsWavelength[0] - 1.558702) < 0.000001); // [1] -> ops0=650, fx0=0.0, ts1=0.10 Assert.IsTrue(Math.Abs(rVsWavelength[1] - 0.391871) < 0.000001); // [2] -> ops0=650, fx1=0.5, ts0=0.05 Assert.IsTrue(Math.Abs(rVsWavelength[2] - 5.023055e-12) < 0.000001e-12); // [3] -> ops0=650, fx1=0.5, ts1=0.10 Assert.IsTrue(Math.Abs(rVsWavelength[3] - 1.032586e-13) < 0.000001e-13); // [4] -> ops1=700, fx0=0.0, ts0=0.05 Assert.IsTrue(Math.Abs(rVsWavelength[4] - 2.218329) < 0.000001); // [5] -> ops1=700, fx1=0.5, ts1=0.10 Assert.IsTrue(Math.Abs(rVsWavelength[5] - 0.797200) < 0.000001); // [6] -> ops1=700, fx0=0.0, ts0=0.05 Assert.IsTrue(Math.Abs(rVsWavelength[6] - 1.347053e-12) < 0.000001e-12); // [7] -> ops1=700, fx1=0.5, ts1=0.10 Assert.IsTrue(Math.Abs(rVsWavelength[7] - 2.052883e-13) < 0.000001e-13); }
public void validate_ROfRhoAndTime_With_Wavelength() { // used values for tissue=liver var scatterer = new PowerLawScatterer(0.84, 0.55); var hbAbsorber = new ChromophoreAbsorber(ChromophoreType.Hb, 66); var hbo2Absorber = new ChromophoreAbsorber(ChromophoreType.HbO2, 124); var fatAbsorber = new ChromophoreAbsorber(ChromophoreType.Fat, 0.02); var waterAbsorber = new ChromophoreAbsorber(ChromophoreType.H2O, 0.87); var n = 1.4; var wvs = new double[] { 650, 700 }; var rhos = new double[] { 0.5, 1.625 }; var times = new double[] { 0.05, 0.10 }; var tissue = new Tissue( new IChromophoreAbsorber[] { hbAbsorber, hbo2Absorber, fatAbsorber, waterAbsorber }, scatterer, "test_tissue", n); var ops = wvs.Select(wv => tissue.GetOpticalProperties(wv)).ToArray(); var rVsWavelength = ComputationFactory.ComputeReflectance( new PointSourceSDAForwardSolver(), SolutionDomainType.ROfRhoAndTime, ForwardAnalysisType.R, new object[] { ops, rhos, times }); // return from ROfRhoAndTime is new double[ops.Length * rhos.Length * ts.Length]; // order is: (ops0,rhos0,ts0), (ops0,rhos0,ts1)...(ops0,rhos0,tsnt-1) // (ops0,rhos1,ts0), (ops0,rhos1,ts1)...(ops0,rhos1,tsnt-1) // ... // (ops0,rhosnr-1,ts0),.................(ops0,rhosnr-1,tsnt-1) // ... repeat above with ops1... // [0] -> ops0=650, rho0=0.5, ts0=0.05 Assert.IsTrue(Math.Abs(rVsWavelength[0] - 0.044606) < 0.000001); // API match // [1] -> ops0=650, rho0=0.5, ts1=0.10 Assert.IsTrue(Math.Abs(rVsWavelength[1] - 0.005555) < 0.000001); // [2] -> ops0=650, rho1=1.635, ts0=0.05 Assert.IsTrue(Math.Abs(rVsWavelength[2] - 0.036900) < 0.000001); // API match // [3] -> ops0=650, rho1=1.635, ts1=0.10 Assert.IsTrue(Math.Abs(rVsWavelength[3] - 0.005053) < 0.000001); // [4] -> ops1=700, rho0=0.5, ts0=0.05 Assert.IsTrue(Math.Abs(rVsWavelength[4] - 0.057894) < 0.000001); // API match // [5] -> ops1=700, rho0=0.5, ts1=0.10 Assert.IsTrue(Math.Abs(rVsWavelength[5] - 0.010309) < 0.000001); // [6] -> ops1=700, rho1=1.635, ts0=0.05 Assert.IsTrue(Math.Abs(rVsWavelength[6] - 0.048493) < 0.000001); // API match // [7] -> ops1=700, rho1=1.635, ts1=0.10 Assert.IsTrue(Math.Abs(rVsWavelength[7] - 0.009434) < 0.000001); }
public static bool isPointOK(Tissue tissue, int X, int Y) { if (!tissue.IsInMap(X, Y)) { return(false); } return(tissue[X, Y].AreaType == AreaEnum.HighDensity | tissue[X, Y].AreaType == AreaEnum.MediumDensity | tissue[X, Y].AreaType == AreaEnum.LowDensity); }
public IActionResult Add(Tissue tissue) { var result = _tissueService.Add(tissue); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public IResult <Tissue> Add(Tissue tissue) { var result = BusinessRules <Tissue> .Checker(DuplicateNameChecker(tissue.Name)); if (result != null) { foreach (var error in result) { return(new FailResult <Tissue>(error.Message)); } } _tissueDal.Add(tissue); return(new SuccessResult <Tissue>(Messages.success, tissue)); }
public static Point getValidPoint(Tissue tissue, Point p) { if (isPointOK(tissue, p.X, p.Y)) { return(p); } int dist = 1; while (true) { //up for (int iX = -dist; iX < dist + 1; iX++) { if (isPointOK(tissue, p.X + iX, p.Y + dist)) { return(new Point(p.X + iX, p.Y + dist)); } } //down for (int iX = -dist; iX < dist + 1; iX++) { if (isPointOK(tissue, p.X + iX, p.Y - dist)) { return(new Point(p.X + iX, p.Y - dist)); } } //left for (int iY = -dist; iY < dist + 1; iY++) { if (isPointOK(tissue, p.X - dist, p.Y + iY)) { return(new Point(p.X - dist, p.Y + iY)); } } //right for (int iY = -dist; iY < dist + 1; iY++) { if (isPointOK(tissue, p.X + dist, p.Y + iY)) { return(new Point(p.X + dist, p.Y + iY)); } } dist++; } }
public ActionResult CreateNewTissue(Tissue tissue) { ViewBag.Error = ""; try { if (ModelState.IsValid) { repoTissue.Insert(tissue.Name); return(RedirectToAction("TissuesManagement")); } } catch { ViewBag.Error = "Die Gewebeart ist schon vorhanden!"; } return(View(tissue)); }
public override void SetupSimulation() { logFrequency = 1; logVTK = true; nbOfSimulationSteps = 1000; popSize = 1; popMaxSize = 128; Tissue t1 = new Tissue(1, popMaxSize); List <Tissue> tissueList = new List <Tissue>() { t1 }; nbCellTypes = tissueList.Count; cellPopulation = new CellPopulation(popSize, popMaxSize, tissueList); Helper.SetNCubedInN(popMaxSize); cellPopulation.PositionCells(false); }
public AStar(VG.Map.Tissue t) { this.map = t; nodeGrid = new AStarNode[200][]; openSet = new bool[200][]; closedSet = new bool[200][]; cacheable = new bool[200][]; for (int i = 0; i < 200; i++) { nodeGrid[i] = new AStarNode[200]; openSet[i] = new bool[200]; closedSet[i] = new bool[200]; cacheable[i] = new bool[200]; } // prepare cacheable set EntityCollection aznCol = map.get_EntitiesByType(EntityEnum.AZN); for (int i = 0; i < aznCol.Count; i++) { cacheable[aznCol[i].X][aznCol[i].Y] = true; } EntityCollection hpCol = map.get_EntitiesByType(EntityEnum.HoshimiPoint); for (int i = 0; i < hpCol.Count; i++) { cacheable[hpCol[i].X][hpCol[i].Y] = true; } //cache PierreIP cacheable[Global.MYAI.PierreTeamInjectionPoint.X][Global.MYAI.PierreTeamInjectionPoint.Y] = true; cache = new System.Collections.Hashtable((hpCol.Count * hpCol.Count) + (aznCol.Count * aznCol.Count)); aznCol = null; // garbage-collected hpCol = null; }
public override void SetupSimulation() { nbOfSimulationSteps = 1000; logFrequency = 1; logVTK = false; popSize = 4; popMaxSize = 8; Icosahedron42 mesh = new Icosahedron42(); Tissue t1 = new Tissue(4, popMaxSize, mesh); List <Tissue> tissueList = new List <Tissue>() { t1 }; nbCellTypes = tissueList.Count; cellPopulation = new CellPopulation(popSize, popMaxSize, tissueList, 1); Helper.SetNCubedInN(popMaxSize); cellPopulation.PositionCells(false); }
public override void SetupSimulation() { nbOfSimulationSteps = 2000; logFrequency = 10; //logVTK = true; popSize = 8; popMaxSize = 64; Cylinder34 mesh = new Cylinder34(new Vector(.5f, 1f, .5f), false); Tissue t1 = new Tissue(8, popMaxSize, mesh); List <Tissue> tissueList = new List <Tissue>() { t1 }; nbCellTypes = tissueList.Count; cellPopulation = new CellPopulation(popSize, popMaxSize, tissueList, 2); Helper.SetNCubedInN(popMaxSize); cellPopulation.PositionCells(false); }
/// <summary> /// Serialize to a JSON object /// </summary> public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } ((Fhir.R4.Models.BackboneElement) this).SerializeJson(writer, options, false); if (Tissue != null) { writer.WritePropertyName("tissue"); Tissue.SerializeJson(writer, options); } if (Value != null) { writer.WritePropertyName("value"); Value.SerializeJson(writer, options); } if (!string.IsNullOrEmpty(SupportingInformation)) { writer.WriteString("supportingInformation", (string)SupportingInformation !); } if (_SupportingInformation != null) { writer.WritePropertyName("_supportingInformation"); _SupportingInformation.SerializeJson(writer, options); } if (includeStartObject) { writer.WriteEndObject(); } }
public override void SetupSimulation() { nbCellTypes = 1; nbOfSimulationSteps = 1000; popSize = 25; popMaxSize = 125; //Cylinder34 mesh = new Cylinder34(); //HexagonalCylinder42 mesh = new HexagonalCylinder42(1f); //Console.WriteLine(mesh.innerRadius); Tissue t1 = new Tissue(25, popMaxSize, new Cylinder34(new Vector(.5f, .5f, .5f))); List <Tissue> tissueList = new List <Tissue>() { t1 }; nbCellTypes = tissueList.Count; cellPopulation = new CellPopulation(popSize, popMaxSize, tissueList); Helper.SetNCubedInN(popMaxSize); cellPopulation.PositionCells(false); }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as WithdrawalPeriodComponent; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if (Tissue != null) { dest.Tissue = (Hl7.Fhir.Model.CodeableConcept)Tissue.DeepCopy(); } if (Value != null) { dest.Value = (Hl7.Fhir.Model.Quantity)Value.DeepCopy(); } if (SupportingInformationElement != null) { dest.SupportingInformationElement = (Hl7.Fhir.Model.FhirString)SupportingInformationElement.DeepCopy(); } return(dest); }
public InitDataContext() { var _context = new DataContext(); if (_context.Stains.Count() == 0) { var stains = new List <Stain> { new Stain { Name = "HE" }, new Stain { Name = "Periodic Acid Schiff (PAS)" }, new Stain { Name = "Giemsa" }, new Stain { Name = "Iron (Prussian Blue)" }, new Stain { Name = "HC" }, new Stain { Name = "Alcian Blue" }, new Stain { Name = "Alcian Blue+PAS" }, new Stain { Name = "Gomori Trichrome blue" }, new Stain { Name = "Gomori Trichrome green" }, new Stain { Name = "EvG" }, new Stain { Name = "AFB" }, new Stain { Name = "GMS" }, new Stain { Name = "Gram" }, new Stain { Name = "Toluidine Blue" }, new Stain { Name = "Acid fast" }, new Stain { Name = "Congo red for amyloid" }, new Stain { Name = "Jones methenamine silver for basement membrane and mesangium" }, new Stain { Name = "Sudan black for lipids & lipochrome pigments" }, new Stain { Name = "Verhoeff's method for elastin" }, new Stain { Name = "Warthin-Starry method for bacteria" }, new Stain { Name = "Weigert’s iron hematoxylin" }, new Stain { Name = "Electron micrograph (EM)" }, new Stain { Name = "Methenamine Silver" }, new Stain { Name = "Jones’ Basement Membrane" }, new Stain { Name = "DMABR" } }; stains.ForEach(s => _context.Stains.Add(s)); _context.SaveChanges(); var organs = new List <Organ> { new Organ { Name = "Organ" }, new Organ { Name = "Liver" }, new Organ { Name = "Kidney" }, new Organ { Name = "Lung" }, new Organ { Name = "Spleen" }, new Organ { Name = "Heart" }, new Organ { Name = "Skin" }, new Organ { Name = "Intestine" }, new Organ { Name = "Submucosa" }, new Organ { Name = "Stomach" }, new Organ { Name = "Urinary bladder" }, new Organ { Name = "Gallbladder" }, new Organ { Name = "Blood vessel" }, new Organ { Name = "Muscles" }, new Organ { Name = "Thyroid" }, new Organ { Name = "Skeleton" }, new Organ { Name = "Breast" }, new Organ { Name = "V****a" }, new Organ { Name = "Uterus" }, new Organ { Name = "Ovar" }, new Organ { Name = "Cervix" }, new Organ { Name = "Prostate" } }; organs.ForEach(o => _context.Organs.Add(o)); _context.SaveChanges(); var reglament = new Reglament { Titel = "Default ", AcceptanceValue = 70, Edges = 200, Scaling = 1.0, SharpnessThresholdValue = 0.3, TileSize = 512, Status = true, }; _context.Reglaments.Add(reglament); _context.SaveChanges(); var tissue = new Tissue { Name = "Tissue" }; _context.Tissues.Add(tissue); _context.SaveChanges(); } }
public List <parentMetabolite> ListOfMetabolites; //metabolite object, level (apriori normalized or non-normalized) public sampleForTissueAndCharge(List <string> _metabolitebVals, List <msMetabolite> _lom) { Id = _metabolitebVals.ElementAt(publicVariables.indexToStartFrom - 3); Tissue = _metabolitebVals.ElementAt(publicVariables.indexToStartFrom - 2); Charge = _metabolitebVals.ElementAt(publicVariables.indexToStartFrom - 1); Phenotype = (clinicalData.List_clinicalData.Any(x => x.Id == Id)) ? clinicalData.List_clinicalData.First(x => x.Id == Id).Phenotype : "U"; ListOfNumClinicalData = new List <sampleClinicalData>(); // add sample weight values if (clinicalData.List_clinicalData.First(x => x.Id == Id).SampleWeight_covariates.Count != 0) { ListOfNumClinicalData.Add(new sampleClinicalData() { name = "sampleweight", n_value = ((publicVariables.prefixValues.mixed == publicVariables.prefix || publicVariables.prefixValues.gcms == publicVariables.prefix) ? clinicalData.List_clinicalData.First(x => x.Id == Id).SampleWeight_covariates.Where(x => x.tissue.ToLower() == Tissue.ToLower()).Average(x => x.weight.Imputed) : clinicalData.List_clinicalData.First(x => x.Id == Id).SampleWeight_covariates .First(x => x.tissue.ToLower() == Tissue.ToLower() && x.charge.ToLower() == Charge.ToLower()).weight.Imputed), typeOf = sampleClinicalData.type.numeric }); } // add numerical clinical data foreach (KeyValuePair <string, imputedValues> kvp_nv in clinicalData.List_clinicalData.First(x => x.Id == Id).Numerical_covariates) { ListOfNumClinicalData.Add(new sampleClinicalData() { name = kvp_nv.Key, n_value = kvp_nv.Value.Imputed, typeOf = sampleClinicalData.type.numeric }); } // add categorical clinical data foreach (KeyValuePair <string, string> kvp_cv in clinicalData.List_clinicalData.First(x => x.Id == Id).Categorical_covariates) { ListOfNumClinicalData.Add(new sampleClinicalData() { name = kvp_cv.Key, c_value = kvp_cv.Value, typeOf = sampleClinicalData.type.categorical }); } // add metabolite levels values ListOfMetabolites = new List <parentMetabolite>(); foreach (msMetabolite _m in _lom) { if (string.IsNullOrEmpty(_metabolitebVals.ElementAt(_m.In_Index)) || string.IsNullOrWhiteSpace(_metabolitebVals.ElementAt(_m.In_Index))) { ListOfMetabolites.Add(new parentMetabolite() { mtbltDetails = _m, mtbltVals = new imputedValues() { Imputed = -1, Non_imputed = -1 } }); } else { ListOfMetabolites.Add(new parentMetabolite() { mtbltDetails = _m, mtbltVals = new imputedValues() { Imputed = Convert.ToDouble(_metabolitebVals.ElementAt(_m.In_Index)), Non_imputed = Convert.ToDouble(_metabolitebVals.ElementAt(_m.In_Index)) } }); } } }
public IResult <Tissue> Update(Tissue tissue) { return(new SuccessResult <Tissue>(Messages.success, tissue)); }
public static Point getValidPoint(Tissue tissue, Point p) { if (isPointOK(tissue, p.X, p.Y)) return p; int dist = 1; while (true) { //up for (int iX = -dist; iX < dist + 1; iX++) if (isPointOK(tissue, p.X + iX, p.Y + dist)) return new Point(p.X + iX, p.Y + dist); //down for (int iX = -dist; iX < dist + 1; iX++) if (isPointOK(tissue, p.X + iX, p.Y - dist)) return new Point(p.X + iX, p.Y - dist); //left for (int iY = -dist; iY < dist + 1; iY++) if (isPointOK(tissue, p.X - dist, p.Y + iY)) return new Point(p.X - dist, p.Y + iY); //right for (int iY = -dist; iY < dist + 1; iY++) if (isPointOK(tissue, p.X + dist, p.Y + iY)) return new Point(p.X + dist, p.Y + iY); dist++; } }
private double[,] CalculateRates(Tissue tissue, List<Point> missionTravelPoints, List<Point> neurocontrollers, Point pierreIP) { //StreamWriter weightsWrite = new StreamWriter("c:\\weights.txt"); //StreamWriter ratesWrite = new StreamWriter("c:\\rates.txt"); neurocontrollers.Add(pierreIP); double[,] rates = new double[tissue.Height, tissue.Width]; for (int i = 0; i < tissue.Height; ++i) { for (int j = 0; j < tissue.Width; ++j) { Entity entity = tissue.getElement(i, j); Double dist = this.GetDistance(pierreIP, new Point(i,j)); if (pierreIP.X == i && pierreIP.Y == j) { rates[i, j] = 0;//weightsWrite.Write("P|");ratesWrite.Write("P|"); continue; } if (null == entity) { rates[i, j] += EmptyPointWeight; } if (this.NeuroControllerInRange(new Point(i, j), neurocontrollers, 14)) { rates[i, j] += NeuroControllerInRangeWeight; } if (null != entity && EntityEnum.AZN == entity.EntityType) { rates[i, j] += AZNPointsWeight; } if (null != entity && EntityEnum.HoshimiPoint == entity.EntityType) { rates[i, j] += HoshimiPointsWeight; } if (missionTravelPoints.Contains(new Point(i, j))) { rates[i, j] += ObjectivesPointsWeight; } if (neurocontrollers.Contains(new Point(i, j))) { rates[i, j] += NeuroControllerWeight; } //weightsWrite.Write("("+i+","+j+")" + rates[i, j].ToString() + "|"); rates[i, j] = rates[i, j] / dist; //ratesWrite.Write("("+i+","+j+")"+rates[i, j].ToString() + "|"); } //weightsWrite.WriteLine(""); //ratesWrite.WriteLine(""); } //weightsWrite.Close(); //ratesWrite.Close(); return rates; }
public Point GetInjectionPoint(Tissue tissue, List<Point> missionTravelPoints, List<Point> hoshimiPoints, List<Point> aznPoints, List<Point> neurocontrollers, Point pierreIP) { // Usar técnica de agrupamentos de SInt para agrupar hoshimi e azn points mais próximos? Point bestPoint = new Point(100, 100); double bestRate = -1; double[,] rates = CalculateRates(tissue, missionTravelPoints, neurocontrollers, pierreIP); for (int i = 0; i < tissue.Height; ++i) { for (int j = 0; j < tissue.Width; ++j) { if (rates[i, j] > bestRate && AreaEnum.Bone != tissue[i,j].AreaType) { bestRate = rates[i, j]; bestPoint = new Point(i, j); } } } return bestPoint; }
public static bool isPointOK(Tissue tissue, int X, int Y) { if (!tissue.IsInMap(X, Y)) return false; return tissue[X, Y].AreaType == AreaEnum.HighDensity | tissue[X, Y].AreaType == AreaEnum.MediumDensity | tissue[X, Y].AreaType == AreaEnum.LowDensity; }
public void validate_ROfFxAndFt_With_Wavelength() { // used values for tissue=liver var scatterer = new PowerLawScatterer(0.84, 0.55); var hbAbsorber = new ChromophoreAbsorber(ChromophoreType.Hb, 66); var hbo2Absorber = new ChromophoreAbsorber(ChromophoreType.HbO2, 124); var fatAbsorber = new ChromophoreAbsorber(ChromophoreType.Fat, 0.02); var waterAbsorber = new ChromophoreAbsorber(ChromophoreType.H2O, 0.87); var n = 1.4; var wvs = new double[] { 650, 700 }; var fxs = new double[] { 0.0, 0.5 }; var fts = new double[] { 0.0, 0.50 }; var tissue = new Tissue( new IChromophoreAbsorber[] { hbAbsorber, hbo2Absorber, fatAbsorber, waterAbsorber }, scatterer, "test_tissue", n); var ops = wvs.Select(wv => tissue.GetOpticalProperties(wv)).ToArray(); var rVsWavelength = ComputationFactory.ComputeReflectance( new DistributedPointSourceSDAForwardSolver(), SolutionDomainType.ROfFxAndFt, ForwardAnalysisType.R, new object[] { ops, fxs, fts }); // return from ROfFxAndFt is new double[ops.Length * fxs.Length * fts.Length]; // order is: (ops0,fxs0,fts0)real, (ops0,fxs0,ts1)real...(ops0,fxs0,ftsnt-1)real // (ops0,fxs1,fts0)real, (ops0,fxs1,ts1)real...(ops0,fxs1,ftsnt-1)real // ... // (ops0,fxsnf-1,fts0)real,.................(ops0,fxsnf-1,ftsnt-1)real // ... repeat above with imag, then with ops1... // [0] -> ops0=650, fx0=0.0, fts0=0.0 real Assert.IsTrue(Math.Abs(rVsWavelength[0] - 1.890007) < 0.000001); // API match // [1] -> ops0=650, fx0=0.0, fts1=0.5 real Assert.IsTrue(Math.Abs(rVsWavelength[1] - 1.888160) < 0.000001); // [2] -> ops0=650, fx1=0.5, fts0=0.0 real Assert.IsTrue(Math.Abs(rVsWavelength[2] - 0.562537) < 0.000001); // API match // [3] -> ops0=650, fx1=0.5, fts1=0.5 real Assert.IsTrue(Math.Abs(rVsWavelength[3] - 0.562543) < 0.000001); // [4] -> ops1=700, fx0=0.0, fts0=0.0 real Assert.IsTrue(Math.Abs(rVsWavelength[4] - 2.118427) < 0.000001); // API match // [5] -> ops1=700, fx0=0.0, fts1=0.5 real Assert.IsTrue(Math.Abs(rVsWavelength[5] - 2.113377) < 0.000001); // [6] -> ops1=700, fx1=0.5, fts0=0.0 real Assert.IsTrue(Math.Abs(rVsWavelength[6] - 0.543539) < 0.000001); // API match // [7] -> ops1=700, fx1=0.5, fts1=0.5 real Assert.IsTrue(Math.Abs(rVsWavelength[7] - 0.543546) < 0.000001); // [8] -> ops0=650, fx0=0.0, fts0=0.0 imag Assert.IsTrue(Math.Abs(rVsWavelength[8] - 0.0) < 0.000001); // API match // [9] -> ops0=650, fx0=0.0, fts1=0.5 imag Assert.IsTrue(Math.Abs(rVsWavelength[9] + 0.045122) < 0.000001); // [10] -> ops0=650, fx1=0.5, fts0=0.0 imag Assert.IsTrue(Math.Abs(rVsWavelength[10] - 0.0) < 0.000001); // API match // [11] -> ops0=650, fx1=0.5, fts1=0.5 imag Assert.IsTrue(Math.Abs(rVsWavelength[11] + 0.000799) < 0.000001); // [12] -> ops1=700, fx0=0.0, fts0=0.0 imag Assert.IsTrue(Math.Abs(rVsWavelength[12] - 0.0) < 0.000001); // API match // [13] -> ops1=700, fx0=0.0, fts1=0.5 imag Assert.IsTrue(Math.Abs(rVsWavelength[13] + 0.071758) < 0.000001); // [14] -> ops1=700, fx1=0.5, fts0=0.0 imag Assert.IsTrue(Math.Abs(rVsWavelength[14] - 0.0) < 0.000001); // API match // [15] -> ops1=700, fx1=0.5, fts1=0.5 imag Assert.IsTrue(Math.Abs(rVsWavelength[15] + 0.000651) < 0.000001); }
public ActionResult Index(HttpPostedFileBase file, WSI wsi, Stain stain, Organ organ, Tissue tissue) { //TODO //Today only one value possible //var tissue = _repoTissues.GetTissueByName("Tissue"); ISharpnessManager manager = new SharpnessManager(); // var root = @"C:\Users\AnnaToshiba2\Desktop\WSI\Sharpness_WebApp_Uploads\"; var fileName = ""; wsi.WSIId = Guid.NewGuid(); string outputDir = Path.Combine(Path.GetDirectoryName(root), User.Identity.GetUserId(), "WSI " + wsi.WSIId + @"\"); if (!Directory.Exists(outputDir)) { Directory.CreateDirectory(outputDir); } if (file.ContentLength > 0) { fileName = Path.GetFileName(file.FileName); var path = Path.Combine(outputDir, fileName); file.SaveAs(path); wsi.Path = path; wsi.UserId = User.Identity.GetUserId(); _repoWSIs.Insert(wsi); } var reportLink = User.Identity.GetUserId() + "/" + "WSI " + wsi.WSIId + "/" + fileName + " "; var evaluationLink = root + reportLink.Replace("/", @"\"); Process first = new Process(); first.StartInfo.FileName = @"C:\Users\AnnaToshiba2\Documents\GitHub\sharpness\sharpness console App\SharpnessExplorationCurrent\SharpnessExplorationCurrent\bin\x64\Release\SharpnessExplorationCurrent.exe"; first.StartInfo.Arguments = String.Format(@"""{0}""", wsi.Path); first.Start(); first.WaitForExit(); var report = new Report(); report.ReglamentId = _repoReglaments.GetReglamentByTitel("Default").ReglamentId; report.Comment = "some words"; report.OrganName = organ.Name; report.TissueName = tissue.Name; report.WSIId = wsi.WSIId; report.StainName = stain.Name; report.SharpnessMapPath = outputDir + Path.GetFileNameWithoutExtension(fileName) + ".png"; report.SharpnessMapPathDebug = outputDir + Path.GetFileNameWithoutExtension(fileName) + "Debug.png"; var semaphoreValues = manager.GetSemaphoreValues(report.SharpnessMapPath); var channelsValues = manager.GetChannelsValues(report.SharpnessMapPathDebug); report.Semaphore_Red = semaphoreValues[0]; report.Semaphore_Green = semaphoreValues[1]; report.Semaphore_Yellow = semaphoreValues[2]; report.Red_Channel = channelsValues[0]; report.Blue_Channel = channelsValues[1]; if (semaphoreValues[1] > 70) { report.Evaluation = true; } else { report.Evaluation = false; } report.ReportLink = reportLink; report.UserId = User.Identity.GetUserId(); _repoReports.Insert(report); return(RedirectToAction("Report", new { ReportId = report.ReportId })); }
public void validate_ROfRhoAndFt_With_Wavelength() { // used values for tissue=liver var scatterer = new PowerLawScatterer(0.84, 0.55); var hbAbsorber = new ChromophoreAbsorber(ChromophoreType.Hb, 66); var hbo2Absorber = new ChromophoreAbsorber(ChromophoreType.HbO2, 124); var fatAbsorber = new ChromophoreAbsorber(ChromophoreType.Fat, 0.02); var waterAbsorber = new ChromophoreAbsorber(ChromophoreType.H2O, 0.87); var n = 1.4; var wvs = new double[] { 650, 700 }; var rhos = new double[] { 0.5, 1.625 }; var fts = new double[] { 0.0, 0.50 }; var tissue = new Tissue( new IChromophoreAbsorber[] { hbAbsorber, hbo2Absorber, fatAbsorber, waterAbsorber }, scatterer, "test_tissue", n); var ops = wvs.Select(wv => tissue.GetOpticalProperties(wv)).ToArray(); var rVsWavelength = ComputationFactory.ComputeReflectance( new PointSourceSDAForwardSolver(), SolutionDomainType.ROfRhoAndFt, ForwardAnalysisType.R, new object[] { ops, rhos, fts }); // return from ROfRhoAndFt is new double[ops.Length * rhos.Length * fts.Length]; // order is: (ops0,rhos0,fts0)real, (ops0,rhos0,fts1)real...(ops0,rhos0,ftsnt-1)real // (ops0,rhos1,fts0)real, (ops0,rhos1,fts1)real...(ops0,rhos1,ftsnt-1)real // ... // (ops0,rhosnr-1,fts0)real,.................(ops0,rhosnr-1,ftsnt-1)real // ... repeat above with imag, then next ops1... // [0] -> ops0=650, rho0=0.5, fts0=0.0 real Assert.IsTrue(Math.Abs(rVsWavelength[0] - 0.037575) < 0.000001); // [1] -> ops0=650, rho0=0.5, fts1=0.5 real Assert.IsTrue(Math.Abs(rVsWavelength[1] - 0.037511) < 0.000001); // [2] -> ops0=650, rho1=1.635, fts0=0.0 real Assert.IsTrue(Math.Abs(rVsWavelength[2] - 0.009306) < 0.000001); // [3] -> ops0=650, rho1=1.635, fts1=0.5 real Assert.IsTrue(Math.Abs(rVsWavelength[3] - 0.009255) < 0.000001); // [4] -> ops1=700, rho0=0.5, fts0=0.0 real Assert.IsTrue(Math.Abs(rVsWavelength[4] - 0.036425) < 0.000001); // [5] -> ops1=700, rho0=0.5, fts1=0.5 real Assert.IsTrue(Math.Abs(rVsWavelength[5] - 0.036310) < 0.000001); // [6] -> ops1=700, rho1=1.635, fts0=0.0 real Assert.IsTrue(Math.Abs(rVsWavelength[6] - 0.010657) < 0.000001); // [7] -> ops1=700, rho1=1.635, fts1=0.5 real Assert.IsTrue(Math.Abs(rVsWavelength[7] - 0.010558) < 0.000001); // [8] -> ops0=650, rho0=0.5, fts0=0.0 imag Assert.IsTrue(Math.Abs(rVsWavelength[8] - 0.0) < 0.000001); // [9] -> ops0=650, rho0=0.5, fts1=0.5 imag Assert.IsTrue(Math.Abs(rVsWavelength[9] + 0.001200) < 0.000001); // [10] -> ops0=650, rho1=1.635, fts0=0.0 imag Assert.IsTrue(Math.Abs(rVsWavelength[10] - 0.0) < 0.000001); // [11] -> ops1=650, rho1=1.635, fts1=0.5 imag Assert.IsTrue(Math.Abs(rVsWavelength[11] + 0.000674) < 0.000001); // [12] -> ops1=700, rho0=0.5, fts0=0.0 Assert.IsTrue(Math.Abs(rVsWavelength[12] - 0.0) < 0.000001); // [13] -> ops1=700, rho0=0.5, fts1=0.5 imag Assert.IsTrue(Math.Abs(rVsWavelength[13] + 0.001446) < 0.000001); // [14] -> ops1=700, rho1=1.635, fts0=0.0 real Assert.IsTrue(Math.Abs(rVsWavelength[14] - 0.0) < 0.000001); // [15] -> ops1=700, rho1=1.635, fts1=0.5 imag Assert.IsTrue(Math.Abs(rVsWavelength[15] + 0.000929) < 0.000001); }
public AStarSpecial(Tissue t) : base(t) { }
public void MyAI_WhatToDoNextEvent() { numHunters = 0; numScanners = 0; numContainers = 0; numDefender = 0; numNeedle = 0; numNavExpBot = 0; numNavColBot = 0; numUNavExpBot = 0; numUNavColBot = 0; numBlocker = 0; numGuard = 0; #region handle objectives if (first1) { int jmlCol = 0; int jmlExp = 0; foreach (BaseObjective bo in Mission.Objectives) { if (bo.Status == ObjectiveStatus.ToBeDone) { if (bo is UniqueNavigationObjective) { UniqueNavigationObjective unav = (UniqueNavigationObjective)bo; if (unav.NanoBotType == NanoBotType.NanoExplorer) { if (unav.NavPoints.Count > 20) { continue; } Global.NBUNAVEXPTOBUILD++; listUNavExpObj.Add(new UniqueNavigationStruct(unav)); } else if (unav.NanoBotType == NanoBotType.Unknown) { bool needStock = false; foreach (NavPoint np in unav.NavPoints) { if (np.Stock > 0) { needStock = true; break; } } if (!needStock) { if (unav.NavPoints.Count > 20) { continue; } Global.NBUNAVEXPTOBUILD++; listUNavExpObj.Add(new UniqueNavigationStruct(unav)); } else { if (unav.NavPoints.Count > 13) { continue; } Global.NBUNAVCOLTOBUILD++; listUNavColObj.Add(new UniqueNavigationStruct(unav)); } } else { if (unav.NavPoints.Count > 13) { continue; } Global.NBUNAVCOLTOBUILD++; listUNavColObj.Add(new UniqueNavigationStruct(unav)); } } else if (bo is NavigationObjective) { NavigationObjective n = (NavigationObjective)bo; if (n.NanoBotType == NanoBotType.NanoExplorer) { if (n.NavPoints.Count > 20) { continue; } jmlExp += n.NavPoints.Count; listNavExpObj.Add(new NavigationStruct(n)); } else if (n.NanoBotType == NanoBotType.Unknown) { bool needStock = false; foreach (NavPoint np in n.NavPoints) { if (np.Stock > 0) { needStock = true; break; } } if (!needStock) { if (n.NavPoints.Count > 20) { continue; } jmlExp += n.NavPoints.Count; listNavExpObj.Add(new NavigationStruct(n)); } else { if (n.NavPoints.Count > 13) { continue; } jmlCol += n.NavPoints.Count; listNavColObj.Add(new NavigationStruct(n)); } } else { if (n.NavPoints.Count > 13) { continue; } jmlCol += n.NavPoints.Count; listNavColObj.Add(new NavigationStruct(n)); } } } } if (jmlExp > 0) { Global.NBNAVEXPTOBUILD = (jmlExp / 3); if ((jmlExp % 3) > 0) { Global.NBNAVEXPTOBUILD++; } if (Global.NBNAVEXPTOBUILD > 5) { Global.NBNAVEXPTOBUILD = 5; } } if (jmlCol > 0) { Global.NBNAVCOLTOBUILD = (jmlCol / 2); if ((jmlCol % 2) > 0) { Global.NBNAVCOLTOBUILD++; } if (Global.NBNAVCOLTOBUILD > 5) { Global.NBNAVCOLTOBUILD = 7; } } first1 = false; } #endregion #region construct bots foreach (NanoBot bot in this.NanoBots) { if (bot is HunterBot) { numHunters++; ((HunterBot)bot).DoNext(this); } else if (bot is DefenderBot) { numDefender++; ((DefenderBot)bot).DoNext(this); } else if (bot is ScannerBot) { numScanners++; ((ScannerBot)bot).DoNext(this); } else if (bot is ContainerBot) { numContainers++; ((ContainerBot)bot).DoNext(this); } else if (bot is GuardBot) { numGuard++; ((GuardBot)bot).DoNext(this); } else if (bot is NeedleBot) { numNeedle++; ((NeedleBot)bot).DoNext(this); } else if (bot is UniqueNavigationExplorerBot) { numUNavExpBot++; ((UniqueNavigationExplorerBot)bot).DoNext(this); } else if (bot is UniqueNavigationCollectorBot) { numUNavColBot++; ((UniqueNavigationCollectorBot)bot).DoNext(this); } else if (bot is NavigationExplorerBot) { numNavExpBot++; ((NavigationExplorerBot)bot).DoNext(this); } else if (bot is NavigationCollectorBot) { numNavColBot++; ((NavigationCollectorBot)bot).DoNext(this); } else if (bot is BlockerBot) { numBlocker++; } } Point prevDest = this.AI.PointInfo; bool stop = false; if (firstInjected2) { bool taken = false; foreach (NanoBotInfo bot in OtherNanoBotsInfo) { if ((bot.Location == AI.Location) && ((bot.NanoBotType == NanoBotType.NanoNeedle) || (bot.NanoBotType == NanoBotType.NanoBlocker))) { taken = true; break; } } if (!taken) { AI.Build(typeof(NeedleBot), "Needle"); //firstNeedleBuilt = true; } firstInjected2 = false; } if (numHunters < Global.NBHUNTERBOTTOBUILD) { AI.StopMoving(); stop = true; AI.Build(typeof(HunterBot), "Hunter"); //return; } if (numDefender < Global.NBDEFENDERTOBUILD) { AI.StopMoving(); stop = true; AI.Build(typeof(DefenderBot), "Defender"); //return; } if (numScanners < Global.NBSCANNERTOBUILD) { AI.StopMoving(); stop = true; AI.Build(typeof(ScannerBot), "Scanner"); //return; } if (numGuard < Global.NBGUARDTOBUILD) { AI.StopMoving(); stop = true; AI.Build(typeof(GuardBot), "Guard"); //return; } if (numContainers < Global.NBCONTAINERTOBUILD) { AI.StopMoving(); stop = true; AI.Build(typeof(ContainerBot), "Containr"); //return; } if (numUNavExpBot < Global.NBUNAVEXPTOBUILD) { AI.StopMoving(); stop = true; AI.Build(typeof(UniqueNavigationExplorerBot), "UNavExplr"); foreach (UniqueNavigationStruct o in MyAI.listUNavExpObj) { o.isAssigned = false; } foreach (NanoBot bot in NanoBots) { if (bot is UniqueNavigationExplorerBot) { ((UniqueNavigationExplorerBot)bot).dapet = false; } } //return; } if (numUNavColBot < Global.NBUNAVCOLTOBUILD) { AI.StopMoving(); stop = true; AI.Build(typeof(UniqueNavigationCollectorBot), "UNavColtr"); foreach (UniqueNavigationStruct o in MyAI.listUNavColObj) { o.isAssigned = false; } foreach (NanoBot bot in NanoBots) { if (bot is UniqueNavigationCollectorBot) { ((UniqueNavigationCollectorBot)bot).dapet = false; } } //return; } if (numNavExpBot < Global.NBNAVEXPTOBUILD) { AI.StopMoving(); stop = true; AI.Build(typeof(NavigationExplorerBot), "NavExplr"); // reset semua Navigasi foreach (NavNode node in NavigationExplorerBot.allNodes) { node.Bot = null; node.Done = false; } //foreach (NavigationStruct ns in MyAI.listNavExpObj) //{ // if ((ns.isActive) && (ns.NavigationObj.Status == ObjectiveStatus.ToBeDone)) // { // ns.isActive = false; // } //} //return; } if (numNavColBot < Global.NBNAVCOLTOBUILD) { AI.StopMoving(); stop = true; AI.Build(typeof(NavigationCollectorBot), "NavColtr"); // reset semua Navigasi foreach (NavNode node in NavigationCollectorBot.allNodes) { node.Bot = null; node.Done = false; } //foreach (NavigationStruct ns in MyAI.listNavColObj) //{ // if ((ns.isActive) && (ns.NavigationObj.Status == ObjectiveStatus.ToBeDone)) // { // ns.isActive = false; // } //} //return; } if ((numBlocker < Global.NBBLOCKERTOBUILD) && (((!firstInjected) && (AI.Location != InjectionPointWanted) && (!skipped)))) //|| // (((this.CurrentTurn % 500) == 0) && // (this.NanoBots.Count < Utils.NbrMaxBots)) // )) { //bool isOnHP = false; //foreach (Entity e in Tissue.GetEntitiesByType(EntityEnum.HoshimiPoint)) //{ // if ((e.X == AI.Location.X) && (e.Y == AI.Location.Y)) // { // isOnHP = true; // break; // } //} //if (!isOnHP) //{ bool isOnHP = false; foreach (Entity e in Tissue.GetEntitiesByType(EntityEnum.HoshimiPoint)) { if (AI.Location.X == e.X && AI.Location.Y == e.Y) { isOnHP = true; break; } } if (!isOnHP) { skipped = true; AI.StopMoving(); stop = true; AI.Build(typeof(BlockerBot), "Blockr"); } //} //return; } //if ((this.CurrentTurn >= 500) && (!Global.AllHPBuilt) && (NanoBots.Count < Utils.NbrMaxBots)) //{ // AI.StopMoving(); // stop = true; // AI.Build(typeof(DummyCrapBot), "DummySht"); // //return; //} if (stop) { this.AI.MoveTo(Global.PF.FindWay(AI.Location, prevDest).Points); } // Filter Nanobots ArrayList hunters = new ArrayList(Global.NBHUNTERBOTTOBUILD); ArrayList defenders = new ArrayList(Global.NBDEFENDERTOBUILD); ArrayList containers = new ArrayList(Global.NBCONTAINERTOBUILD); ArrayList blockers = new ArrayList(Global.NBBLOCKERTOBUILD); ArrayList scanners = new ArrayList(Global.NBSCANNERTOBUILD); ArrayList unavcol = new ArrayList(Global.NBUNAVCOLTOBUILD); ArrayList unavexp = new ArrayList(Global.NBUNAVEXPTOBUILD); ArrayList navcol = new ArrayList(Global.NBNAVCOLTOBUILD); ArrayList navexp = new ArrayList(Global.NBNAVEXPTOBUILD); ArrayList guards = new ArrayList(Global.NBGUARDTOBUILD); foreach (NanoBot bot in NanoBots) { if (bot is HunterBot) { hunters.Add((HunterBot)bot); } else if (bot is DefenderBot) { defenders.Add((DefenderBot)bot); } else if (bot is ContainerBot) { containers.Add((ContainerBot)bot); } else if (bot is BlockerBot) { blockers.Add((BlockerBot)bot); } else if ((bot is ScannerBot) || (bot is DummyCrapBot)) { scanners.Add((ScannerBot)bot); } else if (bot is UniqueNavigationCollectorBot) { unavcol.Add((UniqueNavigationCollectorBot)bot); } else if (bot is UniqueNavigationExplorerBot) { unavexp.Add((UniqueNavigationExplorerBot)bot); } else if (bot is NavigationCollectorBot) { navcol.Add((NavigationCollectorBot)bot); } else if (bot is NavigationExplorerBot) { navexp.Add((NavigationExplorerBot)bot); } else if (bot is GuardBot) { guards.Add((GuardBot)bot); } } #endregion // update NeedleGrid Status foreach (Entity e in this.Tissue.GetEntitiesByType(EntityEnum.HoshimiPoint)) { foreach (NanoBotInfo bot in OtherNanoBotsInfo) { if ((bot.Location.X == e.X) && (bot.Location.Y == e.Y) && (bot.NanoBotType == NanoBotType.NanoNeedle) && (Global.NeedleGrid[e.X][e.Y] == null) ) { Global.NeedleGrid[e.X][e.Y] = new NeedleInfo(); Global.NeedleGrid[e.X][e.Y].Skipped = true; } } // cek apakah ada NeedleBot yang dihancurkan WhiteCell if ((Global.NeedleGrid[e.X][e.Y] != null) && (!Global.NeedleGrid[e.X][e.Y].Skipped)) { // cek semua NeedleBot yang ada bool found = false; foreach (NanoBot bot in NanoBots) { if (bot is NeedleBot) { if ((bot.Location.X == e.X) && (bot.Location.Y == e.Y)) { found = true; break; } } } if (!found) { Global.NeedleGrid[e.X][e.Y] = null; } } } // cek apakah semua HP sudah penuh if (!Global.AllHPBuilt) { bool adaYangKosong = false; foreach (Entity e in Tissue.GetEntitiesByType(EntityEnum.HoshimiPoint)) { Point pt = new Point(e.X, e.Y); if (Global.NeedleGrid[pt.X][pt.Y] == null) { adaYangKosong = true; break; } } if (!adaYangKosong) { Global.AllHPBuilt = true; } } #region AI logic foreach (NanoBot bot in NanoBots) { if ((bot is DefenderBot) && (bot.State == NanoBotState.Defending)) { this.AI.StopMoving(); // AI stop while Defender defends return; } } // cek tujuan, apakah sudah dibuat Needle oleh lawan if (AI.State == NanoBotState.Moving) { if (Global.NeedleGrid[AI.PointInfo.X][AI.PointInfo.Y] != null) { AI.StopMoving(); return; } if (this.CurrentTurn % 10 == 0) { Point nearHP = Global.FindClosest(EntityEnum.HoshimiPoint, this.AI.Location, this.AI.NanoBotType); if ((this.AI.PointInfo != nearHP) && (Global.GetPathLength(this.AI.Location, nearHP) < Global.GetPathLength(this.AI.Location, this.AI.PointInfo))) { this.AI.StopMoving(); this.AI.MoveTo(Global.PF.FindWay(this.AI.Location, nearHP).Points); return; } } } if (this.AI.State == NanoBotState.WaitingOrders) { Random r = new Random(); Point dest = Point.Empty; Point tempatBlocker = Point.Empty; if ((Global.AllHPBuilt) && (NanoBots.Count < Utils.NbrMaxBots)) { // penuhi batas maksimum bot if (Global.NeedleGrid[AI.Location.X][AI.Location.Y] == null) { this.AI.Build(typeof(DummyNeedle), "Dummy"); Global.NeedleGrid[AI.Location.X][AI.Location.Y] = new NeedleInfo(); return; } else { dest = new Point(this.AI.Location.X + r.Next(-5, 5), this.AI.Location.Y + r.Next(-5, 5)); this.AI.MoveTo(Global.PF.FindWay(AI.Location, dest).Points); return; } } if (firstInjected) { dest = this.InjectionPointWanted; firstInjected = false; return; } else { if (!Global.AllHPBuilt) { dest = Global.FindClosest(EntityEnum.HoshimiPoint, this.AI.Location, NanoBotType.NanoAI); } else { dest = new Point(this.AI.Location.X + r.Next(-5, 5), this.AI.Location.Y + r.Next(-5, 5)); return; } } if (dest == Point.Empty) // semua HP sudah diisi { Global.AllHPBuilt = true; } if ((AI.Location.X == tempatBlocker.X && AI.Location.Y == tempatBlocker.Y) && (firstInjected)) { firstInjected = false; AI.Build(typeof(BlockerBot)); return; } if (this.AI.Location != dest) { this.AI.MoveTo(Global.PF.FindWay(this.AI.Location, dest).Points); return; } else { // sebelum buat NeedleBot, cek apakah jumlah NanoBot sudah sampai batas max if (NanoBots.Count >= Utils.NbrMaxBots) { bool destroyOne = false; // cek apakah PierreAI dead -> bisa destroy hunters, scanners dan defenders if (Global.isPierreAIDead) { if (hunters.Count > 0) { ((HunterBot)hunters[0]).ForceAutoDestruction(); Global.NBHUNTERBOTTOBUILD -= 1; destroyOne = true; } if ((!destroyOne) && (defenders.Count > 0)) { ((DefenderBot)defenders[0]).ForceAutoDestruction(); Global.NBDEFENDERTOBUILD -= 1; destroyOne = true; } if ((!destroyOne) && (scanners.Count > 0)) { ((ScannerBot)scanners[0]).ForceAutoDestruction(); Global.NBSCANNERTOBUILD -= 1; destroyOne = true; } } if (!destroyOne) { bool selesai = true; foreach (BaseObjective b in Mission.Objectives) { if ((b is NavigationObjective) && (b.Status == ObjectiveStatus.ToBeDone)) { selesai = false; break; } } if (selesai) // jika semua NavigationObjective selesai -> bisa destroy NavigationBots { if (navexp.Count > 0) { ((NavigationExplorerBot)navexp[0]).ForceAutoDestruction(); Global.NBNAVEXPTOBUILD -= 1; destroyOne = true; } if ((!destroyOne) && (navcol.Count > 0)) { ((NavigationCollectorBot)navcol[0]).ForceAutoDestruction(); Global.NBNAVCOLTOBUILD -= 1; destroyOne = true; } } } if (!destroyOne) { bool selesai = true; foreach (BaseObjective b in Mission.Objectives) { if ((b is UniqueNavigationObjective) && (b.Status == ObjectiveStatus.ToBeDone)) { selesai = false; break; } } if (selesai) // jika semua UniqueNavigationObjective selesai { // -> bisa destroy UniqueNavigationBots if (navexp.Count > 0) { ((UniqueNavigationExplorerBot)unavexp[0]).ForceAutoDestruction(); Global.NBUNAVEXPTOBUILD -= 1; destroyOne = true; } if ((!destroyOne) && (navcol.Count > 0)) { ((UniqueNavigationCollectorBot)unavcol[0]).ForceAutoDestruction(); Global.NBUNAVCOLTOBUILD -= 1; destroyOne = true; } } } // navigation dan defender udah abis -> blocker dan containers if (!destroyOne) { if (blockers.Count > 0) { ((BlockerBot)blockers[0]).ForceAutoDestruction(); Global.NBBLOCKERTOBUILD -= 1; destroyOne = true; } if ((!destroyOne) && (guards.Count > 0)) { ((GuardBot)guards[0]).ForceAutoDestruction(); Global.NBGUARDTOBUILD -= 1; destroyOne = true; } if ((!destroyOne) && (containers.Count > 4)) { ((ContainerBot)containers[0]).ForceAutoDestruction(); Global.NBCONTAINERTOBUILD -= 1; destroyOne = true; } } } else { this.AI.Build(typeof(NeedleBot), "Needle"); Global.NbNeedle++; Global.NeedleGrid[this.AI.Location.X][this.AI.Location.Y] = new NeedleInfo(); Global.NeedleGrid[this.AI.Location.X][this.AI.Location.Y].NeedleBuilt = true; //Global.NeedleGrid[this.AI.Location.X][this.AI.Location.Y].NeedleTargetted = false; if (nextGroup < arrGroup.Length) { arrGroup[nextGroup].NeedleLocation = this.AI.Location; arrGroup[nextGroup].IsSet = true; arrGroup[nextGroup].Done = false; //Global.NeedleGrid[this.AI.Location.X][this.AI.Location.Y].NeedleTargetted = true; nextGroup++; } else { //kalo semua udah di set, cari yang terdekat int jmin = int.MaxValue; Group sel = null; foreach (NanoBot bot in NanoBots) { if (bot is ContainerBot) { ContainerBot b = (ContainerBot)bot; if ((b.group.Done) && (b.Stock != 0) && (!b.group.IsSet)) { //int jarak = MyAI.squareDist(this.AI.Location, b.Location); int jarak = Global.GetPathLength(this.AI.Location, b.Location); if (jarak < jmin) { jmin = jarak; sel = b.group; } } } } if (sel != null) { sel.NeedleLocation = this.AI.Location; sel.IsSet = true; sel.Done = false; //Global.NeedleGrid[this.AI.Location.X][this.AI.Location.Y].NeedleTargetted = true; } else { // semua grup sudah diAssign, masukkan ke HPList Global.HPList.Add(this.AI.Location); } } return; } } } #endregion }
public ActionResult Index(HttpPostedFileBase file, WSI wsi, Stain stain, Organ organ, Tissue tissue) { //TODO var reglement = manager.GetReglement(stain.Name, organ.Name); //var sharpnessEvaluationParameters = '+' + reglament.TileSize.ToString() + '+' + reglament.SharpnessThresholdValue+ '+' + reglament.Scaling.ToString()+ '+' + reglament.Edges.ToString(); //Directory for WSI Uploads on the Server var root = @"C:\Users\AnnaToshiba2\Desktop\WSI\Sharpness_WebApp_Uploads\"; var fileName = ""; wsi.WSIId = Guid.NewGuid(); //Create a directory for a report and WSI string outputDir = Path.Combine(Path.GetDirectoryName(root), User.Identity.GetUserName(), "WSI " + wsi.WSIId + @"\"); if (!Directory.Exists(outputDir)) { Directory.CreateDirectory(outputDir); } if (file.ContentLength > 0) { fileName = Path.GetFileName(file.FileName); var path = Path.Combine(outputDir, fileName); file.SaveAs(path); wsi.Path = path; wsi.UserId = User.Identity.GetUserId(); repoWSIs.Insert(wsi); } //Generate a report link for the Viewer var reportLink = User.Identity.GetUserName() + "/" + "WSI " + wsi.WSIId + "/" + fileName + " "; var evaluationLink = root + reportLink.Replace("/", @"\"); //External sharpness console app Process sharpnessConsoleApp = new Process(); //Path to the sharpness console app sharpnessConsoleApp.StartInfo.FileName = @"C:\Users\AnnaToshiba2\Documents\GitHub\sharpness\sharpness console App\SharpnessExplorationCurrent\SharpnessExplorationCurrent\bin\x64\Release\SharpnessExplorationCurrent.exe"; //WSI Path + Reglemnets arguments //structure -> wsi.path#(separator)#tileSize#threshold#scale#edges sharpnessConsoleApp.StartInfo.Arguments = String.Format(@"""{0}""", wsi.Path + "#" + reglement.TileSize.ToString() + "#" + reglement.Scaling.ToString() + "#" + reglement.SharpnessThresholdValue.ToString() + "#" + reglement.Edges.ToString()); sharpnessConsoleApp.Start(); sharpnessConsoleApp.WaitForExit(); var report = new Report(); //TODO //only one reglement is possible report.ReglementId = reglement.ReglementId; report.Comment = "Kommentar"; report.OrganName = organ.Name; if (tissue != null) { report.TissueName = tissue.Name; } if (tissue == null) { report.TissueName = null; } report.WSIId = wsi.WSIId; report.StainName = stain.Name; report.SharpnessMapPath = outputDir + Path.GetFileNameWithoutExtension(fileName) + ".png"; report.SharpnessMapPathDebug = outputDir + Path.GetFileNameWithoutExtension(fileName) + "Debug.png"; var semaphoreValues = manager.GetSemaphoreValues(report.SharpnessMapPath); var channelsValues = manager.GetChannelsValues(report.SharpnessMapPathDebug); report.Semaphore_Red = semaphoreValues[0]; report.Semaphore_Green = semaphoreValues[1]; report.Semaphore_Yellow = semaphoreValues[2]; report.Red_Channel = channelsValues[0]; report.Blue_Channel = channelsValues[1]; if (semaphoreValues[1] > reglement.AcceptanceValue) { report.Evaluation = true; } else { report.Evaluation = false; } report.ReportLink = reportLink; report.UserId = User.Identity.GetUserId(); repoReports.Insert(report); return(RedirectToAction("Report", new { ReportId = report.ReportId })); }