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()); }
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); } }
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); }