Skip to content

Commit

Permalink
Create test_nii.py
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaroberts committed Feb 20, 2024
1 parent a8a6c3e commit 32aec6d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/test_nii.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pytest

from nii2dcm.nii import Nifti
import nibabel as nib


NII_FILE_PATH = "tests/data/DicomMRISVR/t2-svr-atlas-35wk.nii.gz"
NII_VOXEL_DIMS = (180, 221, 180)
NII_VOXEL_SPACING = (0.5, 0.5, 0.5)

class TestNifti:
def setup_method(self):
self.nii = nib.load(NII_FILE_PATH)

def test_get_nii2dcm_parameters(self):
nii_parameters = Nifti.get_nii2dcm_parameters(self.nii)
assert nii_parameters["Rows"] == NII_VOXEL_DIMS[0]
assert nii_parameters["Columns"] == NII_VOXEL_DIMS[1]
assert nii_parameters["NumberOfSlices"] == NII_VOXEL_DIMS[2]
assert nii_parameters["AcquisitionMatrix"] == [0, NII_VOXEL_DIMS[0], NII_VOXEL_DIMS[1], 0]
assert nii_parameters["dimX"] == NII_VOXEL_SPACING[0]
assert nii_parameters["dimY"] == NII_VOXEL_SPACING[1]
assert nii_parameters["SliceThickness"] == str(NII_VOXEL_SPACING[2])

0 comments on commit 32aec6d

Please sign in to comment.