/// <summary>
        /// Method to validate that the geometry of tissue layers and bounding cylinder agree with capabilities
        /// of code.
        /// </summary>
        /// <param name="layers">list of LayerTissueRegion</param>
        /// <param name="boundingCylinder">CylinderTissueRegion</param>
        /// <returns>ValidationResult</returns>
        private static ValidationResult ValidateGeometry(IList <LayerTissueRegion> layers,
                                                         CaplessCylinderTissueRegion boundingCylinder)
        {
            // check that layer definition is valid
            var tempResult = MultiLayerTissueInputValidation.ValidateLayers(layers);

            if (!tempResult.IsValid)
            {
                return(tempResult);
            }

            // test for air layers and eliminate from list
            var tissueLayers = layers.Where(layer => !layer.IsAir());

            var layersHeight = tissueLayers.Sum(layer => layer.ZRange.Delta);

            if (boundingCylinder.Height != layersHeight)
            {
                tempResult = new ValidationResult(
                    false,
                    "BoundingCylinderTissueInput: bounding cylinder must have same height as tissue",
                    "BoundingCylinderTissueInput: make sure cylinder Height = depth of tissue");
            }

            if (!tempResult.IsValid)
            {
                return(tempResult);
            }

            // check that there is at least one layer of tissue
            if (!tissueLayers.Any())
            {
                tempResult = new ValidationResult(
                    false,
                    "BoundingCylinderTissueInput: tissue layer is assumed to be at least a single layer with air layer above and below",
                    "BoundingCylinderTissueInput: redefine tissue definition to contain at least a single layer of tissue");
            }

            if (!tempResult.IsValid)
            {
                return(tempResult);
            }

            return(new ValidationResult(
                       true,
                       "BoundingCylinderTissueInput: geometry and refractive index settings validated"));
        }
Exemplo n.º 2
0
        /// <summary>
        /// constructor that load excitation simulation AOfXAndYAndZ
        /// </summary>
        public AOfXAndYAndZLoader(string inputFolder, string infile, int fluorescentTissueRegionIndex)
        {
            if (infile != "")
            {
                var inputPath = "";
                if (inputFolder == "")
                {
                    inputPath = infile;
                }
                else
                {
                    inputPath = inputFolder + @"/" + infile;
                }
                var aOfXAndYAndZDetector = (AOfXAndYAndZDetector)DetectorIO.ReadDetectorFromFile(
                    "AOfXAndYAndZ", inputFolder);
                // use DoubleRange X,Y,Z to match detector dimensions
                X            = ((AOfXAndYAndZDetector)aOfXAndYAndZDetector).X;
                Y            = ((AOfXAndYAndZDetector)aOfXAndYAndZDetector).Y;
                Z            = ((AOfXAndYAndZDetector)aOfXAndYAndZDetector).Z;
                AOfXAndYAndZ = ((AOfXAndYAndZDetector)aOfXAndYAndZDetector).Mean;

                var exciteInfile = SimulationInput.FromFile(inputPath);

                FluorescentTissueRegion = exciteInfile.TissueInput.Regions[fluorescentTissueRegionIndex];
                BoundedTissueRegion     = null;
                // check if tissue bounded CH: can this be made more generic?
                if (exciteInfile.TissueInput.TissueType == "BoundingCylinder")
                {
                    var cylinderIndex = exciteInfile.TissueInput.Regions.Length - 1;
                    CaplessCylinderTissueRegion boundingCylinder =
                        (CaplessCylinderTissueRegion)exciteInfile.TissueInput.Regions[cylinderIndex];
                    BoundedTissueRegion = new CaplessCylinderTissueRegion(
                        boundingCylinder.Center,
                        boundingCylinder.Radius,
                        boundingCylinder.Height,
                        boundingCylinder.RegionOP);
                }

                // separate setup of arrays so can unit test method
                InitializeFluorescentRegionArrays();
                SetupRegionIndices();
            }
            else
            {
                throw new ArgumentException("infile string is empty");
            }
        }
 /// <summary>
 /// Method to verify refractive index of tissue layer and bounding cylinder match.
 /// Code does not yet include reflecting/refracting off bounding cylinder surface.
 /// </summary>
 /// <param name="layers">list of LayerTissueRegion</param>
 /// <param name="boundingCylinder">CylinderTissueRegion></param>
 /// <returns>ValidationResult</returns>
 private static ValidationResult ValidateRefractiveIndexMatch(
     IList <LayerTissueRegion> layers, CaplessCylinderTissueRegion boundingCylinder)
 {
     // for all tissue layers
     for (int i = 1; i < layers.Count - 2; i++)
     {
         if (layers[i].RegionOP.N != boundingCylinder.RegionOP.N)
         {
             return(new ValidationResult(
                        false,
                        "BoundingCylinderTissueInput: refractive index of tissue layer must match that of bounding cylinder",
                        "Change N of bounding cylinder to match tissue layer N"));
         }
     }
     return(new ValidationResult(
                true,
                "BoundingCylinderTissueInput: refractive index of tissue and bounding cylinder match"));
 }