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