Howdy, Stranger!

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

Supported by

[solved] Pupil size obtention

edited March 2015 in PyGaze

Hi,

I want to obtain the pupil size of my subject, and to do this I have made the following modifications to Libtobii.py, in the flushData(self) function :

  • addition of 'L.PupilSize' and 'R.PupilSize' in self.datafile.write('\t'.join(['TimeStamp',
  • addition of g.LeftPupil ande g.RightPupil in self.datafile.write('%.1f\t%.4f\t%.4f\t%d\t%.4f\t%.4f\t%d\t%d\t%d'%(

The function now looks like :

        self.datafile.write('\t'.join(['TimeStamp',
                                       'GazePointXLeft',
                                       'GazePointYLeft',
                                       'ValidityLeft',
                                       'GazePointXRight',
                                       'GazePointYRight',
                                       'ValidityRight',
                                                                           'L.PupilSize',
                                       'R.PupilSize',
                                                                           'GazePointX',
                                       'GazePointY',
                                                                           'Event'])+'\n')

        # time of the first event
        timeStampStart = self.gazeData[0].Timestamp

        # loop through all data points
        for g in self.gazeData:

            # write timestamp and gaze position for both eyes to the datafile
            self.datafile.write('%.1f\t%.4f\t%.4f\t%d\t%.4f\t%.4f\t%d\t%d\t%d'%(
                                (g.Timestamp-timeStampStart)/1000.0,
                                g.LeftGazePoint2D.x*self.disp.dispsize[0] if g.LeftValidity!=4 else -1.0,
                                g.LeftGazePoint2D.y*self.disp.dispsize[1] if g.LeftValidity!=4 else -1.0,
                                g.LeftValidity,
                                g.RightGazePoint2D.x*self.disp.dispsize[0] if g.RightValidity!=4 else -1.0,
                                g.RightGazePoint2D.y*self.disp.dispsize[1] if g.RightValidity!=4 else -1.0,
                                g.RightValidity,
                                                                g.LeftPupil,
                                                                g.RightPupil))

My problem is that in the output file colums of R.PupilSize and L.PupilSize I have only '3' or '4' when the sample is valid, -1 if not.
What is my mistake ? Why don't I obtain a pupil size ?

Thanks for any help !

Comments

  • edited 1:25AM

    I finally found the error...

    t%d was just not the good way to treat the value as a decimal, I replace it by t%.4f and it works fine.

    '3' and '4' were just the whole part of the pupil size.

    Sorry for the useless question.

  • edited 1:25AM

    Hi,

    Indeed, %d is for integers, and will effectively round floats down.

    Btw, if you feel that this a wortwhile addition to PyGaze that other people might benefit from as well, you could consider sending Edwin a pull request with the changes through GitHub. The repository is here:

    Cheers!
    Sebastiaan

    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

  • edited 1:25AM

    This is brilliant, thanks for adding this clearly important feature I neglected!

  • Hi @Edwin , I was wondering if this feature is included in the latest version of PyGaze. I also found it'd be very helpful to record pupillary data. I believe that in my current version, pupil size is included for the eye tribe tracker output but not for tobii ouput.

    Thanks,
    Han

  • edited September 2

    Hi @hanzh,

    Yes, it should be possible! What Tobii back-end are you using? Are you using tobii or tobii-legacy in the latest version of PyGaze, or perhaps using an older version that only has tobii (which is the current tobii-legacy)?

    Edit: I just checked, and the functionality above was never pull-requested into the tobii-legacy back-end. It should be supported by the tobii back-end, I believe, which is based on the new Tobii Pro SDK. If you're using the Tobii legacy back-end, I would be very happy to implement the pupil size solution mentioned above.

    Cheers,
    Edwin

  • Hi @Edwin,

    I am using an older version of PyGaze where we only have the tobii backend because we run a Tobii T60. I think it's time for me to update the package, but it would be really nice to add pupillary measures to it!

    Han

Sign In or Register to comment.