示例#1
0
        public void setup_simulation_input_components()
        {
            // delete previously generated files
            clear_folders_and_files();

            _detectorInputs = new List <IDetectorInput>()
            {
                new ROfRhoAndTimeDetectorInput()
                {
                    Rho  = new DoubleRange(0.0, 10.0, 101),
                    Time = new DoubleRange(0.0, 1, 101)
                }
            };
            _sourceInput = new DirectionalPointSourceInput(
                new Position(0.0, 0.0, 0.0),
                new Direction(0.0, 0.0, 1.0),
                1);
            _tissueInput = new MultiLayerTissueInput(
                new ITissueRegion[]
            {
                new LayerTissueRegion(
                    new DoubleRange(double.NegativeInfinity, 0.0),
                    new OpticalProperties(0.0, 1e-10, 0.0, 1.0)),
                new LayerTissueRegion(
                    new DoubleRange(0.0, 20.0),
                    new OpticalProperties(0.01, 1.0, 0.8, 1.4)),
                new LayerTissueRegion(
                    new DoubleRange(20.0, double.PositiveInfinity),
                    new OpticalProperties(0.0, 1e-10, 0.0, 1.0))
            }
                );
        }
示例#2
0
 /// <summary>
 /// Monte Carlo simulation input data
 /// </summary>
 /// <param name="numberOfPhotons">long number indicating number of photons launched from source</param>
 /// <param name="outputName">string indicating output name</param>
 /// <param name="simulationOptions">options to execute simulation</param>
 /// <param name="sourceInput">ISourceInput specifying source of light</param>
 /// <param name="tissueInput">ITissueInput specifying tissue definition</param>
 /// <param name="detectorInputs">IDetectorInput specifying which detectors to tally</param>
 public SimulationInput(
     long numberOfPhotons,
     string outputName,
     SimulationOptions simulationOptions,
     ISourceInput sourceInput,
     ITissueInput tissueInput,
     IList <IDetectorInput> detectorInputs)
 {
     N              = numberOfPhotons;
     OutputName     = outputName;
     Options        = simulationOptions;
     SourceInput    = sourceInput;
     TissueInput    = tissueInput;
     DetectorInputs = detectorInputs ?? new List <IDetectorInput>();
 }
 private static ValidationResult ValidateSourceInput(ISourceInput sourceInput, ITissueInput tissueInput)
 {
     if ((sourceInput.InitialTissueRegionIndex < 0) ||
         (sourceInput.InitialTissueRegionIndex > tissueInput.Regions.Length - 1))
     {
         return(new ValidationResult(
                    false,
                    "Source input not valid given tissue definition",
                    "Alter sourceInput.InitialTissueRegionIndex to be consistent with tissue definition"));
     }
     else
     {
         return(new ValidationResult(
                    true,
                    "Starting photons in region " + sourceInput.InitialTissueRegionIndex));
     }
 }
 /// <summary>
 /// Monte Carlo simulation input data
 /// </summary>
 /// <param name="numberOfPhotons">long number indicating number of photons launched from source</param>
 /// <param name="outputName">string indicating output name</param>
 /// <param name="simulationOptions">options to execute simulation</param>
 /// <param name="sourceInput">ISourceInput specifying source of light</param>
 /// <param name="tissueInput">ITissueInput specifying tissue definition</param>
 /// <param name="detectorInputs">IDetectorInput specifying which detectors to tally</param>
 public SimulationInput(
     long numberOfPhotons,
     string outputName,
     SimulationOptions simulationOptions,
     ISourceInput sourceInput,
     ITissueInput tissueInput,
     IList <IDetectorInput> detectorInputs)
 {
     N              = numberOfPhotons;
     OutputName     = outputName;
     Options        = simulationOptions;
     SourceInput    = sourceInput;
     TissueInput    = tissueInput;
     DetectorInputs = detectorInputs;
     // check if detectorInputs list is null and if so make empty
     if (DetectorInputs == null)
     {
         DetectorInputs = new List <IDetectorInput>()
         {
         };
     }
 }
示例#5
0
        public void execute_Monte_Carlo()
        {
            // instantiate common classes
            _simulationOptions = new SimulationOptions(
                0,
                RandomNumberGeneratorType.MersenneTwister,
                AbsorptionWeightingType.Discrete,
                PhaseFunctionType.HenyeyGreenstein,
                new List <DatabaseType>(),
                false, // track statistics
                0.0,   // RR threshold -> 0 = no RR performed
                0);
            _source = new DirectionalPointSourceInput(
                new Position(0.0, 0.0, 0.0),
                new Direction(0.0, 0.0, 1.0),
                1);

            _tissue =
                new MultiLayerWithSurfaceFiberTissueInput(
                    new SurfaceFiberTissueRegion(
                        new Position(0, 0, 0),
                        _detectorRadius, // needs to match SurfaceFiberDetectorInput
                        new OpticalProperties(0.01, 1.0, 0.8, 1.4)
                        ),
                    new ITissueRegion[]
            {
                new LayerTissueRegion(
                    new DoubleRange(double.NegativeInfinity, 0.0),
                    new OpticalProperties(0.0, 1e-10, 1.0, 1.0)),
                new LayerTissueRegion(
                    new DoubleRange(0.0, 100.0),
                    new OpticalProperties(0.01, 1.0, 0.8, 1.4)),
                new LayerTissueRegion(
                    new DoubleRange(100.0, double.PositiveInfinity),
                    new OpticalProperties(0.0, 1e-10, 1.0, 1.0))
            }
                    );
            // tissue specification to verify MultiLayerWithSurfaceFiberTissue
            // increases reflectance.  If use this tissue need to change FinalTissueRegion
            // for ALL detectors to 0
            //new MultiLayerTissueInput(
            //    new ITissueRegion[]
            //    {
            //        new LayerTissueRegion(
            //            new DoubleRange(double.NegativeInfinity, 0.0),
            //            new OpticalProperties(0.0, 1e-10, 1.0, 1.0)),
            //        new LayerTissueRegion(
            //            new DoubleRange(0.0, 100.0),
            //            new OpticalProperties(0.01, 1.0, 0.8, 1.4)),
            //        new LayerTissueRegion(
            //            new DoubleRange(100.0, double.PositiveInfinity),
            //            new OpticalProperties(0.0, 1e-10, 1.0, 1.0))
            //    }
            //);

            _detectorOpen = new List <IDetectorInput>
            {
                new SurfaceFiberDetectorInput()
                {
                    Center            = new Position(0, 0, 0),
                    Radius            = _detectorRadius,
                    TallySecondMoment = true,
                    N  = 1.4,
                    NA = 1.4,
                    FinalTissueRegionIndex = 3
                },
                new ROfRhoDetectorInput() // 1mm wide ring to match fiber and 2 because beyond goes into 2nd
                {
                    Rho = new DoubleRange(0.0, 2 * _detectorRadius, 3),
                    // since tissue w fiber specified -> photon will be in 3 upon exit
                    FinalTissueRegionIndex = 3,
                    NA = 1.4,
                    TallySecondMoment = true
                },
            };
            _detectorNA = new List <IDetectorInput>
            {
                new SurfaceFiberDetectorInput()
                {
                    Center            = new Position(0, 0, 0),
                    Radius            = _detectorRadius,
                    TallySecondMoment = true,
                    N = 1.4,
                    FinalTissueRegionIndex = 3,
                    NA = 0.39
                },
                new ROfRhoDetectorInput() // ring to match fiber detector
                {
                    Rho = new DoubleRange(0.0, 2 * _detectorRadius, 3),
                    // since tissue w fiber specified -> photon will be in 3 upon exit
                    FinalTissueRegionIndex = 3,
                    NA = 0.39,
                    TallySecondMoment = true
                },
            };
            _detectorNAOffCenter = new List <IDetectorInput>
            {
                new SurfaceFiberDetectorInput()
                {
                    Center            = new Position(_detectorRadius, 0, 0), // diam = [0, 2*radius]
                    Radius            = _detectorRadius,
                    TallySecondMoment = true,
                    N = 1.4,
                    FinalTissueRegionIndex = 3,
                    NA = 1.4
                },
                new ROfRhoDetectorInput() // ring to match fiber detector
                {
                    // place 1st rho bin center at _detectorRadius with width = 2*radius
                    Rho = new DoubleRange(_detectorRadius / 2, 2 * _detectorRadius + _detectorRadius / 2, 3),
                    // since tissue w fiber specified -> photon will be in 3 upon exit
                    FinalTissueRegionIndex = 3,
                    NA = 1.4,
                    TallySecondMoment = true
                },
            };
            var _inputOpen = new SimulationInput(
                100,
                "",
                _simulationOptions,
                _source,
                _tissue,
                _detectorOpen);

            _outputOpen = new MonteCarloSimulation(_inputOpen).Run();

            var _inputNA = new SimulationInput(
                100,
                "",
                _simulationOptions,
                _source,
                _tissue,
                _detectorNA);

            _outputNA = new MonteCarloSimulation(_inputNA).Run();

            var _inputNAOffCenter = new SimulationInput(
                100,
                "",
                _simulationOptions,
                _source,
                _tissue,
                _detectorNAOffCenter);

            _outputNAOffCenter = new MonteCarloSimulation(_inputNAOffCenter).Run();
        }
示例#6
0
        /// <summary>
        /// Method to instantiate the correct source given ISourceInput
        /// </summary>
        /// <param name="input">ISourceInput</param>
        /// <param name="tissue">ITissue</param>
        /// <param name="rng">random number generator instance</param>
        /// <returns>ISource</returns>
        public static ISource GetSource(ISourceInput input, Random rng)
        {
            var source = input.CreateSource(rng);

            return(source);
        }