Пример #1
0
        public void TestFixedSliceSpacingAndThickness()
        {
            const float sliceSpacing = 0.9f;
            var         factory      = new VolumeSliceFactory {
                SliceSpacing = sliceSpacing, SliceThickness = 1f
            };

            var volume = MockVolumeReference.Create(
                new Size3D(200, 200, 100),
                new Vector3D(0.5f, 0.5f, 1),
                new Vector3D(0, 0, 0),
                Matrix3D.GetIdentity());

            var slice = factory.CreateSlice(volume, new Vector3D(50, 50, 50.5f));

            AssertVolumeSlice(slice, 200, 200, new Vector3D(0, 0, 50.5f), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0), 0.5f, 0.5f, 1, null, "single");

            var slices = factory.CreateSlices(volume);

            Assert.AreEqual(112, slices.Count, "SliceCount (full stack)");
            for (var n = 0; n < 112; ++n)
            {
                AssertVolumeSlice(slices[n], 200, 200, new Vector3D(0, 0, 0.05f + n * sliceSpacing), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0), 0.5f, 0.5f, 1, sliceSpacing, "full stack @n={0}", n);
            }

            slices = factory.CreateSlices(volume, new Vector3D(50, 50, 50.5f));
            Assert.AreEqual(112, slices.Count, "SliceCount (ref pos)");
            for (var n = 0; n < 112; ++n)
            {
                AssertVolumeSlice(slices[n], 200, 200, new Vector3D(0, 0, 0.05f + n * sliceSpacing), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0), 0.5f, 0.5f, 1, sliceSpacing, "ref pos @n={0}", n);
            }

            slices = factory.CreateSlices(volume, new Vector3D(50, 50, 50.5f), 10);
            Assert.AreEqual(10, slices.Count, "SliceCount (exact count)");
            for (var n = 0; n < 10; ++n)
            {
                AssertVolumeSlice(slices[n], 200, 200, new Vector3D(0, 0, 50.5f + n * sliceSpacing), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0), 0.5f, 0.5f, 1, sliceSpacing, "exact count @n={0}", n);
            }

            slices = factory.CreateSlices(volume, new Vector3D(50, 50, 50.5f), new Vector3D(50, 50, 58.5f));
            Assert.AreEqual(10, slices.Count, "SliceCount (exact multiple)");
            for (var n = 0; n < 10; ++n)
            {
                AssertVolumeSlice(slices[n], 200, 200, new Vector3D(0, 0, 50.5f + n * sliceSpacing), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0), 0.5f, 0.5f, 1, sliceSpacing, "exact multiple @n={0}", n);
            }

            slices = factory.CreateSlices(volume, new Vector3D(50, 50, 50.5f), new Vector3D(50, 50, 59));
            Assert.AreEqual(10, slices.Count, "SliceCount (round down)");
            for (var n = 0; n < 10; ++n)
            {
                AssertVolumeSlice(slices[n], 200, 200, new Vector3D(0, 0, 50.5f + n * sliceSpacing), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0), 0.5f, 0.5f, 1, sliceSpacing, "round down @n={0}", n);
            }

            slices = factory.CreateSlices(volume, new Vector3D(50, 50, 50.5f), new Vector3D(50, 50, 59.49f));
            Assert.AreEqual(11, slices.Count, "SliceCount (round up)");
            for (var n = 0; n < 11; ++n)
            {
                AssertVolumeSlice(slices[n], 200, 200, new Vector3D(0, 0, 50.5f + n * sliceSpacing), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0), 0.5f, 0.5f, 1, sliceSpacing, "round up @n={0}", n);
            }
        }
Пример #2
0
        private void IncrementRotate(int xIncrement, int yIncrement)
        {
            if (!CanRotate())
            {
                return;
            }

            if (xIncrement == 0 && yIncrement == 0)
            {
                return;
            }

            var transform = (ISpatialTransform3D)_operation.GetOriginator(SelectedPresentationImage);

            // Because the rotation increment is in destination coordinates, we have to convert
            // them to source coordinates, since the transform translation is in source coordinates.
            // This will allow the rotate to work properly irrespective of the zoom, flip and rotation.
            var source  = SelectedSpatialTransformProvider.SpatialTransform.ConvertToSource(new SizeF(xIncrement, yIncrement));
            var sourceX = source.Width;
            var sourceY = source.Height;

            // choose the axis of rotation to be perpendicular to the rotation increment, in the plane of the view port
            var axis = new Vector3D(-sourceY, sourceX, 0).Normalize();

            // compute the magnitude of the rotation
            var angle = (float)Math.Sqrt(sourceX * sourceX + sourceY * sourceY);

            var rotation = transform.Rotation != null?transform.Rotation.Clone() : Matrix3D.GetIdentity();

            Rotate(rotation, angle, axis.X, axis.Y, axis.Z);
            transform.Rotation = rotation;

            SelectedPresentationImage.Draw();
        }
Пример #3
0
        public void TestBasicIdentitySlicing()
        {
            var factory = new VolumeSliceFactory();

            var volume = MockVolumeReference.Create(
                new Size3D(200, 200, 100),
                new Vector3D(0.5f, 0.5f, 1),
                new Vector3D(0, 0, 0),
                Matrix3D.GetIdentity());

            var slice = factory.CreateSlice(volume, new Vector3D(50, 50, 50.5f));

            AssertVolumeSlice(slice, 200, 200, new Vector3D(0, 0, 50.5f), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0), 0.5f, 0.5f, 1, null, "single");

            var slices = factory.CreateSlices(volume);

            Assert.AreEqual(101, slices.Count, "SliceCount (full stack)");
            for (var n = 0; n < 101; ++n)
            {
                AssertVolumeSlice(slices[n], 200, 200, new Vector3D(0, 0, n), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0), 0.5f, 0.5f, 1, 1, "full stack @n={0}", n);
            }

            slices = factory.CreateSlices(volume, new Vector3D(50, 50, 50.5f));
            Assert.AreEqual(101, slices.Count, "SliceCount (ref pos)");
            for (var n = 0; n < 101; ++n)
            {
                AssertVolumeSlice(slices[n], 200, 200, new Vector3D(0, 0, n), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0), 0.5f, 0.5f, 1, 1, "ref pos @n={0}", n);
            }

            slices = factory.CreateSlices(volume, new Vector3D(50, 50, 50.5f), 10);
            Assert.AreEqual(10, slices.Count, "SliceCount (exact count)");
            for (var n = 0; n < 10; ++n)
            {
                AssertVolumeSlice(slices[n], 200, 200, new Vector3D(0, 0, 50.5f + n), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0), 0.5f, 0.5f, 1, 1, "exact count @n={0}", n);
            }

            slices = factory.CreateSlices(volume, new Vector3D(50, 50, 50.5f), new Vector3D(50, 50, 59.5f));
            Assert.AreEqual(10, slices.Count, "SliceCount (exact multiple)");
            for (var n = 0; n < 10; ++n)
            {
                AssertVolumeSlice(slices[n], 200, 200, new Vector3D(0, 0, 50.5f + n), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0), 0.5f, 0.5f, 1, 1, "exact multiple @n={0}", n);
            }

            slices = factory.CreateSlices(volume, new Vector3D(50, 50, 50.5f), new Vector3D(50, 50, 60));
            Assert.AreEqual(10, slices.Count, "SliceCount (round down)");
            for (var n = 0; n < 10; ++n)
            {
                AssertVolumeSlice(slices[n], 200, 200, new Vector3D(0, 0, 50.5f + n), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0), 0.5f, 0.5f, 1, 1, "round down @n={0}", n);
            }

            slices = factory.CreateSlices(volume, new Vector3D(50, 50, 50.5f), new Vector3D(50, 50, 60.49f));
            Assert.AreEqual(11, slices.Count, "SliceCount (round up)");
            for (var n = 0; n < 11; ++n)
            {
                AssertVolumeSlice(slices[n], 200, 200, new Vector3D(0, 0, 50.5f + n), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0), 0.5f, 0.5f, 1, 1, "round up @n={0}", n);
            }
        }
Пример #4
0
        private void ResetRotate()
        {
            if (!CanRotate())
            {
                return;
            }

            var transform = (ISpatialTransform3D)_operation.GetOriginator(SelectedPresentationImage);

            transform.Rotation = Matrix3D.GetIdentity();

            SelectedPresentationImage.Draw();
        }
Пример #5
0
        public void TestFixedPixelSpacingWithSliceExtentPixels()
        {
            var volume = MockVolumeReference.Create(
                new Size3D(200, 200, 100),
                new Vector3D(0.5f, 0.5f, 1),
                new Vector3D(0, 0, 0),
                Matrix3D.GetIdentity());

            var factory = new VolumeSliceFactory {
                ColumnSpacing = 1f, Columns = 80
            };

            var slices = factory.CreateSlices(volume, new Vector3D(35, 75, 50));

            Assert.AreEqual(101, slices.Count, "SliceCount (fixed column spacing)");
            for (var n = 0; n < 101; ++n)
            {
                AssertVolumeSlice(slices[n], 100, 80, new Vector3D(-5, 0, n), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0), 1, 1, 1, 1, "fixed column spacing @n={0}", n);
            }

            factory = new VolumeSliceFactory {
                RowSpacing = 1f, Rows = 40
            };
            slices = factory.CreateSlices(volume, new Vector3D(35, 75, 50));
            Assert.AreEqual(101, slices.Count, "SliceCount (fixed row spacing)");
            for (var n = 0; n < 101; ++n)
            {
                AssertVolumeSlice(slices[n], 40, 100, new Vector3D(0, 55, n), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0), 1, 1, 1, 1, "fixed row spacing @n={0}", n);
            }

            factory = new VolumeSliceFactory {
                ColumnSpacing = 1f, RowSpacing = 1f, Columns = 80, Rows = 40
            };
            slices = factory.CreateSlices(volume, new Vector3D(35, 75, 50));
            Assert.AreEqual(101, slices.Count, "SliceCount (fixed pixel spacing)");
            for (var n = 0; n < 101; ++n)
            {
                AssertVolumeSlice(slices[n], 40, 80, new Vector3D(-5, 55, n), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0), 1, 1, 1, 1, "fixed pixel spacing @n={0}", n);
            }

            // the factory never generates anisotropic output unless explicitly requested
            factory = new VolumeSliceFactory {
                ColumnSpacing = 1f, RowSpacing = 0.5f, Columns = 80, Rows = 80
            };
            slices = factory.CreateSlices(volume, new Vector3D(35, 75, 50));
            Assert.AreEqual(101, slices.Count, "SliceCount (explicit anisotropic spacing)");
            for (var n = 0; n < 101; ++n)
            {
                AssertVolumeSlice(slices[n], 80, 80, new Vector3D(-5, 55, n), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0), 0.5f, 1, 1, 1, "explicit anisotropic spacing @n={0}", n);
            }
        }
Пример #6
0
        public void TestIdentity()
        {
            var identity = new Matrix3D();

            identity.SetRow(0, 1F, 0F, 0F);
            identity.SetRow(1, 0F, 1F, 0F);
            identity.SetRow(2, 0F, 0F, 1F);

            Assert.IsTrue(identity.IsIdentity);
            Assert.IsTrue(Matrix3D.AreEqual(identity, Matrix3D.GetIdentity()));

            identity[0, 1] = 1F;
            Assert.IsFalse(identity.IsIdentity);
        }
Пример #7
0
        public void TestInverse()
        {
            // test identity inverse
            var m = Matrix3D.GetIdentity();

            Assert.IsTrue(Matrix3D.AreEqual(m.Invert(), new Matrix3D(new float[, ] {
                { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 }
            })));

            // test a known inverse
            m = new Matrix3D(new[, ]
            {
                { 0.100f, 0.200f, 0.300f },
                { -0.400f, 0.500f, 0.600f },
                { 0.700f, 0.800f, 0.900f }
            });

            var r = new Matrix3D(new[, ]
            {
                { 0.62500f, -1.25000f, 0.62500f },
                { -16.25000f, 2.50000f, 3.75000f },
                { 13.95833f, -1.25000f, -2.70833f }
            });

            Assert.IsTrue(Matrix3D.AreEqual(m.Invert(), r, 0.00001f));

            // test inverse multiplied against original is the identity
            m.SetRow(0, -1.1F, 2.6F, -7.1F);
            m.SetRow(1, 4.6F, -3.7F, 9.1F);
            m.SetRow(2, 4.1F, -3.1F, 7.7F);

            Assert.IsTrue(Matrix3D.AreEqual(m * m.Invert(), Matrix3D.GetIdentity(), 0.00001f));
            Assert.IsTrue(Matrix3D.AreEqual(m.Invert() * m, Matrix3D.GetIdentity(), 0.00001f));

            // test non-invertible
            m.SetRow(0, 1, 0, 0);
            m.SetRow(1, 0, 1, 0);
            m.SetRow(2, 0, 5, 0);

            try
            {
                m.Invert();
                Assert.Fail("Expected an exception");
            }
            catch (ArgumentException) {}
        }
Пример #8
0
        public void TestBasicObliqueSlicing()
        {
            const float root2     = 1.4142135623730950488016887242097f;
            const float halfRoot2 = root2 / 2;

            var volume = MockVolumeReference.Create(
                new Size3D(160, 200, 100),
                new Vector3D(0.625f, 0.5f, 1),
                new Vector3D(0, 0, 0),
                Matrix3D.GetIdentity());

            // case 1 - stack axis {0,0,1}, stack depth is 100
            {
                const int expectedSliceCount = 101;                 // 100 + 1

                var factory = new VolumeSliceFactory {
                    RowOrientationPatient = new Vector3D(1, 1, 0), ColumnOrientationPatient = new Vector3D(-1, 1, 0)
                };
                var slices = factory.CreateSlices(volume);
                Assert.AreEqual(expectedSliceCount, slices.Count, "SliceCount (case 1)");
                for (var n = 0; n < expectedSliceCount; ++n)
                {
                    const int expectedDimension = (int)(root2 * 200 + 0.5f);                    // 283
                    AssertVolumeSlice(slices[n], expectedDimension, expectedDimension, new Vector3D(50, -50, n), new Vector3D(halfRoot2, halfRoot2, 0), new Vector3D(-halfRoot2, halfRoot2, 0), 0.5f, 0.5f, 1, 1, "case 1 @n={0}", n);
                }
            }

            // case 2 - stack axis {-1,1,0}, stack depth is 100*root(2), computed spacing should be sqrt(0.625^2 + 0.5^2)=0.800...
            {
                const float expectedSpacing    = 0.795495f;              // spacing should really be 0.8, but apparently the floating point error caught up
                const int   expectedSliceCount = (int)(100 * root2 / expectedSpacing + 1.5);

                var factory = new VolumeSliceFactory {
                    RowOrientationPatient = new Vector3D(1, 1, 0), ColumnOrientationPatient = new Vector3D(0, 0, 1)
                };
                var slices = factory.CreateSlices(volume);
                Assert.AreEqual(expectedSliceCount, slices.Count, "SliceCount (case 2)");
                for (var n = 0; n < expectedSliceCount; ++n)
                {
                    const int expectedRows    = 200;
                    const int expectedColumns = (int)(root2 * 200 + 0.5f);                    // 283
                    AssertVolumeSlice(slices[n], expectedRows, expectedColumns, new Vector3D(-50.0625f + n * 0.5625f, 50.0625f - n * 0.5625f, 0), new Vector3D(halfRoot2, halfRoot2, 0), new Vector3D(0, 0, 1), 0.5f, 0.5f, expectedSpacing, expectedSpacing, "case 2 @n={0}", n);
                }
            }
        }
Пример #9
0
        public Volume CreateVolume(int width, int height, int depth, bool signed)
        {
            DicomAttributeCollection dataset = CreateMockDataset(_name, width, height, signed);
            Size3D   dimensions         = new Size3D(width, height, depth);
            Vector3D spacing            = new Vector3D(1, 1, 1);
            Vector3D originPatient      = new Vector3D(0, 0, 0);
            Matrix3D orientationPatient = Matrix3D.GetIdentity();

            if (signed)
            {
                short[] data = CreateSignedArray(width, height, depth);
                return(new S16Volume(data, dimensions, spacing, originPatient, orientationPatient, dataset, short.MinValue));
            }
            else
            {
                ushort[] data = CreateUnsignedArray(width, height, depth);
                return(new U16Volume(data, dimensions, spacing, originPatient, orientationPatient, dataset, ushort.MinValue));
            }
        }
Пример #10
0
        private static void CreateAndResliceVolume(bool signed)
        {
            const int width  = 10;
            const int height = 10;
            const int depth  = 10;

            Volume vol;

            if (signed)
            {
                vol = new S16Volume(new short[width * height * depth],
                                    new Size3D(width, height, depth), new Vector3D(1, 1, 1),
                                    new Vector3D(0, 0, 0), Matrix3D.GetIdentity(),
                                    new DicomAttributeCollection()
                {
                    ValidateVrLengths = false, ValidateVrValues = false
                },
                                    short.MinValue);
            }
            else
            {
                vol = new U16Volume(new ushort[width * height * depth],
                                    new Size3D(width, height, depth), new Vector3D(1, 1, 1),
                                    new Vector3D(0, 0, 0), Matrix3D.GetIdentity(),
                                    new DicomAttributeCollection(),
                                    ushort.MinValue);
            }

            try
            {
                using (var volumeReference = vol.CreateReference())
                {
                    GetSlicePixelData(volumeReference, Matrix.GetIdentity(4), 20, 20, 0.5f, 0.5f, VolumeInterpolationMode.Linear);
                    GetSlabPixelData(volumeReference, Matrix.GetIdentity(4), new Vector3D(0, 0, 1), 20, 20, 3, 0.5f, 0.5f, 1, VolumeInterpolationMode.Linear, VolumeProjectionMode.Average);
                }
            }
            finally
            {
                vol.Dispose();
            }
        }
Пример #11
0
        public void TestMiscSliceProperties()
        {
            var factory = new VolumeSliceFactory();

            var volume = MockVolumeReference.Create(
                new Size3D(100, 100, 100),
                new Vector3D(1, 1, 1),
                new Vector3D(0, 0, 0),
                Matrix3D.GetIdentity());

            var slice = factory.CreateSlice(volume, new Vector3D(50, 50, 50.5f));

            Assert.AreEqual(VolumeInterpolationMode.Linear, slice.SliceArgs.Interpolation, "Interpolation");
            Assert.AreEqual(VolumeProjectionMode.Average, slice.SliceArgs.Projection, "Projection");

            factory.Interpolation = VolumeInterpolationMode.Cubic;
            factory.Projection    = VolumeProjectionMode.Maximum;
            slice = factory.CreateSlice(volume, new Vector3D(50, 50, 50.5f));
            Assert.AreEqual(VolumeInterpolationMode.Cubic, slice.SliceArgs.Interpolation, "Interpolation");
            Assert.AreEqual(VolumeProjectionMode.Maximum, slice.SliceArgs.Projection, "Projection");
        }
Пример #12
0
        public void TestDeterminant()
        {
            var m = Matrix3D.GetIdentity();

            Assert.AreEqual(1, m.GetDeterminant());

            m.SetRow(0, 1, 0, 0);
            m.SetRow(1, 0, 1, 0);
            m.SetRow(2, 0, 5, 0);

            Assert.AreEqual(0, m.GetDeterminant());

            m = new Matrix3D(new float[, ]
            {
                { 1, 2, 3 },
                { 4, 5, 6 },
                { 7, 8, 9 }
            });

            Assert.AreEqual(1 * 5 * 9 + 2 * 6 * 7 + 3 * 4 * 8 - 7 * 5 * 3 - 8 * 6 * 1 - 9 * 2 * 4, m.GetDeterminant());
        }
Пример #13
0
        protected VolumeData CreateVolume(bool signed, Modality modality, Vector3D voxelSpacing)
        {
            Vector3D originPatient = new Vector3D(0, 0, 0);
            Matrix3D orientationPatient = Matrix3D.GetIdentity();
            int      width, height, depth;

            if (signed)
            {
                short[] data = CreateSignedArray(out width, out height, out depth, voxelSpacing);
                DicomAttributeCollection dataset = CreateMockDataset(_name, _studyInstanceUid, _frameOfReferenceUid, modality, width, height, true, new SizeF(voxelSpacing.X, voxelSpacing.Y));
                Size3D dimensions = new Size3D(width, height, depth);
                return(new S16Volume(data, dimensions, voxelSpacing, originPatient, orientationPatient, dataset, short.MinValue));
            }
            else
            {
                ushort[] data = CreateUnsignedArray(out width, out height, out depth, voxelSpacing);
                DicomAttributeCollection dataset = CreateMockDataset(_name, _studyInstanceUid, _frameOfReferenceUid, modality, width, height, false, new SizeF(voxelSpacing.X, voxelSpacing.Y));
                Size3D dimensions = new Size3D(width, height, depth);
                return(new U16Volume(data, dimensions, voxelSpacing, originPatient, orientationPatient, dataset, ushort.MinValue));
            }
        }
Пример #14
0
        public void TestFixedSliceExtentPixels()
        {
            var volume = MockVolumeReference.Create(
                new Size3D(200, 200, 100),
                new Vector3D(0.5f, 0.5f, 1),
                new Vector3D(0, 0, 0),
                Matrix3D.GetIdentity());

            var factory = new VolumeSliceFactory {
                Columns = 160, SliceWidth = 999999
            };

            var slices = factory.CreateSlices(volume, new Vector3D(35, 75, 50));

            Assert.AreEqual(101, slices.Count, "SliceCount (fixed width)");
            for (var n = 0; n < 101; ++n)
            {
                AssertVolumeSlice(slices[n], 200, 160, new Vector3D(-5, 0, n), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0), 0.5f, 0.5f, 1, 1, "fixed width @n={0}", n);
            }

            factory = new VolumeSliceFactory {
                Rows = 80, SliceHeight = 999999
            };
            slices = factory.CreateSlices(volume, new Vector3D(35, 75, 50));
            Assert.AreEqual(101, slices.Count, "SliceCount (fixed height)");
            for (var n = 0; n < 101; ++n)
            {
                AssertVolumeSlice(slices[n], 80, 200, new Vector3D(0, 55, n), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0), 0.5f, 0.5f, 1, 1, "fixed height @n={0}", n);
            }

            factory = new VolumeSliceFactory {
                Columns = 160, Rows = 80, SliceWidth = 999999, SliceHeight = 999999
            };
            slices = factory.CreateSlices(volume, new Vector3D(35, 75, 50));
            Assert.AreEqual(101, slices.Count, "SliceCount (fixed size)");
            for (var n = 0; n < 101; ++n)
            {
                AssertVolumeSlice(slices[n], 80, 160, new Vector3D(-5, 55, n), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0), 0.5f, 0.5f, 1, 1, "fixed size @n={0}", n);
            }
        }
Пример #15
0
        public void TestBasicOrthogonalSlicing()
        {
            var volume = MockVolumeReference.Create(
                new Size3D(160, 200, 100),
                new Vector3D(0.625f, 0.5f, 1),
                new Vector3D(0, 0, 0),
                Matrix3D.GetIdentity());

            var factory = new VolumeSliceFactory {
                RowOrientationPatient = new Vector3D(1, 0, 0), ColumnOrientationPatient = new Vector3D(0, 1, 0)
            };
            var slices = factory.CreateSlices(volume);

            Assert.AreEqual(101, slices.Count, "SliceCount (axial)");
            for (var n = 0; n < 101; ++n)
            {
                AssertVolumeSlice(slices[n], 200, 200, new Vector3D(0, 0, n), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0), 0.5f, 0.5f, 1, 1, "axial @n={0}", n);
            }

            factory = new VolumeSliceFactory {
                RowOrientationPatient = new Vector3D(1, 0, 0), ColumnOrientationPatient = new Vector3D(0, -1, 0)
            };
            slices = factory.CreateSlices(volume);
            Assert.AreEqual(101, slices.Count, "SliceCount (axial reverse)");
            for (var n = 0; n < 101; ++n)
            {
                AssertVolumeSlice(slices[100 - n], 200, 200, new Vector3D(0, 100, n), new Vector3D(1, 0, 0), new Vector3D(0, -1, 0), 0.5f, 0.5f, 1, 1, "axial reverse @n={0}", n);
            }

            factory = new VolumeSliceFactory {
                RowOrientationPatient = new Vector3D(1, 0, 0), ColumnOrientationPatient = new Vector3D(0, 0, -1)
            };
            slices = factory.CreateSlices(volume);
            Assert.AreEqual(201, slices.Count, "SliceCount (coronal)");
            for (var n = 0; n < 201; ++n)
            {
                AssertVolumeSlice(slices[n], 200, 200, new Vector3D(0, n * 0.5f, 100), new Vector3D(1, 0, 0), new Vector3D(0, 0, -1), 0.5f, 0.5f, 0.5f, 0.5f, "coronal @n={0}", n);
            }

            factory = new VolumeSliceFactory {
                RowOrientationPatient = new Vector3D(1, 0, 0), ColumnOrientationPatient = new Vector3D(0, 0, 1)
            };
            slices = factory.CreateSlices(volume);
            Assert.AreEqual(201, slices.Count, "SliceCount (coronal reverse)");
            for (var n = 0; n < 201; ++n)
            {
                AssertVolumeSlice(slices[200 - n], 200, 200, new Vector3D(0, n * 0.5f, 0), new Vector3D(1, 0, 0), new Vector3D(0, 0, 1), 0.5f, 0.5f, 0.5f, 0.5f, "coronal reverse @n={0}", n);
            }

            factory = new VolumeSliceFactory {
                RowOrientationPatient = new Vector3D(0, 1, 0), ColumnOrientationPatient = new Vector3D(0, 0, 1)
            };
            slices = factory.CreateSlices(volume);
            Assert.AreEqual(161, slices.Count, "SliceCount (sagittal)");
            for (var n = 0; n < 161; ++n)
            {
                AssertVolumeSlice(slices[n], 200, 200, new Vector3D(n * 0.625f, 0, 0), new Vector3D(0, 1, 0), new Vector3D(0, 0, 1), 0.5f, 0.5f, 0.625f, 0.625f, "sagittal @n={0}", n);
            }

            factory = new VolumeSliceFactory {
                RowOrientationPatient = new Vector3D(0, 1, 0), ColumnOrientationPatient = new Vector3D(0, 0, -1)
            };
            slices = factory.CreateSlices(volume);
            Assert.AreEqual(161, slices.Count, "SliceCount (sagittal reverse)");
            for (var n = 0; n < 161; ++n)
            {
                AssertVolumeSlice(slices[160 - n], 200, 200, new Vector3D(n * 0.625f, 0, 100), new Vector3D(0, 1, 0), new Vector3D(0, 0, -1), 0.5f, 0.5f, 0.625f, 0.625f, "sagittal reverse @n={0}", n);
            }
        }