示例#1
0
        public void validate_pMC_CAW_ROfFx_nonzero_perturbation_one_layer_tissue()
        {
            var postProcessor = new PhotonDatabasePostProcessor(
                VirtualBoundaryType.pMCDiffuseReflectance,
                new List <IDetectorInput>()
            {
                new pMCROfFxDetectorInput()
                {
                    Fx = new DoubleRange(0.0, 0.5, 11),
                    // set perturbed ops to reference ops
                    PerturbedOps = new List <OpticalProperties>()
                    {
                        _referenceInputOneLayerTissue.TissueInput.Regions[0].RegionOP,
                        new OpticalProperties(
                            _referenceInputOneLayerTissue.TissueInput.Regions[1].RegionOP.Mua * 2,
                            _referenceInputOneLayerTissue.TissueInput.Regions[1].RegionOP.Musp * 1.1,
                            _referenceInputOneLayerTissue.TissueInput.Regions[1].RegionOP.G,
                            _referenceInputOneLayerTissue.TissueInput.Regions[1].RegionOP.N),
                        _referenceInputOneLayerTissue.TissueInput.Regions[2].RegionOP
                    },
                    PerturbedRegionsIndices = new List <int>()
                    {
                        1
                    }
                }
            },
                _databaseOneLayerTissue,
                _referenceInputOneLayerTissue);
            var postProcessedOutput = postProcessor.Run();

            // validation value obtained from prior run
            Assert.Less(Math.Abs(postProcessedOutput.pMC_R_fx[1].Real - 0.303789), 0.000001);
            Assert.Less(Math.Abs(postProcessedOutput.pMC_R_fx[1].Imaginary - 0.036982), 0.000001);
        }
示例#2
0
        public void validate_pMC_CAW_ROfRho_nonzero_perturbation_one_layer_tissue()
        {
            var postProcessor = new PhotonDatabasePostProcessor(
                VirtualBoundaryType.pMCDiffuseReflectance,
                new List <IDetectorInput>()
            {
                new pMCROfRhoDetectorInput()
                {
                    Rho = new DoubleRange(0.0, 10, 101),
                    // set perturbed ops to reference ops
                    PerturbedOps = new List <OpticalProperties>()
                    {
                        _referenceInputOneLayerTissue.TissueInput.Regions[0].RegionOP,
                        new OpticalProperties(
                            _referenceInputOneLayerTissue.TissueInput.Regions[1].RegionOP.Mua * 2,
                            _referenceInputOneLayerTissue.TissueInput.Regions[1].RegionOP.Musp * 1.1,
                            _referenceInputOneLayerTissue.TissueInput.Regions[1].RegionOP.G,
                            _referenceInputOneLayerTissue.TissueInput.Regions[1].RegionOP.N),
                        _referenceInputOneLayerTissue.TissueInput.Regions[2].RegionOP
                    },
                    PerturbedRegionsIndices = new List <int>()
                    {
                        1
                    }
                }
            },
                _databaseOneLayerTissue,
                _referenceInputOneLayerTissue);
            var postProcessedOutput = postProcessor.Run();

            // validation value obtained from linux run using above input and seeded the same
            Assert.Less(Math.Abs(postProcessedOutput.pMC_R_r[0] * _factor - 1.013156), 0.000001);
        }
示例#3
0
        public void validate_pMC_CAW_ROfFx_zero_perturbation_one_layer_tissue()
        {
            var postProcessor = new PhotonDatabasePostProcessor(
                VirtualBoundaryType.pMCDiffuseReflectance,
                new List <IDetectorInput>()
            {
                new pMCROfFxDetectorInput()
                {
                    Fx = new DoubleRange(0.0, 0.5, 11),
                    // set perturbed ops to reference ops
                    PerturbedOps = new List <OpticalProperties>()
                    {
                        _referenceInputOneLayerTissue.TissueInput.Regions[0].RegionOP,
                        _referenceInputOneLayerTissue.TissueInput.Regions[1].RegionOP,
                        _referenceInputOneLayerTissue.TissueInput.Regions[2].RegionOP
                    },
                    PerturbedRegionsIndices = new List <int>()
                    {
                        1
                    },
                    TallySecondMoment = true
                }
            },
                _databaseOneLayerTissue,
                _referenceInputOneLayerTissue);
            var postProcessedOutput = postProcessor.Run();

            // validation value obtained from reference non-pMC run
            Assert.Less(Math.Abs(postProcessedOutput.pMC_R_fx[0].Real -
                                 _referenceOutputOneLayerTissue.R_fx[0].Real), 0.00000000001);
            Assert.Less(Math.Abs(postProcessedOutput.pMC_R_fx[0].Imaginary -
                                 _referenceOutputOneLayerTissue.R_fx[0].Imaginary), 0.00000000001);
            Assert.Less(Math.Abs(postProcessedOutput.pMC_R_fx2[1].Real - 0.483629), 0.000001);
            Assert.Less(Math.Abs(postProcessedOutput.pMC_R_fx2[1].Imaginary - 0.0), 0.000001); // imag of 2nd moment is 0
        }
示例#4
0
        public void validate_photon_database_postprocessor_ROfRhoAndTime_results()
        {
            // DAW postprocssing
            var DAWinput          = GenerateReferenceDAWInput();
            var onTheFlyDAWOutput = new MonteCarloSimulation(DAWinput).Run();

            var DAWdatabase      = PhotonDatabase.FromFile("DiffuseReflectanceDatabase");
            var DAWpostProcessor = new PhotonDatabasePostProcessor(
                VirtualBoundaryType.DiffuseReflectance,
                _detectorInputs,
                DAWdatabase,
                onTheFlyDAWOutput.Input);
            var postProcessedDAWOutput = DAWpostProcessor.Run();

            ValidateROfRhoAndTime(onTheFlyDAWOutput, postProcessedDAWOutput);

            // CAW postprocessing
            var CAWinput          = GenerateReferenceCAWInput();
            var onTheFlyCAWOutput = new MonteCarloSimulation(CAWinput).Run();

            var CAWdatabase      = PhotonDatabase.FromFile("DiffuseReflectanceDatabase");
            var CAWpostProcessor = new PhotonDatabasePostProcessor(
                VirtualBoundaryType.DiffuseReflectance,
                _detectorInputs,
                CAWdatabase,
                onTheFlyCAWOutput.Input);
            var postProcessedCAWOutput = CAWpostProcessor.Run();

            ValidateROfRhoAndTime(onTheFlyCAWOutput, postProcessedCAWOutput);
        }
示例#5
0
        public void validate_pMC_DAW_ROfRhoAndTime_zero_perturbation_of_top_layer()
        {
            var postProcessor = new PhotonDatabasePostProcessor(
                VirtualBoundaryType.pMCDiffuseReflectance,
                new List <IDetectorInput>()
            {
                new pMCROfRhoAndTimeDetectorInput()
                {
                    Rho          = new DoubleRange(0.0, 10.0, 101),
                    Time         = new DoubleRange(0.0, 1.0, 101),
                    PerturbedOps = new List <OpticalProperties>()    // perturbed ops
                    {
                        _referenceInputTwoLayerTissue.TissueInput.Regions[0].RegionOP,
                        _referenceInputTwoLayerTissue.TissueInput.Regions[1].RegionOP,
                        _referenceInputTwoLayerTissue.TissueInput.Regions[2].RegionOP,
                        _referenceInputTwoLayerTissue.TissueInput.Regions[3].RegionOP
                    },
                    PerturbedRegionsIndices = new List <int>()
                    {
                        1
                    }
                }
            },
                _databaseTwoLayerTissue,
                _referenceInputTwoLayerTissue);
            var postProcessedOutput = postProcessor.Run();

            // validation value obtained from reference results
            Assert.Less(Math.Abs(postProcessedOutput.pMC_R_rt[0, 0] - _referenceOutputTwoLayerTissue.R_rt[0, 0]), 0.00000000001);
            // validation value obtained from linux run using above input and seeded the same
            Assert.Less(Math.Abs(postProcessedOutput.pMC_R_rt[0, 0] * _factor - 61.5238307), 0.0000001);
        }
示例#6
0
        public void validate_pMC_DAW_ROfXAndY_zero_perturbation_of_top_layer()
        {
            var postProcessor = new PhotonDatabasePostProcessor(
                VirtualBoundaryType.pMCDiffuseReflectance,
                new List <IDetectorInput>()
            {
                new pMCROfXAndYDetectorInput()
                {
                    X            = new DoubleRange(-10.0, 10.0, 11),
                    Y            = new DoubleRange(-10.0, 10.0, 11),
                    PerturbedOps = new List <OpticalProperties>()    // perturbed ops
                    {
                        _referenceInputTwoLayerTissue.TissueInput.Regions[0].RegionOP,
                        _referenceInputTwoLayerTissue.TissueInput.Regions[1].RegionOP,
                        _referenceInputTwoLayerTissue.TissueInput.Regions[2].RegionOP,
                        _referenceInputTwoLayerTissue.TissueInput.Regions[3].RegionOP
                    },
                    PerturbedRegionsIndices = new List <int>()
                    {
                        1
                    }
                }
            },
                _databaseTwoLayerTissue,
                _referenceInputTwoLayerTissue);
            var postProcessedOutput = postProcessor.Run();

            // validation value obtained from reference results
            Assert.Less(Math.Abs(postProcessedOutput.pMC_R_xy[0, 0] -
                                 _referenceOutputTwoLayerTissue.R_xy[0, 0]), 0.00000000001);
            // validation value obtained from prior run
            Assert.Less(Math.Abs(postProcessedOutput.pMC_R_xy[0, 0] - 0.001097), 0.000001);
        }
示例#7
0
        public void validate_pMC_DAW_ROfRho_zero_perturbation_one_layer_tissue()
        {
            var postProcessor = new PhotonDatabasePostProcessor(
                VirtualBoundaryType.pMCDiffuseReflectance,
                new List <IDetectorInput>()
            {
                new pMCROfRhoDetectorInput()
                {
                    Rho          = new DoubleRange(0.0, 10.0, 101),
                    PerturbedOps = new List <OpticalProperties>()        // perturbed ops
                    {
                        _referenceInputOneLayerTissue.TissueInput.Regions[0].RegionOP,
                        _referenceInputOneLayerTissue.TissueInput.Regions[1].RegionOP,
                        _referenceInputOneLayerTissue.TissueInput.Regions[2].RegionOP
                    },
                    PerturbedRegionsIndices = new List <int>()
                    {
                        1
                    },
                    TallySecondMoment = true
                }
            },
                _databaseOneLayerTissue,
                _referenceInputOneLayerTissue);
            var postProcessedOutput = postProcessor.Run();

            // validation value obtained from reference non-pMC run
            Assert.Less(Math.Abs(postProcessedOutput.pMC_R_r[0] - _referenceOutputOneLayerTissue.R_r[0]), 0.00000000001);
            // validation value obtained from linux run using above input and seeded the same
            Assert.Less(Math.Abs(postProcessedOutput.pMC_R_r[0] * _factor - 0.615238307), 0.000000001);
            // validation value based on previous run
            Assert.Less(Math.Abs(postProcessedOutput.pMC_R_r2[0] - 20.022918), 0.000001);
            Assert.AreEqual(postProcessedOutput.pMC_R_r_TallyCount, 89);
        }
        public void validate_pMC_DAW_ROfFxAndTime_zero_perturbation_one_layer_tissue()
        {
            var postProcessor = new PhotonDatabasePostProcessor(
                VirtualBoundaryType.pMCDiffuseReflectance,
                new List <IDetectorInput>()
            {
                new pMCROfFxAndTimeDetectorInput()
                {
                    Fx           = new DoubleRange(0.0, 0.5, 11),
                    Time         = new DoubleRange(0.0, 1.0, 101),
                    PerturbedOps = new List <OpticalProperties>()    // perturbed ops
                    {
                        _referenceInputOneLayerTissue.TissueInput.Regions[0].RegionOP,
                        _referenceInputOneLayerTissue.TissueInput.Regions[1].RegionOP,
                        _referenceInputOneLayerTissue.TissueInput.Regions[2].RegionOP
                    },
                    PerturbedRegionsIndices = new List <int>()
                    {
                        1
                    }
                }
            },
                _databaseOneLayerTissue,
                _referenceInputOneLayerTissue);
            var postProcessedOutput = postProcessor.Run();

            // validation value obtained from reference non-pMC run
            Assert.Less(Math.Abs(postProcessedOutput.pMC_R_fxt[1, 0].Real -
                                 _referenceOutputOneLayerTissue.R_fxt[1, 0].Real), 0.00000000001);
            Assert.Less(Math.Abs(postProcessedOutput.pMC_R_fxt[1, 0].Imaginary -
                                 _referenceOutputOneLayerTissue.R_fxt[1, 0].Imaginary), 0.00000000001);
            // validation value obtained from prior run
            Assert.Less(Math.Abs(postProcessedOutput.pMC_R_fxt[1, 0].Real - 6.858014), 0.000001);
            Assert.Less(Math.Abs(postProcessedOutput.pMC_R_fxt[1, 0].Imaginary - 0.339772), 0.000001);
        }
        public void validate_dMC_DAW_dROfRhodMua_produces_not_NaN_results()
        {
            var postProcessor = new PhotonDatabasePostProcessor(
                VirtualBoundaryType.pMCDiffuseReflectance,
                new List <IDetectorInput>()
            {
                new dMCdROfRhodMuaDetectorInput()
                {
                    Rho = new DoubleRange(0.0, 10, 101),
                    // set perturbed ops to reference ops
                    PerturbedOps = new List <OpticalProperties>()
                    {
                        _referenceInputOneLayerTissue.TissueInput.Regions[0].RegionOP,
                        new OpticalProperties(
                            _referenceInputOneLayerTissue.TissueInput.Regions[1].RegionOP.Mua,
                            _referenceInputOneLayerTissue.TissueInput.Regions[1].RegionOP.Musp,
                            _referenceInputOneLayerTissue.TissueInput.Regions[1].RegionOP.G,
                            _referenceInputOneLayerTissue.TissueInput.Regions[1].RegionOP.N),
                        _referenceInputOneLayerTissue.TissueInput.Regions[2].RegionOP
                    },
                    PerturbedRegionsIndices = new List <int>()
                    {
                        1
                    }
                },
                new dMCdROfRhodMusDetectorInput()
                {
                    Rho = new DoubleRange(0.0, 10, 101),
                    // set perturbed ops to reference ops
                    PerturbedOps = new List <OpticalProperties>()
                    {
                        _referenceInputOneLayerTissue.TissueInput.Regions[0].RegionOP,
                        new OpticalProperties(
                            _referenceInputOneLayerTissue.TissueInput.Regions[1].RegionOP.Mua,
                            _referenceInputOneLayerTissue.TissueInput.Regions[1].RegionOP.Musp,
                            _referenceInputOneLayerTissue.TissueInput.Regions[1].RegionOP.G,
                            _referenceInputOneLayerTissue.TissueInput.Regions[1].RegionOP.N),
                        _referenceInputOneLayerTissue.TissueInput.Regions[2].RegionOP
                    },
                    PerturbedRegionsIndices = new List <int>()
                    {
                        1
                    }
                }
            },
                _databaseOneLayerTissue,
                _referenceInputOneLayerTissue);
            var postProcessedOutput = postProcessor.Run();

            // validation value obtained from linux run using above input and seeded the same
            Assert.AreNotEqual(Math.Abs(postProcessedOutput.dMCdMua_R_r[0]), double.NaN);
            Assert.AreNotEqual(Math.Abs(postProcessedOutput.dMCdMus_R_r[0]), double.NaN);
            Assert.AreEqual(postProcessedOutput.dMCdMua_R_r_TallyCount, 89);
            Assert.AreEqual(postProcessedOutput.dMCdMus_R_r_TallyCount, 89);
        }
示例#10
0
        public void validate_pMC_dMC_detector_NA_tallies_when_NA_is_0p3()
        {
            var postProcessor = new PhotonDatabasePostProcessor(
                VirtualBoundaryType.pMCDiffuseReflectance,
                new List <IDetectorInput>()
            {
                new pMCROfRhoDetectorInput()
                {
                    Rho          = new DoubleRange(0.0, 10.0, 11),
                    PerturbedOps = new List <OpticalProperties>()    // perturbed ops
                    {
                        _inputForPMC.TissueInput.Regions[0].RegionOP,
                        _inputForPMC.TissueInput.Regions[1].RegionOP,
                        _inputForPMC.TissueInput.Regions[2].RegionOP
                    },
                    PerturbedRegionsIndices = new List <int>()
                    {
                        1
                    },
                    FinalTissueRegionIndex = 0,
                    NA = 0.3,
                },
                new pMCROfRhoAndTimeDetectorInput()
                {
                    Rho          = new DoubleRange(0.0, 10.0, 11),
                    Time         = new DoubleRange(0.0, 1.0, 11),
                    PerturbedOps = new List <OpticalProperties>()    // perturbed ops
                    {
                        _inputForPMC.TissueInput.Regions[0].RegionOP,
                        _inputForPMC.TissueInput.Regions[1].RegionOP,
                        _inputForPMC.TissueInput.Regions[2].RegionOP
                    },
                    PerturbedRegionsIndices = new List <int>()
                    {
                        1
                    },
                    FinalTissueRegionIndex = 0,
                    NA = 0.3,
                },
                new pMCROfFxDetectorInput()
                {
                    Fx           = new DoubleRange(0.0, 0.5, 5),
                    PerturbedOps = new OpticalProperties[] {   // perturbed ops
                        _inputForPMC.TissueInput.Regions[0].RegionOP,
                        _inputForPMC.TissueInput.Regions[1].RegionOP,
                        _inputForPMC.TissueInput.Regions[2].RegionOP
                    },
                    PerturbedRegionsIndices = new int[] { 1 },
                    FinalTissueRegionIndex  = 0,
                    NA = 0.3,
                },
                new pMCROfFxAndTimeDetectorInput()
                {
                    Fx           = new DoubleRange(0.0, 0.5, 5),
                    Time         = new DoubleRange(0.0, 1.0, 11),
                    PerturbedOps = new OpticalProperties[] {   // perturbed ops
                        _inputForPMC.TissueInput.Regions[0].RegionOP,
                        _inputForPMC.TissueInput.Regions[1].RegionOP,
                        _inputForPMC.TissueInput.Regions[2].RegionOP
                    },
                    PerturbedRegionsIndices = new int[] { 1 },
                    FinalTissueRegionIndex  = 0,
                    NA = 0.3,
                },
                new dMCdROfRhodMuaDetectorInput()
                {
                    Rho          = new DoubleRange(0.0, 10.0, 11),
                    PerturbedOps = new List <OpticalProperties>()    // perturbed ops
                    {
                        _inputForPMC.TissueInput.Regions[0].RegionOP,
                        _inputForPMC.TissueInput.Regions[1].RegionOP,
                        _inputForPMC.TissueInput.Regions[2].RegionOP
                    },
                    PerturbedRegionsIndices = new List <int>()
                    {
                        1
                    },
                    FinalTissueRegionIndex = 0,
                    NA = 0.3,
                },
                new dMCdROfRhodMusDetectorInput()
                {
                    Rho          = new DoubleRange(0.0, 10.0, 11),
                    PerturbedOps = new List <OpticalProperties>()    // perturbed ops
                    {
                        _inputForPMC.TissueInput.Regions[0].RegionOP,
                        _inputForPMC.TissueInput.Regions[1].RegionOP,
                        _inputForPMC.TissueInput.Regions[2].RegionOP
                    },
                    PerturbedRegionsIndices = new List <int>()
                    {
                        1
                    },
                    FinalTissueRegionIndex = 0,
                    NA = 0.3,
                },
            },
                _pMCDatabase,
                _inputForPMC);
            var postProcessedOutput = postProcessor.Run();

            Assert.Less(Math.Abs(postProcessedOutput.pMC_R_r[0] - 0.003170), 0.000001);
            Assert.Less(Math.Abs(postProcessedOutput.pMC_R_rt[0, 0] - 0.031704), 0.000001);
            Assert.Less(Math.Abs(postProcessedOutput.pMC_R_fx[1].Real - 0.019227), 0.000001);
            Assert.Less(Math.Abs(postProcessedOutput.pMC_R_fx[1].Imaginary - 0.012466), 0.000001);
            Assert.Less(Math.Abs(postProcessedOutput.pMC_R_fxt[1, 0].Real - 0.252024), 0.000001);
            Assert.Less(Math.Abs(postProcessedOutput.pMC_R_fxt[1, 0].Imaginary - 0.089027), 0.000001);
            Assert.Less(Math.Abs(postProcessedOutput.dMCdMua_R_r[0] + 0.001005), 0.000001);
            Assert.Less(Math.Abs(postProcessedOutput.dMCdMus_R_r[0] - 0.000263), 0.000001);
        }
示例#11
0
        public void validate_pMC_dMC_detector_NA_tallies_are_zero_when_NA_is_0()
        {
            var postProcessor = new PhotonDatabasePostProcessor(
                VirtualBoundaryType.pMCDiffuseReflectance,
                new List <IDetectorInput>()
            {
                new pMCROfRhoDetectorInput()
                {
                    Rho          = new DoubleRange(0.0, 10.0, 11),
                    PerturbedOps = new List <OpticalProperties>()    // perturbed ops
                    {
                        _inputForPMC.TissueInput.Regions[0].RegionOP,
                        _inputForPMC.TissueInput.Regions[1].RegionOP,
                        _inputForPMC.TissueInput.Regions[2].RegionOP
                    },
                    PerturbedRegionsIndices = new List <int>()
                    {
                        1
                    },
                    FinalTissueRegionIndex = 0,
                    NA = 0.0,
                },
                new pMCROfRhoAndTimeDetectorInput()
                {
                    Rho          = new DoubleRange(0.0, 10.0, 11),
                    Time         = new DoubleRange(0.0, 1.0, 11),
                    PerturbedOps = new List <OpticalProperties>()    // perturbed ops
                    {
                        _inputForPMC.TissueInput.Regions[0].RegionOP,
                        _inputForPMC.TissueInput.Regions[1].RegionOP,
                        _inputForPMC.TissueInput.Regions[2].RegionOP
                    },
                    PerturbedRegionsIndices = new List <int>()
                    {
                        1
                    },
                    FinalTissueRegionIndex = 0,
                    NA = 0.0,
                },
                new pMCROfFxDetectorInput()
                {
                    Fx           = new DoubleRange(0.0, 0.5, 5),
                    PerturbedOps = new OpticalProperties[] {   // perturbed ops
                        _inputForPMC.TissueInput.Regions[0].RegionOP,
                        _inputForPMC.TissueInput.Regions[1].RegionOP,
                        _inputForPMC.TissueInput.Regions[2].RegionOP
                    },
                    PerturbedRegionsIndices = new int[] { 1 },
                    FinalTissueRegionIndex  = 0,
                    NA = 0.0,
                },
                new pMCROfFxAndTimeDetectorInput()
                {
                    Fx           = new DoubleRange(0.0, 0.5, 5),
                    Time         = new DoubleRange(0.0, 1.0, 11),
                    PerturbedOps = new OpticalProperties[] {   // perturbed ops
                        _inputForPMC.TissueInput.Regions[0].RegionOP,
                        _inputForPMC.TissueInput.Regions[1].RegionOP,
                        _inputForPMC.TissueInput.Regions[2].RegionOP
                    },
                    PerturbedRegionsIndices = new int[] { 1 },
                    FinalTissueRegionIndex  = 0,
                    NA = 0.0,
                },
                new dMCdROfRhodMuaDetectorInput()
                {
                    Rho          = new DoubleRange(0.0, 10.0, 11),
                    PerturbedOps = new List <OpticalProperties>()    // perturbed ops
                    {
                        _inputForPMC.TissueInput.Regions[0].RegionOP,
                        _inputForPMC.TissueInput.Regions[1].RegionOP,
                        _inputForPMC.TissueInput.Regions[2].RegionOP
                    },
                    PerturbedRegionsIndices = new List <int>()
                    {
                        1
                    },
                    FinalTissueRegionIndex = 0,
                    NA = 0.0,
                },
                new dMCdROfRhodMusDetectorInput()
                {
                    Rho          = new DoubleRange(0.0, 10.0, 11),
                    PerturbedOps = new List <OpticalProperties>()    // perturbed ops
                    {
                        _inputForPMC.TissueInput.Regions[0].RegionOP,
                        _inputForPMC.TissueInput.Regions[1].RegionOP,
                        _inputForPMC.TissueInput.Regions[2].RegionOP
                    },
                    PerturbedRegionsIndices = new List <int>()
                    {
                        1
                    },
                    FinalTissueRegionIndex = 0,
                    NA = 0.0,
                },
            },
                _pMCDatabase,
                _inputForPMC);
            var postProcessedOutput = postProcessor.Run();

            Assert.AreEqual(postProcessedOutput.pMC_R_r[0], 0.0);
            Assert.AreEqual(postProcessedOutput.pMC_R_rt[0, 0], 0.0);
            Assert.AreEqual(postProcessedOutput.pMC_R_fx[0].Real, 0.0);
            Assert.AreEqual(postProcessedOutput.pMC_R_fx[0].Imaginary, 0.0);
            Assert.AreEqual(postProcessedOutput.pMC_R_fxt[0, 0].Real, 0.0);
            Assert.AreEqual(postProcessedOutput.pMC_R_fxt[0, 0].Imaginary, 0.0);
            Assert.AreEqual(postProcessedOutput.dMCdMua_R_r[0], 0.0);
            Assert.AreEqual(postProcessedOutput.dMCdMus_R_r[0], 0.0);
        }
示例#12
0
        // need to work on following
        /// <summary>
        /// Runs the Monte Carlo Post-processor
        /// </summary>
        public static void RunPostProcessor(PostProcessorInput input, string outputFolderPath)
        {
            // locate root folder for output, creating it if necessary
            var path = string.IsNullOrEmpty(outputFolderPath)
                ? Path.GetFullPath(Directory.GetCurrentDirectory())
                : Path.GetFullPath(outputFolderPath);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            // locate destination folder for output, creating it if necessary
            var resultsFolder = Path.Combine(path, input.OutputName);

            if (!Directory.Exists(resultsFolder))
            {
                Directory.CreateDirectory(resultsFolder);
            }

            SimulationOutput postProcessedOutput = null;

            var databaseGenerationInputFile = SimulationInput.FromFile(Path.Combine(input.InputFolder, input.DatabaseSimulationInputFilename + ".txt"));

            // check for pMC tallies first because could have ReflectanceTallies mixed in and want to load CollisionInfo

            // Why not mirror the "on-the-fly" code, and allow for all kinds of detector inputs simultaneously? (dc 12/21/2011)
            if (input.DetectorInputs.Where(di => di.TallyDetails.IspMCReflectanceTally).Any())
            {
                IList <IDetectorInput> pMCDetectorInputs;
                pMCDetectorInputs = input.DetectorInputs;
                var postProcessor = new PhotonDatabasePostProcessor(
                    VirtualBoundaryType.pMCDiffuseReflectance,
                    pMCDetectorInputs,
                    PhotonDatabaseFactory.GetpMCDatabase( // database filenames are assumed to be convention
                        VirtualBoundaryType.pMCDiffuseReflectance,
                        input.InputFolder),
                    databaseGenerationInputFile
                    );
                postProcessedOutput = postProcessor.Run();
            }
            else if (input.DetectorInputs.Where(di => di.TallyDetails.IsReflectanceTally).Any())
            {
                var postProcessor = new PhotonDatabasePostProcessor(
                    VirtualBoundaryType.DiffuseReflectance,
                    input.DetectorInputs,
                    PhotonDatabaseFactory.GetPhotonDatabase( //database filenames are assumed to be convention
                        VirtualBoundaryType.DiffuseReflectance,
                        input.InputFolder),
                    databaseGenerationInputFile
                    );
                postProcessedOutput = postProcessor.Run();
            }
            else if (input.DetectorInputs.Where(di => di.TallyDetails.IsTransmittanceTally).Any())
            {
                var postProcessor = new PhotonDatabasePostProcessor(
                    VirtualBoundaryType.DiffuseTransmittance,
                    input.DetectorInputs,
                    PhotonDatabaseFactory.GetPhotonDatabase( //database filenames are assumed to be convention
                        VirtualBoundaryType.DiffuseTransmittance,
                        input.InputFolder),
                    databaseGenerationInputFile
                    );
                postProcessedOutput = postProcessor.Run();
            }
            else if (input.DetectorInputs.Where(di => di.TallyDetails.IsSpecularReflectanceTally).Any())
            {
                var postProcessor = new PhotonDatabasePostProcessor(
                    VirtualBoundaryType.SpecularReflectance,
                    input.DetectorInputs,
                    PhotonDatabaseFactory.GetPhotonDatabase( //database filenames are assumed to be convention
                        VirtualBoundaryType.SpecularReflectance,
                        input.InputFolder),
                    databaseGenerationInputFile
                    );
                postProcessedOutput = postProcessor.Run();
            }


            var folderPath = input.OutputName;

            if (!Directory.Exists(folderPath))
            {
                Directory.CreateDirectory(folderPath);
            }

            // save input file to output folder with results
            input.ToFile(Path.Combine(resultsFolder, input.OutputName + ".txt"));

            // save database generation input file to output folder
            databaseGenerationInputFile.ToFile(Path.Combine(resultsFolder, input.OutputName + "_database_infile.txt"));

            if (postProcessedOutput != null)
            {
                foreach (var result in postProcessedOutput.ResultsDictionary.Values)
                {
                    // save all detector data to the specified folder
                    DetectorIO.WriteDetectorToFile(result, folderPath);
                }
            }
        }