Esempio n. 1
0
        public void Write()
        {
            // Read our minimal Nifti file
            var nifti = new NiftiFloat32();

            nifti.ReadNifti(_minimalNiftiPath);

            // Write the minimal Nifti file.
            nifti.WriteNifti(_outfile);
            // Check that we've written something.
            Assert.IsTrue(File.Exists(_outfile), "Nifti file does not exist");

            // Read our nifti file back in.
            var nifti2 = new NiftiFloat32();

            nifti2.ReadNifti(_outfile);
            // Delete the old file.
            File.Delete(_outfile);
            Assert.IsFalse(File.Exists(_outfile), "Nifti file could not be deleted.");

            // Check that the dimensions match the expected Nifti file.
            nifti.GetDimensions(SliceType.Axial, out var width, out var height, out var nSlices);
            Assert.AreEqual(height, 64);
            Assert.AreEqual(width, 64);
            Assert.AreEqual(nSlices, 10);
        }
Esempio n. 2
0
        public void Reorient()
        {
            var nifti = new NiftiFloat32();

            nifti.ReadNifti(_minimalNiftiPath);
            nifti.Reorient(nifti.Header.dim[2], nifti.Header.dim[3], nifti.Header.dim[1]);
            nifti.GetDimensions(SliceType.Axial, out var width, out var height, out var nSlices);

            // TODO: Check that this is the expected result.
            Assert.AreEqual(height, 10);
            Assert.AreEqual(width, 64);
            Assert.AreEqual(nSlices, 64);
        }
Esempio n. 3
0
        public void ReadNifti()
        {
            // Read the minimal nifti file.
            var nifti = new NiftiFloat32();

            nifti.ReadNifti(_minimalNiftiPath);

            // Check that the dimensions are correct.
            nifti.GetDimensions(SliceType.Axial, out var width, out var height, out var nSlices);
            Assert.AreEqual(height, 64);
            Assert.AreEqual(width, 64);
            Assert.AreEqual(nSlices, 10);

            //// Read the minimal nifti file.
            //var nifti2 = new NiftiRgb48();
            //nifti2.ReadNifti(_minimalNiftiPath);

            //// Check that the dimensions are correct.
            //nifti2.GetDimensions(SliceType.Axial, out var width2, out var height2, out var nSlices2);
            //Assert.AreEqual(height2, 64);
            //Assert.AreEqual(width2, 64);
            //Assert.AreEqual(nSlices2, 10);
            //Assert.IsFalse(nifti2.Voxels[10] == 0);
        }