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(); }
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(); }
/// <summary> /// InitializeVectorsAndInterpolators reads in reference database and initializes data /// Note that the reference data is now in mm/ns so no conversion needed /// </summary> private void InitializeVectorsAndInterpolators() { // load R(rho,time) reference data var rOfRhoAndTime = (dynamic)DetectorIO.ReadDetectorFromFileInResources("ROfRhoAndTime", "Modeling/Resources/" + folder, _assemblyName); nrReference = rOfRhoAndTime.Rho.Count - 1; drReference = rOfRhoAndTime.Rho.Delta; ntReference = rOfRhoAndTime.Time.Count - 1; dtReference = rOfRhoAndTime.Time.Delta; // assume mus' used by Kienle muspReference = 1.0; RhoReference = new DoubleRange(drReference / 2, drReference * nrReference - drReference / 2, nrReference).AsEnumerable().ToArray(); TimeReference = new DoubleRange(dtReference / 2, dtReference * ntReference - dtReference / 2, ntReference).AsEnumerable().ToArray(); RReferenceOfRhoAndTime = new double[nrReference, ntReference]; for (int ir = 0; ir < nrReference; ir++) { double sum = 0.0; for (int it = 0; it < ntReference; it++) { RReferenceOfRhoAndTime[ir, it] = rOfRhoAndTime.Mean[ir, it]; sum += rOfRhoAndTime.Mean[ir, it]; // debug line } } // load R(fx,time) reference data var rOfFxAndTime = (dynamic)DetectorIO.ReadDetectorFromFileInResources("ROfFxAndTime", "Modeling/Resources/" + folder, _assemblyName); nfxReference = rOfFxAndTime.Fx.Count; dfxReference = 1.0 / nfxReference; FxReference = new DoubleRange(dfxReference / 2, dfxReference * nfxReference - dfxReference / 2, nfxReference).AsEnumerable().ToArray(); RReferenceOfFxAndTime = new double[nfxReference, ntReference]; for (int ifx = 0; ifx < nfxReference; ifx++) { for (int it = 0; it < ntReference; it++) // this only goes to 800 not 801 because ntReference determined from ROfRhoAndTime.txt { RReferenceOfFxAndTime[ifx, it] = rOfFxAndTime.Mean[ifx, it].Real; } } ////if (File.Exists("Resources/" + folder + @"R_fxt")) //if (true) //{ // RReferenceOfFxAndTime = (double[,])FileIO.ReadArrayFromBinaryInResources<double>("Modeling/Resources/" + // folder + @"R_fxt", _assemblyName); //} //else //{ // double[] RReferenceOfRhoAndTj = new double[nrReference]; // double[] RReferenceOfFxAndTj = new double[nfxReference]; // for (int j = 0; j < ntReference; j++) // { // for (int k = 0; k < nrReference; k++) // { // RReferenceOfRhoAndTj[k] = RReferenceOfRhoAndTime[k, j]; // get ROfRho at a particular Time Tj // } // for (int i = 0; i < nfxReference; i++) // { // RReferenceOfFxAndTime[i, j] = LinearDiscreteHankelTransform.GetHankelTransform(RhoReference, // RReferenceOfRhoAndTj, drReference, dfxReference * i); // } // } // FileIO.WriteArrayToBinary<double>(RReferenceOfFxAndTime, @"/R_fxt"); //} }