Howdy, Stranger!

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

Supported by

[open] PygazeAnalyser: Drawing Heatmaps, Scanpaths etc

edited January 2015 in PyGaze

Hi Edwin,

I am currently trying to draw some graphical analyses.
It did not work with 32 bit images but reducing to 24 bit helped when trying to draw heatmaps.
Nevertheless the heatmap was not drawn onto the image but saved in a file with black background.
Same accounts for scanpath and fixations. Images with black backgrounds were produced but also something that looked like a memory allocation error:

alloc: invalid block: 03F6AE90: 90 4

Btw I do also get a warning because the font family 'Ubuntu' is not recognized by windoze :-)

Here's how I try to use the stuff:

readFile = easygui.fileopenbox(msg="Bitte wählen Sie die zu öffnende Datei", filetypes=["*.tsv"])<br>theData = er.read_eyetribe(readFile, "start_trial", "stop_trial", debug=True).
...
fixations = theData[0]['events']['Efix']  # [starttime, endtime, duration, endx, endy]
saccades = theData[0]['events']['Esac']
display = [1036, 812]
imageFile = "somePath"

gp.draw_heatmap(fixations, dispsize=display, imagefile=imageFile, durationweight=True, alpha=0.5, savefilename="saveFilePath")

gp.draw_scanpath(fixations, saccades, dispsize=display, imagefile=imageFile, alpha = 0.5, savefilename = "saveFilePath2")

gp.draw_fixations(fixations, dispsize=display, imagefile=imageFile, durationsize=True, durationcolour=False, alpha=0.5,savefilename="saveFilePath3")

I'd appreciate any hint :-)
Here come the images

source image

image

heatmap

image

scanpath

image

fixations

image

Best regards
Digo

Comments

  • edited 8:40AM

    Thanks for the feedback! Nice to see people using this :)

    In my experience, not all image types are loaded properly. I think JPEGs work best. Could you convert your images?

    As an aside: You could simply install the Ubuntu font, but it's not a requirement. If matplotlib can't find Ubuntu, it will simply revert back to the default option.

    Good luck!

    Edwin

  • edited January 2015

    Thank you so much!
    Having the images converted to .jpg I got all three visualizations working. Note that it was necessary to install Pillow ( see http://stackoverflow.com/questions/24356421/attributeerror-builtin-function-or-method-object-has-no-attribute-iterkeys ). Otherwise I got the error
    AttributeError: 'builtin_function_or_method' object has no attribute 'iterkeys'

    So I am getting very close now. Results look fine except scanpaths which always start at 0/0 (see image). Unfortunately the program crashes with something that looks like a memory allocation error when trying to terminate after using either draw_scanpath or draw_fixations (draw_heatmap does not produce this error).

    alloc: invalid block: 03E55CD8: 58 3

    Btw. I installed the Ubuntu font, but it still isn't recognized.

    Best regards
    Digo


    image

  • edited January 2015

    Hi Digo,

    Thanks for the feedback! I wasn't aware of the matplotlib issue you mention. Did you not have PIL installed, or was Pillow required nonetheless?

    The (0,0) points (top left) are missing data, which is not filtered by the saccade algorithm. And, actually, I rethought the way I construct those scanpaths. They don't really require saccades at all, the fixations alone should be enough. I'll try to reprogram some stuff over the weekend.

    The memory error is probably related to matplotlib. Have you tried closing the figures after creating them? (bottom line of the example below)

    # ...continued from your script above
    
    from matplotlib import pyplot
    
    # fill out your own path
    saveFilePath = "/YOUR/PATH/HERE"
    
    # create a new heatmap
    fig, axes = gp.draw_heatmap(fixations, dispsize=display, imagefile=imageFile, durationweight=True, alpha=0.5, savefilename=saveFilePath)
    
    # add a watermark
    axes.annotate("created using PyGazeAnalyser", (0,0), fontsize=24, color='white', alpha=0.5)
    
    # save your creation
    fig.savefig(saveFilePath)
    
    # close the figure
    pyplot.close(fig)
    

    The Figure and associated Axes instances are native to matplotlib. They are returned so you can do some further image manipulation (annotate texts, add an axis, set a title etc.) by using matplotlib functions. This also means you might want to actively close them afterwards. See the example above for practical info.

    Cheers,
    Edwin

  • edited 8:40AM

    Hi Edwin,

    thanks again. Closing the fig helps! If I got that right it is done using pyplot since figure doesn't have a closing routine:


    import matplotlib.pyplot as plt

    ...

    fig = gp.draw_fixations(fixations, dispsize=display, imagefile=imageFile, durationsize=True, durationcolour=False, alpha=0.5,
    savefilename="saveFilePath")

    plt.close(fig)



    Best regards

    Digo

  • edited 8:40AM

    Apologies, you are completely right! I've updated my post.

    Glad the closing helped solve part of your issue, though! Am still working on the other bit.

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games