#NEWLINE# def add_roi( self , name , pngdata , add_path = True ) : #NEWLINE# #INDENT# 'Adds projected data for defining a new ROI to the saved rois.svg file in a new layer' #NEWLINE# svg = etree . parse ( self . svgfile , parser = parser ) #NEWLINE# imglayer = _find_layer ( svg , 'data' ) #NEWLINE# if add_path : #NEWLINE# #INDENT# _make_layer ( _find_layer ( svg , 'rois' ) , name ) #NEWLINE# #UNINDENT# for layer in imglayer . findall ( ( './/{%s}g' % svgns ) ) : #NEWLINE# #INDENT# layer . attrib [ 'style' ] = 'display:hidden;' #NEWLINE# #UNINDENT# layer = _make_layer ( imglayer , ( 'img_%s' % name ) ) #NEWLINE# layer . append ( E . image ( { #NEWLINE# #INDENT# '{http://www.w3.org/1999/xlink}href' : ( 'data:image/png;base64,%s' % pngdata ) , #NEWLINE# #UNINDENT# } , id = ( 'image_%s' % name ) , x = '0' , y = '0' , width = str ( self . svgshape [ 0 ] ) , height = str ( layer . svgshape [ 1 ] ) ) ) #NEWLINE# with open ( self . svgfile , 'w' ) as xml : #NEWLINE# #INDENT# xml . write ( etree . tostring ( svg , pretty_print = True ) )