Trouble logging participant information

PennController for IBEX Forums Support Trouble logging participant information

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #6864
    rhododendron
    Participant

    Dear Jeremy,

    I am writing to you with regard to a problem that is perhaps easy, that I can however not solve on my own.
    I am trying to implement a Selector Element and introduce 4 images and 4 keys to it, as well as a timer of 8 seconds within which a selection has to be made. For this, I am using a template and I call the pictures through column variables (in this case picture1, picture2, picture3 and picture4). The trouble that I am dealing with is that at the end, in the results, the only information that I get is just the variable name (e.g. picture 2), not the actual picture name from the csv and as well as that, the information about which key was pressed is not loggged. I would be very grateful if you could point me towards a solution or let me know whether I am doing something wrong here. Here is a relevant fragment of the code that I am working with.

    //introducing experimental sentence + pictures
    newText("sentence", variable.sentence)
      .settings.center()
      .settings.css("font-size", "large")
      .settings.css("font-weight", "bold")
      .print()
    ,
    defaultImage
      .size(220,220)
    ,
    newImage("picture1", variable.picture1).css("border", "solid 1px black").print("right at 45vw","bottom at 55vh").log()
    ,
    newImage("picture2", variable.picture2).css("border", "solid 1px black").print("left at 55vw","bottom at 55vh").log()
    ,
    newImage("picture3", variable.picture3).css("border", "solid 1px black").print("right at 45vw","top at 62vh").log()
    ,
    newImage("picture4", variable.picture4).css("border", "solid 1px black").print("left at 55vw","top at 62vh").log()
    ,
    newTimer("timeout", 8000)
      .start()
    ,
    newSelector("shapes")
      .disableClicks()
      .once()
      .add(getImage("picture1") , getImage("picture2"), getImage("picture3"), getImage("picture4") )
      .shuffle()
      .keys(            "E"           ,        "I"     ,         "X"         ,         "M"          )
      .log("all")   
      .callback(getTimer("timeout").stop())    
    ,     
    getTimer("timeout")
      .wait()
    ,
    newVar("selection")
      .set(getSelector("shapes"))
    , //check if the timer timed out
    getSelector("shapes")
      .test.selected()
      .failure(
        getSelector("shapes")
          .remove()
        ,
        getText("sentence")
          .remove()
        ,
        getImage("picture1")
          .remove()
        ,
        getImage("picture2")
          .remove()
        ,
        getImage("picture3")
          .remove()
        ,
        getImage("picture4")
          .remove()
        ,
        newText("timedout","Die Zeit ist um! Sei bitte schneller!")
        .settings.css("font-size", "25px")
        .settings.css("font-family","courier")
        .settings.color("red")
        .settings.center()
        .print("right at 66vw", "top at 45vh" )
      ,
      newText("continue", "<i>Dr&uuml;cke die Leertaste um fortzufahren</i>")
        .settings.css("font-size", "25px")
        .settings.css("font-family","courier")
        .print("right at 65vw", "top at 65vh" )

    P.S. I have tried adding a Canvas for the pictures along with the Selector but that did not seem to help either.

    Thank you very much!

    Best,
    Ana-Maria

    #6868
    Jeremy
    Keymaster

    Dear Ana-Maria,

    First, make sure that your PennController file is not version 1.9: there is a bug in that version where the post-shuffle order reported in the results file is inaccurate

    Once you get the order properly reported in the results file, it’s easy to retrieve which key was pressed: say the picture that was chosen was picture2 and picture2 is third in the reported order, then the key that was pressed was X

    If you want to additionally report the filename of each picture in the results file, you can use newTrial().log

    Here is a basic code that illustrates those ideas:

    Template( row =>
        newTrial(
            newSelector("pictures")
            ,
            defaultImage
                .size("10vw","10vw")
                .selector("pictures")
            ,
            newCanvas("container", "80vw","80vh")
                .color("lightgray")
                .add("center at 25%","middle at 25%",newImage("picture1",row.picture1))
                .add("center at 75%","middle at 25%",newImage("picture2",row.picture2))
                .add("center at 25%","middle at 75%",newImage("picture3",row.picture3))
                .add("center at 75%","middle at 75%",newImage("picture4",row.picture4))
                .print("center at 50vw","middle at 50vh")
            ,
            getSelector("pictures")
                .log()
                .shuffle()
                .keys("E","I","X","M")
                .wait()
        )
        .log("picture1", row.picture1)
        .log("picture2", row.picture2)
        .log("picture3", row.picture3)
        .log("picture4", row.picture4)
    )

    You can try it out here: https://farm.pcibex.net/r/RONttQ/

    Here’s a result line that was generated for the first trial:

    1618581521,c12c0535fba1b8e2ff8e0a39d068826c,PennController,0,0,Item-1,NULL,Selector,pictures,Selection,picture2,1618581519920,bear.png,cat.png,chicken.png,deer.png,picture4;picture1;picture2;picture3

    As you can see, I chose picture2 and if I look up the order, I see that picture2 ended up occupying the third position after the shuffle: this means that I chose the bottom-left picture by pressing X. Additionally, I see that picture2 was cat.png (note that the order of the filenames in the result line are not shuffled)

    You can automatize those associations in R, for example

    Let me know if you have questions

    Jeremy

    #6869
    rhododendron
    Participant

    Dear Jeremy,
    thank you so so much!! I was indeed using the 1.9 version of PennController.

    All the best! Have a great weekend!

    Ana-Maria

    #6890
    rhododendron
    Participant

    Dear Jeremy,

    I have some issues implementing your suggestion and working with the very same experiment without syncing to the latest version of PennController. No matter what I do, I get thrown an “Error: You must define the items variable”. The moment I sync to the 1.9 version everything works just fine. Any idea why this happens? I think it is worth mentioning that the farm that I am using is hosted by the Humboldt Uni servers so this might make matters even more complicated. I have checked the Inspector window to get some insight into what is going on and this is what I have found:

    Uncaught ReferenceError: PennController is not defined
    <anonymous> https://korpling.german.hu-berlin.de/ibexexps/plescaan/Ibex_MA_pk_ap_sh_exim/server.py?include=data:99
    server.py:99:1
    <anonymous> https://korpling.german.hu-berlin.de/ibexexps/plescaan/Ibex_MA_pk_ap_sh_exim/server.py?include=data:99

    To be honest I am not sure how to interpret this. The error is marked at the PennController.ResetPrefix(null) command. I would appreciate your help!

    Best wishes,
    Ana-Maria

    #6891
    Jeremy
    Keymaster

    Dear Ana-Maria,

    You should use version 2.0.alpha of PennController. I was assuming that you were using the (new) PCIbex Farm, where PennController 2.0.alpha comes with new projects by default. You will need to download the file PennController.js from the linked github page and upload it to your project—note that if you previously git-synced PennController.js, you might not be able to overwrite it, unless you git-sync it again from elsewhere (for example, you could create a git repo for your project)

    Right now your experiment seems to be using version 1.8-dev, and I don’t see the error message that you report. Were you able to make things work in the end?

    Jeremy

    #6895
    gzlkj
    Participant

    Dear Jeremy,

    I apologize if this is a bit off-topic. I am also using the selector element, and I was trying to come up with a solution for the same issue here in this thread, (i.e. matching the selected item’s variable with its name):

    As you can see, I chose picture2 and if I look up the order, I see that picture2 ended up occupying the third position after the shuffle: this means that I chose the bottom-left picture by pressing X. Additionally, I see that picture2 was cat.png (note that the order of the filenames in the result line are not shuffled)

    You can automatize those associations in R, for example

    Thank you for mentioning this function in R! I was wondering if you could kindly point to, perhaps, a place in the R’s documentation or a manual where I could learn more about this.

    All the best,
    Zara

    #6898
    Jeremy
    Keymaster

    Hi Zara,

    There is no documentation about it, but it’s a matter of adding columns to each Selector row that will report the position and filename of the selected image. There are many ways of doing this, one option using the dplyr package is (assuming you have loaded your results file in a variable named results using the function read.pcibex):

    library("dplyr")
    results$Value<-as.character(results$Value)
    results$picture1<-as.character(results$picture1)
    results$picture2<-as.character(results$picture2)
    results$picture3<-as.character(results$picture3)
    results$picture4<-as.character(results$picture4)
    getImage <- function(value,p1,p2,p3,p4){
      c(picture1=p1,picture2=p2,picture3=p3,picture4=p4)[value]
    }
    getPosition <- function(value,comments){
      c("top-left","top-right","bottom-left","bottom-right")[
        which(strsplit(as.character(comments), ";")[[1]] == value)
      ]
    }
    choices <- results %>% 
      filter(PennElementType=="Selector") %>% 
      rowwise() %>%
      mutate(ChosenPosition=getPosition(Value,Comments)) %>%
      mutate(ChosenImage=getImage(Value,picture1,picture2,picture3,picture4))

    The choices variable will contain a tibble with two additional columns, ChosenPosition and ChosenImage

    Let me know if you have questions

    Jeremy

    #6935
    gzlkj
    Participant

    I just wanted to thank you for this!
    I still couldn’t get around to use that package, but now I know what I should be expecting and everything is clearer than before.

    Best Regards,

    Zara

    #7096
    Larissa_Cury
    Participant

    Dear Jeremy,

    I’m having a similar problem. I tried this solution but it didn’t work. I need to log the filenames of the images in my Canvas. However, I only see “canvas” in the results file, not the filename (which would tell me the indendepent variables of my experiment). This is the relevant part of my code:

    My csv file is called “tabela-target.csv” and the relavant collun (in which my images are) is called “imagem”)

    Template("tabela-target.csv" , row => 
        newTrial("trial_1_no_cue_UP",
        newText("D1", " <br> <b>+</b>")
        .cssContainer({
        "font-size":"100px",
        "color":"blue"})
        .center()
        .print()
    ,
       newTimer("timer-D1",1000)
        .start()
        .wait()
    ,
       getText("D1")
       .remove()
    ,
        newImage("imagens", row.imagem)
        .size(500, 200)
    ,
       newText("cruz_central", "<br> <b>+</b>")
       .cssContainer({
       "font-size":"100px",
       "color":"red"})
       .center()
       .print()
    ,
        //para cima//
        newCanvas("center", 200,200)
        .add( "center at 50%" , "center at 50%" , getImage("imagens"))
        .cssContainer({
        "position": "relative",
        "margin-left": "-40px",
        "margin-right": "-50px",
        "margin-top": "-285px",
        "margin-bottom": "0px",
        "left": "40%",
        "width": "50%"})
        .log()
        .print()
    ,
        newKey("keypress1","EI")
        .wait()
        .log()
    ,
         getText("cruz_central")
        .remove()
    ,
        getCanvas("center")
        .remove()
    ,
       newText("separacao", "<br> <b>+</b>")
       .cssContainer({
        "font-size":"100px",
        "color":"yellow"})
       .center()
       .print()
    ,
        newTimer("wait-separacao",2500)
        .start()
        .wait()
    
    .log("imagens", row.imagem)
    .log("item", row.versao)
    ));

    Indeed, I also have another collum called “versao” in which I have the corresponding numbers of my items, which is not logging as well 🙁

    Thank you in advance!

    #7098
    Jeremy
    Keymaster

    Hello,

    The reason you see “Canvas” is because you use log on your Canvas element, so the results file will report the timestamp for the execution of its print command.
    You are also using log on your Key element, which you probably want, because it will report which of E/I was pressed.
    Finally, you are calling log on the “wait-separacao” Timer element too, but you meant to call it on newTrial() because what you want is to add columns to every line of your results file for those trials that report the values from the “imagem” and “versao” columns of your table:

        // ...
        ,
        newTimer("wait-separacao",2500)
          .start()
          .wait()
      )
      .log("imagens", row.imagem)
      .log("item", row.versao)
    );
    

    Jeremy

    #7099
    Larissa_Cury
    Participant

    Dear Jeremy,

    I honestly can’t thank you enough! You’ve solved my problem, now it’s working! Thank you so so much!!

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.