private IEnumerable <double> ROfRho(ForwardSolverType fst, OpticalProperties op, DoubleRange rho)
        {
            var ops  = op.AsEnumerable();
            var rhos = rho.AsEnumerable();
            var fs   = Factories.SolverFactory.GetForwardSolver(fst);

            return(fs.ROfRho(ops, rhos));
        }
        private IEnumerable <Complex> ROfFxAndFt(ForwardSolverType fst, OpticalProperties op, double fx, DoubleRange ft)
        {
            var ops = op.AsEnumerable();
            var fxs = fx.AsEnumerable();
            var fts = ft.AsEnumerable();
            var fs  = Factories.SolverFactory.GetForwardSolver(fst);

            return(fs.ROfFxAndFt(ops, fxs, fts));
        }
        private IEnumerable <double> ROfFxAndTime(ForwardSolverType fst, OpticalProperties op, double fx, DoubleRange time)
        {
            var ops   = op.AsEnumerable();
            var fxs   = fx.AsEnumerable();
            var times = time.AsEnumerable();
            var fs    = Factories.SolverFactory.GetForwardSolver(fst);

            return(fs.ROfFxAndTime(ops, fxs, times));
        }
Exemplo n.º 4
0
        public void validate_multi_count_returns_multiple_values_for_matched_start_stop()
        {
            var r = new DoubleRange(10D, 10D, 3);

            var values = r.AsEnumerable().ToArray();

            Assert.AreEqual(values.Length, 3);
            for (int i = 0; i < values.Length; i++)
            {
                Assert.AreEqual(values[i], 10D);
            }
        }
        private IEnumerable <double> ROfRho(ForwardSolverType forwardSolverType, OpticalProperties opticalProperties, DoubleRange rho, double noise)
        {
            var ops  = opticalProperties.AsEnumerable();
            var rhos = rho.AsEnumerable();
            var fs   = SolverFactory.GetForwardSolver(forwardSolverType);

            if (noise > 0.0)
            {
                return(fs.ROfRho(ops, rhos).AddNoise(noise));
            }
            return(fs.ROfRho(ops, rhos));
        }
        private IEnumerable <double> ROfFxAndTime(ForwardSolverType forwardSolverType, OpticalProperties opticalProperties, double fx, DoubleRange time, double noise)
        {
            var ops   = opticalProperties.AsEnumerable();
            var fxs   = fx.AsEnumerable();
            var times = time.AsEnumerable();
            var fs    = SolverFactory.GetForwardSolver(forwardSolverType);

            if (noise > 0.0)
            {
                return(fs.ROfFxAndTime(ops, fxs, times).AddNoise(noise));
            }
            return(fs.ROfFxAndTime(ops, fxs, times));
        }
 private IEnumerable <double> ROfFx(ForwardSolverType fst, OpticalProperties op, DoubleRange fx)
 {
     try
     {
         var ops  = op.AsEnumerable();
         var rhos = fx.AsEnumerable();
         var fs   = Factories.SolverFactory.GetForwardSolver(fst);
         return(fs.ROfFx(ops, rhos));
     }
     catch (Exception e)
     {
         throw new Exception("Error in call to ROfFx: " + e.Message + "values fst: " + fst + ", op: " + op + ", rho:" + fx + " source: " + e.Source + " inner: " + e.InnerException);
     }
 }
Exemplo n.º 8
0
        public void Test_get_plot_data_powerlaw()
        {
            var postData               = "{\"spectralPlotType\":\"musp\",\"plotName\":\"μs'\",\"tissueType\":\"Skin\",\"absorberConcentration\":[{\"label\":\"Hb\",\"value\":28.4,\"units\":\"μM\"},{\"label\":\"HbO2\",\"value\":22.4,\"units\":\"μM\"},{\"label\":\"H2O\",\"value\":0.7,\"units\":\"vol. frac.\"},{\"label\":\"Fat\",\"value\":0,\"units\":\"vol. frac.\"},{\"label\":\"Melanin\",\"value\":0.0051,\"units\":\"vol. frac.\"}],\"bloodConcentration\":{\"totalHb\":50.8,\"bloodVolume\":0.021844,\"stO2\":0.4409448818897638},\"scatteringType\":\"PowerLaw\",\"powerLawScatterer\":{\"a\":1.2,\"b\":1.42},\"intralipidScatterer\":{\"volumeFraction\":0.01},\"mieScatterer\":{\"particleRadius\":0.5,\"ParticleRefractiveIndexMismatch\":1.4,\"MediumRefractiveIndexMismatch\":1,\"volumeFraction\":0.01},\"xAxis\":{\"start\":650,\"stop\":1000,\"count\":36}}";
            var xAxis                  = new DoubleRange(650, 1000, 36);
            var wavelengths            = xAxis.AsEnumerable().ToArray();
            var spectralPlotParameters = JsonConvert.DeserializeObject <SpectralPlotParameters>(postData);

            _plotFactoryMock.Setup(x => x.GetPlot(PlotType.Spectral, spectralPlotParameters)).Returns("");
            var results = _spectralService.GetPlotData(spectralPlotParameters);

            Assert.AreEqual("", results);
            _plotFactoryMock.Verify(mock => mock.GetPlot(PlotType.Spectral, spectralPlotParameters), Times.Once);
            Assert.AreEqual(wavelengths[4], spectralPlotParameters.Wavelengths[4]);
            Assert.AreEqual(TissueType.Skin, spectralPlotParameters.Tissue.TissueType);
        }
        private IEnumerable <Complex> ROfFxAndFt(ForwardSolverType forwardSolverType, OpticalProperties opticalProperties, double fx, DoubleRange ft, double noise)
        {
            var ops     = opticalProperties.AsEnumerable().ToArray();
            var fxs     = fx.AsEnumerable().ToArray();
            var fts     = ft.AsEnumerable().ToArray();
            var fs      = SolverFactory.GetForwardSolver(forwardSolverType);
            var results = fs.ROfRhoAndFt(ops, fxs, fts).ToArray();

            if (noise > 0.0)
            {
                var realsWithNoise = results.Select(r => r.Real).AddNoise(noise);
                var imagsWithNoise = results.Select(i => i.Imaginary).AddNoise(noise);
                IEnumerable <Complex> resultsWithNoise = realsWithNoise.Zip(imagsWithNoise, (a, b) => new Complex(a, b));
                return(resultsWithNoise);
            }
            return(fs.ROfFxAndFt(ops, fxs, fts));
        }
 private IEnumerable <double> ROfFx(ForwardSolverType forwardSolverType, OpticalProperties opticalProperties, DoubleRange fx, double noise)
 {
     try
     {
         var ops = opticalProperties.AsEnumerable();
         var fxs = fx.AsEnumerable();
         var fs  = SolverFactory.GetForwardSolver(forwardSolverType);
         if (noise > 0.0)
         {
             return(fs.ROfFx(ops, fxs).AddNoise(noise));
         }
         return(fs.ROfFx(ops, fxs));
     }
     catch (Exception e)
     {
         _logger.LogError("Error in call to ROfFx: " + e.Message + "values fst: " + forwardSolverType + ", op: " + opticalProperties + ", rho:" + fx + " source: " + e.Source + " inner: " + e.InnerException);
         throw;
     }
 }
        public void Test_plot_musp()
        {
            _plotSpectralResultsService = new PlotSpectralResultsService(_logger);
            var postData = "{\"spectralPlotType\":\"musp\",\"plotName\":\"μs'\",\"tissueType\":\"Skin\",\"absorberConcentration\":[{\"label\":\"Hb\",\"value\":28.4,\"units\":\"μM\"},{\"label\":\"HbO2\",\"value\":22.4,\"units\":\"μM\"},{\"label\":\"H2O\",\"value\":0.7,\"units\":\"vol. frac.\"},{\"label\":\"Fat\",\"value\":0,\"units\":\"vol. frac.\"},{\"label\":\"Melanin\",\"value\":0.0051,\"units\":\"vol. frac.\"}],\"bloodConcentration\":{\"totalHb\":50.8,\"bloodVolume\":0.021844,\"stO2\":0.4409448818897638},\"scatteringType\":\"PowerLaw\",\"powerLawScatterer\":{\"a\":1.2,\"b\":1.42},\"intralipidScatterer\":{\"volumeFraction\":0.01},\"mieScatterer\":{\"particleRadius\":0.5,\"ParticleRefractiveIndexMismatch\":1.4,\"MediumRefractiveIndexMismatch\":1,\"volumeFraction\":0.01},\"xAxis\":{\"start\":650,\"stop\":1000,\"count\":36}}";
            var spectralPlotParameters = JsonConvert.DeserializeObject <SpectralPlotParameters>(postData);
            var xAxis = new DoubleRange(650, 1000, 36);

            spectralPlotParameters.YAxis       = spectralPlotParameters.PlotName;
            spectralPlotParameters.Wavelengths = xAxis.AsEnumerable().ToArray();
            var chromophoreAbsorbers = new List <IChromophoreAbsorber>();

            foreach (var absorber in spectralPlotParameters.AbsorberConcentration)
            {
                chromophoreAbsorbers.Add(new ChromophoreAbsorber(Enum.Parse <ChromophoreType>(absorber.Label, true), absorber.Value));
            }
            var scatterer = new PowerLawScatterer(1.2, 1.42);

            spectralPlotParameters.Tissue = new Tissue(chromophoreAbsorbers, scatterer, spectralPlotParameters.TissueType);
            var data        = _plotSpectralResultsService.Plot(spectralPlotParameters);
            var muspResults = "{\"Id\":\"SpectralMusp\",\"PlotList\":[{\"Label\":\"Skin μs'\",\"Data\":[[650.0,2.2123013258570863],[660.0,2.1648552221223785],[670.0,2.1191174426328576],[680.0,2.0750023361697605],[690.0,2.0324297212859692],[700.0,1.9913244640761809],[710.0,1.9516160940115432],[720.0,1.9132384539276279],[730.0,1.8761293807044339],[740.0,1.8402304135697998],[750.0,1.8054865273011322],[760.0,1.771845887901413],[770.0,1.7392596285897868],[780.0,1.7076816441795259],[790.0,1.6770684021210169],[800.0,1.6473787686682118],[810.0,1.618573848786806],[820.0,1.5906168385639152],[830.0,1.5634728890045213],[840.0,1.5371089802114051],[850.0,1.5114938050444233],[860.0,1.486597661443283],[870.0,1.4623923526767395],[880.0,1.438851094851493],[890.0,1.415948431076983],[900.0,1.3936601517386393],[910.0,1.3719632203826795],[920.0,1.3508357047609152],[930.0,1.330256712624823],[940.0,1.3102063318948318],[950.0,1.290665574863872],[960.0,1.2716163261240603],[970.0,1.2530412939323394],[980.0,1.2349239647552681],[990.0,1.2172485607551906],[1000.0,1.2]]}]}";

            Assert.AreEqual(muspResults, data);
        }
        public void Test_plot_mua()
        {
            _plotSpectralResultsService = new PlotSpectralResultsService(_logger);
            var postData = "{\"spectralPlotType\":\"mua\",\"plotName\":\"μa\",\"tissueType\":\"Skin\",\"absorberConcentration\":[{\"label\":\"Hb\",\"value\":28.4,\"units\":\"μM\"},{\"label\":\"HbO2\",\"value\":22.4,\"units\":\"μM\"},{\"label\":\"H2O\",\"value\":0.7,\"units\":\"vol. frac.\"},{\"label\":\"Fat\",\"value\":0,\"units\":\"vol. frac.\"},{\"label\":\"Melanin\",\"value\":0.0051,\"units\":\"vol. frac.\"}],\"bloodConcentration\":{\"totalHb\":50.8,\"bloodVolume\":0.021844,\"stO2\":0.4409448818897638},\"scatteringType\":\"PowerLaw\",\"powerLawScatterer\":{\"a\":1.2,\"b\":1.42},\"intralipidScatterer\":{\"volumeFraction\":0.01},\"mieScatterer\":{\"particleRadius\":0.5,\"ParticleRefractiveIndexMismatch\":1.4,\"MediumRefractiveIndexMismatch\":1,\"volumeFraction\":0.01},\"xAxis\":{\"start\":650,\"stop\":1000,\"count\":36}}";
            var spectralPlotParameters = JsonConvert.DeserializeObject <SpectralPlotParameters>(postData);
            var xAxis = new DoubleRange(650, 1000, 36);

            spectralPlotParameters.YAxis       = spectralPlotParameters.PlotName;
            spectralPlotParameters.Wavelengths = xAxis.AsEnumerable().ToArray();
            var chromophoreAbsorbers = new List <IChromophoreAbsorber>();

            foreach (var absorber in spectralPlotParameters.AbsorberConcentration)
            {
                chromophoreAbsorbers.Add(new ChromophoreAbsorber(Enum.Parse <ChromophoreType>(absorber.Label, true), absorber.Value));
            }
            var scatterer = new PowerLawScatterer(1.2, 1.42);

            spectralPlotParameters.Tissue = new Tissue(chromophoreAbsorbers, scatterer, spectralPlotParameters.TissueType);
            var data       = _plotSpectralResultsService.Plot(spectralPlotParameters);
            var muaResults = "{\"Id\":\"SpectralMua\",\"PlotList\":[{\"Label\":\"Skin μa\",\"Data\":[[650.0,0.16765660516524314],[660.0,0.15671650246614327],[670.0,0.14697135542801],[680.0,0.13799908824769305],[690.0,0.12973522277796562],[700.0,0.12260932419347584],[710.0,0.11583351729772583],[720.0,0.11010170400729173],[730.0,0.10472095509441402],[740.0,0.10129111493244414],[750.0,0.099521779546167088],[760.0,0.096959293661164639],[770.0,0.092068432646702891],[780.0,0.087311046148140767],[790.0,0.082850035254262877],[800.0,0.079106164468758858],[810.0,0.076218507603072],[820.0,0.07371667586209707],[830.0,0.0719944590933807],[840.0,0.070298642060247829],[850.0,0.0683344235938162],[860.0,0.066498798013490928],[870.0,0.06488501473536043],[880.0,0.063512933452956943],[890.0,0.062254209691212314],[900.0,0.061061385509031681],[910.0,0.060018918288031978],[920.0,0.059569360145074537],[930.0,0.060352136653759242],[940.0,0.062968288552839938],[950.0,0.06862831638709066],[960.0,0.07645596009583773],[970.0,0.077403147687485074],[980.0,0.075685057055814575],[990.0,0.071645012147578471],[1000.0,0.066587976157675921]]}]}";

            Assert.AreEqual(muaResults, data);
        }
        public void ProcessRequest(HttpContext context)
        {
            String action;
            String jsonString;

            try
            {
                action = context.Request["action"];
                context.Response.ContentType         = "text/json";
                context.Request.InputStream.Position = 0;
                using (var inputStream = new StreamReader(context.Request.InputStream))
                {
                    jsonString = inputStream.ReadToEnd();
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error before action: " + e.Message);
            }
            var serializer = new JavaScriptSerializer();

            switch (action)
            {
            case "getdata":
                try
                {
                    dynamic vtsSettings = serializer.DeserializeObject(jsonString);
                    var     sd          = vtsSettings["solutionDomain"];
                    var     fs          = vtsSettings["forwardSolverEngine"];
                    var     msg         = "";
                    var     op          = new OpticalProperties(double.Parse(vtsSettings["opticalProperties"]["mua"]), double.Parse(vtsSettings["opticalProperties"]["mus"]), double.Parse(vtsSettings["opticalProperties"]["g"]), double.Parse(vtsSettings["opticalProperties"]["n"]));
                    if (sd == "rofrho")
                    {
                        var rho = new DoubleRange(double.Parse(vtsSettings["range"]["startValue"]), double.Parse(vtsSettings["range"]["endValue"]), int.Parse(vtsSettings["range"]["numberValue"]));
                        IEnumerable <double> results = null;
                        results = ROfRho(Enum.Parse(typeof(ForwardSolverType), fs), op, rho);
                        var independentValues = rho.AsEnumerable().ToArray();
                        var rhos = independentValues.Skip(1).Zip(independentValues.Take(independentValues.Length - 1), (first, second) => (first + second) / 2).ToArray();

                        var rOfRhoPoints = rhos.Zip(results, (x, y) => new Point(x, y));
                        var rOfRhoPlot   = new PlotData {
                            Data = rOfRhoPoints, Label = "ROfRho"
                        };
                        var rhoPlot = new Plots {
                            id = "ROfRho", detector = "R(ρ)", legend = "R(ρ)", xaxis = "ρ", yaxis = "Reflectance", plotlist = new List <PlotDataJson>()
                        };
                        rhoPlot.plotlist.Add(new PlotDataJson {
                            data = rOfRhoPlot.Data.Select(item => new List <double> {
                                item.X, item.Y
                            }).ToList(), label = fs + " μa=" + op.Mua + " μs'=" + op.Musp
                        });
                        msg = serializer.Serialize(rhoPlot);
                    }
                    else if (sd == "rofrhoandt")
                    {
                        IEnumerable <double> results = null;
                        var independentAxis          = vtsSettings["independentAxes"]["label"];
                        if (independentAxis == "t")
                        {
                            var rho  = new DoubleRange(double.Parse(vtsSettings["range"]["startValue"]), double.Parse(vtsSettings["range"]["endValue"]), int.Parse(vtsSettings["range"]["numberValue"]));
                            var time = double.Parse(vtsSettings["independentAxes"]["value"]);
                            results = ROfRhoAndTime(Enum.Parse(typeof(ForwardSolverType), fs), op, rho, time);
                            var independentValues = rho.AsEnumerable().ToArray();
                            var rhos         = independentValues.Skip(1).Zip(independentValues.Take(independentValues.Length - 1), (first, second) => (first + second) / 2).ToArray();
                            var rOfRhoPoints = rhos.Zip(results, (x, y) => new Point(x, y));
                            var rOfRhoPlot   = new PlotData {
                                Data = rOfRhoPoints, Label = "ROfRhoAndTime"
                            };
                            var rhoPlot = new Plots {
                                id = "ROfRhoAndTimeFixedTime", detector = "R(ρ,time)", legend = "R(ρ,time)", xaxis = "ρ", yaxis = "Reflectance", plotlist = new List <PlotDataJson>()
                            };
                            rhoPlot.plotlist.Add(new PlotDataJson {
                                data = rOfRhoPlot.Data.Select(item => new List <double> {
                                    item.X, item.Y
                                }).ToList(), label = fs + " μa=" + op.Mua + " μs'=" + op.Musp + " t=" + time
                            });
                            msg = serializer.Serialize(rhoPlot);
                        }
                        else
                        {
                            var time = new DoubleRange(double.Parse(vtsSettings["range"]["startValue"]), double.Parse(vtsSettings["range"]["endValue"]), int.Parse(vtsSettings["range"]["numberValue"]));
                            var rho  = double.Parse(vtsSettings["independentAxes"]["value"]);
                            results = ROfRhoAndTime(Enum.Parse(typeof(ForwardSolverType), fs), op, rho, time);
                            var independentValues = time.AsEnumerable().ToArray();
                            var times             = independentValues.Skip(1).Zip(independentValues.Take(independentValues.Length - 1), (first, second) => (first + second) / 2).ToArray();
                            var dataPoints        = times.Zip(results, (x, y) => new Point(x, y));
                            var dataPlot          = new PlotData {
                                Data = dataPoints, Label = "ROfRhoAndTime"
                            };
                            var rhoPlot = new Plots {
                                id = "ROfRhoAndTimeFixedRho", detector = "R(ρ,time)", legend = "R(ρ,time)", xaxis = "Time", yaxis = "Reflectance", plotlist = new List <PlotDataJson>()
                            };
                            rhoPlot.plotlist.Add(new PlotDataJson {
                                data = dataPlot.Data.Select(item => new List <double> {
                                    item.X, item.Y
                                }).ToList(), label = fs + " μa=" + op.Mua + " μs'=" + op.Musp + " ρ=" + rho
                            });
                            msg = serializer.Serialize(rhoPlot);
                        }
                    }
                    else if (sd == "rofrhoandft")
                    {
                        IEnumerable <Complex> results;
                        var independentAxis = vtsSettings["independentAxes"]["label"];
                        if (independentAxis == "ft")
                        {
                            var rho = new DoubleRange(double.Parse(vtsSettings["range"]["startValue"]), double.Parse(vtsSettings["range"]["endValue"]), int.Parse(vtsSettings["range"]["numberValue"]));
                            var ft  = double.Parse(vtsSettings["independentAxes"]["value"]);
                            results = ROfRhoAndFt(Enum.Parse(typeof(ForwardSolverType), fs), op, rho, ft);
                            var independentValues = rho.AsEnumerable().ToArray();
                            var rhos       = independentValues.Skip(1).Zip(independentValues.Take(independentValues.Length - 1), (first, second) => (first + second) / 2).ToArray();
                            var realPoints = rhos.Zip(results, (x, y) => new Point(x, y.Real));
                            var imagPoints = rhos.Zip(results, (x, y) => new Point(x, y.Imaginary));
                            var realPlot   = new PlotData {
                                Data = realPoints, Label = "ROfRhoAndFt"
                            };
                            var imagPlot = new PlotData {
                                Data = imagPoints, Label = "ROfRhoAndFt"
                            };
                            var rhoPlot = new Plots {
                                id = "ROfRhoAndFtFixedFt", detector = "R(ρ,ft)", legend = "R(ρ,ft)", xaxis = "ρ", yaxis = "Reflectance", plotlist = new List <PlotDataJson>()
                            };
                            rhoPlot.plotlist.Add(new PlotDataJson {
                                data = realPlot.Data.Select(item => new List <double> {
                                    item.X, item.Y
                                }).ToList(), label = fs + " μa=" + op.Mua + " μs'=" + op.Musp + " t=" + ft + "(real)"
                            });
                            rhoPlot.plotlist.Add(new PlotDataJson {
                                data = imagPlot.Data.Select(item => new List <double> {
                                    item.X, item.Y
                                }).ToList(), label = fs + " μa=" + op.Mua + " μs'=" + op.Musp + " t=" + ft + "(imag)"
                            });
                            msg = serializer.Serialize(rhoPlot);
                        }
                        else
                        {
                            var ft  = new DoubleRange(double.Parse(vtsSettings["range"]["startValue"]), double.Parse(vtsSettings["range"]["endValue"]), int.Parse(vtsSettings["range"]["numberValue"]));
                            var rho = double.Parse(vtsSettings["independentAxes"]["value"]);
                            results = ROfRhoAndFt(Enum.Parse(typeof(ForwardSolverType), fs), op, rho, ft);
                            var independentValues = ft.AsEnumerable().ToArray();
                            var times             = independentValues.Skip(1).Zip(independentValues.Take(independentValues.Length - 1), (first, second) => (first + second) / 2).ToArray();
                            var realPoints        = times.Zip(results, (x, y) => new Point(x, y.Real));
                            var imagPoints        = times.Zip(results, (x, y) => new Point(x, y.Imaginary));
                            var realPlot          = new PlotData {
                                Data = realPoints, Label = "ROfRhoAndFt"
                            };
                            var imagPlot = new PlotData {
                                Data = imagPoints, Label = "ROfRhoAndFt"
                            };
                            var rhoPlot = new Plots {
                                id = "ROfRhoAndFtFixedRho", detector = "R(ρ,ft)", legend = "R(ρ,ft)", xaxis = "Time", yaxis = "Reflectance", plotlist = new List <PlotDataJson>()
                            };
                            rhoPlot.plotlist.Add(new PlotDataJson {
                                data = realPlot.Data.Select(item => new List <double> {
                                    item.X, item.Y
                                }).ToList(), label = fs + " μa=" + op.Mua + " μs'=" + op.Musp + " ρ=" + rho + "(real)"
                            });
                            rhoPlot.plotlist.Add(new PlotDataJson {
                                data = imagPlot.Data.Select(item => new List <double> {
                                    item.X, item.Y
                                }).ToList(), label = fs + " μa=" + op.Mua + " μs'=" + op.Musp + " ρ=" + rho + "(imag)"
                            });
                            msg = serializer.Serialize(rhoPlot);
                        }
                    }
                    else if (sd == "roffx")
                    {
                        var fx = new DoubleRange(double.Parse(vtsSettings["range"]["startValue"]), double.Parse(vtsSettings["range"]["endValue"]), int.Parse(vtsSettings["range"]["numberValue"]));
                        IEnumerable <double> results = null;
                        results = ROfFx(Enum.Parse(typeof(ForwardSolverType), fs), op, fx);
                        var independentValues = fx.AsEnumerable().ToArray();
                        var fxs = independentValues.Skip(1).Zip(independentValues.Take(independentValues.Length - 1), (first, second) => (first + second) / 2).ToArray();

                        var rOfFxPoints = fxs.Zip(results, (x, y) => new Point(x, y));
                        var rOfFxPlot   = new PlotData {
                            Data = rOfFxPoints, Label = "ROfFx"
                        };
                        var fxPlot = new Plots {
                            id = "ROfFx", detector = "R(fx)", legend = "R(fx)", xaxis = "fx", yaxis = "Reflectance", plotlist = new List <PlotDataJson>()
                        };
                        fxPlot.plotlist.Add(new PlotDataJson {
                            data = rOfFxPlot.Data.Select(item => new List <double> {
                                item.X, item.Y
                            }).ToList(), label = fs + " μa=" + op.Mua + " μs'=" + op.Musp
                        });
                        msg = serializer.Serialize(fxPlot);
                    }
                    else if (sd == "roffxandt")
                    {
                        IEnumerable <double> results = null;
                        var independentAxis          = vtsSettings["independentAxes"]["label"];
                        if (independentAxis == "t")
                        {
                            var fx   = new DoubleRange(double.Parse(vtsSettings["range"]["startValue"]), double.Parse(vtsSettings["range"]["endValue"]), int.Parse(vtsSettings["range"]["numberValue"]));
                            var time = double.Parse(vtsSettings["independentAxes"]["value"]);
                            results = ROfFxAndTime(Enum.Parse(typeof(ForwardSolverType), fs), op, fx, time);
                            var independentValues = fx.AsEnumerable().ToArray();
                            var fxs         = independentValues.Skip(1).Zip(independentValues.Take(independentValues.Length - 1), (first, second) => (first + second) / 2).ToArray();
                            var rOfFxPoints = fxs.Zip(results, (x, y) => new Point(x, y));
                            var rOfFxPlot   = new PlotData {
                                Data = rOfFxPoints, Label = "ROfFxAndTime"
                            };
                            var fxPlot = new Plots {
                                id = "ROfFxAndTimeFixedTime", detector = "R(fx,time)", legend = "R(fx,time)", xaxis = "fx", yaxis = "Reflectance", plotlist = new List <PlotDataJson>()
                            };
                            fxPlot.plotlist.Add(new PlotDataJson {
                                data = rOfFxPlot.Data.Select(item => new List <double> {
                                    item.X, item.Y
                                }).ToList(), label = fs + " μa=" + op.Mua + " μs'=" + op.Musp + " t=" + time
                            });
                            msg = serializer.Serialize(fxPlot);
                        }
                        else
                        {
                            var time = new DoubleRange(double.Parse(vtsSettings["range"]["startValue"]), double.Parse(vtsSettings["range"]["endValue"]), int.Parse(vtsSettings["range"]["numberValue"]));
                            var fx   = double.Parse(vtsSettings["independentAxes"]["value"]);
                            results = ROfFxAndTime(Enum.Parse(typeof(ForwardSolverType), fs), op, fx, time);
                            var independentValues = time.AsEnumerable().ToArray();
                            var times             = independentValues.Skip(1).Zip(independentValues.Take(independentValues.Length - 1), (first, second) => (first + second) / 2).ToArray();
                            var dataPoints        = times.Zip(results, (x, y) => new Point(x, y));
                            var dataPlot          = new PlotData {
                                Data = dataPoints, Label = "ROfFxAndTime"
                            };
                            var fxPlot = new Plots {
                                id = "ROfFxAndTimeFixedFx", detector = "R(fx,time)", legend = "R(fx,time)", xaxis = "Time", yaxis = "Reflectance", plotlist = new List <PlotDataJson>()
                            };
                            fxPlot.plotlist.Add(new PlotDataJson {
                                data = dataPlot.Data.Select(item => new List <double> {
                                    item.X, item.Y
                                }).ToList(), label = fs + " μa=" + op.Mua + " μs'=" + op.Musp + " ρ=" + fx
                            });
                            msg = serializer.Serialize(fxPlot);
                        }
                    }
                    else if (sd == "roffxandft")
                    {
                        IEnumerable <Complex> results;
                        var independentAxis = vtsSettings["independentAxes"]["label"];
                        if (independentAxis == "ft")
                        {
                            var fx = new DoubleRange(double.Parse(vtsSettings["range"]["startValue"]), double.Parse(vtsSettings["range"]["endValue"]), int.Parse(vtsSettings["range"]["numberValue"]));
                            var ft = double.Parse(vtsSettings["independentAxes"]["value"]);
                            results = ROfFxAndFt(Enum.Parse(typeof(ForwardSolverType), fs), op, fx, ft);
                            var independentValues = fx.AsEnumerable().ToArray();
                            var fxs        = independentValues.Skip(1).Zip(independentValues.Take(independentValues.Length - 1), (first, second) => (first + second) / 2).ToArray();
                            var realPoints = fxs.Zip(results, (x, y) => new Point(x, y.Real));
                            var imagPoints = fxs.Zip(results, (x, y) => new Point(x, y.Imaginary));
                            var realPlot   = new PlotData {
                                Data = realPoints, Label = "ROfFxAndFt"
                            };
                            var imagPlot = new PlotData {
                                Data = imagPoints, Label = "ROfFxAndFt"
                            };
                            var fxPlot = new Plots {
                                id = "ROfFxAndFtFixedFt", detector = "R(fx,ft)", legend = "R(fx,ft)", xaxis = "fx", yaxis = "Reflectance", plotlist = new List <PlotDataJson>()
                            };
                            fxPlot.plotlist.Add(new PlotDataJson {
                                data = realPlot.Data.Select(item => new List <double> {
                                    item.X, item.Y
                                }).ToList(), label = fs + " μa=" + op.Mua + " μs'=" + op.Musp + " t=" + ft + "(real)"
                            });
                            fxPlot.plotlist.Add(new PlotDataJson {
                                data = imagPlot.Data.Select(item => new List <double> {
                                    item.X, item.Y
                                }).ToList(), label = fs + " μa=" + op.Mua + " μs'=" + op.Musp + " t=" + ft + "(imag)"
                            });
                            msg = serializer.Serialize(fxPlot);
                        }
                        else
                        {
                            var ft = new DoubleRange(double.Parse(vtsSettings["range"]["startValue"]), double.Parse(vtsSettings["range"]["endValue"]), int.Parse(vtsSettings["range"]["numberValue"]));
                            var fx = double.Parse(vtsSettings["independentAxes"]["value"]);
                            results = ROfFxAndFt(Enum.Parse(typeof(ForwardSolverType), fs), op, fx, ft);
                            var independentValues = ft.AsEnumerable().ToArray();
                            var times             = independentValues.Skip(1).Zip(independentValues.Take(independentValues.Length - 1), (first, second) => (first + second) / 2).ToArray();
                            var realPoints        = times.Zip(results, (x, y) => new Point(x, y.Real));
                            var imagPoints        = times.Zip(results, (x, y) => new Point(x, y.Imaginary));
                            var realPlot          = new PlotData {
                                Data = realPoints, Label = "ROfFxAndFt"
                            };
                            var imagPlot = new PlotData {
                                Data = imagPoints, Label = "ROfFxAndFt"
                            };
                            var fxPlot = new Plots {
                                id = "ROfFxAndFtFixedFx", detector = "R(fx,ft)", legend = "R(fx,ft)", xaxis = "Time", yaxis = "Reflectance", plotlist = new List <PlotDataJson>()
                            };
                            fxPlot.plotlist.Add(new PlotDataJson {
                                data = realPlot.Data.Select(item => new List <double> {
                                    item.X, item.Y
                                }).ToList(), label = fs + " μa=" + op.Mua + " μs'=" + op.Musp + " fx=" + fx + "(real)"
                            });
                            fxPlot.plotlist.Add(new PlotDataJson {
                                data = imagPlot.Data.Select(item => new List <double> {
                                    item.X, item.Y
                                }).ToList(), label = fs + " μa=" + op.Mua + " μs'=" + op.Musp + " fx=" + fx + "(imag)"
                            });
                            msg = serializer.Serialize(fxPlot);
                        }
                    }
                    context.Response.Write(msg);
                }
                catch (Exception e)
                {
                    throw new Exception("Error during action: " + e.Message);
                }
                break;

            case "getfile":
                string dataLocation = "Modeling/Resources/HankelData/";
                var    hankelPoints = (double[])FileIO.ReadArrayFromBinaryInResources <double>
                                          (dataLocation + @"basepoints.dat", "Vts", 801);
                context.Response.Write(serializer.Serialize(hankelPoints));
                break;

            default:
                break;
            }
        }