diff --git a/medvol/__init__.py b/medvol/__init__.py index 89b0070..0702d9f 100644 --- a/medvol/__init__.py +++ b/medvol/__init__.py @@ -1,3 +1,3 @@ -__version__ = "0.0.5" +__version__ = "0.0.6" from medvol.medvol import MedVol \ No newline at end of file diff --git a/medvol/medvol.py b/medvol/medvol.py index 0b38208..475ce90 100644 --- a/medvol/medvol.py +++ b/medvol/medvol.py @@ -83,9 +83,13 @@ def _load(self, filepath): def save(self, filepath): image_sitk = sitk.GetImageFromArray(self.array) - image_sitk.SetSpacing(self.spacing.tolist()[::-1]) - image_sitk.SetOrigin(self.origin.tolist()[::-1]) - image_sitk.SetDirection(self.direction.flatten().tolist()[::-1]) - for key, value in self.header.items(): - image_sitk.SetMetaData(key, value) + if self.spacing is not None: + image_sitk.SetSpacing(self.spacing.tolist()[::-1]) + if self.origin is not None: + image_sitk.SetOrigin(self.origin.tolist()[::-1]) + if self.direction is not None: + image_sitk.SetDirection(self.direction.flatten().tolist()[::-1]) + if self.header is not None: + for key, value in self.header.items(): + image_sitk.SetMetaData(key, value) sitk.WriteImage(image_sitk, filepath) \ No newline at end of file