Skip to content

Commit

Permalink
Added test for nifti in realtime_zshimming
Browse files Browse the repository at this point in the history
  • Loading branch information
po09i committed Nov 11, 2020
1 parent a056a4a commit b403705
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/test_load_nifti.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
import numpy as np
import nibabel as nib
import json
import math

from io import StringIO
from pathlib import Path
from shimmingtoolbox.load_nifti import load_nifti
from shimmingtoolbox.load_nifti import read_nii
from shimmingtoolbox import __dir_testing__


class TestCore(object):
Expand Down Expand Up @@ -370,3 +373,12 @@ def test_load_nifti_modality_check(self, monkeypatch):
assert (json.dumps(json_info[0], sort_keys=True) == json.dumps(self._json_mag, sort_keys=True)), \
"JSON file is not correctly loaded for first JSON 2"
assert (niftis.shape == (3, 3, 3, 1, 1)), "Wrong shape for the Nifti output data 2"

def test_read_nii_real_data(self):
fname_phasediff = os.path.join(__dir_testing__, 'realtime_zshimming_data', 'nifti', 'sub-example', 'fmap',
'sub-example_phasediff.nii.gz')
nii, json_info, phasediff = read_nii(fname_phasediff)

assert nii.shape == (64, 96, 1, 10)
assert ('P' in json_info['ImageType'])
assert (phasediff.max() <= 2 * math.pi) and (phasediff.min() >= 0)

0 comments on commit b403705

Please sign in to comment.