Skip to content

Commit

Permalink
[utils] Fix assert and torch.from_numpy() warning in MetaImage IO (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
aschuh-hf committed Jul 28, 2023
1 parent 304e2f6 commit 125b3a9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/deepali/utils/imageio/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def read_meta_image(arg: Union[PathUri, bytes, io.BufferedReader]) -> Tuple[Tens
data = np.expand_dims(data, 0)
else:
data = np.squeeze(np.swapaxes(np.expand_dims(data, 0), 0, -1), -1)
size = meta.get("DimSize", data.shape[:0:-1])
size = tuple(meta.get("DimSize", data.shape[:0:-1]))
assert size[::-1] == data.shape[1:]
origin = meta.get("Position", meta.get("Origin", meta.get("Offset")))
matrix = meta.get("Rotation", meta.get("Orientation", meta.get("TransformMatrix")))
Expand Down Expand Up @@ -292,6 +292,7 @@ def read_meta_image_from_fileobj(f: io.BufferedReader) -> Tuple[np.ndarray, Meta
image = np.frombuffer(buffer, dtype=meta["ElementType"]).reshape(shape)
if meta.get("BinaryDataByteOrderMSB") or meta.get("ElementByteOrderMSB"):
image.byteswap(inplace=True)
image = image.copy()

# remove unused metadata
meta["ElementDataFile"] = None
Expand Down

0 comments on commit 125b3a9

Please sign in to comment.