rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
'it_IT':'Italiano',
def GetLocales(): """Return a dictionary which defines supported languages""" d = utl.TwoWaysDictionary ({'zh_TW': u'中文', 'en': u'English', 'es': u'Español', 'pt_BR': u'Português (Brasil)', 'fr':u'Français', 'el_GR':u'Ελληνική', 'it_IT':'Italiano', 'de_DE': 'Deutsch'}) return d
quality='Optimal'
quality=_('Optimal *')
def AddNewActor(self, pubsub_evt): """ Create surface actor, save into project and send it to viewer. """ imagedata, colour, [min_value, max_value], edited_points = pubsub_evt.data quality='Optimal' mode = 'CONTOUR' # 'GRAYSCALE' imagedata_tmp = None if (edited_points): imagedata_tmp = vtk.vtkImageData() imagedata_tmp...
try:
if sys.platform == "win32": try: os.remove(filename_img) os.remove(filename_polydata) except (WindowsError): print "Error while removing surface temporary file" else:
def AddNewActor(self, pubsub_evt): """ Create surface actor, save into project and send it to viewer. """ imagedata, colour, [min_value, max_value], edited_points = pubsub_evt.data quality='Optimal' mode = 'CONTOUR' # 'GRAYSCALE' imagedata_tmp = None if (edited_points): imagedata_tmp = vtk.vtkImageData() imagedata_tmp...
except(WindowsError): print "Error remove temp file"
def AddNewActor(self, pubsub_evt): """ Create surface actor, save into project and send it to viewer. """ imagedata, colour, [min_value, max_value], edited_points = pubsub_evt.data quality='Optimal' mode = 'CONTOUR' # 'GRAYSCALE' imagedata_tmp = None if (edited_points): imagedata_tmp = vtk.vtkImageData() imagedata_tmp...
data = self.data_image['0008']['0008']
try: data = self.data_image['0008']['0008'] except(IndexError): return []
def GetImageType(self): """ Return list containing strings related to image origin. Eg: ["ORIGINAL", "PRIMARY", "AXIAL"] or ["DERIVED", "SECONDARY", "OTHER"] Return "" if field is not defined.
self.filepath = filepath.encode(utils.get_system_encode())
self.filepath = filepath.encode(utils.get_system_encoding())
def __init__(self, grouper, filepath): #threading.Thread.__init__(self) self.grouper = grouper if sys.platform == 'win32': self.filepath = filepath.encode(utils.get_system_encode()) else: self.filepath = filepath self.run()
print "---- measures: _remove_measurements"
def _remove_measurements(self, pubsub_evt): print "---- measures: _remove_measurements" indexes = pubsub_evt.data print indexes for index in indexes: m, mr = self.measures.pop(index) actors = mr.GetActors() prj.Project().RemoveMeasurement(index) ps.Publisher().sendMessage(('Remove actors', m.location), (actors, m.slice...
self.OnText()
def SetStateProjectOpen(self): self.ontool_text = False self.OnText() for tool in self.enable_items: self.EnableTool(tool, True)
self.OnText()
def SetStateProjectClose(self): self.ontool_text = True self.OnText() for tool in self.enable_items: self.EnableTool(tool, False)
slice_imagedata = ResampleImage2D(reader.GetOutput(), px, py, update_progress)
slice_imagedata = ResampleImage2D(tmp_image, px, py, update_progress)
def CreateImageData(filelist, zspacing, xyspacing,size, bits, use_dcmspacing): message = _("Generating multiplanar visualization...") if not const.VTK_WARNING: log_path = os.path.join(const.LOG_FOLDER, 'vtkoutput.txt') fow = vtk.vtkFileOutputWindow() fow.SetFileName(log_path) ow = vtk.vtkOutputWindow() ow.SetInstance(...
imagedata.Update() if (use_dcmspacing): spacing = xyspacing spacing[2] = zspacing else: spacing = imagedata.GetSpacing()
def CreateImageData(filelist, zspacing, xyspacing,size, bits, use_dcmspacing): message = _("Generating multiplanar visualization...") if not const.VTK_WARNING: log_path = os.path.join(const.LOG_FOLDER, 'vtkoutput.txt') fow = vtk.vtkFileOutputWindow() fow.SetFileName(log_path) ow = vtk.vtkOutputWindow() ow.SetInstance(...
locale_descriptions = {'es':'Español',\ 'en_GB':'English',\ 'pt_BR':'Português (Brasil)'}
locale_descriptions = {'es': u'Español', 'en_GB': u'English', 'pt_BR': u'Português (Brasil)'}
def GetLocales(): """Return a dictionary which defines supported languages""" locale_descriptions = {'es':'Español',\ 'en_GB':'English',\ 'pt_BR':'Português (Brasil)'} return locale_descriptions
ps.Publisher().sendMessage('Bright and contrast adjustment image',\ (proj.window, proj.level)) ps.Publisher().sendMessage('Update window level value',\ (proj.window, proj.level))
def LoadProject(self): proj = prj.Project()
m.points.append(position)
def _add_point(self, pubsub_evt): position = pubsub_evt.data[0] type = pubsub_evt.data[1] # Linear or Angular location = pubsub_evt.data[2] # 3D, AXIAL, SAGITAL, CORONAL try: slice_number = pubsub_evt.data[3] except IndexError: slice_number = 0
for buffer_ in self.buffer_slices:
for buffer_ in self.buffer_slices.values():
def ShowMask(self, index, value): "Show a mask given its index and 'show' value (0: hide, other: show)" proj = Project() proj.mask_dict[index].is_shown = value if (index == self.current_mask.index): for buffer_ in self.buffer_slices: buffer_.discard_vtk_mask() buffer_.discard_mask() ps.Publisher().sendMessage('Reload a...
print self.window_width, self.window_level
print "WW, WL", self.window_width, self.window_level
def do_ww_wl(self, image): print self.window_width, self.window_level print image.GetScalarRange() colorer = vtk.vtkImageMapToWindowLevelColors() colorer.SetInput(image) colorer.SetWindow(self.window_width) colorer.SetLevel(self.window_level) colorer.SetOutputFormatToRGB() colorer.Update()
m = numpy.zeros(slice_matrix.shape, self.current_mask.matrix.dtype) m[numpy.logical_and(slice_matrix >= thresh_min, slice_matrix <= thresh_max)] = 255
m= numpy.logical_and(slice_matrix >= thresh_min, slice_matrix <= thresh_max) * 255
def do_threshold_to_a_slice(self, slice_matrix): """ Based on the current threshold bounds generates a threshold mask to given slice_matrix. """ thresh_min, thresh_max = self.current_mask.threshold_range m = numpy.zeros(slice_matrix.shape, self.current_mask.matrix.dtype) m[numpy.logical_and(slice_matrix >= thresh_min, ...
ps.Publisher().subscribe(print_events, ps.ALL_TOPICS)
try: ps.Publisher().subscribe(print_events, ps.ALL_TOPICS) except AttributeError: ps.Publisher().subscribe(print_events, ps.pub.getStrAllTopics())
def parse_comand_line(): """ Handle command line arguments. """ session = ses.Session() # Parse command line arguments parser = op.OptionParser() # -d or --debug: print all pubsub messagessent parser.add_option("-d", "--debug", action="store_true", dest="debug") # -i or --import: import DICOM directory # chooses lar...
print "To Create" to_create = True elif self.current[0].slice_number != slice_number:
def _add_point(self, pubsub_evt): position = pubsub_evt.data[0] type = pubsub_evt.data[1] # Linear or Angular location = pubsub_evt.data[2] # 3D, AXIAL, SAGITAL, CORONAL try: slice_number = pubsub_evt.data[3] except IndexError: slice_number = 0
m.type = type
if to_remove: print "---To REMOVE" actors = self.current[1].GetActors() slice_number = self.current[0].slice_number ps.Publisher().sendMessage(('Remove actors', self.current[0].location), (actors, slice_number)) if self.current[0].location == const.SURFACE: ps.Publisher().sendMessage('Render volume viewer') else: ps.Pu...
def _add_point(self, pubsub_evt): position = pubsub_evt.data[0] type = pubsub_evt.data[1] # Linear or Angular location = pubsub_evt.data[2] # 3D, AXIAL, SAGITAL, CORONAL try: slice_number = pubsub_evt.data[3] except IndexError: slice_number = 0
path = os.path.join(d, "print.png"),
path = os.path.join(d, "print.png")
def __init_items(self): """ Add tools into toolbar. """ # Load bitmaps d = const.ICON_DIR if sys.platform == 'darwin': path = os.path.join(d,"file_from_internet_original.png") BMP_NET = wx.Bitmap(path, wx.BITMAP_TYPE_PNG)
path = os.path.join(d, "tool_photo.png"),
path = os.path.join(d, "tool_photo.png")
def __init_items(self): """ Add tools into toolbar. """ # Load bitmaps d = const.ICON_DIR if sys.platform == 'darwin': path = os.path.join(d,"file_from_internet_original.png") BMP_NET = wx.Bitmap(path, wx.BITMAP_TYPE_PNG)
return image.Scale(*self.GetSize())
self.Update() self.Layout() new_size = self.GetSize() if new_size != (0,0): self.last_size = new_size return image.Scale(*new_size) else: return image.Scale(*self.last_size)
def _image_resize(self, image): return image.Scale(*self.GetSize())
def __init__(self, grouper, tempdir, q, l):
def __init__(self, grouper, q, l):
def __init__(self, grouper, tempdir, q, l): threading.Thread.__init__(self) self.grouper = grouper self.tempdir = tempdir self.q = q self.l = l
self.tempdir = tempdir
def __init__(self, grouper, tempdir, q, l): threading.Thread.__init__(self) self.grouper = grouper self.tempdir = tempdir self.q = q self.l = l
tempdir = self.tempdir
def run(self): grouper = self.grouper q = self.q tempdir = self.tempdir while 1: filepath = q.get() print "thread %s consumed %s" % (self.getName(), filepath) if not filepath: break parser = dicom.Parser() if parser.SetFileName(filepath): dcm = dicom.Dicom() self.l.acquire() dcm.SetParser(parser) grouper.AddFile(dcm) s...
dcm.image.SetTempDir(tempdir)
def run(self): grouper = self.grouper q = self.q tempdir = self.tempdir while 1: filepath = q.get() print "thread %s consumed %s" % (self.getName(), filepath) if not filepath: break parser = dicom.Parser() if parser.SetFileName(filepath): dcm = dicom.Dicom() self.l.acquire() dcm.SetParser(parser) grouper.AddFile(dcm) s...
tempdir = tempfile.mkdtemp()
def yGetDicomGroups(directory, recursive=True, gui=True): """ Return all full paths to DICOM files inside given directory. """ nfiles = 0 tempdir = tempfile.mkdtemp() # Find total number of files if recursive: for dirpath, dirnames, filenames in os.walk(directory): nfiles += len(filenames) else: dirpath, dirnames, file...
t = LoadDicom(grouper, tempdir, q, l)
t = LoadDicom(grouper, q, l)
def yGetDicomGroups(directory, recursive=True, gui=True): """ Return all full paths to DICOM files inside given directory. """ nfiles = 0 tempdir = tempfile.mkdtemp() # Find total number of files if recursive: for dirpath, dirnames, filenames in os.walk(directory): nfiles += len(filenames) else: dirpath, dirnames, file...
b = ctx.CreateLinearGradientBrush(nodei.x, height, nodej.x, height,
b = ctx.CreateLinearGradientBrush(int(nodei.x), height, int(nodej.x), height,
def _draw_gradient(self, ctx, height): #The gradient height += self.padding for curve in self.curves: for nodei, nodej in zip(curve.nodes[:-1], curve.nodes[1:]): path = ctx.CreatePath() path.MoveToPoint(int(nodei.x), height) path.AddLineToPoint(int(nodei.x), height) path.AddLineToPoint(int(nodei.x), nodei.y) path.AddLi...
colour = self.GetBackgroundColour() ps.Publisher.sendMessage('Change volume viewer background colour', colour) ps.Publisher.sendMessage('Change volume viewer gui colour', colour)
def OnUpdatePreset(self, pubsub_evt): self.__load_preset_config() if self.config: if self.exist: self.__load_preset() self.volume.SetVisibility(1) #ps.Publisher().sendMessage('Render volume viewer') else: self.LoadVolume() self.CalculateHistogram() self.exist = 1
colour = self.GetBackgroundColour() ps.Publisher.sendMessage('Change volume viewer background colour', colour) ps.Publisher.sendMessage('Change volume viewer gui colour', colour)
def __load_preset(self): # Update colour table self.__update_colour_table()
super(Preview, self).__init__(parent, style= wx.BORDER)
super(Preview, self).__init__(parent, style=wx.SUNKEN_BORDER)
def __init__(self, parent): super(Preview, self).__init__(parent, style= wx.BORDER) # Will it be white? self.select_on = False self._init_ui() self._bind_events()
self.title = wx.StaticText(self, -1, _("Image"), style=wx.ALIGN_CENTER) self.subtitle = wx.StaticText(self, -1, _("Image"), style=wx.ALIGN_CENTER)
self.title = wx.StaticText(self, -1, _("Image")) self.subtitle = wx.StaticText(self, -1, _("Image"))
def _init_ui(self): self.title = wx.StaticText(self, -1, _("Image"), style=wx.ALIGN_CENTER) self.subtitle = wx.StaticText(self, -1, _("Image"), style=wx.ALIGN_CENTER) self.image_viewer = wx.StaticBitmap(self, -1, size=(70, 70))
sizer_image = wx.BoxSizer(wx.HORIZONTAL) sizer_image.Add(self.image_viewer, 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL)
def _init_ui(self): self.title = wx.StaticText(self, -1, _("Image"), style=wx.ALIGN_CENTER) self.subtitle = wx.StaticText(self, -1, _("Image"), style=wx.ALIGN_CENTER) self.image_viewer = wx.StaticBitmap(self, -1, size=(70, 70))
self.sizer.AddSpacer(2)
def _init_ui(self): self.title = wx.StaticText(self, -1, _("Image"), style=wx.ALIGN_CENTER) self.subtitle = wx.StaticText(self, -1, _("Image"), style=wx.ALIGN_CENTER) self.image_viewer = wx.StaticBitmap(self, -1, size=(70, 70))
wx.GROW|wx.EXPAND|wx. ALIGN_CENTER_HORIZONTAL)
wx.ALIGN_CENTER_HORIZONTAL)
def _init_ui(self): self.title = wx.StaticText(self, -1, _("Image"), style=wx.ALIGN_CENTER) self.subtitle = wx.StaticText(self, -1, _("Image"), style=wx.ALIGN_CENTER) self.image_viewer = wx.StaticBitmap(self, -1, size=(70, 70))
wx.GROW|wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL) self.sizer.Add(sizer_image, 5, wx.GROW|wx.EXPAND|wx.ALL, 4)
wx.ALIGN_CENTER_HORIZONTAL) self.sizer.Add(self.image_viewer, 0, wx.ALIGN_CENTER_HORIZONTAL)
def _init_ui(self): self.title = wx.StaticText(self, -1, _("Image"), style=wx.ALIGN_CENTER) self.subtitle = wx.StaticText(self, -1, _("Image"), style=wx.ALIGN_CENTER) self.image_viewer = wx.StaticBitmap(self, -1, size=(70, 70))
self.Refresh()
def Select(self, on=True): if self.select_on: c = wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHT) else: c = (255,255,255) self.SetBackgroundColour(c) self.Refresh()
print '_'+encoding+'_' print type(encoding)
def GetEncoding(self): """ Return the dicom encoding DICOM standard tag (0x0008, 0x0005) was used. """ tag = gdcm.Tag(0x0008, 0x0005) ds = self.gdcm_reader.GetFile().GetDataSet() if ds.FindDataElement(tag): encoding = str(ds.GetDataElement(tag).GetValue())
self.dlg.Update(value,message)
return self.dlg.Update(value,message)
def Update(self, value, message): if(int(value) != self.maximum): try: self.dlg.Update(value,message) #TODO: #Exception in the Windows XP 64 Bits with wxPython 2.8.10 except(wx._core.PyAssertionError): pass return True else: return False
pass return True
return True
def Update(self, value, message): if(int(value) != self.maximum): try: self.dlg.Update(value,message) #TODO: #Exception in the Windows XP 64 Bits with wxPython 2.8.10 except(wx._core.PyAssertionError): pass return True else: return False
self.__TranslateMessage__()
def __init__(self, parent, startApp = None):
label=('Choose user interface language'),
label=_('Choose user interface language'),
def __init__(self, parent, startApp = None):
os_language = ivI18n.GetLocaleOS()
os_language = i18n.GetLocaleOS()
def __TranslateMessage__(self): """Translate Messages of the Window""" os_language = ivI18n.GetLocaleOS()
_ = ivI18n.ParseLang('pt_BR')
_ = i18n.InstallLanguage('pt_BR')
def __TranslateMessage__(self): """Translate Messages of the Window""" os_language = ivI18n.GetLocaleOS()
_ = ivI18n.ParseLang('es')
_ = i18n.InstallLanguage('es')
def __TranslateMessage__(self): """Translate Messages of the Window""" os_language = ivI18n.GetLocaleOS()
_ = ivI18n.ParseLang('en_GB')
_ = i18n.InstallLanguage('en_GB')
def __TranslateMessage__(self): """Translate Messages of the Window""" os_language = ivI18n.GetLocaleOS()
BMP_LARGEST = wx.Bitmap("../icons/connectivity_largest.png", wx.BITMAP_TYPE_PNG) BMP_SPLIT_ALL = wx.Bitmap("../icons/connectivity_split_all.png", wx.BITMAP_TYPE_PNG) BMP_SEEDS = wx.Bitmap("../icons/connectivity_manual.png", wx.BITMAP_TYPE_PNG) bmp_list = [BMP_LARGEST, BMP_SPLIT_ALL, BMP_SEEDS] for bmp in bmp_list: bmp...
img_largest = wx.Image("../icons/connectivity_largest.png", wx.BITMAP_TYPE_PNG) img_largest.Rescale(25, 25) bmp_largest = img_largest.ConvertToBitmap() img_split_all = wx.Image("../icons/connectivity_split_all.png", wx.BITMAP_TYPE_PNG) img_split_all.Rescale(25, 25) bmp_split_all = img_split_all.ConvertToBitmap() img_...
def __init__(self, parent): wx.Panel.__init__(self, parent, size=(50,400)) default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR) self.SetBackgroundColour(default_colour)
button_split = pbtn.PlateButton(self, BTN_SPLIT, "", BMP_SPLIT_ALL, style=button_style) button_largest = pbtn.PlateButton(self, BTN_LARGEST, "", BMP_LARGEST, style=button_style) button_seeds = pbtn.PlateButton(self, BTN_SEEDS, "", BMP_SEEDS, style=button_style_plus)
button_split = pbtn.PlateButton(self, BTN_SPLIT, "", bmp_split_all, style=button_style) button_largest = pbtn.PlateButton(self, BTN_LARGEST, "", bmp_largest, style=button_style) button_seeds = pbtn.PlateButton(self, BTN_SEEDS, "", bmp_seeds, style=button_style_plus)
def __init__(self, parent): wx.Panel.__init__(self, parent, size=(50,400)) default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR) self.SetBackgroundColour(default_colour)
if sys.platform == 'linux2':
elif sys.platform == 'linux2':
def AddNewActor(self, pubsub_evt): """ Create surface actor, save into project and send it to viewer. """ imagedata, colour, [min_value, max_value], edited_points = pubsub_evt.data quality=_('Optimal *') mode = 'CONTOUR' # 'GRAYSCALE'
if not proj.mask_dict: self.blend_filter.SetOpacity(1, 0) self.blend_filter.Update() ps.Publisher().sendMessage('Update slice viewer')
if self.current_mask is not None and item == self.current_mask.index: self.current_mask = None for buffer_ in self.buffer_slices.values(): buffer_.discard_vtk_mask() buffer_.discard_mask() ps.Publisher().sendMessage('Reload actual slice')
def OnRemoveMasks(self, pubsub_evt): selected_items = pubsub_evt.data
self.renderers_by_slice_number = None
def set_slice_number(self, index): self.slice_number = index # for m in self.actors_by_slice_number.values(): # for actor in m: # actor.SetVisibility(0) # Removing actor from the previous renderers/slice. for n in self.renderers_by_slice_number: renderer = self.renderers_by_slice_number[n] for actor in self.actors_by_s...
image = proj.imagedata
slice_data = slice_.Slice() n_array = slice_data.matrix spacing = slice_data.spacing slice_number = 0 orientation = 'AXIAL' image = imagedata_utils.to_vtk(n_array, spacing, slice_number, orientation) self.image = image
def LoadVolume(self): proj = prj.Project() image = proj.imagedata
proj = prj.Project() image = proj.imagedata
image = self.image
def CalculateHistogram(self): proj = prj.Project() image = proj.imagedata r = int(image.GetScalarRange()[1] - image.GetScalarRange()[0]) accumulate = vtk.vtkImageAccumulate() accumulate.SetInput(image) accumulate.SetComponentExtent(0, r -1, 0, 0, 0, 0) accumulate.SetComponentOrigin(image.GetScalarRange()[0], 0, 0) accu...
if encoding != None:
print '_'+encoding+'_' print type(encoding) if encoding != None and encoding != "None": print 'ENTROU......'
def GetEncoding(self): """ Return the dicom encoding DICOM standard tag (0x0008, 0x0005) was used. """ tag = gdcm.Tag(0x0008, 0x0005) ds = self.gdcm_reader.GetFile().GetDataSet() if ds.FindDataElement(tag): encoding = str(ds.GetDataElement(tag).GetValue()) if encoding != None: #Problem with 0051 anonymized if (encoding...
image.SetMagnification(2)
image.SetMagnification(1)
def OnExportPicture(self, pubsub_evt): ps.Publisher().sendMessage('Begin busy cursor') id, filename, filetype = pubsub_evt.data if id == const.VOLUME: if filetype == const.FILETYPE_POV: renwin = self.interactor.GetRenderWindow() image = vtk.vtkWindowToImageFilter() image.SetInput(renwin) writer = vtk.vtkPOVExporter() ...
slice_data.renderer.Render()
def __update_camera(self, slice_data): orientation = self.orientation proj = project.Project() orig_orien = proj.original_orientation
mapper.SetInput(surface.polydata)
mapper.SetInput(stripper.GetOutput())
def OnLoadSurfaceDict(self, pubsub_evt): surface_dict = pubsub_evt.data
normals = vtk.vtkPolyDataNormals() normals.SetInput(polydata) normals.SetFeatureAngle(80) normals.AutoOrientNormalsOn() normals.GetOutput().ReleaseDataFlagOn()
def AddNewActor(self, pubsub_evt): """ Create surface actor, save into project and send it to viewer. """ imagedata, colour, [min_value, max_value], edited_points = pubsub_evt.data quality='Optimal' mode = 'CONTOUR' # 'GRAYSCALE' imagedata_tmp = None if (edited_points): imagedata_tmp = vtk.vtkImageData() imagedata_tmp...
stripper.SetInput(polydata)
stripper.SetInput(normals.GetOutput())
def AddNewActor(self, pubsub_evt): """ Create surface actor, save into project and send it to viewer. """ imagedata, colour, [min_value, max_value], edited_points = pubsub_evt.data quality='Optimal' mode = 'CONTOUR' # 'GRAYSCALE' imagedata_tmp = None if (edited_points): imagedata_tmp = vtk.vtkImageData() imagedata_tmp...
ps.Publisher().sendMessage('Update slice viewer')
if m.location == const.SURFACE: ps.Publisher().sendMessage('Render volume viewer') else: ps.Publisher().sendMessage('Update slice viewer')
def _set_visibility(self, pubsub_evt): index, visibility = pubsub_evt.data m, mr = self.measures[index] m.is_shown = visibility mr.SetVisibility(visibility) ps.Publisher().sendMessage('Update slice viewer')
self.file = parser.filename
if (sys.platform == 'win32'): self.file = parser.filename.encode(utils.get_system_encoding()) else: self.file = parser.filename.encode('utf-8')
def SetParser(self, parser): self.level = parser.GetImageWindowLevel() self.window = parser.GetImageWindowWidth()
actual_colour = [i * 255 for i in self.curves[i].nodes[j].colour]
actual_colour = self.curves[i].nodes[j].colour
def OnDoubleClick(self, evt): """ Used to change the colour of a point """ point = self._has_clicked_in_a_point(evt.GetPositionTuple()) if point: i, j = point actual_colour = [i * 255 for i in self.curves[i].nodes[j].colour] colour_dialog = wx.GetColourFromUser(self, actual_colour) if colour_dialog.IsOk(): i,j = point ...
r, g, b = [x/255.0 for x in colour_dialog.Get()] self.colours[i][j]['red'] = r self.colours[i][j]['green'] = g self.colours[i][j]['blue'] = b print self.curves[i].nodes
r, g, b = colour_dialog.Get() self.colours[i][j]['red'] = r / 255.0 self.colours[i][j]['green'] = g / 255.0 self.colours[i][j]['blue'] = b / 255.0
def OnDoubleClick(self, evt): """ Used to change the colour of a point """ point = self._has_clicked_in_a_point(evt.GetPositionTuple()) if point: i, j = point actual_colour = [i * 255 for i in self.curves[i].nodes[j].colour] colour_dialog = wx.GetColourFromUser(self, actual_colour) if colour_dialog.IsOk(): i,j = point ...
reader.SetFileName(str(filepath))
reader.SetFileName(filepath.encode('utf-8'))
def run(self):
data_dict['invesalius'] = {'orientation_label' : GetImageOrientationLabel(str(filepath))}
data_dict['invesalius'] = {'orientation_label' : GetImageOrientationLabel(filepath.encode('utf-8'))}
def run(self):
os.remove(filename_img) os.remove(filename_polydata)
try: os.remove(filename_img) os.remove(filename_polydata) except(WindowsError): print "Error remove temp file"
def AddNewActor(self, pubsub_evt): """ Create surface actor, save into project and send it to viewer. """ imagedata, colour, [min_value, max_value], edited_points = pubsub_evt.data quality='Optimal' mode = 'CONTOUR' # 'GRAYSCALE' imagedata_tmp = None if (edited_points): imagedata_tmp = vtk.vtkImageData() imagedata_tmp...
locale_descriptions = {'es':'Espa\xf1ol',\
locale_descriptions = {'es':'Español',\
def GetLocales(): """Return a dictionary which defines supported languages""" locale_descriptions = {'es':'Espa\xf1ol',\ 'en_GB':'English',\ 'pt_BR':'Portugu\xeas (Brasil)'} return locale_descriptions
'pt_BR':'Portugu\xeas (Brasil)'}
'pt_BR':'Português (Brasil)'}
def GetLocales(): """Return a dictionary which defines supported languages""" locale_descriptions = {'es':'Espa\xf1ol',\ 'en_GB':'English',\ 'pt_BR':'Portugu\xeas (Brasil)'} return locale_descriptions
class SplashScreen(wx.SplashScreen):
class SplashScreen(AS.AdvancedSplash):
def MacOpenFile(self, filename): """ Open drag & drop files under darwin """ path = os.path.abspath(filename) ps.Publisher().sendMessage('Open project', path)
wx.SplashScreen.__init__(self,
AS.AdvancedSplash.__init__(self,
def __init__(self): # Splash screen image will depend on currently language lang = False
splashStyle=style, milliseconds=1500,
style=style, timeout=5000,
def __init__(self): # Splash screen image will depend on currently language lang = False
self.fc = wx.FutureCall(1, self.ShowMain)
self.fc = wx.FutureCall(2000, self.ShowMain)
def __init__(self): # Splash screen image will depend on currently language lang = False
utils.debug("Different Acquisition Modality!!!")
debug("Different Acquisition Modality!!!")
def SetAcquisitionModality(self, type_=None): if type_ is None: type_ = self.modality
self.BMP_WITH_TEXT = wx.Bitmap(os.path.join(const.ICON_DIR,"text.png")) self.BMP_WITHOUT_TEXT =\ wx.Bitmap(os.path.join(const.ICON_DIR,"text_inverted.png"))
self.BMP_WITH_TEXT = wx.Bitmap(os.path.join(const.ICON_DIR,"text.gif"), wx.BITMAP_TYPE_GIF) self.BMP_WITHOUT_TEXT = wx.Bitmap(os.path.join(const.ICON_DIR,"text_inverted.png"))
def __init_items(self):
dc = wx.AutoBufferedPaintDC(self)
dc = wx.PaintDC(self)
def OnPaint(self, evt): if self.image: dc = wx.AutoBufferedPaintDC(self) dc.Clear() dc.DrawBitmap(self.bmp, 0, 0)
type_="LINEAR", location="SURFACE", value="0 mm"):
location="SURFACE", type_="LINEAR", value="0 mm"):
def InsertNewItem(self, index=0, label="Measurement 1", colour=None, type_="LINEAR", location="SURFACE", value="0 mm"): self.InsertStringItem(index, "") self.SetStringItem(index, 1, label, imageId = self._list_index[index]) self.SetStringItem(index, 2, location) self.SetStringItem(index, 3, type_) self.SetStringItem(in...
imagedata = utils.CreateImageData(filelist, zspacing, size, bits)
sop_class_uid = dicom.acquisition.sop_class_uid xyspacing = dicom.image.spacing if sop_class_uid == '1.2.840.10008.5.1.4.1.1.7': use_dcmspacing = 1 else: use_dcmspacing = 0 imagedata = utils.CreateImageData(filelist, zspacing, xyspacing,size, bits, use_dcmspacing)
def OpenDicomGroup(self, dicom_group, interval, gui=True):
gauss.SetRadiusFactor(0.8)
gauss.SetRadiusFactor(0.6)
def BuildEditedImage(imagedata, points): """ Editing the original image in accordance with the edit points in the editor, it is necessary to generate the vtkPolyData via vtkContourFilter """ for point in points: x, y, z = point colour = points[point] imagedata.SetScalarComponentFromDouble(x, y, z, 0, colour) imagedata....
configfile = open(path, 'wb') config.write(configfile)
try: configfile = open(path, 'wb') except IOError: return utl.debug("Session - IOError") else: config.write(configfile)
def Write(self):
return self.dicom
size = len(self.slices_dict) dicom = self.GetHandSortedList()[size/2] return dicom
def GetDicomSample(self): return self.dicom
print dirpath
def ShowDialogImportDirectory(self): # Offer to save current project if necessary session = ses.Session() st = session.project_status if (st == const.PROJ_NEW) or (st == const.PROJ_CHANGE): filename = session.project_path[1] answer = dialog.SaveChangesDialog2(filename) if answer: self.ShowDialogSaveProject()
print "ShowDialogCloseProject"
utils.debug("ShowDialogCloseProject")
def ShowDialogCloseProject(self): print "ShowDialogCloseProject" session = ses.Session() st = session.project_status print "* st", st if st == const.PROJ_CLOSE: return -1 filename = session.project_path[1] if (st == const.PROJ_NEW) or (st == const.PROJ_CHANGE): answer = dialog.SaveChangesDialog(filename) if not answer:...
print "* st", st
def ShowDialogCloseProject(self): print "ShowDialogCloseProject" session = ses.Session() st = session.project_status print "* st", st if st == const.PROJ_CLOSE: return -1 filename = session.project_path[1] if (st == const.PROJ_NEW) or (st == const.PROJ_CHANGE): answer = dialog.SaveChangesDialog(filename) if not answer:...
print "Close without changes"
utils.debug("Close without changes")
def ShowDialogCloseProject(self): print "ShowDialogCloseProject" session = ses.Session() st = session.project_status print "* st", st if st == const.PROJ_CLOSE: return -1 filename = session.project_path[1] if (st == const.PROJ_NEW) or (st == const.PROJ_CHANGE): answer = dialog.SaveChangesDialog(filename) if not answer:...
print "Save changes and close"
utils.debug("Save changes and close")
def ShowDialogCloseProject(self): print "ShowDialogCloseProject" session = ses.Session() st = session.project_status print "* st", st if st == const.PROJ_CLOSE: return -1 filename = session.project_path[1] if (st == const.PROJ_NEW) or (st == const.PROJ_CHANGE): answer = dialog.SaveChangesDialog(filename) if not answer:...
print "Cancel"
utils.debug("Cancel")
def ShowDialogCloseProject(self): print "ShowDialogCloseProject" session = ses.Session() st = session.project_status print "* st", st if st == const.PROJ_CLOSE: return -1 filename = session.project_path[1] if (st == const.PROJ_NEW) or (st == const.PROJ_CHANGE): answer = dialog.SaveChangesDialog(filename) if not answer:...
imagedata, dicom = self.OpenDicomGroup(group, gui=True)
imagedata, dicom = self.OpenDicomGroup(group, 0, gui=True)
def ImportMedicalImages(self, directory): # OPTION 1: DICOM? patients_groups = dcm.GetDicomGroups(directory)
print "No medical images found on given directory"
utils.debug("No medical images found on given directory")
def ImportMedicalImages(self, directory): # OPTION 1: DICOM? patients_groups = dcm.GetDicomGroups(directory)
print ">Not used the IPPSorter"
utils.debug("Not used the IPPSorter")
def OpenDicomGroup(self, dicom_group, interval, gui=True):
self.lut_mask.SetTableValue(1, r, g, b, 1.0)
self.lut_mask.SetTableValue(0, 0, 0, 0, 0.0)
def SetMaskColour(self, index, colour, update=True): "Set a mask colour given its index and colour (RGB 0-1 values)" proj = Project() proj.mask_dict[index].colour = colour
(10, 170), 0,fpb.FPB_SINGLE_FOLD)
(10, 190), 0,fpb.FPB_SINGLE_FOLD)
def __init__(self, parent): wx.Panel.__init__(self, parent) default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR) self.SetBackgroundColour(default_colour)
ps.Publisher().sendMessage('Update slice viewer')
for buffer_ in self.buffer_slices.values(): buffer_.discard_vtk_mask() ps.Publisher().sendMessage('Reload actual slice')
def SetMaskColour(self, index, colour, update=True): "Set a mask colour given its index and colour (RGB 0-1 values)" proj = Project() proj.mask_dict[index].colour = colour
tag = gdcm.Tag(0x0018, 0x1050) ds = self.gdcm_reader.GetFile().GetDataSet() if ds.FindDataElement(tag): data = str(ds.GetDataElement(tag).GetValue())
tag = gdcm.Tag(0x0018, 0x0050) ds = self.gdcm_reader.GetFile().GetDataSet() if ds.FindDataElement(tag): data = str(ds.GetDataElement(tag).GetValue()) print data
def GetImageThickness(self): """ Return float value related to the nominal reconstructed slice thickness (expressed in mm). Return "" if not defined.
reader = itk.ImageFileReader.IUC3.New()
pipe_in, pipe_out = multiprocessing.Pipe() sp = ItktoVtk(pipe_in, filename) sp.start() while 1: msg = pipe_out.recv() if(msg is None): break filename = pipe_out.recv() reader = vtk.vtkXMLImageDataReader()
def ReadAnalyze(filename): reader = itk.ImageFileReader.IUC3.New() reader.SetFileName(filename) reader.Update() x_spacing = reader.GetOutput().GetSpacing().GetElement(0) y_spacing = reader.GetOutput().GetSpacing().GetElement(1) z_spacing = reader.GetOutput().GetSpacing().GetElement(2) spacing = (x_spacing, y_spacing, ...
x_spacing = reader.GetOutput().GetSpacing().GetElement(0) y_spacing = reader.GetOutput().GetSpacing().GetElement(1) z_spacing = reader.GetOutput().GetSpacing().GetElement(2) spacing = (x_spacing, y_spacing, z_spacing) glue = ItkVtkGlue.ImageToVTKImageFilter.IUC3.New() glue.SetInput(reader.GetOutput()) glue.Update()
def ReadAnalyze(filename): reader = itk.ImageFileReader.IUC3.New() reader.SetFileName(filename) reader.Update() x_spacing = reader.GetOutput().GetSpacing().GetElement(0) y_spacing = reader.GetOutput().GetSpacing().GetElement(1) z_spacing = reader.GetOutput().GetSpacing().GetElement(2) spacing = (x_spacing, y_spacing, ...
imagedata = vtk.vtkImageData() imagedata.DeepCopy(glue.GetOutput()) imagedata.SetSpacing(spacing) return imagedata
os.remove(filename) return reader.GetOutput()
def ReadAnalyze(filename): reader = itk.ImageFileReader.IUC3.New() reader.SetFileName(filename) reader.Update() x_spacing = reader.GetOutput().GetSpacing().GetElement(0) y_spacing = reader.GetOutput().GetSpacing().GetElement(1) z_spacing = reader.GetOutput().GetSpacing().GetElement(2) spacing = (x_spacing, y_spacing, ...
if (sys.platform != 'darwin'):
except(wx._core.PyAssertionError): if (dlg.GetPath()): path = dlg.GetPath() if (sys.platform != 'darwin'): if (path):
def ShowImportDirDialog(): current_dir = os.path.abspath(".") if (sys.platform == 'win32') or (sys.platform == 'linux2'): session = ses.Session() if (session.GetLastDicomFolder()): folder = session.GetLastDicomFolder() else: folder = '' else: folder = '' dlg = wx.DirDialog(None, _("Choose a DICOM folder:"), folder, ...
except(wx._core.PyAssertionError): path = dlg.GetPath()
def ShowImportDirDialog(): current_dir = os.path.abspath(".") if (sys.platform == 'win32') or (sys.platform == 'linux2'): session = ses.Session() if (session.GetLastDicomFolder()): folder = session.GetLastDicomFolder() else: folder = '' else: folder = '' dlg = wx.DirDialog(None, _("Choose a DICOM folder:"), folder, ...