예제 #1
0
        public void setup()
        {
            // set up MC simulation that generated the absorbed energy detector results in embedded resources
            //var input = new SimulationInput(
            //100,
            //"test",
            //new SimulationOptions(
            //    0, // random number generator seed, -1=random seed, 0=fixed seed
            //    RandomNumberGeneratorType.MersenneTwister,
            //    AbsorptionWeightingType.Discrete,
            //    PhaseFunctionType.HenyeyGreenstein,
            //    new List<DatabaseType>() { }, // databases to be written
            //    false, // track statistics
            //    0.0, // RR threshold -> no RR performed
            //    0),
            //    new DirectionalPointSourceInput(
            //        new Position(0.0, 0.0, 0.0),
            //        new Direction(0.0, 0.0, 1.0),
            //        0), // 0=start in air, 1=start in tissue
            //    new SingleInfiniteCylinderTissueInput(
            //        new InfiniteCylinderTissueRegion(
            //            new Position(0, 0, 1),
            //            1.0,
            //            new OpticalProperties(0.05, 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))
            //        }
            //    ),
            //    new List<IDetectorInput>()
            //    {
            //        new AOfXAndYAndZDetectorInput(){
            //            X =new DoubleRange(-2, 2, 5),
            //            Y =new DoubleRange(-10, 10, 2),
            //            Z =new DoubleRange(0, 3, 4)}
            //    }
            //);
            //var output = new MonteCarloSimulation(input).Run();  //NOTE: this puts output in Vts.MCCL/bin/Debug
            var name         = Assembly.GetExecutingAssembly().FullName;
            var assemblyName = new AssemblyName(name).Name;

            _aOfXAndYAndZDetector = (dynamic)DetectorIO.ReadDetectorFromFileInResources(
                "AOfXAndYAndZ", "Resources/sourcetest/", assemblyName);
            // overwrite statistical data in Mean with deterministic values to test
            int count = 1;

            for (int i = 0; i < _aOfXAndYAndZDetector.X.Count - 1; i++)
            {
                for (int j = 0; j < _aOfXAndYAndZDetector.Y.Count - 1; j++)
                {
                    for (int k = 0; k < _aOfXAndYAndZDetector.Z.Count - 1; k++)
                    {
                        _aOfXAndYAndZDetector.Mean[i, j, k] = count; // make all nonzero and unique
                        ++count;
                    }
                }
            }
            DetectorIO.WriteDetectorToFile(_aOfXAndYAndZDetector, "sourcetest");

            FileIO.CopyFileFromResources(
                "Resources/sourcetest/input.txt", "sourcetest/input.txt", assemblyName);
            // following setup is used to test FluorescenceEmissionSource
            _fluorescenceEmissionAOfXAndYAndZSource = new FluorescenceEmissionAOfXAndYAndZSource(
                "sourcetest", "input.txt", 3);
            // empty infileFolder will initialize AOfXAndYAndZLoader with no AOfXAndYAndZ read
            _fluorescenceEmissionAOfXAndYAndZSource.Loader = new AOfXAndYAndZLoader(
                "sourcetest", "input.txt", 3);
            _loader = _fluorescenceEmissionAOfXAndYAndZSource.Loader;

            _loader.InitializeFluorescentRegionArrays();
        }
        public void setup()
        {
            var name         = Assembly.GetExecutingAssembly().FullName;
            var assemblyName = new AssemblyName(name).Name;

            // AOfXAndYAndZ in resource is defined by:
            // single layer tissue with embedded infinite cylinder center=(0,0,1) radius=1
            // detector x=[-2 2] 4 bins, y=[-10 10] 1 bin, z=[0 3] 3 bins
            _aOfXAndYAndZDetector = (dynamic)DetectorIO.ReadDetectorFromFileInResources(
                "AOfXAndYAndZ", "Resources/sourcetest/", assemblyName);
            // overwrite statistical data in Mean with deterministic values to test
            int count = 1;

            for (int i = 0; i < _aOfXAndYAndZDetector.X.Count - 1; i++)
            {
                for (int j = 0; j < _aOfXAndYAndZDetector.Y.Count - 1; j++)
                {
                    for (int k = 0; k < _aOfXAndYAndZDetector.Z.Count - 1; k++)
                    {
                        _aOfXAndYAndZDetector.Mean[i, j, k] = count; // make all nonzero and unique
                        ++count;
                    }
                }
            }
            DetectorIO.WriteDetectorToFile(_aOfXAndYAndZDetector, "sourcetest");

            FileIO.CopyFileFromResources(
                "Resources/sourcetest/inputAOfXAndYAndZ.txt", "sourcetest/inputAOfXAndYAndZ.txt", assemblyName);

            // following setup is used to test FluorescenceEmissionSource CDF sampling method
            _fluorEmissionAOfXAndYAndZSourceCDF = new FluorescenceEmissionAOfXAndYAndZSource(
                "sourcetest", "inputAOfXAndYAndZ.txt", 3, SourcePositionSamplingType.CDF);
            // empty infileFolder will initialize AOfXAndYAndZLoader with no AOfXAndYAndZ read
            _fluorEmissionAOfXAndYAndZSourceCDF.Loader = new AOfXAndYAndZLoader(
                "sourcetest", "inputAOfXAndYAndZ.txt", 3);
            _xyzLoaderCDF = _fluorEmissionAOfXAndYAndZSourceCDF.Loader;
            _xyzLoaderCDF.InitializeFluorescentRegionArrays();

            // following setup is used to test FluorescenceEmissionSource Unif sampling method
            _fluorEmissionAOfXAndYAndZSourceUnif = new FluorescenceEmissionAOfXAndYAndZSource(
                "sourcetest", "inputAOfXAndYAndZ.txt", 3, SourcePositionSamplingType.Uniform);
            // empty infileFolder will initialize AOfXAndYAndZLoader with no AOfXAndYAndZ read
            _fluorEmissionAOfXAndYAndZSourceUnif.Loader = new AOfXAndYAndZLoader(
                "sourcetest", "inputAOfXAndYAndZ.txt", 3);
            _xyzLoaderUnif = _fluorEmissionAOfXAndYAndZSourceCDF.Loader;

            _xyzLoaderCDF.InitializeFluorescentRegionArrays();

            // AOfRhoAndZ in resource is defined by:
            // single layer tissue with embedded infinite cylinder center=(0,0,1) radius=4
            // detector rho=[0 4] 4 bins, z=[0 2] 2 bins
            _aOfRhoAndZDetector = (dynamic)DetectorIO.ReadDetectorFromFileInResources(
                "AOfRhoAndZ", "Resources/sourcetest/", assemblyName);
            // overwrite statistical data in Mean with deterministic values to test
            count = 1;
            for (int i = 0; i < _aOfRhoAndZDetector.Rho.Count - 1; i++)
            {
                for (int k = 0; k < _aOfRhoAndZDetector.Z.Count - 1; k++)
                {
                    _aOfRhoAndZDetector.Mean[i, k] = count; // make all nonzero and unique
                    ++count;
                }
            }
            DetectorIO.WriteDetectorToFile(_aOfRhoAndZDetector, "sourcetest");

            FileIO.CopyFileFromResources(
                "Resources/sourcetest/inputAOfRhoAndZ.txt", "sourcetest/inputAOfRhoAndZ.txt", assemblyName);

            // following setup is used to test FluorescenceEmissionSource CDF sampling method
            _fluorEmissionAOfRhoAndZSourceCDF = new FluorescenceEmissionAOfRhoAndZSource(
                "sourcetest", "inputAOfRhoAndZ.txt", 3, SourcePositionSamplingType.CDF);
            // empty infileFolder will initialize AOfRhoAndZLoader with no AOfRhoAndZ read
            _fluorEmissionAOfRhoAndZSourceCDF.Loader = new AOfRhoAndZLoader(
                "sourcetest", "inputAOfRhoAndZ.txt", 3);
            _rhozLoaderCDF = _fluorEmissionAOfRhoAndZSourceCDF.Loader;
            _rhozLoaderCDF.InitializeFluorescentRegionArrays();

            // following setup is used to test FluorescenceEmissionSource Unif sampling method
            _fluorEmissionAOfRhoAndZSourceUnif = new FluorescenceEmissionAOfRhoAndZSource(
                "sourcetest", "inputAOfRhoAndZ.txt", 3, SourcePositionSamplingType.Uniform);
            // empty infileFolder will initialize AOfRhoAndZLoader with no AOfRhoAndZ read
            _fluorEmissionAOfRhoAndZSourceUnif.Loader = new AOfRhoAndZLoader(
                "sourcetest", "inputAOfRhoAndZ.txt", 3);
            _rhozLoaderUnif = _fluorEmissionAOfRhoAndZSourceCDF.Loader;

            _rhozLoaderCDF.InitializeFluorescentRegionArrays();
        }