export to svg

81 views
Skip to first unread message

Jonas Kubilius

unread,
Jan 21, 2014, 9:31:32 AM1/21/14
to psycho...@googlegroups.com
Hey all,

Recently I wanted to get a screen capture of stimuli for my paper. Since I needed high resolution images, the usual getMovieFrame did not help. Since my stimuli were simple shapes, I decided to convert everything to an svg file and enjoy the precision of vector graphics. I've implemented it in the most recent version of psychopy_ext using svgwrite for most shape stimuli and also a text stimulus.

But perhaps this feature would be useful for all psychopy users? I can see several use cases where SVG output would be preferred over the usual images:
  • High quality
  • Ability to manipulate figures, such as getting rid of certain shapes or copy them to data plots
  • Web-oriented so might find unexpected uses (e.g., ideal for JS-based presentations)
If there is an interest in this, I think the following changes to psychopy would be required:
  • Add a canvas argument in visual.Window:
    • If canvas is None, nothing is exported.
    • If canvas is png, jpg etc, getMovieFrame is used.
    • If canvas is svg, exporting to svg is performed during draw() such that object properties would be recorded even if a user is reusing the same object to draw a frame.
  • Add to_svg() method to all stimuli.
  • Add svgwrite to dependencies.
Here is window capture (please ignore gray lines on the disk; must be some problems with my drivers):

And here is the currently implemented conversion to SVG in psychopy_ext:

Looks quite good already except for the vertical text positioning (I'm not sure how to get the correct text height -- stim.height or stim.heightPix do not report the actual size for some reason). Also, text wrapping will probably be too difficult to implement until SVG 2.0 becomes mainstream.

Michael MacAskill

unread,
Jan 22, 2014, 9:11:49 PM1/22/14
to psycho...@googlegroups.com
Hi Jonas,

That is pretty cool, for the more anally-retentive of us who don't like submitting lo-res images amongst our much higher quality figures.

I guess it handles it OK when the window also contains stimuli that aren't inherently vector-based, like Gabor patches, bitmap images, etc?

Cheers,

Mike

On 22 Jan, 2014, at 03:31, Jonas Kubilius <qbi...@gmail.com> wrote:

> Hey all,
>
> Recently I wanted to get a screen capture of stimuli for my paper. Since I needed high resolution images, the usual getMovieFrame did not help. Since my stimuli were simple shapes, I decided to convert everything to an svg file and enjoy the precision of vector graphics. I've implemented it in the most recent version of psychopy_ext using svgwrite for most shape stimuli and also a text stimulus.
>
> But perhaps this feature would be useful for all psychopy users? I can see several use cases where SVG output would be preferred over the usual images:
> • High quality
> • Ability to manipulate figures, such as getting rid of certain shapes or copy them to data plots
> • Web-oriented so might find unexpected uses (e.g., ideal for JS-based presentations)
> If there is an interest in this, I think the following changes to psychopy would be required:
> • Add a canvas argument in visual.Window:
> • If canvas is None, nothing is exported.
> • If canvas is png, jpg etc, getMovieFrame is used.
> • If canvas is svg, exporting to svg is performed during draw() such that object properties would be recorded even if a user is reusing the same object to draw a frame.
> • Add to_svg() method to all stimuli.
> • Add svgwrite to dependencies.
> Here is window capture (please ignore gray lines on the disk; must be some problems with my drivers):
>
>
>
> And here is the currently implemented conversion to SVG in psychopy_ext:
>
>
>
> Looks quite good already except for the vertical text positioning (I'm not sure how to get the correct text height -- stim.height or stim.heightPix do not report the actual size for some reason). Also, text wrapping will probably be too difficult to implement until SVG 2.0 becomes mainstream.

--
Michael R. MacAskill, PhD 66 Stewart St
Research Director, Christchurch 8011
New Zealand Brain Research Institute NEW ZEALAND

Research Fellow, michael....@nzbri.org
Te Whare Wānanga o Otāgo, Otautahi Ph: +64 3 3786 072
University of Otago, Christchurch http://www.nzbri.org/macaskill



Jonas Kubilius

unread,
Jan 23, 2014, 11:52:49 AM1/23/14
to psycho...@googlegroups.com
I haven't implemented image and Gabor patch support yet. It's doable in principle, of course, since svg allows embedding of non-svg elements.

Jonathan Peirce

unread,
Jan 24, 2014, 5:03:01 AM1/24/14
to psycho...@googlegroups.com
I can't make my mind up on this one. It's right on the threshold of my
anti-bloat drive.

It is cool, for sure, and it has relatively few additional methods, but
you know how I hate adding things that will confuse newbies. Is this a
sought-after feature? Or a rarely used tool, the point of which new
users have to parse? I can't decide.

Jon

On 23/01/2014 02:11, Michael MacAskill wrote:
> Hi Jonas,
>
> That is pretty cool, for the more anally-retentive of us who don't like submitting lo-res images amongst our much higher quality figures.
>
> I guess it handles it OK when the window also contains stimuli that aren't inherently vector-based, like Gabor patches, bitmap images, etc?
>
> Cheers,
>
> Mike
>
> On 22 Jan, 2014, at 03:31, Jonas Kubilius<qbi...@gmail.com> wrote:
>
>> Hey all,
>>
>> Recently I wanted to get a screen capture of stimuli for my paper. Since I needed high resolution images, the usual getMovieFrame did not help. Since my stimuli were simple shapes, I decided to convert everything to an svg file and enjoy the precision of vector graphics. I've implemented it in the most recent version of psychopy_ext using svgwrite for most shape stimuli and also a text stimulus.
>>
>> But perhaps this feature would be useful for all psychopy users? I can see several use cases where SVG output would be preferred over the usual images:
>> • High quality
>> • Ability to manipulate figures, such as getting rid of certain shapes or copy them to data plots
>> • Web-oriented so might find unexpected uses (e.g., ideal for JS-based presentations)
>> If there is an interest in this, I think the following changes to psychopy would be required:
>> • Add a canvas argument in visual.Window:
>> • If canvas is None, nothing is exported.
>> • If canvas is png, jpg etc, getMovieFrame is used.
>> • If canvas is svg, exporting to svg is performed during draw() such that object properties would be recorded even if a user is reusing the same object to draw a frame.
>> • Add to_svg() method to all stimuli.
>> • Add svgwrite to dependencies.
>> Here is window capture (please ignore gray lines on the disk; must be some problems with my drivers):
>>
>>
>>
>> And here is the currently implemented conversion to SVG in psychopy_ext:
>>
>>
>>
>> Looks quite good already except for the vertical text positioning (I'm not sure how to get the correct text height -- stim.height or stim.heightPix do not report the actual size for some reason). Also, text wrapping will probably be too difficult to implement until SVG 2.0 becomes mainstream.

--
Jonathan Peirce
Nottingham Visual Neuroscience

http://www.peirce.org.uk

This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.

This message has been checked for viruses but the contents of an attachment
may still contain software viruses which could damage your computer system, you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.




Jonas Kubilius

unread,
Jan 24, 2014, 6:46:24 AM1/24/14
to psycho...@googlegroups.com
It would be hard to figure out if this is a sought-after feature or not (remember Ford's quote: "If I had asked people what they wanted, they would have said faster horses."). My guess however is that most people are not aware of the svg format and its advantages. Perhaps we just keep it then in psychopy_ext and see what happens.

Though regarding the point on confusing newbies, I'm not sure that this feature would be such. But I also don't have too much experience dealling with PsychoPy newbies.

Jonathan Peirce

unread,
Jan 24, 2014, 8:09:44 AM1/24/14
to psycho...@googlegroups.com
The point isn't that any individual feature is difficult for a new user to take on board; rather that when the total number of features is large then learning/using a system is increasingly difficult. When you're already accustomed to the key features it isn't so bad to add one more - like learning one more person in a group of friends. For someone that hasn't seen any of this before though, the more material that doesn't get them closer to their direct goal, the less likely they are to stick with it.

As an example where I consider myself the beginner, I now never use Adobe Photoshop/Illustrator because they're far too feature-rich for someone that isn't a professional artist and I struggle to find the core things that I need.

Maybe we need a way to enable 'plugins' to do this sort of thing (actually in Builder the hooks are already there for plugin Components) that allow users to download advanced tools that do more peripheral jobs, without being overwhelmed by them at the outset.

For the stim.to_svg() feature I don't know the answer, but I know its a question we have to ask about every single feature we add to PsychoPy.

best wishes
Jon
--
You received this message because you are subscribed to the Google Groups "psychopy-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-dev...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages