Ejemplo n.º 1
0
        public void LoadNiftiInUInt16Format()
        {
            var filename       = TestData.GetFullImagesPath("vol_uint16.nii.gz");
            var niftiInUShort  = MedIO.LoadNiftiInUShortFormat(filename);
            var distinctValues = niftiInUShort.Array.Distinct().ToArray();
            var expected       = new ushort[] { 0, 1, 2 };

            Assert.AreEqual(expected, distinctValues, "The Nifti file contains 2 contours, should hence have 3 distinct values");
            var niftiCastToByte  = MedIO.LoadNiftiAsByte(filename);
            var niftiCastToShort = MedIO.LoadNiftiAsShort(filename);

            Assert.AreEqual(niftiCastToByte.Length, niftiCastToShort.Length);
            Assert.AreEqual(niftiCastToByte.Length, niftiInUShort.Length);
            Assert.AreEqual(new ushort[] { 0, 1, 2 }, niftiCastToShort.Array.Distinct().ToArray());
            Assert.AreEqual(new byte[] { 0, 1, 2 }, niftiCastToByte.Array.Distinct().ToArray());
        }