/// <summary>
        /// method to determine index of region photon is about to enter
        /// </summary>
        /// <param name="photon">photon info including position and direction</param>
        /// <returns>region index</returns>
        public int GetNeighborRegionIndex(Photon photon)
        {
            if (photon.DP.Direction.Uz == 0.0)
            {
                throw new Exception("GetNeighborRegionIndex called and Photon not on boundary");
            }

            if (photon.DP.Direction.Uz > 0.0) // move to layer below if pointed down
            {
                return(Math.Min(photon.CurrentRegionIndex + 1, Regions.Count - 1));
            }
            else // pointed up
            {
                if (photon.CurrentRegionIndex == 1) // check if at surface
                {
                    if (_surfaceFiberRegion.ContainsPosition(photon.DP.Position))
                    {
                        return(Regions.Count - 1); // return index of surfaceFiberRegion
                    }

                    return(0); // return air
                }
                else
                {
                    if (photon.CurrentRegionIndex == 3) // in surfaceFiberRegion
                    {
                        return(0);
                    }
                }
                return(photon.CurrentRegionIndex - 1);  // must be layer above
            }
        }
コード例 #2
0
        public void InitializeFluorescentRegionArrays()
        {
            MapOfXAndYAndZ = new int[X.Count - 1, Y.Count - 1, Z.Count - 1];
            PDFOfXAndYAndZ = new double[X.Count - 1, Y.Count - 1, Z.Count - 1];
            CDFOfXAndYAndZ = new double[X.Count - 1, Y.Count - 1, Z.Count - 1];

            // the following algorithm assumes that if the midpoint of the voxel is inside the
            // fluorescent tissue region, then it is part of emission
            TotalProb = 0.0;
            for (int i = 0; i < X.Count - 1; i++)
            {
                double xMidpoint = X.Start + i * X.Delta + X.Delta / 2;
                for (int j = 0; j < Y.Count - 1; j++)
                {
                    var yMidpoint = Y.Start + j * Y.Delta + Y.Delta / 2;
                    for (int k = 0; k < Z.Count - 1; k++)
                    {
                        var zMidpoint = Z.Start + k * Z.Delta + Z.Delta / 2;
                        //xMidpoint = -1.85; // debug code
                        //yMidpoint = 4.65;
                        //zMidpoint = 0.85;
                        // first check if in tissue region
                        bool inFluorescentTissue = FluorescentTissueRegion.ContainsPosition(
                            new Position(xMidpoint, yMidpoint, zMidpoint));
                        // next check if not in bounding region if exists
                        if (BoundedTissueRegion != null)
                        {
                            inFluorescentTissue = BoundedTissueRegion.ContainsPosition(
                                new Position(xMidpoint, yMidpoint, zMidpoint));
                        }
                        // default values of numeric array elements are set to 0 so no else needed
                        if (inFluorescentTissue)
                        {
                            MapOfXAndYAndZ[i, j, k] = 1;
                            PDFOfXAndYAndZ[i, j, k] = AOfXAndYAndZ[i, j, k];
                            TotalProb += AOfXAndYAndZ[i, j, k];
                            CDFOfXAndYAndZ[i, j, k] += TotalProb;
                        }
                    }
                }
            }
            // create pdf and cdf
            for (int i = 0; i < X.Count - 1; i++)
            {
                for (int j = 0; j < Y.Count - 1; j++)
                {
                    for (int k = 0; k < Z.Count - 1; k++)
                    {
                        if (MapOfXAndYAndZ[i, j, k] == 1)
                        {
                            PDFOfXAndYAndZ[i, j, k] /= TotalProb;
                            CDFOfXAndYAndZ[i, j, k] /= TotalProb;
                        }
                    }
                }
            }
        }
コード例 #3
0
        public void InitializeFluorescentRegionArrays()
        {
            MapOfRhoAndZ = new int[Rho.Count - 1, Z.Count - 1];
            PDFOfRhoAndZ = new double[Rho.Count - 1, Z.Count - 1];
            CDFOfRhoAndZ = new double[Rho.Count - 1, Z.Count - 1];

            // the following algorithm assumes that if the midpoint of the voxel is inside the
            // fluorescent tissue region, then it is part of emission
            TotalProb = 0.0;
            for (int i = 0; i < Rho.Count - 1; i++)
            {
                // following code assumes tissue region is cylindrical in nature
                // therefore, if (rho,z) in region, (x=rho,0,z) is in region
                var xMidpoint = Rho.Start + i * Rho.Delta + Rho.Delta / 2;
                var yMidpoint = 0.0;
                for (int k = 0; k < Z.Count - 1; k++)
                {
                    var  zMidpoint           = Z.Start + k * Z.Delta + Z.Delta / 2;
                    bool inFluorescentTissue = FluorescentTissueRegion.ContainsPosition(
                        new Position(xMidpoint, yMidpoint, zMidpoint));
                    // next check if not in bounding region if exists
                    if (BoundedTissueRegion != null)
                    {
                        inFluorescentTissue = BoundedTissueRegion.ContainsPosition(
                            new Position(xMidpoint, yMidpoint, zMidpoint));
                    }
                    // default values of numeric array elements are set to 0 so no else needed
                    if (inFluorescentTissue)
                    {
                        MapOfRhoAndZ[i, k]  = 1;
                        PDFOfRhoAndZ[i, k]  = AOfRhoAndZ[i, k];
                        TotalProb          += AOfRhoAndZ[i, k];
                        CDFOfRhoAndZ[i, k] += TotalProb;
                    }
                }
            }
            // create pdf and cdf
            for (int i = 0; i < Rho.Count - 1; i++)
            {
                for (int k = 0; k < Z.Count - 1; k++)
                {
                    if (MapOfRhoAndZ[i, k] == 1)
                    {
                        PDFOfRhoAndZ[i, k] /= TotalProb;
                        CDFOfRhoAndZ[i, k] /= TotalProb;
                    }
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// diffuse reflectance VB
        /// </summary>
        /// <param name="tissue">ITissue</param>
        /// <param name="detectorController">IDetectorController</param>
        /// <param name="name">string name</param>
        public BoundingCylinderVirtualBoundary(ITissue tissue, IDetectorController detectorController, string name)
        {
            _boundingTissueRegion = tissue.Regions[tissue.Regions.Count - 1]; // bounding region always last by convention
            _center = _boundingTissueRegion.Center;
            _radius = ((CaplessCylinderTissueRegion)_boundingTissueRegion).Radius;

            WillHitBoundary = dp =>
                              dp.StateFlag.HasFlag(PhotonStateType.PseudoBoundingVolumeTissueBoundary) &&
                              _boundingTissueRegion.ContainsPosition(dp.Position);

            VirtualBoundaryType = VirtualBoundaryType.BoundingCylinderVolume;
            PhotonStateType     = PhotonStateType.PseudoBoundingCylinderVolumeVirtualBoundary;

            _detectorController = detectorController;

            Name = name;
        }
コード例 #5
0
 /// <summary>
 /// method to get tissue region index of photon's current position
 /// </summary>
 /// <param name="position">photon Position</param>
 /// <returns>integer tissue region index</returns>
 public int GetRegionIndex(Position position)
 {
     // if it's in the inclusion, return "3", otherwise, call the layer method to determine
     return(_inclusionRegion.ContainsPosition(position) ? _inclusionRegionIndex : base.GetRegionIndex(position));
 }
コード例 #6
0
ファイル: BoundedTissue.cs プロジェクト: acs3235/VTS
 /// <summary>
 /// method to get tissue region index of photon's current position
 /// </summary>
 /// <param name="position">photon Position</param>
 /// <returns>integer tissue region index</returns>
 public override int GetRegionIndex(Position position)
 {
     // if it's in the bounding region, return "3", otherwise, call the layer method to determine
     return(!_boundingRegion.ContainsPosition(position)  ? _boundingRegionExteriorIndex : base.GetRegionIndex(position));
 }