Ejemplo n.º 1
0
        public void ReadHdr()
        {
            string file = Path.Combine("resources", "avg152T1_LR_nifti.hdr");
            var    hdr  = NiftiFile.ReadHeader(file);

            Assert.IsTrue((hdr.sizeof_hdr == 348 && !hdr.SourceIsBigEndian()) || hdr.SourceIsBigEndian());
        }
Ejemplo n.º 2
0
        public void TestBadFormat()
        {
            string path = Path.Combine("resources", "gato.nii");

            Assert.IsFalse(NiftiFile.IsCompressed(path));
            try
            {
                _ = NiftiFile.ReadHeader(path);
                Assert.Fail("Failed to fail.");
            }
            catch (InvalidDataException) {}
            catch (Exception e)
            {
                Assert.Fail("Hmmm... " + e.Message);
            }

            try
            {
                _ = NiftiFile.Read(path);
                Assert.Fail("Failed to fail.");
            }
            catch (InvalidDataException) { }
            catch (Exception e)
            {
                Assert.Fail("Hmmm..." + e.Message);
            }
        }
Ejemplo n.º 3
0
        public void TestWriteHeader()
        {
            var niiFile = Path.Combine("resources", "minimal.nii.gz");
            var tmp     = "tmp.hdr";

            var nifti = NiftiFile.Read(niiFile);

            NiftiFile.Write(nifti.Header, tmp);
            var niftiHdr = NiftiFile.ReadHeader(tmp);

            // Maybe we could play with the bits at some point.
            // At the moment this will fail.
            //Assert.IsTrue(niftiHdr.magic[1] == 0x69);
            //Assert.IsTrue(nifti.Header.magic[1] == 0X2B);

            Assert.IsTrue(nifti.Header.cal_max == niftiHdr.cal_max);

            File.Delete(tmp);
        }