viper, a visual programming environment for python · michel f. sanner tsri 2002 viper, a visual...
TRANSCRIPT
![Page 1: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/1.jpg)
Michel F. SANNER TSRI 2002
ViPErViPEr, a Visual, a Visualprogramming Environmentprogramming Environment
for Pythonfor Python
Michel F. Sanner, Daniel Stoffler
The Scripps Research InstituteLa Jolla, California
The Molecular Graphics Laboratory
SciPy’02
CalTech Pasadena CA. Sept. 2002
![Page 2: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/2.jpg)
SciPy’02, © M.Sanner, TSRI
AcknowledgmentAcknowledgmento NIH - NBCR (Peter Arzberger)
? 5 NCRR representedo NBCR (SDSC)o NCMI (Baylor college)o Computer Graphics Lab (UCSF)o MMTSB (TSRI)o MMMB
o Camera men: Art Olson, Chenglong Lio Enthought: Eric Jones, Travis Vaughto Michael Aivasis, CalTech
![Page 3: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/3.jpg)
SciPy’02, © M.Sanner, TSRI
SCHEDULESCHEDULE
o I –AVSo II – ViPEr
? Basics, Architecture, Libraries
? Nodes, Execution Flow, Widgets, Data Types
o III - Demos
o IV - Conclusion
![Page 4: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/4.jpg)
SciPy’02, © M.Sanner, TSRI
AVS-5: AVS-5: Advanced Visualization System Inc.Advanced Visualization System Inc.
Enabling scientists (non-programmers)to build computational networksEnabling scientists (non-programmers)to build computational networks
![Page 5: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/5.jpg)
SciPy’02, © M.Sanner, TSRI
Lessons learn from AVS-5Lessons learn from AVS-5o GOOD:
? Modularity / extensibility / code-reuse? Enabling scientists (non-programmers) to
build computational networkso BAD:
? Application centric? Lack of programmability? Limited sets of data types? Hard to add new nodes
![Page 6: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/6.jpg)
SciPy’02, © M.Sanner, TSRI
Python to the rescuePython to the rescue
High level language as a scripting environmentHigh level language as a scripting environment
MolecularSurfaces
Molecular
MolecularSurfaces
Surfaces
Molecules
Molecules
Molecules
DataBase
DataDataBaseBaseElectrostatics
Electrostatics
Electrostatics
DelaunayDelaunayDelaunay
Homology
Homology
HomologyCSGCSGCSG
3DViewer
3D3DViewerViewer
MM-MDMM-MDMM-MD
NewMethod
NewNewMethodMethod
Your
MethodYourYour
MethodMethod
![Page 7: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/7.jpg)
SciPy’02, © M.Sanner, TSRI
ViPErViPEr: almost AVS-5: almost AVS-5
![Page 8: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/8.jpg)
SciPy’02, © M.Sanner, TSRI
ViPErViPEr: NOT AVS-5: NOT AVS-5
![Page 9: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/9.jpg)
SciPy’02, © M.Sanner, TSRI
Demo 1Demo 1
![Page 10: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/10.jpg)
SciPy’02, © M.Sanner, TSRI
Architecture OverviewArchitecture Overview
NetworEditor
ViPEr
![Page 11: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/11.jpg)
SciPy’02, © M.Sanner, TSRI
LibrariesLibraries
Standard 3D Viewer Misc.MolKitSymServerImageLibCCP4…
DejaVu
MolKitsymservPIL
ViPER Libraries Python Packages
![Page 12: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/12.jpg)
SciPy’02, © M.Sanner, TSRI
NetworkNodeNetworkNode
MyNode
Input PortName: inPort1Type: StringRequired: 1
Output Portname: outPort1Type: None
‘myfile.dat’ ‘file1.dat’
[myfile.dat’, ‘file1.dat’]
def doit(self, inPort1): out =[] for n in names: out.append( read(n)) self.outputData(outPort1=out)
![Page 13: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/13.jpg)
SciPy’02, © M.Sanner, TSRI
NetworkNodeNetworkNodeclass ReadImage(NetworkNode): """based on the Image.open function. Reads an image file Input: filename (string) Output: Image""" def __init__(self, name='Read Image'): NetworkNode.__init__(self, name=name) self.readOnly = 1 self.inputPortsDescr.append( {'name':'filename', 'datatype':‘string’} ) self.outputPortsDescr.append( {'name':'image', 'datatype':’image’ } )
self.widgetDescr['filename'] = {'class':NEEntryWithFileBrowser, 'master':'node', 'filetypes': [('all', '*')], 'title':'read image’, 'width':10 } code = """def doit(self, filename): import Image im = Image.open(filename) if im: self.outputData(image=im)\n""" self.setFunction(code)
![Page 14: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/14.jpg)
SciPy’02, © M.Sanner, TSRI
class ReadImage(NetworkNode): """based on the Image.open function. Reads an image file Input: filename (string) Output: Image""" def __init__(self, name='Read Image'): NetworkNode.__init__(self, name=name) self.readOnly = 1 self.inputPortsDescr.append( {'name':'filename', 'datatype':‘string’} ) self.outputPortsDescr.append( {'name':'image', 'datatype':’image’ } )
self.widgetDescr['filename'] = {'class':NEEntryWithFileBrowser, 'master':'node', 'filetypes': [('all', '*')], 'title':'read image’, 'width':10 } code = """def doit(self, filename): import Image im = Image.open(filename) if im: self.outputData(image=im)\n""" self.setFunction(code)
NetworkNodeNetworkNode
SubclassNetworkNode
![Page 15: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/15.jpg)
SciPy’02, © M.Sanner, TSRI
NetworkNodeNetworkNodeclass ReadImage(NetworkNode): """based on the Image.open function. Reads an image file Input: filename (string) Output: Image""" def __init__(self, name='Read Image'): NetworkNode.__init__(self, name=name) self.readOnly = 1 self.inputPortsDescr.append( {'name':'filename', 'datatype':‘string’} ) self.outputPortsDescr.append( {'name':'image', 'datatype':’image’ } )
self.widgetDescr['filename'] = {'class':NEEntryWithFileBrowser, 'master':'node', 'filetypes': [('all', '*')], 'title':'read image’, 'width':10 } code = """def doit(self, filename): import Image im = Image.open(filename) if im: self.outputData(image=im)\n""" self.setFunction(code)
Doc string:will serve as the tooltipin the nodes library
![Page 16: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/16.jpg)
SciPy’02, © M.Sanner, TSRI
NetworkNodeNetworkNodeclass ReadImage(NetworkNode): """based on the Image.open function. Reads an image file Input: filename (string) Output: Image""" def __init__(self, name='Read Image'): NetworkNode.__init__(self, name=name) self.readOnly = 1 self.inputPortsDescr.append( {'name':'filename', 'datatype':‘string’} ) self.outputPortsDescr.append( {'name':'image', 'datatype':’image’ } )
self.widgetDescr['filename'] = {'class':NEEntryWithFileBrowser, 'master':'node', 'filetypes': [('all', '*')], 'title':'read image’, 'width':10 } code = """def doit(self, filename): import Image im = Image.open(filename) if im: self.outputData(image=im)\n""" self.setFunction(code)
This node will N0Tbe editable by a user
![Page 17: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/17.jpg)
SciPy’02, © M.Sanner, TSRI
NetworkNodeNetworkNodeclass ReadImage(NetworkNode): """based on the Image.open function. Reads an image file Input: filename (string) Output: Image""" def __init__(self, name='Read Image'): NetworkNode.__init__(self, name=name) self.readOnly = 1 self.inputPortsDescr.append( {'name':'filename', 'datatype':‘string’} ) self.outputPortsDescr.append( {'name':'image', 'datatype':’image’ } )
self.widgetDescr['filename'] = {'class':NEEntryWithFileBrowser, 'master':'node', 'filetypes': [('all', '*')], 'title':'read image’, 'width':10 } code = """def doit(self, filename): import Image im = Image.open(filename) if im: self.outputData(image=im)\n""" self.setFunction(code)
Input ports description: required arguments: name: string optional arguments: required: (0,1) datatype: type ballons: string noWidgetValue: value
![Page 18: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/18.jpg)
SciPy’02, © M.Sanner, TSRI
NetworkNodeNetworkNodeclass ReadImage(NetworkNode): """based on the Image.open function. Reads an image file Input: filename (string) Output: Image""" def __init__(self, name='Read Image'): NetworkNode.__init__(self, name=name) self.readOnly = 1 self.inputPortsDescr.append( {'name':'filename', 'datatype':‘string’} ) self.outputPortsDescr.append( {'name':'image', 'datatype':’image’ } )
self.widgetDescr['filename'] = {'class':NEEntryWithFileBrowser, 'master':'node', 'filetypes': [('all', '*')], 'title':'read image’, 'width':10 } code = """def doit(self, filename): import Image im = Image.open(filename) if im: self.outputData(image=im)\n""" self.setFunction(code)
Output ports description: required arguments: name: string optional arguments: datatype: type ballons: string noWidgetValue: value
![Page 19: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/19.jpg)
SciPy’02, © M.Sanner, TSRI
NetworkNodeNetworkNodeclass ReadImage(NetworkNode): """based on the Image.open function. Reads an image file Input: filename (string) Output: Image""" def __init__(self, name='Read Image'): NetworkNode.__init__(self, name=name) self.readOnly = 1 self.inputPortsDescr.append( {'name':'filename', 'datatype':‘string’} ) self.outputPortsDescr.append( {'name':'image', 'datatype':’image’ } )
self.widgetDescr['filename'] = {'class':NEEntryWithFileBrowser, 'master':'node', 'filetypes': [('all', '*')], 'title':'read image’, 'width':10 } code = """def doit(self, filename): import Image im = Image.open(filename) if im: self.outputData(image=im)\n""" self.setFunction(code)
Widgets description: Key: port name values: class: widget class master: ‘node’ or None widget specific name:value pairs
![Page 20: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/20.jpg)
SciPy’02, © M.Sanner, TSRI
NetworkNodeNetworkNodeclass ReadImage(NetworkNode): """based on the Image.open function. Reads an image file Input: filename (string) Output: Image""" def __init__(self, name='Read Image'): NetworkNode.__init__(self, name=name) self.readOnly = 1 self.inputPortsDescr.append( {'name':'filename', 'datatype':‘string’} ) self.outputPortsDescr.append( {'name':'image', 'datatype':’image’ } )
self.widgetDescr['filename'] = {'class':NEEntryWithFileBrowser, 'master':'node', 'filetypes': [('all', '*')], 'title':'read image’, 'width':10 } code = """def doit(self, filename): import Image im = Image.open(filename) if im: self.outputData(image=im)\n""" self.setFunction(code)
Computational function: defined as a string set dynamically
![Page 21: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/21.jpg)
SciPy’02, © M.Sanner, TSRI
Node EditorNode Editor
Demo 2
![Page 22: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/22.jpg)
SciPy’02, © M.Sanner, TSRI
Node Libraries, data typesNode Libraries, data types
newlib = NodeLibrary(‘mylibrary’, ‘#AAEECC’)newlib.addNode(ReadImage, ‘Read Image’, ‘input’)
class ImageType(AnyType): def __init__(self): self.name = ‘image’ self.color = ‘#995699’ self.shape = ‘rect1’ def validate(self, data): import Image return isinstance(data, Image.Image)
newlib.typesTable.append( ImageType() )
Create a NodeLibraryObjectcalled ‘mylibrary’ andwith a specific color
![Page 23: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/23.jpg)
SciPy’02, © M.Sanner, TSRI
Node Libraries, data typesNode Libraries, data types
newlib = NodeLibrary(‘mylibrary’, ‘#AAEECC’)newlib.addNode(ReadImage, ‘Read Image’, ‘input’)
class ImageType(AnyType): def __init__(self): self.name = ‘image’ self.color = ‘#995699’ self.shape = ‘rect1’ def validate(self, data): import Image return isinstance(data, Image.Image)
newlib.typesTable.append( ImageType() )
Add a node to the library: (Class, Name, Category)
![Page 24: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/24.jpg)
SciPy’02, © M.Sanner, TSRI
class ImageType(AnyType): def __init__(self): self.name = ‘image’ self.color = ‘#995699’ self.shape = ‘rect1’ def validate(self, data): import Image return isinstance(data, Image.Image)
newlib.typesTable.append( ImageType() )
Node Libraries, data typesNode Libraries, data types
newlib = NodeLibrary(‘mylibrary’, ‘#AAEECC’)newlib.addNode(ReadImage, ‘Read Image’, ‘input’)
Define a new type bysubclassing AnyType.A type object providesat least a name, a colorand a shape.I can also provide avalidation function.
![Page 25: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/25.jpg)
SciPy’02, © M.Sanner, TSRI
Node Libraries, data typesNode Libraries, data types
newlib = NodeLibrary(‘mylibrary’, ‘#AAEECC’)newlib.addNode(ReadImage, ‘Read Image’, ‘input’)
class ImageType(AnyType): def __init__(self): self.name = ‘image’ self.color = ‘#995699’ self.shape = ‘rect1’ def validate(self, data): import Image return isinstance(data, Image.Image)
newlib.typesTable.append( ImageType() )
Add a type to alibrary of nodes.When this library isloaded the type willbe registered
![Page 26: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/26.jpg)
SciPy’02, © M.Sanner, TSRI
Saving NetworksSaving Networks## Network: Network 0## file written by viper## saving node Read Imagefrom ViPEr.pillib import ReadImagenode0 = ReadImage(name='Read Image’)masterNet.addNode(node0,103,57)widget = node0.inputPorts[0].widgetcfg = {}apply( widget.configure, (), cfg)if restoreWidgetValues: widget.set(‘lena.jpg’,0)## saving node Show Imagefrom ViPEr.pillib import ShowImagenode1 = ShowImage(name='Show Image')masterNet.addNode(node1, 84, 116)
## saving connections for network Network 0masterNet.connectNodes(node0, node1,0,0)
![Page 27: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/27.jpg)
SciPy’02, © M.Sanner, TSRI
Saving NetworksSaving Networks## Network: Network 0## file written by viper## saving node Read Imagefrom ViPEr.pillib import ReadImagenode0 = ReadImage(name='Read Image’)masterNet.addNode(node0,103,57)widget = node0.inputPorts[0].widgetcfg = {}apply( widget.configure, (), cfg)if restoreWidgetValues: widget.set(‘lena.jpg’,0)## saving node Show Imagefrom ViPEr.pillib import ShowImagenode1 = ShowImage(name='Show Image')masterNet.addNode(node1, 84, 116)
## saving connections for network Network 0masterNet.connectNodes(node0, node1,0,0)
Create a NodeLibraryObjectcalled ‘mylibrary’ andwith a specific color
![Page 28: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/28.jpg)
SciPy’02, © M.Sanner, TSRI
Saving NetworksSaving Networks## Network: Network 0## file written by viper## saving node Read Imagefrom ViPEr.pillib import ReadImagenode0 = ReadImage(name='Read Image’)masterNet.addNode(node0,103,57)widget = node0.inputPorts[0].widgetcfg = {}apply( widget.configure, (), cfg)if restoreWidgetValues: widget.set(‘lena.jpg’,0)## saving node Show Imagefrom ViPEr.pillib import ShowImagenode1 = ShowImage(name='Show Image')masterNet.addNode(node1, 84, 116)
## saving connections for network Network 0masterNet.connectNodes(node0, node1,0,0)
Get a handle to the widgetConfigure he widgetSet the Widget’s value
![Page 29: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/29.jpg)
SciPy’02, © M.Sanner, TSRI
Saving NetworksSaving Networks## Network: Network 0## file written by viper## saving node Read Imagefrom ViPEr.pillib import ReadImagenode0 = ReadImage(name='Read Image’)masterNet.addNode(node0,103,57)widget = node0.inputPorts[0].widgetcfg = {}apply( widget.configure, (), cfg)if restoreWidgetValues: widget.set(‘lena.jpg’,0)## saving node Show Imagefrom ViPEr.pillib import ShowImagenode1 = ShowImage(name='Show Image')masterNet.addNode(node1, 84, 116)
## saving connections for network Network 0masterNet.connectNodes(node0, node1,0,0)
Create second node
![Page 30: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/30.jpg)
SciPy’02, © M.Sanner, TSRI
Saving NetworksSaving Networks## Network: Network 0## file written by viper## saving node Read Imagefrom ViPEr.pillib import ReadImagenode0 = ReadImage(name='Read Image’)masterNet.addNode(node0,103,57)widget = node0.inputPorts[0].widgetcfg = {}apply( widget.configure, (), cfg)if restoreWidgetValues: widget.set(‘lena.jpg’,0)## saving node Show Imagefrom ViPEr.pillib import ShowImagenode1 = ShowImage(name='Show Image')masterNet.addNode(node1, 84, 116)
## saving connections for network Network 0masterNet.connectNodes(node0, node1,0,0)
Create Connectionfrom node0’s output port 0to node1’s input port 0
![Page 31: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/31.jpg)
SciPy’02, © M.Sanner, TSRI
Saving edited nodesSaving edited nodes
![Page 32: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/32.jpg)
SciPy’02, © M.Sanner, TSRI
Saving NetworksSaving Networks## Network: Network 0## file written by viper## saving node Read Imagefrom ViPEr.pillib import ReadImageclass NewNode(ReadImage): def __init__(self, name='Read Image'): apply( ReadImage.__init__, (self,), {'name':name,'originalClass':ReadImage}) code = """def doit(self, filename): print 'Reading file:', filename if filename: im = Image.open(filename)
if im: self.outputData(image=im)""" if code: self.setFunction(code) self.inputPortsDescr=[] self.outputPortsDescr=[] self.widgetDescr = {} self.inputPortsDescr.append( {'validateSrc': None, 'name': 'filename', 'balloons': None, 'required': 1, 'noWidgetValue': '', 'datatype': 'string'})
self.outputPortsDescr.append( {'balloons': None, 'name': 'image', 'datatype': 'image'}) self.widgetDescr['filename'] = { 'class': 'NEEntryWithFileBrowser', 'master': 'node'}node0 = NewNode(name='Read Image')node0.modified=1masterNet.addNode(node0,95,65)
widget = node0.inputPorts[0].widgetcfg = {}apply( widget.configure, (), cfg)if restoreWidgetValues: widget.set(”lena,jpg",0)...
![Page 33: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/33.jpg)
SciPy’02, © M.Sanner, TSRI
Saving NetworksSaving Networks## Network: Network 0## file written by viper## saving node Read Imagefrom ViPEr.pillib import ReadImageclass NewNode(ReadImage): def __init__(self, name='Read Image'): apply( ReadImage.__init__, (self,), {'name':name,'originalClass':ReadImage}) code = """def doit(self, filename): print 'Reading file:', filename if filename: im = Image.open(filename)
if im: self.outputData(image=im)""" if code: self.setFunction(code) self.inputPortsDescr=[] self.outputPortsDescr=[] self.widgetDescr = {} self.inputPortsDescr.append( {'validateSrc': None, 'name': 'filename', 'balloons': None, 'required': 1, 'noWidgetValue': '', 'datatype': 'string'})
self.outputPortsDescr.append( {'balloons': None, 'name': 'image', 'datatype': 'image'}) self.widgetDescr['filename'] = { 'class': 'NEEntryWithFileBrowser', 'master': 'node'}node0 = NewNode(name='Read Image')node0.modified=1masterNet.addNode(node0,95,65)
widget = node0.inputPorts[0].widgetcfg = {}apply( widget.configure, (), cfg)if restoreWidgetValues: widget.set(”lena,jpg",0)...
Subclass originalReadImage node
from ViPEr.pillib import ReadImageclass NewNode(ReadImage): def __init__(self, name='Read Image'): apply( ReadImage.__init__, (self,), {'name':name,'originalClass':ReadImage})
![Page 34: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/34.jpg)
SciPy’02, © M.Sanner, TSRI
Saving NetworksSaving Networks## Network: Network 0## file written by viper## saving node Read Imagefrom ViPEr.pillib import ReadImageclass NewNode(ReadImage): def __init__(self, name='Read Image'): apply( ReadImage.__init__, (self,), {'name':name,'originalClass':ReadImage}) code = """def doit(self, filename): print 'Reading file:', filename if filename: im = Image.open(filename)
if im: self.outputData(image=im)""" if code: self.setFunction(code) self.inputPortsDescr=[] self.outputPortsDescr=[] self.widgetDescr = {} self.inputPortsDescr.append( {'validateSrc': None, 'name': 'filename', 'balloons': None, 'required': 1, 'noWidgetValue': '', 'datatype': 'string'})
self.outputPortsDescr.append( {'balloons': None, 'name': 'image', 'datatype': 'image'}) self.widgetDescr['filename'] = { 'class': 'NEEntryWithFileBrowser', 'master': 'node'}node0 = NewNode(name='Read Image')node0.modified=1masterNet.addNode(node0,95,65)
widget = node0.inputPorts[0].widgetcfg = {}apply( widget.configure, (), cfg)if restoreWidgetValues: widget.set(”lena,jpg",0)...
Define modifiedcomputationalfunction
code = """def doit(self, filename): print 'Reading file:', filename if filename: im = Image.open(filename)
if im: self.outputData(image=im)""" if code: self.setFunction(code)
![Page 35: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/35.jpg)
SciPy’02, © M.Sanner, TSRI
Saving NetworksSaving Networks## Network: Network 0## file written by viper## saving node Read Imagefrom ViPEr.pillib import ReadImageclass NewNode(ReadImage): def __init__(self, name='Read Image'): apply( ReadImage.__init__, (self,), {'name':name,'originalClass':ReadImage}) code = """def doit(self, filename): print 'Reading file:', filename if filename: im = Image.open(filename)
if im: self.outputData(image=im)""" if code: self.setFunction(code) self.inputPortsDescr=[] self.outputPortsDescr=[] self.widgetDescr = {} self.inputPortsDescr.append( {'validateSrc': None, 'name': 'filename', 'balloons': None, 'required': 1, 'noWidgetValue': '', 'datatype': 'string'})
self.outputPortsDescr.append( {'balloons': None, 'name': 'image', 'datatype': 'image'}) self.widgetDescr['filename'] = { 'class': 'NEEntryWithFileBrowser', 'master': 'node'}node0 = NewNode(name='Read Image')node0.modified=1masterNet.addNode(node0,95,65)
widget = node0.inputPorts[0].widgetcfg = {}apply( widget.configure, (), cfg)if restoreWidgetValues: widget.set(”lena,jpg",0)...
Describe portsand widgets
![Page 36: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/36.jpg)
SciPy’02, © M.Sanner, TSRI
Saving NetworksSaving Networks## Network: Network 0## file written by viper## saving node Read Imagefrom ViPEr.pillib import ReadImageclass NewNode(ReadImage): def __init__(self, name='Read Image'): apply( ReadImage.__init__, (self,), {'name':name,'originalClass':ReadImage}) code = """def doit(self, filename): print 'Reading file:', filename if filename: im = Image.open(filename)
if im: self.outputData(image=im)""" if code: self.setFunction(code) self.inputPortsDescr=[] self.outputPortsDescr=[] self.widgetDescr = {} self.inputPortsDescr.append( {'validateSrc': None, 'name': 'filename', 'balloons': None, 'required': 1, 'noWidgetValue': '', 'datatype': 'string'})
self.outputPortsDescr.append( {'balloons': None, 'name': 'image', 'datatype': 'image'}) self.widgetDescr['filename'] = { 'class': 'NEEntryWithFileBrowser', 'master': 'node'}node0 = NewNode(name='Read Image')node0.modified=1masterNet.addNode(node0,95,65)
widget = node0.inputPorts[0].widgetcfg = {}apply( widget.configure, (), cfg)if restoreWidgetValues: widget.set(”lena,jpg",0)...
Create an instance ofNewNode.Remember it does notcome from a library.Add it to the network.
node0 = NewNode(name='Read Image')node0.modified=1masterNet.addNode(node0,95,65)
![Page 37: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/37.jpg)
SciPy’02, © M.Sanner, TSRI
Saving NetworksSaving Networks## Network: Network 0## file written by viper## saving node Read Imagefrom ViPEr.pillib import ReadImageclass NewNode(ReadImage): def __init__(self, name='Read Image'): apply( ReadImage.__init__, (self,), {'name':name,'originalClass':ReadImage}) code = """def doit(self, filename): print 'Reading file:', filename if filename: im = Image.open(filename)
if im: self.outputData(image=im)""" if code: self.setFunction(code) self.inputPortsDescr=[] self.outputPortsDescr=[] self.widgetDescr = {} self.inputPortsDescr.append( {'validateSrc': None, 'name': 'filename', 'balloons': None, 'required': 1, 'noWidgetValue': '', 'datatype': 'string'})
self.outputPortsDescr.append( {'balloons': None, 'name': 'image', 'datatype': 'image'}) self.widgetDescr['filename'] = { 'class': 'NEEntryWithFileBrowser', 'master': 'node'}node0 = NewNode(name='Read Image')node0.modified=1masterNet.addNode(node0,95,65)
widget = node0.inputPorts[0].widgetcfg = {}apply( widget.configure, (), cfg)if restoreWidgetValues: widget.set(”lena,jpg",0)...
Get a handle to widgetand configure it
widget = node0.inputPorts[0].widgetcfg = {}apply( widget.configure, (), cfg)
![Page 38: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/38.jpg)
SciPy’02, © M.Sanner, TSRI
Saving NetworksSaving Networks## Network: Network 0## file written by viper## saving node Read Imagefrom ViPEr.pillib import ReadImageclass NewNode(ReadImage): def __init__(self, name='Read Image'): apply( ReadImage.__init__, (self,), {'name':name,'originalClass':ReadImage}) code = """def doit(self, filename): print 'Reading file:', filename if filename: im = Image.open(filename)
if im: self.outputData(image=im)""" if code: self.setFunction(code) self.inputPortsDescr=[] self.outputPortsDescr=[] self.widgetDescr = {} self.inputPortsDescr.append( {'validateSrc': None, 'name': 'filename', 'balloons': None, 'required': 1, 'noWidgetValue': '', 'datatype': 'string'})
self.outputPortsDescr.append( {'balloons': None, 'name': 'image', 'datatype': 'image'}) self.widgetDescr['filename'] = { 'class': 'NEEntryWithFileBrowser', 'master': 'node'}node0 = NewNode(name='Read Image')node0.modified=1masterNet.addNode(node0,95,65)
widget = node0.inputPorts[0].widgetcfg = {}apply( widget.configure, (), cfg)if restoreWidgetValues: widget.set(”lena,jpg",0)...
Restore the widget’svalue only if therestoreWidgetValueoption is enabled.
if restoreWidgetValues: widget.set(”lena,jpg",0)
![Page 39: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/39.jpg)
SciPy’02, © M.Sanner, TSRI
MacrosMacros
![Page 40: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/40.jpg)
SciPy’02, © M.Sanner, TSRI
WidgetsWidgets
![Page 41: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/41.jpg)
SciPy’02, © M.Sanner, TSRI
Example 1:Example 1: Tomographic Tomographic reconstructionreconstruction
Image by Daniel Stoffler
![Page 42: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/42.jpg)
SciPy’02, © M.Sanner, TSRI
Example 2:Example 2: symmetry server symmetry server
![Page 43: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/43.jpg)
SciPy’02, © M.Sanner, TSRI
Future DirectionsFuture Directionso Still needs a lot of work :)
? optimization, documentation, addingfeatures
o Multi-threaded execution schedulingo Layered networkso Become Tkinter independent ?o More nodes and libraries, Web repositoryo Integration into PMVo Open Source
![Page 44: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/44.jpg)
Michel F. SANNER TSRI 2002
ConclusionConclusion
o General Purpose VisualProgramming Environment
o Lightweight nodes / code reuseo Dynamically extensibleo Scriptable
o Used on real scientific problems
![Page 45: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/45.jpg)
SciPy’02, © M.Sanner, TSRI
Availability: the Availability: the packagerpackager
http://www.scripps.edu/~sanner/python
![Page 46: ViPEr, a Visual programming Environment for Python · Michel F. SANNER TSRI 2002 ViPEr, a Visual programming Environment](https://reader034.vdocuments.site/reader034/viewer/2022052008/601cc535165d861aa26a9182/html5/thumbnails/46.jpg)
SciPy’02, © M.Sanner, TSRI
AcknowledgmentsAcknowledgments
o Molecular Graphics Lab. at TSRIo NIH (NBCR RR08605)o Swiss National Science Foundationo Garrett M. Morris
? (“if > 5” network design)
http://www.scripps.edu/~sanner/python