Пример #1
0
        public void verify_default_constructor_sets_properties_correctly()
        {
            ITissueInput tissueInput;

            // verify MultiLayerTissueInput
            tissueInput = new MultiLayerTissueInput();
            var viewModel = new MultiRegionTissueViewModel(tissueInput);

            Assert.IsTrue(viewModel.RegionsVM != null);
            var listOfTissueRegions = viewModel.RegionsVM;

            Assert.IsTrue(((LayerRegionViewModel)listOfTissueRegions[1]).IsLayer);
            // verify SingleEllipsoidTissueInput
            tissueInput = new SingleEllipsoidTissueInput();
            viewModel   = new MultiRegionTissueViewModel(tissueInput);
            Assert.IsTrue(viewModel.RegionsVM != null);
            listOfTissueRegions = viewModel.RegionsVM;
            Assert.IsTrue(((EllipsoidRegionViewModel)listOfTissueRegions[3]).IsEllipsoid);
            // verify SingleVoxelTissueInput
            tissueInput = new SingleVoxelTissueInput();
            viewModel   = new MultiRegionTissueViewModel(tissueInput);
            Assert.IsTrue(viewModel.RegionsVM != null);
            listOfTissueRegions = viewModel.RegionsVM;
            Assert.IsTrue(((VoxelRegionViewModel)listOfTissueRegions[3]).IsVoxel);
        }
Пример #2
0
        private object GetTissueInputVM(string tissueType)
        {
            // ops to use as the basis for instantiating multi-region tissues based on homogeneous values (for differential comparison)
            if (_currentHomogeneousOpticalProperties == null)
            {
                _currentHomogeneousOpticalProperties = new OpticalProperties(0.01, 1, 0.8, 1.4);
            }

            switch (tissueType)
            {
            case "SemiInfinite":
                if (_currentSemiInfiniteTissueInput == null)
                {
                    _currentSemiInfiniteTissueInput =
                        new SemiInfiniteTissueInput(
                            new SemiInfiniteTissueRegion(_currentHomogeneousOpticalProperties));
                }
                return(new OpticalPropertyViewModel(
                           _currentSemiInfiniteTissueInput.Regions.First().RegionOP,
                           IndependentVariableAxisUnits.InverseMM.GetInternationalizedString(),
                           StringLookup.GetLocalizedString("Heading_OpticalProperties")));

            case "MultiLayer":
                if (_currentMultiLayerTissueInput == null)
                {
                    _currentMultiLayerTissueInput = new MultiLayerTissueInput(new ITissueRegion[]
                    {
                        new LayerTissueRegion(new DoubleRange(0, 2), _currentHomogeneousOpticalProperties.Clone()),
                        new LayerTissueRegion(new DoubleRange(2, double.PositiveInfinity),
                                              _currentHomogeneousOpticalProperties.Clone())
                    });
                }
                return(new MultiRegionTissueViewModel(_currentMultiLayerTissueInput));

            case "SingleEllipsoid":
                if (_currentSingleEllipsoidTissueInput == null)
                {
                    _currentSingleEllipsoidTissueInput = new SingleEllipsoidTissueInput(
                        new EllipsoidTissueRegion(new Position(0, 0, 10), 5, 5, 5,
                                                  new OpticalProperties(0.05, 1.0, 0.8, 1.4)),
                        new ITissueRegion[]
                    {
                        new LayerTissueRegion(new DoubleRange(0, double.PositiveInfinity),
                                              _currentHomogeneousOpticalProperties.Clone())
                    });
                }
                return(new MultiRegionTissueViewModel(_currentSingleEllipsoidTissueInput));

            default:
                throw new ArgumentOutOfRangeException(nameof(tissueType));
            }
        }
        public void validate_deserialized_class_is_correct()
        {
            var i = new SingleEllipsoidTissueInput(new EllipsoidTissueRegion(new Position(0, 0, 1), 0.5, 0.5, 0.5,
                                                                             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))
            }
                                                   );

            var iCloned = i.Clone();

            Assert.AreEqual(iCloned.Regions[1].RegionOP.Mua, i.Regions[1].RegionOP.Mua);
        }
        public void validate_deserialized_class_is_correct_when_using_FileIO()
        {
            var i = new SingleEllipsoidTissueInput(new EllipsoidTissueRegion(new Position(0, 0, 1), 0.5, 0.5, 0.5,
                                                                             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))
            }
                                                   );

            i.WriteToJson("SingleEllipsoidTissue.txt");
            var iCloned = FileIO.ReadFromJson <SingleEllipsoidTissueInput>("SingleEllipsoidTissue.txt");

            Assert.AreEqual(iCloned.Regions[1].RegionOP.Mua, i.Regions[1].RegionOP.Mua);
        }