Skip to content

Commit

Permalink
Merge b866677 into f9cd9c9
Browse files Browse the repository at this point in the history
  • Loading branch information
po09i committed Nov 20, 2020
2 parents f9cd9c9 + b866677 commit 3a302fe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions shimmingtoolbox/load_nifti.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def load_nifti(path_data, modality='phase'):
# Generate file_list
file_list = []
[file_list.append(os.path.join(path_data, f)) for f in os.listdir(path_data) if f not in file_list]
file_list = sorted(file_list)

nifti_path = ""
# Check for incompatible acquisition source path
Expand Down Expand Up @@ -92,6 +93,7 @@ def load_nifti(path_data, modality='phase'):

# Get a list of nii files
nifti_list = [os.path.join(nifti_path, f) for f in os.listdir(nifti_path) if f.endswith((".nii", ".nii.gz"))]
nifti_list = sorted(nifti_list)

# Read all images and headers available and store them
nifti_init = [read_nii(nifti_list[i]) for i in range(len(nifti_list))]
Expand Down
8 changes: 4 additions & 4 deletions test/test_load_nifti.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@ def test_load_nifti_multiple_echoes(self, monkeypatch):
niftis, info, json_info = load_nifti(self.tmp_path)
assert (len(info) == 2), "Wrong number od info data 1"
assert (len(json_info) == 2), "Wrong number of JSON data 1"
self._json_phase['EchoNumber'] = 2
self._json_phase['EchoNumber'] = 1
assert (json.dumps(json_info[0], sort_keys=True) == json.dumps(self._json_phase, sort_keys=True)), \
"JSON file is not correctly loaded for first JSON1"
self._json_phase['EchoNumber'] = 1
self._json_phase['EchoNumber'] = 2
assert (json.dumps(json_info[1], sort_keys=True) == json.dumps(self._json_phase, sort_keys=True)), \
"JSON file is not correctly loaded for second JSON 1"
assert (niftis.shape == (3, 3, 3, 2, 1)), "Wrong shape for the Nifti output data 1"
Expand All @@ -278,10 +278,10 @@ def test_load_nifti_multiple_echoes(self, monkeypatch):
niftis, info, json_info = load_nifti(self.tmp_path)
assert (len(info) == 2), "Wrong number of info data 2"
assert (len(json_info) == 2), "Wrong number of JSON data 2"
self._json_phase['EchoNumber'] = 2
self._json_phase['EchoNumber'] = 1
assert (json.dumps(json_info[0], sort_keys=True) == json.dumps(self._json_phase, sort_keys=True)), \
"JSON file is not correctly loaded for first JSON 2"
self._json_phase['EchoNumber'] = 1
self._json_phase['EchoNumber'] = 2
assert (json.dumps(json_info[1], sort_keys=True) == json.dumps(self._json_phase, sort_keys=True)), \
"JSON file is not correctly loaded for second JSON 2"
assert (niftis.shape == (3, 3, 3, 2, 1)), "Wrong shape for the Nifti output data 2"
Expand Down

0 comments on commit 3a302fe

Please sign in to comment.