public void verify_that_GetFinalPositionAndWeight_samples_from_CDFOfRhoAndZ_correctly() { var countArray = new int[_aOfRhoAndZDetector.Rho.Count - 1, _aOfRhoAndZDetector.Z.Count - 1]; ITissueInput tissueInput = new SingleInfiniteCylinderTissueInput(); ITissue tissue = tissueInput.CreateTissue(AbsorptionWeightingType.Discrete, PhaseFunctionType.HenyeyGreenstein, 0); tissue.Regions[1] = _rhozLoaderCDF.FluorescentTissueRegion; for (int i = 0; i < 100; i++) { var photon = _fluorEmissionAOfRhoAndZSourceCDF.GetNextPhoton(tissue); // verify that photons start within range of midpoints of voxels in bounding cylinder var rho = Math.Sqrt(photon.DP.Position.X * photon.DP.Position.X + photon.DP.Position.Y * photon.DP.Position.Y); Assert.IsTrue(rho <= 3.5); Assert.IsTrue((photon.DP.Position.Z >= 0.5) && (photon.DP.Position.Z <= 1.5)); Assert.IsTrue(Math.Abs(photon.DP.Weight - 1.0) < 1e-6); int irho = (int)(Math.Floor(rho)); int iz = (int)(Math.Floor(photon.DP.Position.Z)); countArray[irho, iz] += 1; } // check that countArray is > 1 in region of AOfRhoAndZ Assert.AreEqual(countArray[0, 0], 2); Assert.AreEqual(countArray[0, 1], 4); Assert.AreEqual(countArray[1, 0], 11); Assert.AreEqual(countArray[1, 1], 7); Assert.AreEqual(countArray[2, 0], 12); Assert.AreEqual(countArray[2, 1], 19); Assert.AreEqual(countArray[3, 0], 22); Assert.AreEqual(countArray[3, 1], 23); }
public void Initialize(ITissue tissue, Random rng) { // intialize any necessary class fields here _tissue = tissue; _rng = rng; //_ops = _tissue.Regions.Select(r => r.RegionOP).ToArray(); // assign any user-defined outputs (except arrays...we'll make those on-demand) TallyCount = 0; NumSubregions = _tissue.Regions.Count; // if the data arrays are null, create them (only create second moment if TallySecondMoment is true) Mean = Mean ?? new double[X.Count - 1, Y.Count - 1, MTBins.Count - 1]; SecondMoment = SecondMoment ?? (TallySecondMoment ? new double[X.Count - 1, Y.Count - 1, MTBins.Count - 1] : null); TotalMTOfZ = TotalMTOfZ ?? new double[X.Count - 1, Y.Count - 1, Z.Count - 1]; DynamicMTOfZ = DynamicMTOfZ ?? new double[X.Count - 1, Y.Count - 1, Z.Count - 1]; TotalMTOfZSecondMoment = TotalMTOfZSecondMoment ?? new double[X.Count - 1, Y.Count - 1, Z.Count - 1]; DynamicMTOfZSecondMoment = DynamicMTOfZSecondMoment ?? new double[X.Count - 1, Y.Count - 1, Z.Count - 1]; // Fractional MT has FractionalMTBins.Count numnber of bins PLUS 2, one for =1, an d one for =0 FractionalMT = FractionalMT ?? new double[X.Count - 1, Y.Count - 1, MTBins.Count - 1, FractionalMTBins.Count + 1]; SubregionCollisions = new double[NumSubregions, 2]; // 2nd index: 0=static, 1=dynamic // intialize any other necessary class fields here _bloodVolumeFraction = BloodVolumeFraction; }
public void verify_that_GetFinalPositionAndWeight_samples_from_UnifOfRhoAndZ_sampling_correctly() { ITissueInput tissueInput = new SingleInfiniteCylinderTissueInput(); ITissue tissue = tissueInput.CreateTissue(AbsorptionWeightingType.Discrete, PhaseFunctionType.HenyeyGreenstein, 0); tissue.Regions[1] = _xyzLoaderUnif.FluorescentTissueRegion; for (int i = 0; i < 100; i++) { var photon = _fluorEmissionAOfRhoAndZSourceUnif.GetNextPhoton(tissue); // verify that photons start within range of midpoints of voxels in infinite cylinder Assert.IsTrue(photon.DP.Position.X <= 3.5); Assert.AreEqual(photon.DP.Position.Y, 0); Assert.IsTrue((photon.DP.Position.Z >= 0.5) && (photon.DP.Position.Z <= 1.5)); // verify sampling is proceeding in coded sequence // detector center=(0,0,1) radius=4, rho=[0 4] 4 bins, z=[0 2] 2 bins var ir = DetectorBinning.WhichBin(DetectorBinning.GetRho( photon.DP.Position.X, photon.DP.Position.Y), _rhozLoaderUnif.Rho.Count - 1, _rhozLoaderUnif.Rho.Delta, _rhozLoaderUnif.Rho.Start); var iz = DetectorBinning.WhichBin(photon.DP.Position.Z, _rhozLoaderUnif.Z.Count - 1, _rhozLoaderUnif.Z.Delta, _rhozLoaderUnif.Z.Start); var rhozNorm = (_rhozLoaderUnif.Rho.Start + (ir + 0.5) * _rhozLoaderUnif.Rho.Delta) * 2.0 * Math.PI * _rhozLoaderUnif.Rho.Delta * _rhozLoaderUnif.Z.Delta; // verify weight at location is equal to AOfRhoAndZ note: setup with single y bin // expected: Map [ 1 1 1 1; 1 1 1 1] row major // expected: A [ 1 3 5 7; 2 4 6 8] row major Assert.IsTrue(Math.Abs(photon.DP.Weight - _rhozLoaderUnif.AOfRhoAndZ[ir, iz] * rhozNorm) < 1e-6); } }
/*/// <summary> * /// Surface molecular pattern of the cell. An array of bits each of which represents a nucleotide. * /// </summary> * public MolecularPattern Pattern * { * get { return pattern; } * }*/ #endregion #region Public Methods /*public Cell(CellType type, ITissue parent, MolecularPattern initialPattern) * { * Type = type; * Parent = parent; * pattern = initialPattern; * maturationLevel = CellMaturationLevel.Immature; * Start(); * }*/ public Cell(CellType type, ITissue parent) { Type = type; Parent = parent; maturationLevel = CellMaturationLevel.Immature; Start(); }
public void verify_that_GetFinalPositionAndWeight_samples_from_UnifOfXAndYAndZ_sampling_correctly() { ITissueInput tissueInput = new SingleInfiniteCylinderTissueInput(); ITissue tissue = tissueInput.CreateTissue(AbsorptionWeightingType.Discrete, PhaseFunctionType.HenyeyGreenstein, 0); tissue.Regions[3] = _xyzLoaderUnif.FluorescentTissueRegion; var xyzNorm = _xyzLoaderUnif.X.Delta * _xyzLoaderUnif.Y.Delta * _xyzLoaderUnif.Z.Delta; int ix, iz; for (int i = 0; i < 100; i++) { var photon = _fluorEmissionAOfXAndYAndZSourceUnif.GetNextPhoton(tissue); // verify that photons start within range of midpoints of voxels in infinite cylinder Assert.IsTrue((photon.DP.Position.X >= -0.5) && (photon.DP.Position.X <= 0.5)); Assert.AreEqual(photon.DP.Position.Y, 0); Assert.IsTrue((photon.DP.Position.Z >= 0.5) && (photon.DP.Position.Z <= 1.5)); // verify sampling is proceeding in coded sequence // detector x=[-2 2] 4 bins, y=[-10 10] 1 bin, z=[0 3] 3 bins ix = (int)(photon.DP.Position.X + 0.5) + 1; iz = (int)(Math.Floor(photon.DP.Position.Z)); // verify weight at location is equal to AOfXAndYAndZ note: setup with single y bin // expected: Map [ 0 1 1 0; 0 1 1 0; 0 0 0 0] row major // expected: A [ 1 4 7 10; 2 5 8 11; 3 6 9 12] row major Assert.IsTrue(Math.Abs(photon.DP.Weight - _xyzLoaderUnif.AOfXAndYAndZ[ix, 0, iz] * xyzNorm) < 1e-6); } }
public static UnmanagedTissue ToUnmanagedTissue(this ITissue tissptr) { UnmanagedTissue unmanagedTissue = new UnmanagedTissue(); // comment to rework later //unmanagedTissue.num_layers = tissptr.num_layers; ////unmanagedTissue.z_focus = tissptr.z_focus; ////unmanagedTissue.NA = tissptr.NA; //unmanagedTissue.cylinder_radius = tissptr.cylinder_radius; //unmanagedTissue.cylinder_height = tissptr.cylinder_height; //unmanagedTissue.zup = tissptr.zup; //unmanagedTissue.zlow = tissptr.zlow; //unmanagedTissue.do_ellip_layer = tissptr.do_ellip_layer; //unmanagedTissue.ellip_x = tissptr.ellip_x; //unmanagedTissue.ellip_y = tissptr.ellip_y; //unmanagedTissue.ellip_z = tissptr.ellip_z; //unmanagedTissue.ellip_rad_x = tissptr.ellip_rad_x; //unmanagedTissue.ellip_rad_y = tissptr.ellip_rad_y; //unmanagedTissue.ellip_rad_z = tissptr.ellip_rad_z; //unmanagedTissue.layer_z_min = tissptr.layer_z_min; //UnmanagedIO.Assign1DPointer(ref Tissue.Regions, ref unmanagedTissue.layerprops); return(unmanagedTissue); }
/// <summary> /// Implements Get next photon /// </summary> /// <param name="tissue">tissue</param> /// <returns>photon</returns> public Photon GetNextPhoton(ITissue tissue) { //Source starts at the origin Position finalPosition = SourceDefaults.DefaultPosition.Clone(); // sample angular distribution Direction finalDirection = SourceToolbox.GetDirectionForGivenPolarAzimuthalAngleRangeRandom( _polarAngleEmissionRange, _azimuthalAngleEmissionRange, Rng); //Find the relevent polar and azimuthal pair for the direction _rotationalAnglesOfPrincipalSourceAxis = SourceToolbox.GetPolarAzimuthalPairFromDirection(_direction); //Rotation and translation SourceToolbox.UpdateDirectionPositionAfterGivenFlags( ref finalPosition, ref finalDirection, _rotationalAnglesOfPrincipalSourceAxis, _pointLocation, _rotationAndTranslationFlags); var photon = new Photon(finalPosition, finalDirection, 1.0, tissue, _initialTissueRegionIndex, Rng); return(photon); }
/*/// <summary> /// Surface molecular pattern of the cell. An array of bits each of which represents a nucleotide. /// </summary> public MolecularPattern Pattern { get { return pattern; } }*/ #endregion #region Public Methods /*public Cell(CellType type, ITissue parent, MolecularPattern initialPattern) { Type = type; Parent = parent; pattern = initialPattern; maturationLevel = CellMaturationLevel.Immature; Start(); }*/ public Cell(CellType type, ITissue parent) { Type = type; Parent = parent; maturationLevel = CellMaturationLevel.Immature; Start(); }
/// <summary> /// Implements Get next photon /// </summary> /// <param name="tissue">tissue</param> /// <returns>photon</returns> public Photon GetNextPhoton(ITissue tissue) { // sample angular distribution Direction finalDirection = SourceToolbox.GetDirectionForGivenPolarAzimuthalAngleRangeRandom(_polarAngleRangeToDefineSphericalSurface, _azimuthalAngleRangeToDefineSphericalSurface, Rng); //Source starts from anywhere in the sphere Position finalPosition = GetFinalPositionFromProfileType(finalDirection, _radius, Rng); //Lambertian distribution (uniform hemispherical distribution) PolarAzimuthalAngles polarAzimuthalPair = SourceToolbox.GetPolarAzimuthalPairForGivenAngleRangeRandom( SourceDefaults.DefaultHalfPolarAngleRange.Clone(), SourceDefaults.DefaultAzimuthalAngleRange.Clone(), Rng); //Avoid updating the finalDirection during following rotation Position dummyPosition = finalPosition; //Rotate polar azimutahl angle by polarAzimuthalPair vector SourceToolbox.UpdateDirectionPositionAfterRotatingByGivenAnglePair(polarAzimuthalPair, ref finalDirection, ref dummyPosition); //Find the relevent polar and azimuthal pair for the direction PolarAzimuthalAngles _rotationalAnglesOfPrincipalSourceAxis = SourceToolbox.GetPolarAzimuthalPairFromDirection(_newDirectionOfPrincipalSourceAxis); //Translation and source rotation SourceToolbox.UpdateDirectionPositionAfterGivenFlags( ref finalPosition, ref finalDirection, _rotationalAnglesOfPrincipalSourceAxis, _translationFromOrigin, _rotationAndTranslationFlags); var photon = new Photon(finalPosition, finalDirection, 1.0, tissue, _initialTissueRegionIndex, Rng); return(photon); }
/// <summary> /// Class that keeps a photon's data as it moves through the tissue /// </summary> /// <param name="p">Position</param> /// <param name="d">Direction</param> /// <param name="tissue">Tissue></param> /// <param name="currentTissueRegionIndex">integer index within ITissue definition indicating photon's current position</param> /// <param name="generator">Random Number Generator</param> public Photon( Position p, Direction d, ITissue tissue, int currentTissueRegionIndex, Random generator) { DP = new PhotonDataPoint( p, d, 1.0, // weight 0.0, // total time PhotonStateType.Alive); //PreviousDP = null; History = new PhotonHistory(tissue.Regions.Count); History.AddDPToHistory(DP); // add initial datapoint S = 0.0; SLeft = 0.0; CurrentRegionIndex = currentTissueRegionIndex; // flag to determin whether passing through specular or not // the following assumes tissues considered are slabs, only ones we have coded to date // todo: make more general to handle other types of tissues _firstTimeEnteringDomain = true; if (CurrentRegionIndex >= 1) // photon does not go through specular { _firstTimeEnteringDomain = false; } CurrentTrackIndex = 0; _tissue = tissue; SetAbsorbAction(_tissue.AbsorptionWeightingType); SetScatterAction(_tissue.PhaseFunctionType); _rng = generator; _russianRouletteWeightThreshold = _tissue.RussianRouletteWeightThreshold; }
public DendriticCell(ITissue parent, ProcessSpampHandler spampProcessor, ProcessSdampHandler sdampProcessor, ProcessAntigenHandler <T> antigenProcessor) : base(CellType.APC, parent) { OnProcessSpamp = spampProcessor; OnProcessSdamp = sdampProcessor; OnProcessAntigen = antigenProcessor; }
/// <summary> /// controller for history type detectors /// </summary> /// <param name="detectors">IEnumerable of IHistoryDetector</param> /// <param name="tissue">ITissue</param> public HistoryDetectorController(IEnumerable <IHistoryDetector> detectors, ITissue tissue) { //_detectors = (from d in detectors // where d is IHistoryDetector // select d).ToList(); _detectors = detectors.ToList(); _tissue = tissue; }
/// <summary> /// generic volume virtual boundary, used to capture all internal volume detectors e.g. FluenceOfRhoAndZ /// </summary> /// <param name="tissue">ITissue</param> /// <param name="detectorController">IDetectorController</param> /// <param name="name">string name</param> public GenericVolumeVirtualBoundary(ITissue tissue, IDetectorController detectorController, string name) { VirtualBoundaryType = VirtualBoundaryType.GenericVolumeBoundary; PhotonStateType = PhotonStateType.PseudoGenericVolumeVirtualBoundary; _detectorController = detectorController; Name = name; }
/// <summary> /// Implements Get next photon /// </summary> /// <param name="tissue">tissue</param> /// <returns>photon</returns> public Photon GetNextPhoton(ITissue tissue) { double curved = 2 * Math.PI * _fiberRadius * _fiberHeightZ * _curvedSurfaceEfficiency; double bottom = Math.PI * _fiberRadius * _fiberRadius * _bottomSurfaceEfficiency; Direction finalDirection = SourceToolbox.GetDirectionForGivenPolarAzimuthalAngleRangeRandom( SourceDefaults.DefaultHalfPolarAngleRange.Clone(), SourceDefaults.DefaultAzimuthalAngleRange.Clone(), Rng); Position finalPosition = SourceDefaults.DefaultPosition.Clone(); if (_fiberRadius > 0.0) { if (Rng.NextDouble() > bottom / (curved + bottom)) //Consider { /* Curved surface */ // To utilize the final direction given above, we can assume a tube // parallel to the y-axis. We can rotate it about the x-axis by pi/2 // to compute the new direction. SourceToolbox.UpdateDirectionAfterRotatingAroundXAxis(-0.5 * Math.PI, finalDirection); //Sample tube perimeter first to compute x and y coordinates finalPosition = SourceToolbox.GetPositionAtCirclePerimeter(finalPosition, _fiberRadius, Rng); //Sample tube height to compute z coordinate finalPosition.Z = _fiberHeightZ * (Rng.NextDouble() - 0.5); } else { /* Bottom Surface */ //Shift finalPosition by _fiberHeightZ / 2 finalPosition = new Position(0.0, 0.0, _fiberHeightZ * 0.5); //Sample the bottom face to find x, y coordinates of the emission finalPosition = SourceToolbox.GetPositionInACircleRandomFlat(finalPosition, 0.0, _fiberRadius, Rng); } } //Find the relevent polar and azimuthal pair for the direction PolarAzimuthalAngles _rotationalAnglesOfPrincipalSourceAxis = SourceToolbox.GetPolarAzimuthalPairFromDirection(_newDirectionOfPrincipalSourceAxis); //Translation and source rotation SourceToolbox.UpdateDirectionPositionAfterGivenFlags( ref finalPosition, ref finalDirection, _rotationalAnglesOfPrincipalSourceAxis, _translationFromOrigin, _rotationAndTranslationFlags); var photon = new Photon(finalPosition, finalDirection, 1.0, tissue, _initialTissueRegionIndex, Rng); return photon; }
/// <summary> /// Implements Get next photon /// </summary> /// <param name="tissue">tissue</param> /// <returns>photon</returns> public Photon GetNextPhoton(ITissue tissue) { //Source starts from anywhere in the tissue region of fluorescence Position finalPosition = GetFinalPosition(Rng); Direction finalDirection = GetFinalDirection(Rng); var photon = new Photon(finalPosition, finalDirection, tissue, _initialTissueRegionIndex, Rng); return(photon); }
public void Initialize(ITissue tissue, Random rng) { // assign any user-defined outputs (except arrays...we'll make those on-demand) TallyCount = 0; // if the data arrays are null, create them (only create second moment if TallySecondMoment is true) Mean = Mean ?? new double[Rho.Count - 1]; SecondMoment = SecondMoment ?? (TallySecondMoment ? new double[Rho.Count - 1] : null); // intialize any other necessary class fields here }
// todo: revisit to make signatures here and in Tissue/TissueInput class signatures strongly typed /// <summary> /// Method to return ITissue given inputs /// </summary> /// <param name="ti">ITissueInput</param> /// <param name="awt">AbsorptionWeightingType enum</param> /// <param name="pft">PhaseFunctionType enum</param> /// <param name="russianRouletteWeightThreshold">Russian Roulette weight threshold</param> /// <returns>ITissue</returns> public static ITissue GetTissue(ITissueInput ti, AbsorptionWeightingType awt, PhaseFunctionType pft, double russianRouletteWeightThreshold) { ITissue t = ti.CreateTissue(awt, pft, russianRouletteWeightThreshold); if (t == null) { throw new ArgumentException( "Problem generating ITissue instance. Check that TissueInput, ti, has a matching ITissue definition."); } return(t); }
/// <summary> /// Implements Get next photon /// </summary> /// <param name="tissue">tissue</param> /// <returns>photon</returns> public Photon GetNextPhoton(ITissue tissue) { //Source starts from anywhere in the tissue region of fluorescence Position finalPosition = GetFinalPositionAndWeight(Rng, out _weight); //Starting weight based on sampling method //Lambertian direction Direction finalDirection = GetFinalDirection(Rng); var photon = new Photon(finalPosition, finalDirection, _weight, tissue, _initialTissueRegionIndex, Rng); return(photon); }
/// <summary> /// Static method to instantiate correct CollisionInfoDatabaseWriter given a /// virtual boundary DatabaseType, path to where to output database and database filename. /// </summary> /// <param name="databaseType">database type enum</param> /// <param name="tissue">ITissue to know how many regions</param> /// <param name="filePath">path string of database output</param> /// <param name="outputName">filename string of database file</param> /// <returns>a CollisionInfoDatabaseWriter</returns> public static CollisionInfoDatabaseWriter GetCollisionInfoDatabaseWriter( DatabaseType databaseType, ITissue tissue, string filePath, string outputName) { switch (databaseType) { default: case DatabaseType.pMCDiffuseReflectance: return(new CollisionInfoDatabaseWriter(VirtualBoundaryType.pMCDiffuseReflectance, Path.Combine(filePath, outputName, "CollisionInfoDatabase"), tissue.Regions.Count())); } }
public void Initialize(ITissue tissue, Random rng) { _tissue = tissue; // assign any user-defined outputs (except arrays...we'll make those on-demand) TallyCount = 0; NumSubregions = _tissue.Regions.Count; // if the data arrays are null, create them (only create second moment if TallySecondMoment is true) Mean = Mean ?? new double[Rho.Count - 1, NumSubregions, Time.Count - 1]; SecondMoment = SecondMoment ?? (TallySecondMoment ? new double[Rho.Count - 1, NumSubregions, Time.Count - 1] : null); FractionalTime = FractionalTime ?? new double[Rho.Count - 1, NumSubregions]; }
/// <summary> /// Method to instantiate a single IDetectorInput. This method is called by /// the method below that instantiates a list of detectors. /// </summary> /// <param name="detectorInput">IEnumerable of IDetectorInput</param> /// <param name="tissue">ITissue</param> /// <param name="rng">random number generator</param> /// <returns>List of IDetector</returns> public static IDetector GetDetector(IDetectorInput detectorInput, ITissue tissue, Random rng) { if (detectorInput == null) { return(null); } var detector = detectorInput.CreateDetector(); detector.Initialize(tissue, rng); return(detector); }
public HelperTCell(ITissue parent, int mpLen) : base(CellType.Helper, parent) { Activators = new List<Address>(); // generate a random molecular pattern // NOTE: pattern vectors should be normalized var pat = new double[mpLen]; for (int i = 0; i < mpLen; i++) { pat[i] = RandGen.NextDouble(); } Pattern = new MolecularPattern(pat); }
// /// <summary> // /// This static method instantiates a list of virtual boundaries // /// and the appropriate detectors are deposited into it. // /// </summary> // /// <param name="detectors"></param> // /// <returns></returns> // public static IList<IVirtualBoundary> GetVirtualBoundaries( // IList<IVirtualBoundaryInput> virtualBoundaryGroups, ITissue tissue, bool tallySecondMoment) // { // // this sql returns all VBs even when only RSpecularDetector in detectors // //var virtualBoundaries = // // from vb in EnumHelper.GetValues<VirtualBoundaryType>() // for each virtual boundary type // // where detectors.Select(d => d.TallyType.AppliesToBoundary(vb)).First() // where any detectors apply // // let vbDetectors = detectors.Where(d => d.TallyType.AppliesToBoundary(vb)).ToList() // gather the appropriate detectors // // select GetVirtualBoundary(vb, tissue, vbDetectors); // and instantiate the vb with the appropriate detectors // var virtualBoundaries = new List<IVirtualBoundary>(); // foreach (var vbg in virtualBoundaryGroups) // { // var detectors = DetectorFactory.GetDetectors( // vbg.DetectorInputs, tissue, tallySecondMoment); // var detectorController = DetectorControllerFactory.GetDetectorController( // vbg.VirtualBoundaryType, detectors); // if (detectors.Count > 0) // { // var vb = GetVirtualBoundary(vbg.VirtualBoundaryType, tissue, detectorController); // if (vb != null) // virtualBoundaries.Add(vb); // } // } // return virtualBoundaries.ToList(); // } /// <summary> /// method that gets appropriate VB /// </summary> /// <param name="vbType">VirtualBoundaryType</param> /// <param name="tissue">ITissue</param> /// <param name="detectorController">IDetectorController</param> /// <returns>IVirtualBoundary</returns> public static IVirtualBoundary GetVirtualBoundary( VirtualBoundaryType vbType, ITissue tissue, IDetectorController detectorController) { IVirtualBoundary vb = null; // todo: predicate defines switch (vbType) { case VirtualBoundaryType.DiffuseReflectance: vb = new DiffuseReflectanceVirtualBoundary( tissue, detectorController, VirtualBoundaryType.DiffuseReflectance.ToString()); break; case VirtualBoundaryType.DiffuseTransmittance: vb = new DiffuseTransmittanceVirtualBoundary( tissue, detectorController, VirtualBoundaryType.DiffuseTransmittance.ToString()); break; case VirtualBoundaryType.SpecularReflectance: // reflecting off first layer without transporting in medium vb = new SpecularReflectanceVirtualBoundary( tissue, detectorController, VirtualBoundaryType.SpecularReflectance.ToString()); break; case VirtualBoundaryType.SurfaceRadiance: vb = new RadianceVirtualBoundary( detectorController, VirtualBoundaryType.SurfaceRadiance.ToString()); break; case VirtualBoundaryType.GenericVolumeBoundary: vb = new GenericVolumeVirtualBoundary( tissue, detectorController, VirtualBoundaryType.GenericVolumeBoundary.ToString()); break; case VirtualBoundaryType.pMCDiffuseReflectance: vb = new pMCDiffuseReflectanceVirtualBoundary( tissue, detectorController, VirtualBoundaryType.DiffuseReflectance.ToString()); break; case VirtualBoundaryType.BoundingCylinderVolume: vb = new BoundingCylinderVirtualBoundary( tissue, detectorController, VirtualBoundaryType.BoundingCylinderVolume.ToString()); break; default: throw new ArgumentOutOfRangeException("Virtual boundary type not recognized: " + vbType); } return(vb); }
public void Initialize(ITissue tissue, Random rng) { // assign any user-defined outputs (except arrays...we'll make those on-demand) TallyCount = 0; // if the data arrays are null, create them (only create second moment if TallySecondMoment is true) Mean = Mean ?? new double[X.Count - 1, Y.Count - 1, Z.Count - 1, Time.Count - 1]; SecondMoment = SecondMoment ?? (TallySecondMoment ? new double[X.Count - 1, Y.Count - 1, Z.Count - 1, Time.Count - 1] : null); // intialize any other necessary class fields here _absorptionWeightingMethod = AbsorptionWeightingMethods.GetVolumeAbsorptionWeightingMethod(tissue, this); _tissue = tissue; _ops = _tissue.Regions.Select(r => r.RegionOP).ToArray(); _tallyForOnePhoton = _tallyForOnePhoton ?? (TallySecondMoment ? new double[X.Count - 1, Y.Count - 1, Z.Count - 1, Time.Count - 1] : null); }
public void Initialize(ITissue tissue, Random rng) { // assign any user-defined outputs (except arrays...we'll make those on-demand) TallyCount = 0; // if the data arrays are null, create them (only create second moment if TallySecondMoment is true) Mean = Mean ?? new double[Rho.Count - 1, Time.Count - 1]; SecondMoment = SecondMoment ?? (TallySecondMoment ? new double[Rho.Count - 1, Time.Count - 1] : null); // intialize any other necessary class fields here _perturbedOps = PerturbedOps; _referenceOps = tissue.Regions.Select(r => r.RegionOP).ToList(); _perturbedRegionsIndices = PerturbedRegionsIndices; _absorbAction = AbsorptionWeightingMethods.GetpMCTerminationAbsorptionWeightingMethod(tissue, this); }
public void Initialize(ITissue tissue, Random rng) { // assign any user-defined outputs (except arrays...we'll make those on-demand) TallyCount = 0; // if the data arrays are null, create them (only create second moment if TallySecondMoment is true) Mean = new double(); if (TallySecondMoment) { SecondMoment = new double(); } // initialize any other necessary class fields here _tissue = tissue; }
public HelperTCell(ITissue parent, int mpLen) : base(CellType.Helper, parent) { Activators = new List <Address>(); // generate a random molecular pattern // NOTE: pattern vectors should be normalized var pat = new double[mpLen]; for (int i = 0; i < mpLen; i++) { pat[i] = RandGen.NextDouble(); } Pattern = new MolecularPattern(pat); }
/// <summary> /// diffuse transmittance VB /// </summary> /// <param name="tissue">ITissue</param> /// <param name="detectorController">IDetectorController</param> /// <param name="name">string name</param> public DiffuseTransmittanceVirtualBoundary(ITissue tissue, IDetectorController detectorController, string name) { _zPlanePosition = ((LayerTissueRegion)tissue.Regions.Where(r => r is LayerTissueRegion).Last()).ZRange.Start; WillHitBoundary = dp => dp.StateFlag.HasFlag(PhotonStateType.PseudoTransmittedTissueBoundary) && dp.Direction.Uz > 0 && Math.Abs(dp.Position.Z - _zPlanePosition) < 10E-16; VirtualBoundaryType = VirtualBoundaryType.DiffuseTransmittance; PhotonStateType = PhotonStateType.PseudoDiffuseTransmittanceVirtualBoundary; _detectorController = detectorController; Name = name; }
public void Initialize(ITissue tissue, Random rng) { // intialize any necessary class fields here _tissue = tissue; _ops = _tissue.Regions.Select(r => r.RegionOP).ToArray(); // assign any user-defined outputs (except arrays...we'll make those on-demand) TallyCount = 0; NumSubregions = _tissue.Regions.Count; // if the data arrays are null, create them (only create second moment if TallySecondMoment is true) Mean = Mean ?? new double[Rho.Count - 1, MTBins.Count - 1]; SecondMoment = SecondMoment ?? (TallySecondMoment ? new double[Rho.Count - 1, MTBins.Count - 1] : null); // Fractional MT has FractionalMTBins.Count numnber of bins PLUS 2, one for =1, an d one for =0 FractionalMT = FractionalMT ?? new double[Rho.Count - 1, MTBins.Count - 1, NumSubregions, FractionalMTBins.Count + 1]; }
/// <summary> /// class for perturbation Monte Carlo (pMC) diffuse reflectance virtual boundary /// </summary> /// <param name="tissue">ITissue</param> /// <param name="detectorController">IDetectorController</param> /// <param name="name">string name</param> public pMCDiffuseReflectanceVirtualBoundary(ITissue tissue, IDetectorController detectorController, string name) { _zPlanePosition = ((LayerTissueRegion)tissue.Regions[0]).ZRange.Stop; WillHitBoundary = dp => dp.StateFlag.HasFlag(PhotonStateType.PseudoReflectedTissueBoundary) && dp.Direction.Uz < 0 && Math.Abs(dp.Position.Z - _zPlanePosition) < 10E-16; VirtualBoundaryType = VirtualBoundaryType.pMCDiffuseReflectance; PhotonStateType = PhotonStateType.PseudoDiffuseReflectanceVirtualBoundary; _detectorController = detectorController; Name = name; }
/// <summary> /// generic volume virtual boundary, used to capture all internal volume detectors /// </summary> /// <param name="tissue">ITissue</param> /// <param name="detectorController">IDetectorController</param> /// <param name="name">string name</param> public GenericVolumeVirtualBoundary(ITissue tissue, IDetectorController detectorController, string name) { //_zPlanePosition = ((LayerTissueRegion)tissue.Regions[0]).ZRange.Stop; //WillHitBoundary = dp => // dp.StateFlag.Has(PhotonStateType.Transmitted) && // dp.Direction.Uz < 0 && // Math.Abs(dp.Position.Z - _zPlanePosition) < 10E-16; VirtualBoundaryType = VirtualBoundaryType.GenericVolumeBoundary; PhotonStateType = PhotonStateType.PseudoGenericVolumeVirtualBoundary; _detectorController = detectorController; Name = name; }
/// <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; }