best way to present a lot of text

1,728 views
Skip to first unread message

Martin Batholdy

unread,
Sep 3, 2012, 12:03:27 PM9/3/12
to psychop...@googlegroups.com
Hi,

I would like to give instructions of an experimental task on the screen.
But since it is a lot of text, i am a little bit struggling how to present it.

As far as I can see, the TextStim object has no arguments to control for instance the line-spacing when you have multiple line breaks.
In my opinion the line-space is a little bit low (the lines are very near to each other).

So my only option seems to be, to create a TextStim for every line and set the position-parameter accordingly.

Or is there any other way to present a paragraph of text efficiently but also nicely readable (nice line-spacing etc.)?


thanks!


Emily Ward

unread,
Sep 3, 2012, 2:08:15 PM9/3/12
to psychop...@googlegroups.com
Try \n :

text = 'I have a lot of text \n\n \
and I want to have more space \n\n \
between all the lines.'

Another solution may be to break it down and present different parts on different pages and have the user click to advance. 





--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To post to this group, send email to psychop...@googlegroups.com.
To unsubscribe from this group, send email to psychopy-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



Martin Batholdy

unread,
Sep 4, 2012, 9:07:18 AM9/4/12
to psychop...@googlegroups.com
Ok, \n gives me a line-break but I can't control the spacing between two lines.
And I would like to have two lines to be more separated ...

Jonathan Peirce

unread,
Sep 5, 2012, 12:01:17 PM9/5/12
to psychop...@googlegroups.com
No, pyglet doesn't provide that level of layout control to my knowledge
Jon
-- 
Jonathan Peirce
Nottingham Visual Neuroscience

http://www.peirce.org.uk/

Jeremy Gray

unread,
Sep 5, 2012, 1:03:28 PM9/5/12
to psychop...@googlegroups.com
one way to do things is to format the text however you like (e.g.,
using Gimp or PowerPoint) and take a screenshot. then in your
experiment present the instructions as an image rather than text. this
is less efficient in terms of memory and disk space, but maybe more
efficient in terms of programming effort.

--Jeremy

Jonathan Peirce

unread,
Sep 5, 2012, 1:04:57 PM9/5/12
to psychop...@googlegroups.com
Actually Jeremy's suggestion is likely to render faster too, because
fewer vertex calculations are done at render time.

Dave Braze

unread,
Sep 5, 2012, 2:47:21 PM9/5/12
to psychop...@googlegroups.com
You could also build rasters programmatically in python using PIL.
-Dave

Thomas K.M.

unread,
Nov 23, 2012, 6:02:36 AM11/23/12
to psychop...@googlegroups.com
I'm using this method, but the image of text has a lot of shadows when shown in PsychoPy. I tried to set interpolate=False, but alas, no improvement.

Any ideas how to avoid it?

Henrik Singmann

unread,
Nov 23, 2012, 6:22:29 AM11/23/12
to psychop...@googlegroups.com
Hi Thomas,

I don't know if this is a good general advice, but on my PC with Win 7 and decent (i.e., OpenGL supporting) graphics card the following setup works to give me nice text from pictures (which I also create in PowerPoint):

first = visual.SimpleImageStim(myWin, image = imageLocation, pos=(0,0))
firstStim = visual.BufferImageStim(myWin, stim = [first])
firstStim.draw()
myWin.flip()

On my pc, SimpleImageStim looks way smoother than with ImageStim. But you need to use the BufferImageStim if you want to draw something on it.

Cheers,
Henrik



2012/11/23 Thomas K.M. <thomas....@gmail.com>
To view this discussion on the web visit https://groups.google.com/d/msg/psychopy-users/-/7Ga3gCNvs1AJ.

Thomas K.M.

unread,
Nov 23, 2012, 7:17:48 AM11/23/12
to psychop...@googlegroups.com
Hi Henrik

I would like to try this, but I'm not a coder, so I might mess it up without a few guidelines. So, I initially created the image component in Builder and then compiled the script. Do I now only change the stuff in #Initialize components for Routine "trial", or do I need to change stuff later in #Prepare to start Routine "trial" and #Start Routine "trial"?
I'm thinking if your "first"-variable is called "image" in the initialize phase, then it will be okay, but what about the BufferImageStim part?

Henrik Singmann

unread,
Nov 23, 2012, 8:30:22 AM11/23/12
to psychop...@googlegroups.com
Unfortunately, I have no experience with the builder at all, so cannot steer you in the right direction.

But what you could try is to exchange the instance(s) of visual.ImageStim with visual.SimpleImageStim. Perhaps this already helps.

Henrik


2012/11/23 Thomas K.M. <thomas....@gmail.com>
To view this discussion on the web visit https://groups.google.com/d/msg/psychopy-users/-/ClMRQdYgyeAJ.

Jeremy Gray

unread,
Nov 23, 2012, 10:58:02 AM11/23/12
to psychop...@googlegroups.com
Thomas, I would make sure that you are drawing the image at exactly the same size it was captured, in terms of pixel resolution. Otherwise it will have to be interpolated, and this will look bad for text, not as bad for images.
 
I don't know if this is a good general advice, but on my PC with Win 7 and decent (i.e., OpenGL supporting) graphics card the following setup works to give me nice text from pictures (which I also create in PowerPoint):

first = visual.SimpleImageStim(myWin, image = imageLocation, pos=(0,0))
firstStim = visual.BufferImageStim(myWin, stim = [first])
firstStim.draw()
myWin.flip()

On my pc, SimpleImageStim looks way smoother than with ImageStim.

I'm glad this works, but its not supposed to be that complicated. a) a BufferImageStim should make no difference (except to the speed of rendering, which is not a concern for instructions), b) SimpleImageStim /should/ look the same as an ImageStim, so its a little concerning that it does not.
 
But you need to use the BufferImageStim if you want to draw something on it.

You can draw on top of anything--just keep doing several .draw()'s before you do the win.flip(). 

A BufferImageStim should only be necessary if you have slow-rendering stimuli (like SimpleImageStim) and need them to be drawn quickly (slow is fine for instructions). A BufferImageStim can also allow you to combine lots of slow stimuli into one fast one (or combine lots of fast ones into a single, even faster one), but you lose control over the ability to changes individual visual elements dynamically--it has literally become a single image.

--Jeremy

Henrik Singmann

unread,
Nov 23, 2012, 11:10:34 AM11/23/12
to psychop...@googlegroups.com
Hi Jeremy,

unfortunately it does make a difference on my PC if you display images via SimpleImageStim or ImageStim when it comes about displaying of text. With ImageStim it looks worse (less antialiasing).
(the images have the same size, the difference is only from the cutting, and the only thing I changed in the code is the removing Simple)

Here is my system info (from standalone PsychoPy):
System info:
Windows-7-6.1.7601-SP1

Python info
C:\Program Files\PsychoPy2\pythonw.exe
2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)]
numpy 1.6.0
scipy 0.9.0
matplotlib 1.0.1
pyglet 1.1.4
pyo version 0.6.2 (uses single precision)
pyo 0.6.2
PsychoPy 1.75.01

OpenGL info:
vendor: ATI Technologies Inc.
rendering engine: ATI Radeon HD 5450
OpenGL version: 4.2.11931 Compatibility Profile Context
(Selected) Extensions:
    True GL_ARB_multitexture
    True GL_EXT_framebuffer_object
    True GL_ARB_fragment_program
    True GL_ARB_shader_objects
    True GL_ARB_vertex_shader
    True GL_ARB_texture_non_power_of_two
    True GL_ARB_texture_float
    False GL_STEREO
    max vertices in vertex array: 2147483647
1.3748    WARNING    Creating new monitor...

As I said, I get around this problem via using BufferImageStim on the SimpleImageStim. Looks good and you can draw on it.

Cheers,
Henrik


COmpare the two attached pictures which I just made

2012/11/23 Jeremy Gray <jrg...@gmail.com>
SimpleImageStim.png
ImageStim.png

Michael MacAskill

unread,
Nov 24, 2012, 11:11:31 PM11/24/12
to psychop...@googlegroups.com

On 24 Nov, 2012, at 05:10, Henrik Singmann <sing...@gmail.com> wrote:

> unfortunately it does make a difference on my PC if you display images via SimpleImageStim or ImageStim when it comes about displaying of text. With ImageStim it looks worse (less antialiasing).
> (the images have the same size, the difference is only from the cutting, and the only thing I changed in the code is the removing Simple)

This is an old trick, and may no longer still apply, but you may have more luck with ImageStim if your original source image is square, with power-of-two dimensions. e.g. 512 x 512, 1024 x 1024. That way, ImageStim may not need to scale and re-scale it in the background, which may be what is causing the visible changes that don't occur with SimpleImageStim, which just displays exactly what it is given, but at some cost in flexibility (e.g. drawing other stimuli on top of it).

In the case of a single line of text, this is going to mean extra spare space above and below the text, but that often isn't a problem if the background colour matches the window background.

Regards,

Mike

Thomas K.M.

unread,
Nov 27, 2012, 8:24:06 AM11/27/12
to psychop...@googlegroups.com
This actually helps.
If I really need it to be more width than height is there a ratio that would function well - just as a square - perhaps half a square, that is f.ex. 1024 x 512 ?

Michael MacAskill

unread,
Nov 27, 2012, 3:04:14 PM11/27/12
to psychop...@googlegroups.com

On 28 Nov, 2012, at 02:24, Thomas K.M. <thomas....@gmail.com> wrote:
> This actually helps.
> If I really need it to be more width than height is there a ratio that would function well - just as a square - perhaps half a square, that is f.ex. 1024 x 512 ?

Glad to hear it helped.

I think the source image has to be square: this is one of the optimisations in the graphics card hardware rather than an arbitrary requirement of PsychoPy itself. But this shouldn't actually be much of a limitation to you:

(1) e.g. say your window is 1024 x 768, I think you can still draw a 1024 x 1024 image on to it: you get the full 1024 pixels of width, but the extra pixels in height are invisible, falling outside the window boundary.

(2) If you are worried about other stimuli being occluded by the extra blank space around the text, this might be avoided just by drawing the text stimulus first, and then other stimuli on top of it.

(3) You could apply a mask to remove the extra background, so that just the desired area gets drawn to the screen, rather than the whole square image. e.g. see <http://www.psychopy.org/api/visual/imagestim.html>

Cheers,

Mike

Reply all
Reply to author
Forward
0 new messages