Changeset 119

Show
Ignore:
Timestamp:
07/03/07 15:29:43 (1 year ago)
Author:
apdavison
Message:

Poster now seems to be complete, although improvements to the text and appearance are needed, together with checks for errors/typos/inaccuracies

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • doc/CNS2007/poster_cns2007.py

    r117 r119  
    117117    return title_bottom 
    118118 
    119 def make_abstract(styles,text,x,y,width,height,_debug): 
    120     abstract_frame = Frame(x, y - height, width, height, 
    121                            showBoundary=_debug) 
    122  
    123     abstract = [Paragraph(p, styles['BodyText']) for p in ABSTRACT.split("\n\n")] 
    124     #print abstract 
    125     abstract_frame.addFromList(abstract, poster) 
    126     #while not abstract_frame.addFromList(abstract, poster): 
    127     #    abstract_frame._height += 1*cm 
    128     #    abstract_frame._geom() 
    129     #    abstract_frame._reset() 
    130     #    print abstract_frame._height 
     119def make_text_frame(styles,text,x,y,width,height,_debug): 
     120    pad = 0.5*cm 
     121    frame = Frame(x, y - height, width, height, 
     122                  leftPadding=pad, rightPadding=pad, bottomPadding=pad, 
     123                  topPadding=pad, showBoundary=_debug) 
     124 
     125    paragraph_list = [Paragraph(p, styles['BodyText']) for p in text.split("\n\n")] 
     126    frame.addFromList(paragraph_list, poster) 
     127    poster.roundRect(x,y-height,width,height,1*cm) 
     128 
     129def make_deflist_frame(styles,definition_list,x,y,width,height,_debug): 
     130    pad = 0.5*cm 
     131    frame = Frame(x, y - height, width, height, 
     132                  leftPadding=pad, rightPadding=pad, bottomPadding=pad, 
     133                  topPadding=pad, showBoundary=_debug) 
     134     
     135    def calc_height(): 
     136        paragraph_list = [Paragraph('<font color="darkgreen"><b>%s</b></font> %s' % item, styles['BodyText']) for item in definition_list] 
     137        f_height = 2*pad 
     138        for p in paragraph_list: 
     139            f_height += p.wrap(width-2*pad,pageheight)[1] + p.getSpaceAfter() + p.getSpaceBefore() 
     140        return f_height 
     141 
     142    while calc_height() > height: 
     143        scale_style(styles['BodyText'], 0.99) 
     144    styles['BodyText'].alignment = TA_JUSTIFY # otherwise we get a 'bad align' error 
     145         
     146    paragraph_list = [Paragraph('<font color="darkgreen"><b>%s</b></font> %s' % item, styles['BodyText']) for item in definition_list] 
     147    frame.addFromList(paragraph_list, poster) 
     148    poster.roundRect(x,y-height,width,height,1*cm) 
    131149 
    132150def make_users_guide(styles,x,y,width,height,_debug=False): 
     
    138156    import restxsl.transform 
    139157    import re 
    140      
    141     #scale_factor = 3.6 
    142     #users_guide_style = ParagraphStyle('UsersGuide', parent=styles['BodyText']) 
    143     #scale_style(users_guide_style, 1.5/scale_factor) 
    144     #styles.add(users_guide_style) 
    145      
    146     #for style in "Heading1","Heading2","Heading3","Code": 
    147     #    newstyle = ParagraphStyle('UsersGuide%s' % style, parent=styles[style]) 
    148     #    scale_style(newstyle, 1.5/scale_factor) 
    149     #    styles.add(newstyle) 
    150     #styles['UsersGuide'].alignment = TA_JUSTIFY 
    151158     
    152159    user_guide_frame = Frame(x, y - height, width, height, showBoundary=_debug) 
     
    226233        f_height += p.wrap(subcol_width-pad, pageheight)[1] + p.getSpaceAfter() + p.getSpaceBefore() 
    227234    f_height = f_height/2.0 + 2*pad 
    228     apidoc_frame1 = Frame(x, y - height, subcol_width, f_height, showBoundary=_debug, 
     235    apidoc_frame1 = Frame(x, y - f_height, subcol_width, f_height, showBoundary=_debug, 
    229236                          leftPadding=pad, rightPadding=0, bottomPadding=pad, 
    230237                          topPadding=pad) 
    231     apidoc_frame2 = Frame(x+width-subcol_width, y - height, subcol_width, f_height, showBoundary=_debug, 
     238    apidoc_frame2 = Frame(x+width-subcol_width, y - f_height, subcol_width, f_height, showBoundary=_debug, 
    232239                          leftPadding=0, rightPadding=pad, bottomPadding=pad, 
    233240                          topPadding=pad) 
     
    235242    apidoc_frame2.addFromList(paragraph_list, poster) 
    236243    assert len(paragraph_list) == 0 
    237     poster.roundRect(x,y-height,width,f_height,1*cm) 
     244    poster.roundRect(x,y-f_height,width,f_height,1*cm) 
     245    return x, y-f_height, width, f_height 
    238246 
    239247def colourize(code): 
     
    258266    return output 
    259267 
    260 def make_example(styles,x,y,width,height,_debug=False): 
     268def make_example(styles,x_r,y,width,height,_debug=False): 
    261269    """ Make a frame showing the VAbenchmarks.py script, together with figure.""" 
    262270    global poster 
     
    268276    example_script = f.read() 
    269277    f.close() 
     278    lines = example_script.split('\n') 
     279    nlines = len(lines) 
     280    maxlength = 0 
     281    for line in lines: 
     282        if len(line) > maxlength: 
     283            maxlength = len(line) 
    270284    example_script = colourize(example_script) 
     285     
     286    scale_style(styles['Code'], 10.0/styles['Code'].fontSize) 
    271287     
    272288    pad = 0.5*cm 
    273289    code_flowable = XPreformatted(example_script, styles['Code']) 
    274     f_width = stringWidth("m"*110, styles['Code'].fontName, styles['Code'].fontSize, 'UTF-8') + 2*pad 
     290     
    275291    paragraph_list = [Paragraph("Example", styles['Title']), 
    276292                      code_flowable] 
    277     # Scale the font size to fill the space 
    278     def calc_height(): 
    279         f_height = 0 
    280         for p in paragraph_list: 
    281             f_height += p.wrap(f_width, pageheight)[1] + p.getSpaceAfter() + p.getSpaceBefore() 
    282         ##f_height = nlines*(styles['Code'].leading+styles['Code'].spaceAfter+styles['Code'].spaceBefore) 
    283         ##f_height += styles['Title'].leading + styles['Title'].spaceBefore + styles['Title'].spaceAfter 
    284         f_height += 2*pad 
    285         return f_height 
    286     scale_style(styles['Code'],5.0) 
    287     while calc_height() > height: 
    288         #print styles['Code'].fontSize 
    289         scale_style(styles['Code'], 0.99) 
    290     print styles['Code'].fontSize 
    291     example_frame = Frame(x, y-height, f_width, height, showBoundary=_debug, 
     293 
     294    code_height = styles['Code'].leading+styles['Code'].spaceAfter+styles['Code'].spaceBefore 
     295    f_height = nlines * code_height 
     296    f_height += styles['Title'].leading + styles['Title'].spaceBefore + styles['Title'].spaceAfter 
     297    f_height /= 2.0 
     298     
     299    lines_in_first_frame = int(nlines - f_height/code_height) 
     300    maxlength = 0 
     301    for line in lines[:lines_in_first_frame]: 
     302        if len(line) > maxlength: 
     303            maxlength = len(line) 
     304    f_width1 = stringWidth("m"*maxlength, styles['Code'].fontName, styles['Code'].fontSize, 'UTF-8') + pad 
     305    maxlength = 0 
     306    for line in lines[lines_in_first_frame:]: 
     307        if len(line) > maxlength: 
     308            maxlength = len(line) 
     309    f_width2 = stringWidth("m"*maxlength, styles['Code'].fontName, styles['Code'].fontSize, 'UTF-8') + pad 
     310    f_height += 2*pad 
     311 
     312    x = x_r - f_width1 - f_width2 
     313 
     314    frame1 = Frame(x, y-f_height, f_width1, f_height, showBoundary=_debug, 
     315                          leftPadding=pad, rightPadding=0, bottomPadding=pad, 
     316                          topPadding=pad) 
     317    frame1.add(Paragraph("Example", styles['Title']), poster) 
     318    flowables = frame1.split(code_flowable, poster) 
     319     
     320    frame1.addFromList(flowables, poster) 
     321    frame2 = Frame(x + f_width1, y-f_height, f_width2, f_height, showBoundary=_debug, 
    292322                          leftPadding=pad, rightPadding=pad, bottomPadding=pad, 
    293323                          topPadding=pad) 
    294     example_frame.addFromList(paragraph_list, poster) 
    295     poster.roundRect(x,y-height,f_width,height,1*cm) 
    296  
    297 def make_example_figure(styles,filename,caption,x,y,width,_debug=False): 
    298     global poster 
    299     img = Image(filename, width=width, height=1e12, kind='proportional', lazy=0) 
    300     caption_paras = [Paragraph(p.strip(), styles['BodyText']) for p in caption.split("\n") if p.strip()] 
    301     print len(caption_paras) 
     324    frame2.addFromList(flowables, poster) 
     325    #frame3 = Frame(x + 2*f_width, y-f_height, f_width, f_height, showBoundary=_debug, 
     326    #                      leftPadding=0, rightPadding=pad, bottomPadding=pad, 
     327    #                      topPadding=pad) 
     328    #frame3.addFromList(flowables, poster) 
     329 
     330    poster.roundRect(x,y-f_height,f_width1+f_width2,f_height,1*cm) 
     331    return x, y-f_height, f_width1+f_width2,f_height 
     332 
     333def make_example_figure(filename,x,y,width,height,_debug=False): 
     334    global poster 
    302335    pad = 0.5*cm 
     336    img = Image(filename, width=width-2*pad, height=height-2*pad, kind='proportional', lazy=0) 
    303337    f_height = img.drawHeight + 2*pad 
    304     for p in caption_paras: 
    305         f_height += p.wrap(width,pageheight)[1] + p.getSpaceAfter() + p.getSpaceBefore() 
    306338    figure_frame = Frame(x, y-f_height, 
    307                          width + 2*pad, f_height, 
     339                         width, f_height, 
    308340                         showBoundary=_debug, 
    309341                         leftPadding=pad, rightPadding=pad, 
    310342                         bottomPadding=pad, topPadding=pad) 
    311     figure_frame.addFromList([img] + caption_paras, poster) 
    312  
     343    #poster.roundRect(x,y-f_height,width,f_height,1*cm) 
     344    figure_frame.add(img, poster) 
     345 
     346def make_example_figure_caption(caption,x,y,width,height,_debug=False): 
     347    global poster 
     348    styles = getStyleSheet(20, 72) 
     349     
     350    pad = 0.5*cm 
     351    def calc_height(): 
     352        caption_paras = [Paragraph(p.strip(), styles['BodyText']) for p in caption.split("\n") if p.strip()] 
     353        f_height = 2*pad 
     354        for p in caption_paras: 
     355            f_height += p.wrap(width-2*pad,pageheight)[1] + p.getSpaceAfter() + p.getSpaceBefore() 
     356        return f_height 
     357    while calc_height() > height: 
     358        #print styles['BodyText'].fontSize 
     359        scale_style(styles['BodyText'], 0.99) 
     360    scale_style(styles['BodyText'], 1/0.99) 
     361    styles['BodyText'].alignment = TA_JUSTIFY # otherwise we get a 'bad align' error 
     362    caption_paras = [Paragraph(p.strip(), styles['BodyText']) for p in caption.split("\n") if p.strip()] 
     363    caption_frame = Frame(x, y-height, 
     364                         width, height, 
     365                         showBoundary=_debug, 
     366                         leftPadding=pad, rightPadding=pad, 
     367                         bottomPadding=pad, topPadding=pad) 
     368    caption_frame.addFromList(caption_paras, poster) 
     369 
     370def make_fancy_box(x,y,w1,w2,h1,h2): 
     371    global poster 
     372    r = 1*cm 
     373    path = poster.beginPath() 
     374    path.arc(x,y,x+2*r,y+2*r,startAng=180,extent=90) 
     375    path.lineTo(x+w1-r,y) 
     376    path.arc(x+w1-2*r,y+2*r,x+w1,y,startAng=270,extent=90) 
     377    path.lineTo(x+w1,y+h2-r) 
     378    path.arc(x+w1-2*r,y+h2-2*r,x+w1,y+h2,startAng=0,extent=90) 
     379    path.lineTo(x+w2+r,y+h2) 
     380    path.arc(x+w2,y+h2,x+w2+2*r,y+h2+2*r,startAng=180,extent=90) 
     381    path.moveTo(x+w2,y+h2+r) 
     382    path.lineTo(x+w2, y+h1-r) 
     383    path.arc(x+w2-2*r,y+h1-2*r,x+w2,y+h1,startAng=0,extent=90) 
     384    path.lineTo(x+r, y+h1) 
     385    path.arc(x,y+h1-2*r,x+2*r,y+h1,startAng=90,extent=90) 
     386    path.lineTo(x, y+r) 
     387    poster.drawPath(path) 
     388     
    313389def huge_url(x,y,width): 
    314390    global poster 
     
    329405if __name__ == "__main__": 
    330406    svnpath = "https://neuralensemble.kip.uni-heidelberg.de/svn/PyNN/branches/0.3" 
    331     DEBUG = Tru
     407    DEBUG = Fals
    332408     
    333409    TITLE = "PyNN: Towards a universal neural simulator API in Python" 
     
    368444    developed 'meta-simulator' system would then represent a powerful tool for overcoming the so-called 
    369445    <i>complexity bottleneck</i> that is presently a major roadblock for neural modeling. 
    370      
    371     This work is supported by the European Union through the FACETS project (contract number FP6- 
    372     2004-IST-FETPI-15879).""" 
     446    """ 
     447     
     448    QA = [("What is PyNN?", "A Python package that defines and implements a uniform 'application programming interface' (API) across neural simulators. In other words, you can <b>write your simulation script <i>once</i>, then run it <i>without modification</i> on any supported simulator</b> (currently NEURON, NEST and PCSIM)."), 
     449          ("I use simulator <i>X</i>. Why should I switch to PyNN?", "Increased productivity. The main aim of PyNN is to increase the productivity of neuronal network modeling, by making it <b>faster to develop models</b> <i>de novo</i>, by <b>promoting code sharing and reuse</b> across simulator communities, and by making it much <b>easier to debug, test and validate simulations by running them on more than one simulator</b>. Even if you're not interested in using multiple simulators, if you don't already use Python or another dynamic, object-oriented language, and if your simulator doesn't already support programming using abstractions above the level of individual neurons and synaptic connections, you should see major gains from using a more powerful language and from more readable, shorter, more easily-maintainable code."), 
     450           ("Why Python?", 'Most simulators use configuration files or have their own specific scripting language. These are inevitably less powerful and flexible than a general-purpose programming language such as Python. Furthermore, Python has a huge standard library ("batteries included"), excellent numerical and graphical packages (making it an excellent Matlab replacement), a large developer-base outside the neuroscience community, and is free software.'), 
     451           ("I have a model written for simulator <i>X</i>. How do I convert it to PyNN?", "If <i>X</i> already has a Python interface (NEURON, NEST, PCSIM), first convert the code to Python (e.g. in NEURON, replace your hoc code with Python code) then gradually replace simulator-specific code with PyNN code, all the time checking that the model still runs and gives the same results. If <i>X</i> does not have a Python interface, contact us! We would be happy to work with you on adding support for <i>X</i> to PyNN, whether this is through a direct Python interface or a code-generation tool."), 
     452           ("Where can I download PyNN?", "http://neuralensemble.org/PyNN"), 
     453           ("What other solutions are there for developing simulator-independent models?", "<b>NeuroML</b> (http://neuroml.org) is a standard for model specification in XML. <b>NeuroConstruct</b> (http://neuroconstruct.org) is a tool for developing network models, using a graphical interface, that can then be exported as either NEURON or GENESIS code. There is also some overlap with <b>Neurospaces</b> (http://www.neurospaces.org/), a framework for modular construction of computational neuroscience simulators."), 
     454           ("What are your future plans for PyNN?", "We are currently working on: (i) support for NEST version 2, which adds support for distributed (parallel) simulations (distributed simulations in NEURON and PCSIM are already supported); (ii) support for import/export of network models specified in NeuroML; (iii) various improvements/extensions to the API, (iv) general performance improvements."), 
     455           ("Why shouldn't I use PyNN?", "(i) If your work does not involve network modelling; (ii) if you prefer to use a graphical interface to develop your simulations."), 
     456           ("Who is using PyNN now?", "PyNN was first developed within the FACETS project, an EC-funded consortium of fifteen or so European research groups including seven groups doing computational neuroscience, using six simulators between them. In the absence of agreement that everyone should use the same simulator, a tool to make it easier to share models between groups was needed, and PyNN was born. Within FACETS, PyNN is being used for simulations of large-scale models of primary visual cortex and of generic cortical circuits with synaptic plasticity. We would like to encourage wider use, and anyone interested in using or developing PyNN should check out http://neuralensemble.org.") 
     457         ] 
     458     
     459    ACKNOWLEDGEMENTS = "This work is supported by the European Commission through the FACETS project (contract number FP6-2004-IST-FETPI-15879) and by the CNRS. PY is supported by a MENRT bursary." 
    373460     
    374461    CAPTIONS = { 
     
    384471        Even when using exactly the same connectivity pattern, the membrane potential trajectories diverge after about the first 100 ms, although the pattern of mean activity across the network is well preserved between simulators. 
    385472         
    386         With a different random connectivity (but with the same connection probability), there is no similarity in detailed activity patterns, but the statistical behaviour of the network in terms of spike train variability is the same. 
    387         """ 
     473        With a different random connectivity (but with the same connection probability), there is no similarity in detailed activity patterns, but the statistical behaviour of the network in terms of spike train variability is the same.""" 
    388474    } 
    389475         
    390476         
    391      
    392477    main_font = 'Helvetica' 
    393478    margins = {'left':2*cm, 'right':2*cm, 'top':2*cm, 'bottom':2*cm} 
     
    417502    colwidth = (pagewidth - (ncol-1)*colsep)/float(ncol) 
    418503    colheight = title_bottom - margins['bottom'] 
    419     huge_url(poster._pagesize[0]/2.0, title_bottom/2.0, pagewidth) 
    420     make_abstract(getStyleSheet(36, 72),ABSTRACT, margins['left'], title_bottom, colwidth, colheight, DEBUG) 
     504    #huge_url(poster._pagesize[0]/2.0, title_bottom/2.0, pagewidth) 
     505     
     506    apiwidth = 0.25*pagewidth 
     507    x_api,y_api,w_api,h_api = make_apidocs(getStyleSheet(9,36),margins['left']+pagewidth-apiwidth, title_bottom, apiwidth, 
     508                 colheight, DEBUG) 
     509 
     510     
    421511    #make_users_guide(getStyleSheet(15),margins['left']+colwidth+colsep, title_bottom, colwidth, colheight, DEBUG) 
    422     make_example(getStyleSheet(10.5,36),margins['left']+colwidth+colsep, title_bottom, colwidth, colheight, DEBUG) 
    423     make_example_figure(getStyleSheet(20, 72), "VAbenchmark_CUBA_exc.png", 
    424                         CAPTIONS["VAbenchmark_CUBA_exc.png"], 
    425                         margins['left']+colwidth+colsep, title_bottom, colwidth, DEBUG) 
    426     apiwidth = 0.25*pagewidth 
    427     make_apidocs(getStyleSheet(9,36),margins['left']+pagewidth-apiwidth, title_bottom, apiwidth, 
    428                  colheight, DEBUG) 
     512    x_ex,y_ex,w_ex,h_ex = make_example(getStyleSheet(10.5,36), x_api-colsep, title_bottom, colwidth, colheight, DEBUG) 
     513    make_example_figure("VAbenchmark_CUBA_exc.png", x_ex, y_ex-colsep, w_ex, y_ex-colsep-margins['bottom'], DEBUG) 
     514    make_example_figure_caption(CAPTIONS["VAbenchmark_CUBA_exc.png"], x_api-colsep, y_api-colsep, w_api+colsep, y_api-colsep-margins['bottom'], DEBUG) 
     515    make_fancy_box(x_ex, margins['bottom'],w_ex+colsep+w_api,w_ex,y_ex-colsep-margins['bottom'],y_api-colsep-margins['bottom']) 
     516 
     517    make_deflist_frame(getStyleSheet(36, 72),QA, margins['left'], title_bottom, x_ex-margins['left']-colsep, colheight, DEBUG) 
     518 
     519    poster.setFont("Helvetica", 20) 
     520    poster.drawCentredString(margins['left']+pagewidth/2.0, 0.4*margins['bottom'], ACKNOWLEDGEMENTS) 
    429521 
    430522    poster.save()