Commit d160d17fc03911711195e5db4735d3cb4cbe5309
1 parent
bc3ba9d1
Exists in
master
and in
68 other branches
FIX: #68 DICOM enconding == None
Showing
1 changed file
with
15 additions
and
8 deletions
Show diff stats
invesalius/reader/dicom.py
@@ -1137,8 +1137,13 @@ class Parser(): | @@ -1137,8 +1137,13 @@ class Parser(): | ||
1137 | data = self.vtkgdcm_reader.GetMedicalImageProperties()\ | 1137 | data = self.vtkgdcm_reader.GetMedicalImageProperties()\ |
1138 | .GetPatientName() | 1138 | .GetPatientName() |
1139 | if (data): | 1139 | if (data): |
1140 | - # Returns a unicode decoded in the own dicom encoding | ||
1141 | - return data.strip().decode(self.GetEncoding()) | 1140 | + name = data.strip() |
1141 | + encoding = self.GetEncoding() | ||
1142 | + if encoding != None: | ||
1143 | + # Returns a unicode decoded in the own dicom encoding | ||
1144 | + return name.decode(encoding) | ||
1145 | + else: | ||
1146 | + return name.strip() | ||
1142 | return "" | 1147 | return "" |
1143 | 1148 | ||
1144 | def GetPatientID(self): | 1149 | def GetPatientID(self): |
@@ -1152,8 +1157,12 @@ class Parser(): | @@ -1152,8 +1157,12 @@ class Parser(): | ||
1152 | data = self.vtkgdcm_reader.GetMedicalImageProperties()\ | 1157 | data = self.vtkgdcm_reader.GetMedicalImageProperties()\ |
1153 | .GetPatientID() | 1158 | .GetPatientID() |
1154 | if (data): | 1159 | if (data): |
1155 | - # Returns a unicode decoded in the own dicom encoding | ||
1156 | - return data.decode(self.GetEncoding()) | 1160 | + encoding = self.GetEncoding() |
1161 | + if encoding != None: | ||
1162 | + # Returns a unicode decoded in the own dicom encoding | ||
1163 | + return data.decode(self.GetEncoding()) | ||
1164 | + else: | ||
1165 | + return data | ||
1157 | return "" | 1166 | return "" |
1158 | 1167 | ||
1159 | 1168 | ||
@@ -1496,13 +1505,11 @@ class Parser(): | @@ -1496,13 +1505,11 @@ class Parser(): | ||
1496 | Return the dicom encoding | 1505 | Return the dicom encoding |
1497 | DICOM standard tag (0x0008, 0x0005) was used. | 1506 | DICOM standard tag (0x0008, 0x0005) was used. |
1498 | """ | 1507 | """ |
1499 | - if self.encoding: | ||
1500 | - return self.encoding | ||
1501 | tag = gdcm.Tag(0x0008, 0x0005) | 1508 | tag = gdcm.Tag(0x0008, 0x0005) |
1502 | ds = self.gdcm_reader.GetFile().GetDataSet() | 1509 | ds = self.gdcm_reader.GetFile().GetDataSet() |
1503 | if ds.FindDataElement(tag): | 1510 | if ds.FindDataElement(tag): |
1504 | - self.encoding = str(ds.GetDataElement(tag).GetValue()) | ||
1505 | - return self.encoding | 1511 | + encoding = str(ds.GetDataElement(tag).GetValue()) |
1512 | + return encoding | ||
1506 | 1513 | ||
1507 | 1514 | ||
1508 | class DicomWriter: | 1515 | class DicomWriter: |