Esempio n. 1
0
        public void TestFillGantryTiltedVoxelData2()
        {
            const double angleDegrees = -30;
            const double angleRadians = angleDegrees * _degreesInRadians;
            const int    paddingRows  = 50;         // 50 padding rows because sin(-30)*(100 voxels deep) = 50 voxels high (just padding starts at bottom this time)

            DataSetOrientation orientation = DataSetOrientation.CreateGantryTiltedAboutX(angleDegrees);

            TestVolume(VolumeFunction.Stars,
                       orientation.Initialize,
                       volume =>
            {
                Assert.AreEqual(new Size3D(100, 100 + paddingRows, 100), volume.ArrayDimensions, "ArrayDimensions");
                AssertAreEqual(new Vector3D(1, 0, 0), volume.VolumeOrientationPatientX, "VolumeOrientationPatientX");
                AssertAreEqual(new Vector3D(0, (float)Math.Cos(angleRadians), -(float)Math.Sin(angleRadians)), volume.VolumeOrientationPatientY, "VolumeOrientationPatientY");
                AssertAreEqual(new Vector3D(0, (float)Math.Sin(angleRadians), (float)Math.Cos(angleRadians)), volume.VolumeOrientationPatientZ, "VolumeOrientationPatientZ");
                AssertAreEqual(new Vector3D(0, 0, 0), volume.VolumePositionPatient, "VolumePositionPatient");
                AssertAreEqual(new Vector3D(100, 100 + paddingRows, (float)(100 * Math.Cos(angleRadians))), volume.VolumeSize, "VolumeSize");
                AssertAreEqual(new Vector3D(1, 1, (float)Math.Cos(angleRadians)), volume.VoxelSpacing, "VoxelSpacing");

                foreach (KnownSample sample in StarsKnownSamples)
                {
                    Vector3D realPoint   = sample.Point;
                    Vector3D paddedPoint = realPoint + new Vector3D(0, (float)(-Math.Sin(angleRadians) * (realPoint.Z)), 0);

                    int actual = volume[(int)paddedPoint.X, (int)paddedPoint.Y, (int)paddedPoint.Z];
                    Trace.WriteLine(string.Format("Sample {0} @{1} ({2} before padding)", actual, paddedPoint, realPoint));
                    Assert.AreEqual(sample.Value, actual, "Wrong colour sample @{0} ({1} before padding)", paddedPoint, realPoint);
                }
            });
        }
Esempio n. 2
0
        public void TestGantryTiltedSource()
        {
            {
                string imageOrientationPatient = string.Format(@"{1:f9}\{1:f9}\{0:f9}\-{0:f9}\{0:f9}\0", Math.Cos(Math.PI / 4), Math.Pow(Math.Cos(Math.PI / 4), 2));
                try
                {
                    // it doesn't really matter what function we use
                    TestVolume(VolumeFunction.Void, sopDataSource => sopDataSource[DicomTags.ImageOrientationPatient].SetStringValue(imageOrientationPatient), null);
                    Assert.Fail("Expected an exception of type {0}", typeof(UnsupportedGantryTiltAxisException));
                }
                catch (UnsupportedGantryTiltAxisException) {}
            }

            {
                DataSetOrientation orientation = DataSetOrientation.CreateGantryTiltedAboutX(30);

                // it doesn't really matter what function we use
                TestVolume(VolumeFunction.Void, orientation.Initialize, null);
            }

            {
                DataSetOrientation orientation = DataSetOrientation.CreateGantryTiltedAboutX(-30);

                // it doesn't really matter what function we use
                TestVolume(VolumeFunction.Void, orientation.Initialize, null);
            }

            {
                DataSetOrientation orientation = DataSetOrientation.CreateGantryTiltedAboutY(30);

                try
                {
                    // it doesn't really matter what function we use
                    TestVolume(VolumeFunction.Void, orientation.Initialize, null);
                    Assert.Fail("Expected an exception of type {0}", typeof(UnsupportedGantryTiltAxisException));
                }
                catch (UnsupportedGantryTiltAxisException) {}
            }

            {
                DataSetOrientation orientation = DataSetOrientation.CreateGantryTiltedAboutY(-30);

                try
                {
                    // it doesn't really matter what function we use
                    TestVolume(VolumeFunction.Void, orientation.Initialize, null);
                    Assert.Fail("Expected an exception of type {0}", typeof(UnsupportedGantryTiltAxisException));
                }
                catch (UnsupportedGantryTiltAxisException) {}
            }
        }
Esempio n. 3
0
        public void TestDifferentImageOrientationSource()
        {
            int n = 0;

            try
            {
                // it doesn't really matter what function we use
                TestVolume(VolumeFunction.Void, sopDataSource => sopDataSource[DicomTags.ImageOrientationPatient].SetStringValue(DataSetOrientation.CreateGantryTiltedAboutX(n++).ImageOrientationPatient), null);
                Assert.Fail("Expected an exception of type {0}", typeof(MultipleImageOrientationsException));
            }
            catch (MultipleImageOrientationsException) {}
        }