Commit 203f403de2d015c8590a6845d62892a825bd57a8

Authored by tfmoraes
1 parent 711eafe8

STL: removed certain prints

invesalius/control.py
... ... @@ -36,6 +36,8 @@ import reader.dicom_reader as dcm
36 36 import reader.analyze_reader as analyze
37 37 import session as ses
38 38  
  39 +from utils import debug
  40 +
39 41 DEFAULT_THRESH_MODE = 0
40 42  
41 43 class Controller():
... ... @@ -147,7 +149,7 @@ class Controller():
147 149  
148 150  
149 151 def ShowDialogCloseProject(self):
150   - utils.debug("ShowDialogCloseProject")
  152 + debug("ShowDialogCloseProject")
151 153 session = ses.Session()
152 154 st = session.project_status
153 155 if st == const.PROJ_CLOSE:
... ... @@ -156,18 +158,18 @@ class Controller():
156 158 if (st == const.PROJ_NEW) or (st == const.PROJ_CHANGE):
157 159 answer = dialog.SaveChangesDialog(filename)
158 160 if not answer:
159   - utils.debug("Close without changes")
  161 + debug("Close without changes")
160 162 self.CloseProject()
161 163 ps.Publisher().sendMessage("Enable state project", False)
162 164 ps.Publisher().sendMessage('Set project name')
163 165 elif answer == 1:
164 166 self.ShowDialogSaveProject()
165   - utils.debug("Save changes and close")
  167 + debug("Save changes and close")
166 168 self.CloseProject()
167 169 ps.Publisher().sendMessage("Enable state project", False)
168 170 ps.Publisher().sendMessage('Set project name')
169 171 elif answer == -1:
170   - utils.debug("Cancel")
  172 + debug("Cancel")
171 173 else:
172 174 self.CloseProject()
173 175 ps.Publisher().sendMessage("Enable state project", False)
... ... @@ -307,7 +309,7 @@ class Controller():
307 309 self.CreateAnalyzeProject(imagedata)
308 310 # OPTION 3: Nothing...
309 311 else:
310   - utils.debug("No medical images found on given directory")
  312 + debug("No medical images found on given directory")
311 313 return
312 314 self.LoadProject()
313 315 ps.Publisher().sendMessage("Enable state project", True)
... ... @@ -392,7 +394,7 @@ class Controller():
392 394 interval += 1
393 395 filelist = dicom_group.GetFilenameList()[::interval]
394 396 if not filelist:
395   - utils.debug("Not used the IPPSorter")
  397 + debug("Not used the IPPSorter")
396 398 filelist = [i.image.file for i in dicom_group.GetHandSortedList()[::interval]]
397 399  
398 400  
... ...
invesalius/data/imagedata_utils.py
... ... @@ -227,7 +227,7 @@ def CreateImageData(filelist, zspacing, size, bits):
227 227 x,y = size
228 228 px, py = utils.PredictingMemory(len(filelist), x, y, bits)
229 229  
230   - print "Image Resized to >>>", px, "x", py
  230 + utils.debug("Image Resized to >>> %f x %f" % (px, py))
231 231  
232 232 if (x == px) and (y == py):
233 233 const.REDUCE_IMAGEDATA_QUALITY = 0
... ... @@ -294,35 +294,61 @@ def CreateImageData(filelist, zspacing, size, bits):
294 294 return imagedata
295 295  
296 296  
297   -"""
298 297 class ImageCreator:
299 298 def __init__(self):
300   - ps.Publisher().sendMessage("Cancel imagedata load", self.CancelImageDataLoad)
  299 + self.running = True
  300 + ps.Publisher().subscribe(self.CancelImageDataLoad, "Cancel DICOM load")
301 301  
302 302 def CancelImageDataLoad(self, evt_pusub):
303   - self.running = evt_pusub.data
  303 + utils.debug("Canceling")
  304 + self.running = False
  305 +
  306 + def CreateImageData(self, filelist, zspacing, size, bits):
  307 + message = _("Generating multiplanar visualization...")
  308 +
  309 + if not const.VTK_WARNING:
  310 + log_path = os.path.join(const.LOG_FOLDER, 'vtkoutput.txt')
  311 + fow = vtk.vtkFileOutputWindow()
  312 + fow.SetFileName(log_path)
  313 + ow = vtk.vtkOutputWindow()
  314 + ow.SetInstance(fow)
  315 +
  316 + x,y = size
  317 + px, py = utils.PredictingMemory(len(filelist), x, y, bits)
  318 + utils.debug("Image Resized to >>> %f x %f" % (px, py))
  319 +
  320 + if (x == px) and (y == py):
  321 + const.REDUCE_IMAGEDATA_QUALITY = 0
  322 + else:
  323 + const.REDUCE_IMAGEDATA_QUALITY = 1
304 324  
305   - def CreateImageData(filelist, zspacing):
306   - message = "Generating multiplanar visualization..."
307 325 if not(const.REDUCE_IMAGEDATA_QUALITY):
308   - update_progress= vtk_utils.ShowProgress(1)
  326 + update_progress= vtk_utils.ShowProgress(1, dialog_type = "ProgressDialog")
309 327  
310 328 array = vtk.vtkStringArray()
311 329 for x in xrange(len(filelist)):
  330 + if not self.running:
  331 + return False
312 332 array.InsertValue(x,filelist[x])
313 333  
  334 + if not self.running:
  335 + return False
314 336 reader = vtkgdcm.vtkGDCMImageReader()
315 337 reader.SetFileNames(array)
316 338 reader.AddObserver("ProgressEvent", lambda obj,evt:
317 339 update_progress(reader,message))
318 340 reader.Update()
319 341  
  342 + if not self.running:
  343 + reader.AbortExecuteOn()
  344 + return False
320 345 # The zpacing is a DicomGroup property, so we need to set it
321 346 imagedata = vtk.vtkImageData()
322 347 imagedata.DeepCopy(reader.GetOutput())
323 348 spacing = imagedata.GetSpacing()
324 349 imagedata.SetSpacing(spacing[0], spacing[1], zspacing)
325 350 else:
  351 +
326 352 update_progress= vtk_utils.ShowProgress(2*len(filelist),
327 353 dialog_type = "ProgressDialog")
328 354  
... ... @@ -330,11 +356,14 @@ class ImageCreator:
330 356 appender = vtk.vtkImageAppend()
331 357 appender.SetAppendAxis(2) #Define Stack in Z
332 358  
  359 +
333 360 # Reformat each slice
334 361 for x in xrange(len(filelist)):
335 362 # TODO: We need to check this automatically according
336 363 # to each computer's architecture
337 364 # If the resolution of the matrix is too large
  365 + if not self.running:
  366 + return False
338 367 reader = vtkgdcm.vtkGDCMImageReader()
339 368 reader.SetFileName(filelist[x])
340 369 reader.AddObserver("ProgressEvent", lambda obj,evt:
... ... @@ -342,15 +371,15 @@ class ImageCreator:
342 371 reader.Update()
343 372  
344 373 #Resample image in x,y dimension
345   -
346   - slice_imagedata = ResampleImage2D(reader.GetOutput(), 256, update_progress)
347   -
  374 + slice_imagedata = ResampleImage2D(reader.GetOutput(), px, py, update_progress)
348 375 #Stack images in Z axes
349 376 appender.AddInput(slice_imagedata)
350 377 #appender.AddObserver("ProgressEvent", lambda obj,evt:update_progress(appender))
351 378 appender.Update()
352 379  
353 380 # The zpacing is a DicomGroup property, so we need to set it
  381 + if not self.running:
  382 + return False
354 383 imagedata = vtk.vtkImageData()
355 384 imagedata.DeepCopy(appender.GetOutput())
356 385 spacing = imagedata.GetSpacing()
... ... @@ -362,5 +391,3 @@ class ImageCreator:
362 391 imagedata.Update()
363 392  
364 393 return imagedata
365   -"""
366   -
... ...
invesalius/data/slice_.py
... ... @@ -581,8 +581,8 @@ class Slice(object):
581 581 mask = mask_dict[key]
582 582  
583 583 # update gui related to mask
584   - print "__load_masks"
585   - print 'THRESHOLD_RANGE', mask.threshold_range
  584 + utils.debug("__load_masks")
  585 + utils.debug('THRESHOLD_RANGE %s', mask.threshold_range)
586 586 ps.Publisher().sendMessage('Add mask',
587 587 (mask.index,
588 588 mask.name,
... ...
invesalius/data/viewer_slice.py
... ... @@ -35,6 +35,7 @@ import data.slice_ as sl
35 35 import data.vtk_utils as vtku
36 36 import project
37 37 import slice_data as sd
  38 +import utils
38 39  
39 40 ID_TO_TOOL_ITEM = {}
40 41 STR_WL = "WL: %d WW: %d"
... ... @@ -286,14 +287,12 @@ class Viewer(wx.Panel):
286 287 style.AddObserver("RightButtonPressEvent", self.QuitRubberBandZoom)
287 288  
288 289 def OnRightClick(self, evt, obj):
289   - print "OnRightClick"
290 290 self.last_position_mouse_move = \
291 291 self.interactor.GetLastEventPosition()
292 292  
293 293 self.right_pressed = 1
294 294  
295 295 def OnReleaseRightButton(self, evt, obj):
296   - print "OnReleaseRightButton"
297 296 self.right_pressed = 0
298 297 ps.Publisher().sendMessage('Update slice viewer')
299 298  
... ... @@ -301,7 +300,6 @@ class Viewer(wx.Panel):
301 300 self.left_pressed = 1
302 301  
303 302 def OnZoomLeftClick(self, evt, obj):
304   - print "OnZoomLeftClick"
305 303 evt.StartDolly()
306 304  
307 305 def OnReleaseLeftButton(self, evt, obj):
... ... @@ -383,12 +381,10 @@ class Viewer(wx.Panel):
383 381  
384 382 def OnZoomMoveLeft(self, evt, obj):
385 383 if self.left_pressed:
386   - print "OnZoomMoveLeft:"
387 384 evt.Dolly()
388 385 evt.OnRightButtonDown()
389 386  
390 387 def OnVtkRightRelease(self, evt, obj):
391   - print "On VTK"
392 388 evt.OnRightButtonUp()
393 389  
394 390  
... ... @@ -688,12 +684,10 @@ class Viewer(wx.Panel):
688 684  
689 685  
690 686 if (self.right_pressed):
691   - print "OnZoomMoveRight"
692 687 evt.Dolly()
693 688 evt.OnRightButtonDown()
694 689  
695 690 def OnZoomRightClick(self, evt, obj):
696   - print "OnZoomRightClick"
697 691 evt.StartDolly()
698 692  
699 693  
... ... @@ -752,8 +746,6 @@ class Viewer(wx.Panel):
752 746 coord[index] = extent_max[index]
753 747 elif coord[index] < extent_min[index]:
754 748 coord[index] = extent_min[index]
755   - #print "New coordinate: ", coord
756   -
757 749 return coord
758 750  
759 751 def get_coordinate_cursor(self):
... ... @@ -854,9 +846,7 @@ class Viewer(wx.Panel):
854 846 "SAGITAL": const.SAGITAL}
855 847  
856 848 if id == dict[self.orientation]:
857   - print "ok"
858 849 if filetype == const.FILETYPE_POV:
859   - print 1
860 850 renwin = self.interactor.GetRenderWindow()
861 851 image = vtk.vtkWindowToImageFilter()
862 852 image.SetInput(renwin)
... ... @@ -866,7 +856,6 @@ class Viewer(wx.Panel):
866 856 writer.Write()
867 857 return
868 858 else:
869   - print 2
870 859 #Use tiling to generate a large rendering.
871 860 image = vtk.vtkRenderLargeImage()
872 861 image.SetInput(self.ren)
... ... @@ -877,19 +866,14 @@ class Viewer(wx.Panel):
877 866  
878 867 # write image file
879 868 if (filetype == const.FILETYPE_BMP):
880   - print 3
881 869 writer = vtk.vtkBMPWriter()
882 870 elif (filetype == const.FILETYPE_JPG):
883   - print 4
884 871 writer = vtk.vtkJPEGWriter()
885 872 elif (filetype == const.FILETYPE_PNG):
886   - print 5
887 873 writer = vtk.vtkPNGWriter()
888 874 elif (filetype == const.FILETYPE_PS):
889   - print 6
890 875 writer = vtk.vtkPostScriptWriter()
891 876 elif (filetype == const.FILETYPE_TIF):
892   - print 7
893 877 writer = vtk.vtkTIFFWriter()
894 878 filename = "%s.tif"%filename.strip(".tif")
895 879  
... ... @@ -904,11 +888,9 @@ class Viewer(wx.Panel):
904 888 ps.Publisher().sendMessage('End busy cursor')
905 889  
906 890 def OnShowText(self, pubsub_evt):
907   - print "OnShowText"
908 891 self.ShowTextActors()
909 892  
910 893 def OnHideText(self, pubsub_evt):
911   - print "OnHideText"
912 894 self.HideTextActors()
913 895  
914 896  
... ... @@ -939,7 +921,6 @@ class Viewer(wx.Panel):
939 921  
940 922  
941 923 def ChangeBrushOperation(self, pubsub_evt):
942   - #print pubsub_evt.data
943 924 self._brush_cursor_op = pubsub_evt.data
944 925  
945 926 def __bind_events_wx(self):
... ... @@ -1005,8 +986,6 @@ class Viewer(wx.Panel):
1005 986 if i == self.layout[0] - 1:
1006 987 style = style | sd.BORDER_RIGHT
1007 988  
1008   - print "->Style", style
1009   -
1010 989 slice_data.SetBorderStyle(style)
1011 990 n += 1
1012 991  
... ... @@ -1130,21 +1109,10 @@ class Viewer(wx.Panel):
1130 1109 extent = slice_data.actor.GetDisplayExtent()
1131 1110 cam = slice_data.renderer.GetActiveCamera()
1132 1111  
1133   - #print
1134   - #print self.orientation
1135   - #print x, y, z
1136   - #print actor_bound
1137   - #print "ViewUp", cam.GetViewUp()
1138   - #print "Position", cam.GetPosition()
1139   - #print "Orientation", cam.GetOrientation()
1140   - #print "Focal Point", cam.GetFocalPoint()
1141   -
1142 1112 vCamera = numpy.array(cam.GetPosition()) - numpy.array(cam.GetFocalPoint())
1143 1113 n_vCamera = vCamera / numpy.linalg.norm(vCamera)
1144   - #print "Normalized", n_vCamera
1145 1114  
1146 1115 pos = [j + 0.01 * i for i,j in zip(n_vCamera, (x, y, z))]
1147   - #print "posicao", pos
1148 1116  
1149 1117 #yz = [x + abs(x * 0.001), y, z]
1150 1118 #xz = [x, y - abs(y * 0.001), z]
... ... @@ -1174,7 +1142,6 @@ class Viewer(wx.Panel):
1174 1142 # elif orientation == "CORONAL":
1175 1143 # pos[1] -= abs(pos[1] * 0.001)
1176 1144  
1177   - #print ">POS", pos
1178 1145  
1179 1146 #pos = [x, y, z]
1180 1147 #if orientation == "AXIAL":
... ...
invesalius/data/viewer_volume.py
... ... @@ -25,10 +25,10 @@ from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor
25 25 import wx.lib.pubsub as ps
26 26  
27 27 import constants as const
28   -import project as prj
29 28 import data.vtk_utils as vtku
30   -from gui.widgets.clut_raycasting import CLUTRaycastingWidget
  29 +import project as prj
31 30 import style as st
  31 +import utils
32 32  
33 33 class Viewer(wx.Panel):
34 34 def __init__(self, parent):
... ... @@ -274,7 +274,6 @@ class Viewer(wx.Panel):
274 274  
275 275 # Check each event available for each mode
276 276 for event in action[state]:
277   - print event
278 277 # Bind event
279 278 style.AddObserver(event,action[state][event])
280 279  
... ... @@ -439,14 +438,14 @@ class Viewer(wx.Panel):
439 438 self.interactor.Render()
440 439  
441 440 def RemoveActor(self, pubsub_evt):
442   - print "RemoveActor"
  441 + utils.debug("RemoveActor")
443 442 actor = pubsub_evt.data
444 443 ren = self.ren
445 444 ren.RemoveActor(actor)
446 445 self.interactor.Render()
447 446  
448 447 def RemoveAllActor(self, pubsub_evt):
449   - print "RemoveAllActor"
  448 + utils.debug("RemoveAllActor")
450 449 self.ren.RemoveAllProps()
451 450 ps.Publisher().sendMessage('Render volume viewer')
452 451  
... ... @@ -503,7 +502,6 @@ class Viewer(wx.Panel):
503 502 self.interactor.Render()
504 503  
505 504 def ShowOrientationCube(self):
506   - print "ORIENTATION CUBE!"
507 505 cube = vtk.vtkAnnotatedCubeActor()
508 506 cube.GetXMinusFaceProperty().SetColor(1,0,0)
509 507 cube.GetXPlusFaceProperty().SetColor(1,0,0)
... ... @@ -696,7 +694,6 @@ class SlicePlane:
696 694 a.SetBackfaceCulling(0)
697 695 c = self.plane_x.GetTexture()
698 696 c.SetRestrictPowerOf2ImageSmaller(1)
699   - #print dir(a)
700 697  
701 698 elif(self.original_orientation == const.SAGITAL):
702 699 if(label == "Axial"):
... ...
invesalius/data/volume.py
... ... @@ -418,17 +418,13 @@ class Volume():
418 418 def SetTypeRaycasting(self):
419 419 if self.volume_mapper.IsA("vtkFixedPointVolumeRayCastMapper"):
420 420 if self.config.get('MIP', False):
421   - print "MIP"
422 421 self.volume_mapper.SetBlendModeToMaximumIntensity()
423 422 else:
424   - print "Composite"
425 423 self.volume_mapper.SetBlendModeToComposite()
426 424 else:
427 425 if self.config.get('MIP', False):
428   - print "MIP"
429 426 raycasting_function = vtk.vtkVolumeRayCastMIPFunction()
430 427 else:
431   - print "Composite"
432 428 raycasting_function = vtk.vtkVolumeRayCastCompositeFunction()
433 429 raycasting_function.SetCompositeMethodToInterpolateFirst()
434 430 self.volume_mapper.SetVolumeRayCastFunction(raycasting_function)
... ... @@ -551,20 +547,16 @@ class Volume():
551 547 (volume, colour, (self.ww, self.wl)))
552 548  
553 549 def OnEnableTool(self, pubsub_evt):
554   - print "OnEnableTool"
555 550 tool_name, enable = pubsub_evt.data
556 551 if tool_name == _("Cut plane"):
557 552 if self.plane:
558 553 if enable:
559   - print "Enable"
560 554 self.plane_on = True
561 555 self.plane.Enable()
562 556 else:
563   - print "Disable"
564 557 self.plane_on = False
565 558 self.plane.Disable()
566 559 else:
567   - print "Enable"
568 560 self.final_imagedata.Update()
569 561 self.plane_on = True
570 562 self.plane = CutPlane(self.final_imagedata,
... ...
invesalius/gui/default_viewers.py
... ... @@ -262,7 +262,6 @@ class VolumeInteraction(wx.Panel):
262 262 self.aui_manager.Update()
263 263  
264 264 def OnPointChanged(self, evt):
265   - print "Removed"
266 265 ps.Publisher.sendMessage('Set raycasting refresh', None)
267 266 ps.Publisher.sendMessage('Set raycasting curve', evt.GetCurve())
268 267 ps.Publisher().sendMessage('Render volume viewer')
... ... @@ -278,7 +277,6 @@ class VolumeInteraction(wx.Panel):
278 277  
279 278 def OnSetRaycastPreset(self, evt_pubsub):
280 279 preset = project.Project().raycasting_preset
281   - print "Preset >>>", preset
282 280 p = self.aui_manager.GetPane(self.clut_raycasting)
283 281 self.clut_raycasting.SetRaycastPreset(preset)
284 282 if self.clut_raycasting.to_draw_points and \
... ... @@ -542,13 +540,11 @@ class VolumeToolPanel(wx.Panel):
542 540 # if i is not item:
543 541 # i.Check(0)
544 542 if not TOOL_STATE[id]:
545   - print "item is checked"
546 543 ps.Publisher().sendMessage('Enable raycasting tool',
547 544 [ID_TO_TOOL[id],1])
548 545 TOOL_STATE[id] = True
549 546 item.Check(1)
550 547 else:
551   - print "item is not checked"
552 548 ps.Publisher().sendMessage('Enable raycasting tool',
553 549 [ID_TO_TOOL[id],0])
554 550 TOOL_STATE[id] = False
... ...
invesalius/gui/dialogs.py
... ... @@ -28,6 +28,7 @@ import wx.lib.pubsub as ps
28 28 import constants as const
29 29 import project as proj
30 30 import session as ses
  31 +import utils
31 32  
32 33  
33 34 class NumberDialog(wx.Dialog):
... ... @@ -275,7 +276,7 @@ def SaveChangesDialog__Old(filename):
275 276  
276 277  
277 278 def ImportEmptyDirectory(dirpath):
278   - msg = _("%s is an empty directory.") % dirpath
  279 + msg = _("%s is an empty directory.") % dirpath.decode("utf-8")
279 280 if sys.platform == 'darwin':
280 281 dlg = wx.MessageDialog(None, "",
281 282 msg,
... ... @@ -532,7 +533,7 @@ def ExportPicture(type_=&quot;&quot;):
532 533 4: const.FILETYPE_POV,
533 534 5: const.FILETYPE_TIF}
534 535  
535   - print "ExportPicture"
  536 + utils.debug("ExportPicture")
536 537 project = proj.Project()
537 538  
538 539 if sys.platform == 'win32':
... ... @@ -554,7 +555,6 @@ def ExportPicture(type_=&quot;&quot;):
554 555 filetype = INDEX_TO_TYPE[filetype_index]
555 556 extension = INDEX_TO_EXTENSION[filetype_index]
556 557 filename = dlg.GetPath()
557   - print "filename", filename
558 558 if sys.platform != 'win32':
559 559 if filename.split(".")[-1] != extension:
560 560 filename = filename + "."+ extension
... ...
invesalius/gui/dicom_preview_panel.py
... ... @@ -32,6 +32,7 @@ from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor
32 32 import constants as const
33 33 from reader import dicom_reader
34 34 import data.vtk_utils as vtku
  35 +import utils
35 36  
36 37 NROWS = 3
37 38 NCOLS = 6
... ... @@ -107,7 +108,6 @@ class DicomInfo(object):
107 108 if self._preview:
108 109 return self._preview
109 110 else:
110   - print "First time!"
111 111 colorer = vtk.vtkImageMapToWindowLevelColors()
112 112 colorer.SetInput(self.dicom.image.imagedata)
113 113 colorer.SetWindow(float(self.dicom.image.window))
... ... @@ -256,7 +256,6 @@ class Preview(wx.Panel):
256 256 if not self.select_on:
257 257 #c = wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DHILIGHT)
258 258 c = wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE)
259   - print c
260 259 self.SetBackgroundColour(c)
261 260  
262 261 def OnLeave(self, evt):
... ... @@ -265,7 +264,6 @@ class Preview(wx.Panel):
265 264 self.SetBackgroundColour(c)
266 265  
267 266 def OnSelect(self, evt):
268   - print "OnSelect"
269 267 self.select_on = True
270 268 self.dicom_info.selected = True
271 269 ##c = wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNHIGHLIGHT)
... ... @@ -287,7 +285,6 @@ class Preview(wx.Panel):
287 285 my_evt.SetSelectedID(self.dicom_info.id)
288 286 my_evt.SetItemData(self.dicom_info.dicom)
289 287 my_evt.SetEventObject(self)
290   - print "patient", self.dicom_info.dicom.patient
291 288 self.GetEventHandler().ProcessEvent(my_evt)
292 289  
293 290 def OnSize(self, evt):
... ... @@ -370,7 +367,6 @@ class DicomPreviewSeries(wx.Panel):
370 367 self.Bind(wx.EVT_MOUSEWHEEL, self.OnWheel)
371 368  
372 369 def OnSelect(self, evt):
373   - print dir(evt)
374 370 my_evt = SerieEvent(myEVT_CLICK_SERIE, self.GetId())
375 371 my_evt.SetSelectedID(evt.GetSelectID())
376 372 my_evt.SetItemData(evt.GetItemData())
... ... @@ -379,7 +375,6 @@ class DicomPreviewSeries(wx.Panel):
379 375 self.selected_dicom.selected = self.selected_dicom is \
380 376 evt.GetEventObject().dicom_info
381 377 self.selected_panel.select_on = self.selected_panel is evt.GetEventObject()
382   - print "Unselecting a panel", self.selected_panel.select_on
383 378 self.selected_panel.Select()
384 379 self.selected_panel = evt.GetEventObject()
385 380 self.selected_dicom = self.selected_panel.dicom_info
... ... @@ -416,7 +411,7 @@ class DicomPreviewSeries(wx.Panel):
416 411 try:
417 412 self.previews[-i-1].Hide()
418 413 except IndexError:
419   - #print "doesn't exist!"
  414 + utils.debug("doesn't exist!")
420 415 pass
421 416 self.nhidden_last_display = final-len(self.files)
422 417 else:
... ... @@ -425,16 +420,14 @@ class DicomPreviewSeries(wx.Panel):
425 420 try:
426 421 self.previews[-i-1].Show()
427 422 except IndexError:
428   - #print "doesn't exist!"
  423 + utils.debug("doesn't exist!")
429 424 pass
430 425 self.nhidden_last_display = 0
431 426  
432 427 for f, p in zip(self.files[initial:final], self.previews):
433   - #print "f", f
434 428 p.SetDicomToPreview(f)
435 429 if f.selected:
436 430 self.selected_panel = p
437   - #p.interactor.Render()
438 431  
439 432 for f, p in zip(self.files[initial:final], self.previews):
440 433 p.Show()
... ... @@ -449,7 +442,6 @@ class DicomPreviewSeries(wx.Panel):
449 442 self._display_previews()
450 443  
451 444 def OnWheel(self, evt):
452   - print "OnWheel"
453 445 d = evt.GetWheelDelta() / evt.GetWheelRotation()
454 446 self.scroll.SetThumbPosition(self.scroll.GetThumbPosition() - d)
455 447 self.OnScroll()
... ... @@ -506,7 +498,7 @@ class DicomPreviewSlice(wx.Panel):
506 498 self.Bind(wx.EVT_MOUSEWHEEL, self.OnWheel)
507 499  
508 500 def SetDicomDirectory(self, directory):
509   - print "Setting Dicom Directory", directory
  501 + utils.debug("Setting Dicom Directory %s" % directory)
510 502 self.directory = directory
511 503 self.series = dicom_reader.GetSeries(directory)[0]
512 504  
... ... @@ -561,16 +553,13 @@ class DicomPreviewSlice(wx.Panel):
561 553 def _display_previews(self):
562 554 initial = self.displayed_position * NCOLS
563 555 final = initial + NUM_PREVIEWS
564   - print "len:", len(self.files)
565 556  
566 557 if len(self.files) < final:
567 558 for i in xrange(final-len(self.files)):
568   - print "hide ", i
569 559 try:
570 560 self.previews[-i-1].Hide()
571 561 except IndexError:
572   - #print "doesn't exist!"
573   - pass
  562 + utils.debug("doesn't exist!")
574 563 self.nhidden_last_display = final-len(self.files)
575 564 else:
576 565 if self.nhidden_last_display:
... ... @@ -578,8 +567,7 @@ class DicomPreviewSlice(wx.Panel):
578 567 try:
579 568 self.previews[-i-1].Show()
580 569 except IndexError:
581   - #print "doesn't exist!"
582   - pass
  570 + utils.debug("doesn't exist!")
583 571 self.nhidden_last_display = 0
584 572  
585 573 for f, p in zip(self.files[initial:final], self.previews):
... ... @@ -592,7 +580,6 @@ class DicomPreviewSlice(wx.Panel):
592 580 p.Show()
593 581  
594 582 def OnPreviewClick(self, evt):
595   - print "Hey man, you've clicked over me"
596 583 my_evt = SerieEvent(myEVT_CLICK_SLICE, self.GetId())
597 584 my_evt.SetSelectedID(evt.GetSelectID())
598 585 my_evt.SetItemData(evt.GetItemData())
... ... @@ -601,7 +588,6 @@ class DicomPreviewSlice(wx.Panel):
601 588 self.selected_dicom.selected = self.selected_dicom is \
602 589 evt.GetEventObject().dicom_info
603 590 self.selected_panel.select_on = self.selected_panel is evt.GetEventObject()
604   - print "Unselecting a panel", self.selected_panel.select_on
605 591 self.selected_panel.Select()
606 592 self.selected_panel = evt.GetEventObject()
607 593 self.selected_dicom = self.selected_panel.dicom_info
... ... @@ -617,7 +603,6 @@ class DicomPreviewSlice(wx.Panel):
617 603 self._display_previews()
618 604  
619 605 def OnWheel(self, evt):
620   - print "OnWheel"
621 606 d = evt.GetWheelDelta() / evt.GetWheelRotation()
622 607 self.scroll.SetThumbPosition(self.scroll.GetThumbPosition() - d)
623 608 self.OnScroll()
... ... @@ -747,7 +732,7 @@ class SingleImagePreview(wx.Panel):
747 732 #TODO: temporary fix necessary in the Windows XP 64 Bits
748 733 #BUG in wxWidgets http://trac.wxwidgets.org/ticket/10896
749 734 except(wx._core.PyAssertionError):
750   - print "wx._core.PyAssertionError"
  735 + utils.debug("wx._core.PyAssertionError")
751 736 finally:
752 737 wx.CallAfter(self.OnRun)
753 738  
... ... @@ -757,12 +742,10 @@ class SingleImagePreview(wx.Panel):
757 742 self.nimages = len(self.dicom_list)
758 743 # GUI
759 744 self.slider.SetMax(self.nimages-1)
760   - print self.nimages
761 745 self.slider.SetValue(0)
762 746 self.ShowSlice()
763 747  
764 748 def ShowSlice(self, index = 0):
765   - print "ShowSlice"
766 749 dicom = self.dicom_list[index]
767 750  
768 751 # UPDATE GUI
... ... @@ -773,7 +756,6 @@ class SingleImagePreview(wx.Panel):
773 756 ## Text related to slice position
774 757 value1 = STR_SPC %(dicom.image.spacing[2])
775 758 value2 = STR_LOCAL %(dicom.image.position[2])
776   - print "Este eh o meu tipo", type(value1)
777 759 value = "%s\n%s" %(value1, value2)
778 760 self.text_image_location.SetValue(value)
779 761  
... ... @@ -802,7 +784,3 @@ class SingleImagePreview(wx.Panel):
802 784  
803 785 # Setting slider position
804 786 self.slider.SetValue(index)
805   -
806   - def __del__(self):
807   - print "---------> morri"
808   -
... ...
invesalius/gui/frame.py
... ... @@ -32,6 +32,7 @@ import gui.dialogs as dlg
32 32 import import_panel as imp
33 33 import project as prj
34 34 import session as ses
  35 +import utils
35 36  
36 37 # Object toolbar
37 38 #OBJ_TOOLS = [ID_ZOOM, ID_ZOOM_SELECT, ID_ROTATE, ID_MOVE,
... ... @@ -200,7 +201,7 @@ class Frame(wx.Frame):
200 201 aui_manager.Update()
201 202  
202 203 def HideImportPanel(self, evt_pubsub):
203   - print "HideImportPanel"
  204 + utils.debug("HideImportPanel")
204 205 aui_manager = self.aui_manager
205 206 aui_manager.GetPane("Import").Show(0)
206 207 aui_manager.GetPane("Data").Show(0)
... ... @@ -208,7 +209,7 @@ class Frame(wx.Frame):
208 209 aui_manager.Update()
209 210  
210 211 def ShowContentPanel(self, evt_pubsub):
211   - print "ShowContentPanel"
  212 + utils.debug("ShowContentPanel")
212 213 ps.Publisher().sendMessage("Set layout button full")
213 214 aui_manager = self.aui_manager
214 215 aui_manager.GetPane("Import").Show(0)
... ... @@ -264,16 +265,15 @@ class Frame(wx.Frame):
264 265 ps.Publisher().sendMessage('Show save dialog', False)
265 266  
266 267 def CloseProject(self):
267   - print "CloseProject"
  268 + utils.debug("CloseProject")
268 269 ps.Publisher().sendMessage('Close Project')
269 270  
270 271 def OnExit(self, event):
271   - print "OnExit"
272 272 self.Exit()
273 273 event.Skip()
274 274  
275 275 def Exit(self):
276   - print "Exit"
  276 + utils.debug("Exit")
277 277 ps.Publisher().sendMessage('Close Project')
278 278  
279 279 def ShowTask(self, pubsub_evt):
... ... @@ -284,7 +284,6 @@ class Frame(wx.Frame):
284 284 self.aui_manager.GetPane("Tasks").Hide()
285 285 self.aui_manager.Update()
286 286  
287   -
288 287 #def OnClose(self):
289 288 # # TODO: implement this, based on wx.Demo
290 289 # pass
... ... @@ -387,9 +386,7 @@ class MenuBar(wx.MenuBar):
387 386 self.SetStateProjectClose()
388 387  
389 388 def OnEnableState(self, pubsub_evt):
390   - print "----- OnEnableState"
391 389 state = pubsub_evt.data
392   - print "state", state
393 390 if state:
394 391 self.SetStateProjectOpen()
395 392 else:
... ... @@ -473,7 +470,7 @@ class StatusBar(wx.StatusBar):
473 470 #TODO: temporary fix necessary in the Windows XP 64 Bits
474 471 #BUG in wxWidgets http://trac.wxwidgets.org/ticket/10896
475 472 except(wx._core.PyAssertionError):
476   - print "wx._core.PyAssertionError"
  473 + utils.debug("wx._core.PyAssertionError")
477 474  
478 475 def UpdateStatusLabel(self, pubsub_evt):
479 476 label = pubsub_evt.data
... ...
invesalius/gui/import_panel.py
... ... @@ -152,10 +152,10 @@ class InnerPanel(wx.Panel):
152 152 self.image_panel.SetSerie(group)
153 153  
154 154 def OnSelectSlice(self, evt):
155   - print "You've selected the slice", evt.GetSelectID()
  155 + pass
156 156  
157 157 def OnSelectPatient(self, evt):
158   - print "You've selected the patient", evt.GetSelectID()
  158 + pass
159 159  
160 160 def OnDblClickTextPanel(self, evt):
161 161 group = evt.GetItemData()
... ... @@ -286,10 +286,7 @@ class TextPanel(wx.Panel):
286 286 dicom.acquisition.serie_number)] = child
287 287  
288 288 tree.Expand(self.root)
289   -
290 289 tree.SelectItem(parent_select)
291   - print "parent select", parent_select
292   -
293 290 tree.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate)
294 291 tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged)
295 292  
... ... @@ -372,12 +369,9 @@ class ImagePanel(wx.Panel):
372 369 self.text_panel.Bind(EVT_SELECT_SLICE, self.OnSelectSlice)
373 370  
374 371 def OnSelectSerie(self, evt):
375   - print "Hi, You selected Serie"
376 372 evt.Skip()
377 373  
378 374 def OnSelectSlice(self, evt):
379   - print "Hi, You selected slice"
380   - print "Selected ID", evt.GetSelectID()
381 375 self.image_panel.dicom_preview.ShowSlice(evt.GetSelectID())
382 376 evt.Skip()
383 377  
... ... @@ -437,7 +431,6 @@ class SeriesPanel(wx.Panel):
437 431 self.Update()
438 432  
439 433 def OnSelectSerie(self, evt):
440   - print "Hey, You selected a serie"
441 434 serie = evt.GetItemData()
442 435 data = evt.GetItemData()
443 436  
... ... @@ -454,8 +447,6 @@ class SeriesPanel(wx.Panel):
454 447 self.Update()
455 448  
456 449 def OnSelectSlice(self, evt):
457   - print "Hey, Ho, Let's go", evt.GetSelectID()
458   -
459 450 my_evt = SelectEvent(myEVT_SELECT_SLICE, self.GetId())
460 451 my_evt.SetSelectedID(evt.GetSelectID())
461 452 my_evt.SetItemData(evt.GetItemData())
... ... @@ -481,7 +472,6 @@ class SlicePanel(wx.Panel):
481 472  
482 473 def __init_gui(self):
483 474 self.SetBackgroundColour((255,255,255))
484   - print "----------------------------"
485 475 self.dicom_preview = dpp.SingleImagePreview(self)
486 476  
487 477 sizer = wx.BoxSizer(wx.VERTICAL)
... ...
invesalius/gui/task_slice.py
... ... @@ -408,6 +408,7 @@ class MaskProperties(wx.Panel):
408 408  
409 409 def SetThresholdModes(self, pubsub_evt):
410 410 (thresh_modes_names, default_thresh) = pubsub_evt.data
  411 + print pubsub_evt.data
411 412 self.combo_thresh.SetItems(thresh_modes_names)
412 413 if isinstance(default_thresh, int):
413 414 self.combo_thresh.SetSelection(default_thresh)
... ... @@ -417,10 +418,12 @@ class MaskProperties(wx.Panel):
417 418 self.combo_thresh.SetSelection(3)
418 419 thresh_min, thresh_max = default_thresh
419 420  
  421 + print "Este e threshold", thresh_min, thresh_max
420 422 self.gradient.SetMinValue(thresh_min)
421 423 self.gradient.SetMaxValue(thresh_max)
422 424  
423 425 def SetThresholdBounds(self, pubsub_evt):
  426 + print ">>>Threshold Limits", pubsub_evt.data
424 427 thresh_min = pubsub_evt.data[0]
425 428 thresh_max = pubsub_evt.data[1]
426 429 self.gradient.SetMinRange(thresh_min)
... ...
invesalius/gui/widgets/gradient.py
... ... @@ -582,6 +582,7 @@ class GradientSlider(wx.Panel):
582 582 self.GradientPanel.Refresh()
583 583  
584 584 def SetMaxRange(self, value):
  585 + print "Setting max range ", value
585 586 self.SliderData.SetMaxRange(value)
586 587 self.SpinMin.SetMax(value)
587 588 self.SpinMax.SetMax(value)
... ...
invesalius/invesalius.py
... ... @@ -25,6 +25,7 @@ import sys
25 25 import gui.language_dialog as lang_dlg
26 26 import i18n
27 27 from session import Session
  28 +import utils
28 29  
29 30  
30 31 # TODO: This should be called during installation
... ... @@ -179,7 +180,7 @@ def parse_comand_line():
179 180  
180 181  
181 182 def print_events(data):
182   - print data.topic
  183 + utils.debug(data.topic)
183 184  
184 185 def main():
185 186 application = InVesalius(0)
... ...
invesalius/project.py
... ... @@ -153,7 +153,7 @@ class Project(object):
153 153 elif type_ == "CT":
154 154 self.threshold_modes = self.presets.thresh_ct
155 155 else:
156   - print "Different Acquisition Modality!!!"
  156 + utils.debug("Different Acquisition Modality!!!")
157 157 self.modality = type_
158 158  
159 159 def SetRaycastPreset(self, label):
... ... @@ -187,13 +187,11 @@ class Project(object):
187 187 for index in self.mask_dict:
188 188 masks[str(index)] = {'#mask':\
189 189 self.mask_dict[index].SavePlist(filename_tmp).decode('utf-8')}
190   - print index
191 190  
192 191 surfaces = {}
193 192 for index in self.surface_dict:
194 193 surfaces[str(index)] = {'#surface':\
195 194 self.surface_dict[index].SavePlist(filename_tmp)}
196   - print index
197 195  
198 196 project['surface_dict'] = surfaces
199 197 project['mask_dict'] = masks
... ... @@ -219,15 +217,8 @@ class Project(object):
219 217 filelist = Extract(filename, tempfile.gettempdir())
220 218 main_plist = min(filter(lambda x: x.endswith('.plist'), filelist),
221 219 key=lambda x: len(x))
222   - #print main_plist
223   - print main_plist
224 220 project = plistlib.readPlist(main_plist)
225   -
226   - #print "antes", self.__dict__
227   -
228   - # Path were extracted project is
229 221 dirpath = os.path.abspath(os.path.split(filelist[0])[0])
230   - #print "* dirpath", dirpath
231 222  
232 223 for key in project:
233 224 if key == 'imagedata':
... ...
invesalius/reader/dicom.py
... ... @@ -1821,7 +1821,6 @@ class Acquisition(object):
1821 1821 def SetParser(self, parser):
1822 1822 self.patient_orientation = parser.GetImagePatientOrientation()
1823 1823 self.tilt = parser.GetAcquisitionGantryTilt()
1824   - self.serie_number = parser.GetImageSeriesNumber()
1825 1824 self.id_study = parser.GetStudyID()
1826 1825 self.modality = parser.GetAcquisitionModality()
1827 1826 self.study_description = parser.GetStudyDescription()
... ...
invesalius/reader/dicom_grouper.py
... ... @@ -53,6 +53,8 @@
53 53  
54 54 import gdcm
55 55  
  56 +import utils
  57 +
56 58 ORIENT_MAP = {"SAGITTAL":0, "CORONAL":1, "AXIAL":2, "OBLIQUE":2}
57 59  
58 60  
... ... @@ -209,12 +211,15 @@ class PatientGroup:
209 211  
210 212 # Check if Problem 1 occurs (n groups with 1 slice each)
211 213 is_there_problem_1 = False
  214 + utils.debug("n slice %d" % self.nslices)
  215 + utils.debug("len %d" % len(self.groups_dict))
212 216 if (self.nslices == len(self.groups_dict)) and\
213 217 (self.nslices > 1):
214 218 is_there_problem_1 = True
215 219  
216 220 # Fix Problem 1
217 221 if is_there_problem_1:
  222 + utils.debug("Problem1")
218 223 self.groups_dict = self.FixProblem1(self.groups_dict)
219 224  
220 225 def GetGroups(self):
... ...
invesalius/reader/dicom_reader.py
... ... @@ -141,6 +141,8 @@ def yGetDicomGroups(directory, recursive=True, gui=True):
141 141 for t in threads:
142 142 t.join()
143 143  
  144 + #TODO: Is this commented update necessary?
  145 + #grouper.Update()
144 146 yield grouper.GetPatientsGroups()
145 147  
146 148 def GetDicomGroups(directory, recursive=True):
... ...
invesalius/session.py
... ... @@ -4,7 +4,7 @@ from threading import Thread
4 4 import time
5 5 import wx.lib.pubsub as ps
6 6  
7   -from utils import Singleton
  7 +from utils import Singleton, debug
8 8  
9 9 import wx.lib.pubsub as ps
10 10  
... ... @@ -46,7 +46,6 @@ class Session(object):
46 46  
47 47 # Recent projects list
48 48 self.recent_projects = [(const.SAMPLE_DIR, "Cranium.inv3")]
49   - print self.recent_projects
50 49 self.last_dicom_folder = ''
51 50  
52 51 self.CreateSessionFile()
... ... @@ -57,7 +56,7 @@ class Session(object):
57 56  
58 57 def CloseProject(self):
59 58 import constants as const
60   - print "-- CloseProject"
  59 + debug("Session.CloseProject")
61 60 self.project_path = ()
62 61 self.project_status = const.PROJ_CLOSE
63 62 self.mode = const.MODE_RP
... ... @@ -65,7 +64,7 @@ class Session(object):
65 64  
66 65 def SaveProject(self, path=()):
67 66 import constants as const
68   - print "-- SaveProject"
  67 + debug("Session.SaveProject")
69 68 self.project_status = const.PROJ_OPEN
70 69 if path:
71 70 self.project_path = path
... ... @@ -75,13 +74,13 @@ class Session(object):
75 74  
76 75 def ChangeProject(self):
77 76 import constants as const
78   - print "-- ChangeProject"
  77 + debug("Session.ChangeProject")
79 78 self.project_status = const.PROJ_CHANGE
80 79  
81 80 def CreateProject(self, filename):
82 81 import constants as const
  82 + debug("Session.CreateProject")
83 83 ps.Publisher().sendMessage('Begin busy cursor')
84   - print "-- CreateProject"
85 84 # Set session info
86 85 self.project_path = (self.tempdir, filename)
87 86 self.project_status = const.PROJ_NEW
... ... @@ -90,7 +89,7 @@ class Session(object):
90 89  
91 90 def OpenProject(self, filepath):
92 91 import constants as const
93   - print "-- OpenProject"
  92 + debug("Session.OpenProject")
94 93 # Add item to recent projects list
95 94 item = (path, file) = os.path.split(filepath)
96 95 self.__add_to_list(item)
... ...
invesalius/utils.py
... ... @@ -25,10 +25,10 @@ import sys
25 25  
26 26  
27 27 def debug(error_str):
28   - from project import Project
29   - proj = Project()
30   - if proj.debug:
31   - print >> stderr, str
  28 + from session import Session
  29 + session = Session()
  30 + if session.debug:
  31 + print >> sys.stderr, error_str
32 32  
33 33  
34 34 #http://www.garyrobinson.net/2004/03/python_singleto.html
... ... @@ -67,7 +67,7 @@ class TwoWaysDictionary(dict):
67 67 try:
68 68 self.pop(key)
69 69 except TypeError:
70   - print "TwoWaysDictionary: no item"
  70 + debug("TwoWaysDictionary: no item")
71 71  
72 72 def get_value(self, key):
73 73 """
... ...