Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ jobs:
name: Install torch cpu from pytorch.org (Windows only)
run: |
python -m pip install torch==1.12.1+cpu torchvision==0.13.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
- if: runner.os == 'Linux'
name: Install itk pre-release (Linux only)
run: |
python -m pip install --pre -U itk
- name: Install the dependencies
run: |
python -m pip install torch==1.12.1 torchvision==0.13.1
Expand Down
7 changes: 6 additions & 1 deletion monai/data/image_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,12 @@ def _get_meta_dict(self, img) -> Dict:

"""
img_meta_dict = img.GetMetaDataDictionary()
meta_dict = {key: img_meta_dict[key] for key in img_meta_dict.GetKeys() if not key.startswith("ITK_")}
meta_dict = {}
for key in img_meta_dict.GetKeys():
if key.startswith("ITK_"):
continue
val = img_meta_dict[key]
meta_dict[key] = np.asarray(val) if type(val).__name__.startswith("itk") else val

meta_dict["spacing"] = np.asarray(img.GetSpacing())
return meta_dict
Expand Down
2 changes: 1 addition & 1 deletion tests/test_load_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def test_channel_dim(self, input_param, filename, expected_shape):
with tempfile.TemporaryDirectory() as tempdir:
filename = os.path.join(tempdir, filename)
nib.save(nib.Nifti1Image(test_image, np.eye(4)), filename)
result = LoadImage(image_only=True, **input_param)(filename)
result = LoadImage(image_only=True, **input_param)(filename) # with itk, meta has 'qto_xyz': itkMatrixF44

self.assertTupleEqual(
result.shape, (3, 128, 128, 128) if input_param.get("ensure_channel_first", False) else expected_shape
Expand Down