Commit 0e4def2656205ecb9babf1c1fc997eb8fbb021de

Authored by Paulo Henrique Junqueira Amorim
1 parent 0241ef01

FIX: temporary fix latin caracters

invesalius/reader/dicom.py
... ... @@ -186,14 +186,21 @@ class Parser():
186 186  
187 187 filename = path.abspath(filename)
188 188  
  189 + var_file = open("c:\\arquivo.txt","w")
  190 + var_file.write(filename)
  191 + var_file.close()
  192 + #print type(filename)
  193 + #print filename
  194 + #print filename
  195 + #print "____________"
189 196 if path.isfile(filename):
190 197 # Several information can be acquired from DICOM using
191 198 # vtkgdcm.vtkGDCMImageReader.GetMedicalImageProperties()
192 199 # but some tags (such as spacing) can only be achieved
193 200 # with gdcm.ImageReader()
194   -
195 201 # used to parse DICOM files - similar to vtkDICOMParser
196 202 gdcm_reader = gdcm.ImageReader()
  203 + #filename = filename.encode('utf-8')
197 204  
198 205 gdcm_reader.SetFileName(filename)
199 206  
... ...
invesalius/reader/dicom_reader.py
... ... @@ -32,14 +32,14 @@ import dicom_grouper
32 32 import session
33 33  
34 34 def ReadDicomGroup(dir_):
35   -
  35 +
36 36 patient_group = GetDicomGroups(dir_)
37 37 if len(patient_group) > 0:
38 38 filelist, dicom, zspacing = SelectLargerDicomGroup(patient_group)
39 39 filelist = SortFiles(filelist, dicom)
40 40 size = dicom.image.size
41 41 bits = dicom.image.bits_allocad
42   -
  42 +
43 43 imagedata = CreateImageData(filelist, zspacing, size, bits)
44 44 session.Session().project_status = const.NEW_PROJECT
45 45 return imagedata, dicom
... ... @@ -55,7 +55,7 @@ def SelectLargerDicomGroup(patient_group):
55 55 if group.nslices > maxslices:
56 56 maxslices = group.nslices
57 57 larger_group = group
58   -
  58 +
59 59 return larger_group
60 60  
61 61 def SortFiles(filelist, dicom):
... ... @@ -107,7 +107,7 @@ def yGetDicomGroups(directory, recursive=True, gui=True):
107 107 else:
108 108 dirpath, dirnames, filenames = os.walk(directory)
109 109 nfiles = len(filenames)
110   -
  110 +
111 111 counter = 0
112 112 grouper = dicom_grouper.DicomPatientGrouper()
113 113 q = Queue.Queue()
... ... @@ -121,7 +121,7 @@ def yGetDicomGroups(directory, recursive=True, gui=True):
121 121 if recursive:
122 122 for dirpath, dirnames, filenames in os.walk(directory):
123 123 for name in filenames:
124   - filepath = str(os.path.join(dirpath, name))
  124 + filepath = os.path.join(dirpath, name).encode('latin-1')
125 125 counter += 1
126 126 if gui:
127 127 yield (counter,nfiles)
... ... @@ -156,10 +156,10 @@ class ProgressDicomReader:
156 156 def CancelLoad(self, evt_pubsub):
157 157 self.running = False
158 158 self.stoped = True
159   -
  159 +
160 160 def SetWindowEvent(self, frame):
161 161 self.frame = frame
162   -
  162 +
163 163 def SetDirectoryPath(self, path,recursive=True):
164 164 self.running = True
165 165 self.stoped = False
... ... @@ -172,14 +172,14 @@ class ProgressDicomReader:
172 172 ps.Publisher().sendMessage("End dicom load", patient_list)
173 173  
174 174 def GetDicomGroups(self, path, recursive):
175   -
  175 +
176 176 if not const.VTK_WARNING:
177 177 log_path = os.path.join(const.LOG_FOLDER, 'vtkoutput.txt')
178 178 fow = vtk.vtkFileOutputWindow()
179 179 fow.SetFileName(log_path)
180 180 ow = vtk.vtkOutputWindow()
181 181 ow.SetInstance(fow)
182   -
  182 +
183 183 y = yGetDicomGroups(path, recursive)
184 184 for value_progress in y:
185 185 if not self.running:
... ...
invesalius/session.py
... ... @@ -118,10 +118,10 @@ class Session(object):
118 118 config.add_section('paths')
119 119 config.set('paths','homedir',self.homedir)
120 120 config.set('paths','tempdir',self.tempdir)
121   - config.set('paths','last_dicom_folder',self.last_dicom_folder)
  121 + config.set('paths','last_dicom_folder',self.last_dicom_folder.encode('utf-8'))
122 122 path = os.path.join(self.homedir ,
123 123 '.invesalius', 'config.cfg')
124   -
  124 +
125 125 configfile = open(path, 'wb')
126 126 config.write(configfile)
127 127 configfile.close()
... ... @@ -185,6 +185,11 @@ class Session(object):
185 185 self.homedir = config.get('paths','homedir')
186 186 self.tempdir = config.get('paths','tempdir')
187 187 self.last_dicom_folder = config.get('paths','last_dicom_folder')
  188 + self.last_dicom_folder = self.last_dicom_folder.decode('utf-8')
  189 + #print "_______________________________"
  190 + #print self.last_dicom_folder
  191 + #print type(self.last_dicom_folder)
  192 + #print "_______________________________"
188 193 return True
189 194 except(ConfigParser.NoSectionError,
190 195 ConfigParser.NoOptionError,
... ...