From f3bf427920feac1e8264c46aa7ece08300fef0dc Mon Sep 17 00:00:00 2001 From: paulojamorim Date: Thu, 15 Oct 2009 18:52:13 +0000 Subject: [PATCH] FIX: Error getting date from dicom (case \_other\DICOM Dornelas\) --- invesalius/reader/dicom.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/invesalius/reader/dicom.py b/invesalius/reader/dicom.py index 33de505..fb70d2b 100644 --- a/invesalius/reader/dicom.py +++ b/invesalius/reader/dicom.py @@ -17,6 +17,7 @@ # PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais # detalhes. #--------------------------------------------------------------------- +from numpy.lib import type_check # In DICOM file format, if multiple values are present for the # "Window Center" (Level) and "Window Width", both attributes @@ -1438,16 +1439,21 @@ class Parser(): def __format_date(self, value): sp1 = value.split(".") - if (len(sp1) > 1): - if (len(sp1[0]) <= 2): - data = time.strptime(value, "%D.%M.%Y") + try: + + if (len(sp1) > 1): + if (len(sp1[0]) <= 2): + data = time.strptime(value, "%D.%M.%Y") + else: + data = time.strptime(value, "%Y.%M.%d") + elif(len(value.split("//")) > 1): + data = time.strptime(value, "%D/%M/%Y") else: - data = time.strptime(value, "%Y.%M.%d") - elif(len(value.split("//")) > 1): - data = time.strptime(value, "%D/%M/%Y") - else: - data = time.strptime(value, "%Y%M%d") - return time.strftime("%d/%M/%Y",data) + data = time.strptime(value, "%Y%M%d") + return time.strftime("%d/%M/%Y",data) + + except(ValueError): + return "" def GetAcquisitionTime(self): """ -- libgit2 0.21.2