Commit 7d09e69fc82b0fdaff30d3a43e58f51de0cbcd41
1 parent
baf0e949
Exists in
master
and in
68 other branches
FIX: Error open dicom with orietation images
Showing
1 changed file
with
11 additions
and
3 deletions
Show diff stats
invesalius/reader/dicom.py
... | ... | @@ -1678,7 +1678,11 @@ class Image(object): |
1678 | 1678 | def SetParser(self, parser): |
1679 | 1679 | self.level = parser.GetImageWindowLevel() |
1680 | 1680 | self.window = parser.GetImageWindowWidth() |
1681 | + | |
1681 | 1682 | self.position = parser.GetImagePosition() |
1683 | + if not (self.position): | |
1684 | + self.position = [1, 1, 1] | |
1685 | + | |
1682 | 1686 | self.number = parser.GetImageNumber() |
1683 | 1687 | self.spacing = spacing = parser.GetPixelSpacing() |
1684 | 1688 | self.orientation_label = parser.GetImageOrientationLabel() |
... | ... | @@ -1687,12 +1691,16 @@ class Image(object): |
1687 | 1691 | if (parser.GetImageThickness()): |
1688 | 1692 | spacing.append(parser.GetImageThickness()) |
1689 | 1693 | else: |
1690 | - spacing.append(1.5) | |
1691 | - | |
1694 | + try: | |
1695 | + spacing.append(1.5) | |
1696 | + except(AttributeError): | |
1697 | + spacing = [1, 1, 1] | |
1698 | + | |
1692 | 1699 | spacing[0] = round(spacing[0],2) |
1693 | 1700 | spacing[1] = round(spacing[1],2) |
1694 | 1701 | spacing[2] = round(spacing[2],2) |
1695 | - | |
1702 | + self.spacing = spacing | |
1703 | + | |
1696 | 1704 | try: |
1697 | 1705 | self.type = parser.GetImageType()[2] |
1698 | 1706 | except(IndexError): | ... | ... |