public void SpatialAndTemporalFrequencyTwoLayerSDATest()
        {
            var _thresholdValue = 0.03;

            double[] fxs = new double[] { 0.0, 0.02 };  // 0.3 just doesn't give good results
            var      _twoLayerSDAForwardSolver   = new TwoLayerSDAForwardSolver();
            var      _oneLayerNurbsForwardSolver = new NurbsForwardSolver();

            // make sure layer thickess is greater than l*=1/(mua+musp)=1mm
            LayerTissueRegion[] _twoLayerTissue =
                new LayerTissueRegion[]
            {
                new LayerTissueRegion(new DoubleRange(0, 3), new OpticalProperties(ops)),
                new LayerTissueRegion(new DoubleRange(3, 100), new OpticalProperties(ops)),
            };
            for (int ifx = 0; ifx < fxs.Length; ifx++)
            {
                var oneLayerResult = _oneLayerNurbsForwardSolver.ROfFxAndFt(ops, fxs[ifx], ft);
                var twoLayerResult = _twoLayerSDAForwardSolver.ROfFxAndFt(_twoLayerTissue, fxs[ifx], ft);
                var relDiffRe      = Math.Abs(twoLayerResult.Real - oneLayerResult.Real) / oneLayerResult.Real;
                var relDiffIm      = Math.Abs((twoLayerResult.Imaginary - oneLayerResult.Imaginary) / oneLayerResult.Imaginary);
                Assert.IsTrue(relDiffRe < _thresholdValue, "Test failed for fx =" + fxs[ifx] +
                              " and ft=", +ft + ", with Real relative difference " + relDiffRe);
                Assert.IsTrue(relDiffIm < _thresholdValue, "Test failed for fx =" + fxs[ifx] +
                              " and ft=", +ft + ", with Imag relative difference " + relDiffIm);
            }
        }
        public void SpatialFrequencyAndTemporalTwoLayerSDATest()
        {
            var _thresholdValue = 0.06;

            double[] _fxs   = new double[] { 0.0, 0.02 }; // 0.3 just doesn't give good results
            double[] _times = { 0.004, 0.014 };           // ns, these times were chosen for each fx
            var      _twoLayerSDAForwardSolver = new TwoLayerSDAForwardSolver();
            var      _oneLayerSDAForwardSolver = new PointSourceSDAForwardSolver();

            // make sure layer thickess is greater than l*=1/(mua+musp)=1mm
            LayerTissueRegion[] _twoLayerTissue =
                new LayerTissueRegion[]
            {
                new LayerTissueRegion(new DoubleRange(0, 3), new OpticalProperties(ops)),
                new LayerTissueRegion(new DoubleRange(3, 100), new OpticalProperties(ops)),
            };
            for (int i = 0; i < _fxs.Length; i++)
            {
                var oneLayerResult = _oneLayerSDAForwardSolver.ROfFxAndTime(ops, _fxs[i], _times[i]);
                var twoLayerResult = _twoLayerSDAForwardSolver.ROfFxAndTime(_twoLayerTissue, _fxs[i], _times[i]);
                var relDiffRe      = Math.Abs(twoLayerResult - oneLayerResult) / oneLayerResult;
                Assert.IsTrue(relDiffRe < _thresholdValue, "Test failed for fx =" + _fxs[i] +
                              " and ft=", +_times[i] + ", with relative difference " + relDiffRe);
            }
        }
        public void TemporalFrequencyTwoLayerSDATest()
        {
            var _thresholdValue                      = 1e-8;
            var _twoLayerSDAForwardSolver            = new TwoLayerSDAForwardSolver();
            var _oneLayerPointSourceSDAForwardSolver = new PointSourceSDAForwardSolver();

            // make sure layer thickess is greater than l*=1/(mua+musp)=1mm
            LayerTissueRegion[] _twoLayerTissue =
                new LayerTissueRegion[]
            {
                new LayerTissueRegion(new DoubleRange(0, 3), new OpticalProperties(ops)),
                new LayerTissueRegion(new DoubleRange(3, 100), new OpticalProperties(ops)),
            };
            for (int irho = 0; irho < rhos.Length; irho++)
            {
                var oneLayerResult = _oneLayerPointSourceSDAForwardSolver.ROfRhoAndFt(ops, rhos[irho], ft);
                var twoLayerResult = _twoLayerSDAForwardSolver.ROfRhoAndFt(_twoLayerTissue, rhos[irho], ft);
                var relDiffRe      = Math.Abs(twoLayerResult.Real - oneLayerResult.Real) / oneLayerResult.Real;
                var relDiffIm      = Math.Abs((twoLayerResult.Imaginary - oneLayerResult.Imaginary) / oneLayerResult.Imaginary);
                Assert.IsTrue(relDiffRe < _thresholdValue, "Test failed for rho =" + rhos[irho] +
                              "mm, with Real relative difference " + relDiffRe);
                Assert.IsTrue(relDiffIm < _thresholdValue, "Test failed for rho =" + rhos[irho] +
                              "mm, with Imaginary relative difference " + relDiffIm);
            }
        }
        public void TemporalTwoLayerSDATest()
        {
            var    _twoLayerSDAForwardSolver = new TwoLayerSDAForwardSolver();
            var    _oneLayerForwardSolver    = new PointSourceSDAForwardSolver();
            double _thresholdValue           = 0.03;

            double[] _rhos  = { 1, 3, 6, 10 };
            double[] _times = { 0.0038, 0.014, 0.058, 0.14 }; // ns, these times where chosen for each rho

            // make sure layer thickess is greater than l*=1/(mua+musp)=1mm
            LayerTissueRegion[] _twoLayerTissue =
                new LayerTissueRegion[]
            {
                new LayerTissueRegion(new DoubleRange(0, 3), new OpticalProperties(ops)),
                new LayerTissueRegion(new DoubleRange(3, 100), new OpticalProperties(ops)),
            };
            for (int i = 0; i < _rhos.Length; i++)
            {
                var oneLayerResult = _oneLayerForwardSolver.ROfRhoAndTime(ops, _rhos[i], _times[i]);
                var twoLayerResult = _twoLayerSDAForwardSolver.ROfRhoAndTime(_twoLayerTissue, _rhos[i], _times[i]);
                var relDiff        = Math.Abs(twoLayerResult - oneLayerResult) / oneLayerResult;
                Assert.IsTrue(relDiff < _thresholdValue, "Test failed for rho =" + _rhos[i] +
                              "mm, with relative difference " + relDiff);
            }
        }
예제 #5
0
 public LayerRegionViewModel(LayerTissueRegion region, string name)
 {
     _region            = region;
     _name              = name ?? "";
     _zRangeVM          = new RangeViewModel(_region.ZRange, StringLookup.GetLocalizedString("Measurement_mm"), IndependentVariableAxis.Z, "", false);
     _opticalPropertyVM = new OpticalPropertyViewModel(_region.RegionOP, StringLookup.GetLocalizedString("Measurement_Inv_mm"), "", true, true, true, true);
     _opticalPropertyVM.PropertyChanged += (s, a) => OnPropertyChanged("Name");
 }
예제 #6
0
 public LayerRegionViewModel(LayerTissueRegion region, string name)
 {
     _region            = region;
     _name              = name ?? "";
     _zRangeVM          = new RangeViewModel(_region.ZRange, "mm", IndependentVariableAxis.Z, "", false);
     _opticalPropertyVM = new OpticalPropertyViewModel(_region.RegionOP, "mm-1", "", true, true, true, true);
     _opticalPropertyVM.PropertyChanged += (s, a) => OnPropertyChanged("Name");
 }
예제 #7
0
        public void validate_serialization_of_LayerRegion()
        {
            var layer = new LayerTissueRegion(
                zRange: new DoubleRange(3, 4, 2),
                op: new OpticalProperties(mua: 0.011, musp: 1.1, g: 0.99, n: 1.44));

            var jsonSerialized = VtsMonteCarloJsonSerializer.WriteToJson(layer);

            Assert.IsTrue(jsonSerialized != null && jsonSerialized.Length > 0);
        }
예제 #8
0
        public void validate_serialization_of_MultiLayerTissueInput()
        {
            var layer0 = new LayerTissueRegion(
                zRange: new DoubleRange(2.0, 3.0, 2),
                op: new OpticalProperties(mua: 0.011, musp: 1.1, g: 0.99, n: 1.44));

            var layer1 = new LayerTissueRegion(
                zRange: new DoubleRange(3.0, 4.0, 2),
                op: new OpticalProperties(mua: 0.0111, musp: 1.11, g: 0.999, n: 1.444));

            var multiRegionInput = new MultiLayerTissueInput(new[] { layer0, layer1 });

            var jsonSerialized = VtsMonteCarloJsonSerializer.WriteToJson(multiRegionInput);

            Assert.IsTrue(jsonSerialized != null && jsonSerialized.Length > 0);
        }
예제 #9
0
        public void validate_deserialization_of_LayerRegion()
        {
            Func <double, double, bool> areRoughlyEqual = (a, b) => Math.Abs(a - b) < 0.001;

            var layer = new LayerTissueRegion(
                zRange: new DoubleRange(3.0, 4.0, 2),
                op: new OpticalProperties(mua: 0.011, musp: 1.1, g: 0.99, n: 1.44));

            var jsonSerialized    = VtsMonteCarloJsonSerializer.WriteToJson(layer);
            var layerDeserialized = VtsMonteCarloJsonSerializer.ReadFromJson <LayerTissueRegion>(jsonSerialized);

            Assert.IsTrue(layerDeserialized != null);
            Assert.IsTrue(areRoughlyEqual(layerDeserialized.ZRange.Start, 3.0));
            Assert.IsTrue(areRoughlyEqual(layerDeserialized.ZRange.Stop, 4.0));
            Assert.IsTrue(areRoughlyEqual(layerDeserialized.ZRange.Count, 2));
            Assert.IsTrue(areRoughlyEqual(layerDeserialized.RegionOP.Mua, 0.011));
            Assert.IsTrue(areRoughlyEqual(layerDeserialized.RegionOP.Musp, 1.1));
            Assert.IsTrue(areRoughlyEqual(layerDeserialized.RegionOP.G, 0.99));
            Assert.IsTrue(areRoughlyEqual(layerDeserialized.RegionOP.N, 1.44));
        }
예제 #10
0
        public void validate_deserialization_of_MultiLayerTissueInput()
        {
            Func <double, double, bool> areRoughlyEqual = (a, b) => Math.Abs(a - b) < 0.001;

            var layer0 = new LayerTissueRegion(
                zRange: new DoubleRange(2.0, 3.0, 2),
                op: new OpticalProperties(mua: 0.011, musp: 1.1, g: 0.99, n: 1.44));

            var layer1 = new LayerTissueRegion(
                zRange: new DoubleRange(3.0, 4.0, 2),
                op: new OpticalProperties(mua: 0.0111, musp: 1.11, g: 0.999, n: 1.444));

            var multiRegionInput = new MultiLayerTissueInput(new[] { layer0, layer1 });

            var jsonSerialized = VtsMonteCarloJsonSerializer.WriteToJson(multiRegionInput);
            var multiRegionInputDeserialized = VtsMonteCarloJsonSerializer.ReadFromJson <MultiLayerTissueInput>(jsonSerialized);

            Assert.IsTrue(multiRegionInputDeserialized != null);

            var region0Deserialized = (LayerTissueRegion)multiRegionInputDeserialized.Regions[0];

            Assert.IsTrue(areRoughlyEqual(region0Deserialized.ZRange.Start, 2.0));
            Assert.IsTrue(areRoughlyEqual(region0Deserialized.ZRange.Stop, 3.0));
            Assert.IsTrue(areRoughlyEqual(region0Deserialized.ZRange.Count, 2));
            Assert.IsTrue(areRoughlyEqual(region0Deserialized.RegionOP.Mua, 0.011));
            Assert.IsTrue(areRoughlyEqual(region0Deserialized.RegionOP.Musp, 1.1));
            Assert.IsTrue(areRoughlyEqual(region0Deserialized.RegionOP.G, 0.99));
            Assert.IsTrue(areRoughlyEqual(region0Deserialized.RegionOP.N, 1.44));

            var region1Deserialized = (LayerTissueRegion)multiRegionInputDeserialized.Regions[1];

            Assert.IsTrue(areRoughlyEqual(region1Deserialized.ZRange.Start, 3.0));
            Assert.IsTrue(areRoughlyEqual(region1Deserialized.ZRange.Stop, 4.0));
            Assert.IsTrue(areRoughlyEqual(region1Deserialized.ZRange.Count, 2));
            Assert.IsTrue(areRoughlyEqual(region1Deserialized.RegionOP.Mua, 0.0111));
            Assert.IsTrue(areRoughlyEqual(region1Deserialized.RegionOP.Musp, 1.11));
            Assert.IsTrue(areRoughlyEqual(region1Deserialized.RegionOP.G, 0.999));
            Assert.IsTrue(areRoughlyEqual(region1Deserialized.RegionOP.N, 1.444));
        }
        public void SteadyStateTwoLayerSDATest()
        {
            var _thresholdValue                   = 1e-8;
            var _twoLayerSDAForwardSolver         = new TwoLayerSDAForwardSolver();
            var _oneLayerPointSourceForwardSolver = new PointSourceSDAForwardSolver();

            // make sure layer thickess is greater than l*=1/(mua+musp)=1mm
            LayerTissueRegion[] _twoLayerTissue =
                new LayerTissueRegion[]
            {
                new LayerTissueRegion(new DoubleRange(0, 3), new OpticalProperties(ops)),
                new LayerTissueRegion(new DoubleRange(3, 100), new OpticalProperties(ops)),
            };
            for (int irho = 0; irho < rhos.Length; irho++)
            {
                var oneLayerResult = _oneLayerPointSourceForwardSolver.ROfRho(ops, rhos[irho]);
                var twoLayerResult = _twoLayerSDAForwardSolver.ROfRho(_twoLayerTissue, rhos[irho]);
                var relDiff        = Math.Abs(twoLayerResult - oneLayerResult) / oneLayerResult;
                Assert.IsTrue(relDiff < _thresholdValue, "Test failed for rho =" + rhos[irho] +
                              "mm, with relative difference " + relDiff);
            }
        }
        public void SpatialFrequencyTwoLayerSDATest()
        {
            var _thresholdValue = 0.03;

            double[] fxs = new double[] { 0.0, 0.02 };  // 0.3 results not good
            var      _twoLayerSDAForwardSolver   = new TwoLayerSDAForwardSolver();
            var      _oneLayerNurbsForwardSolver = new NurbsForwardSolver();

            // make sure layer thickess is greater than l*=1/(mua+musp)=1mm
            LayerTissueRegion[] _twoLayerTissue =
                new LayerTissueRegion[]
            {
                new LayerTissueRegion(new DoubleRange(0, 3), new OpticalProperties(ops)),
                new LayerTissueRegion(new DoubleRange(3, 100), new OpticalProperties(ops)),
            };
            for (int ifx = 0; ifx < fxs.Length; ifx++)
            {
                var oneLayerResult = _oneLayerNurbsForwardSolver.ROfFx(ops, fxs[ifx]);
                var twoLayerResult = _twoLayerSDAForwardSolver.ROfFx(_twoLayerTissue, fxs[ifx]);
                var relDiff        = Math.Abs(twoLayerResult - oneLayerResult) / oneLayerResult;
                Assert.IsTrue(relDiff < _thresholdValue, "Test failed for fx =" + fxs[ifx] +
                              ", with relative difference " + relDiff);
            }
        }
예제 #13
0
 public void create_instance_of_class()
 {
     _layerTissueRegion = new LayerTissueRegion(
         new DoubleRange(0, 10), new OpticalProperties(0.01, 1.0, 0.8, 1.4));
 }