Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Eye-tracking sentence reading: definition of areas of interest

Hi all,

I know similar questions have been asked before, but I couldn't really find a thread on this issue – apologies in advance if I've missed it or it's something very basic that I'm missing.
I'm quite new to programming eye-tracking experiments in OpenSesame (and I'm not an OpenSesame expert in general), and I'm currently trying to program quite a basic sentence reading task.
All sentences contain different words, but follow this basic structure:
[chunk1] [chunk2] [chunk3] [chunk4] [chunk5] [chunk6] [chunk7] [chunk8]
In each sentence, our target items – that should be areas of interest – are chunk4 and chunk5, which occupy different positions in each sentence, based on the length of those words and of the previous ones. Therefore, defining interest areas based on x and y coordinates doesn't seem to help much, here, as they vary every time.
So, here's the core of my question: I'd like to know if it's possible to define as areas of interest certain parts of each sentence, as defined by the labels we adopted (in our case, say, the words that occupy chunk4 and chunk5 in each sentence).
Also having an interest area for all of the 8 chunks would be fine, of course, as I can select a posteriori which interest areas I want to analyze, in terms of eye movement measures.

Any suggestion or advice is most welcome.

Thanks a lot,
Valentina

Comments

  • Hi Valentina,

    That's a a good question. As of v3.2, Canvas elements can have a name, and you can therefore use them to define regions of interest (ROIs). The next question is then how to define ROIs for separate words in a sentence. There are many ways to do this, but one way is to split the sentence into individual words, see how much space they take up, and then define a region of interest for each word through a named Rect() element.

    The script below shows a function (draw_roi_text()) that does this. The end product is a Canvas object with named elements that you can subsequently use, in whatever way you need to, for an ROI analysis.

    Cheers!
    Sebastiaan

    def draw_roi_text(c, text, x=0, y=0, show=False, **kwargs):
    
        """Draws text to a Canvas and additionally defines an ROI for each word and
        following space. The ROIs are named Canvas elements. The show keyword
        indicates whether the ROIs should be colored for visual debugging.
        """
    
        roi_x = x
        roi_y = y
        for i, word in enumerate(text.split()):
            # Words
            w, h = c.text_size(
                u'<span style="background:red;">%s</span>' % word,
                center=False,
                **kwargs
            )
            # Define ROI for word
            c['word%d' % i] = Rect(
                roi_x,
                roi_y,
                w,
                h,
                color='red' if show else var.background,
                fill=True
            )
            roi_x += w
            # Spaces
            w, h = c.text_size(
                u'<span style="background:red;">&nbsp;</span>',
                center=False,
                **kwargs
            )
            # Define ROI for word
            c['space%d' % i] = Rect(
                roi_x,
                roi_y,
                w,
                h,
                color='green' if show else var.background,
                fill=True
            )
            roi_x += w      
        c.text(text, x=x, y=y, center=False, **kwargs)
    
    
    c = Canvas()
    draw_roi_text(c, 'This is a string', show=False)
    c.show()
    
    Thanked by 1Edwin

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

Sign In or Register to comment.