Howdy, Stranger!

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

Supported by

[solved] possible to use time logger within trail?

edited October 2013 in OpenSesame

Hi,

thank you so much for this forum.
In a dection task I would like to record multiple responses in one trail, as we measure the time it takes participants to detect multiple features. Importantnly, participants use the same response-key, and the trail terminates when the time (eg 30s) is over, independent of the responses.
Unfortunately, now the output only gives me the log (time ect) of a single response.
Is it possible to record multiple response (-times) in one trail ? Maybe similar to a time logger?

Kind regards,

Comments

  • edited 8:39PM

    Hi,

    Perhaps you could look at a previous thread on a similar topic:

    Please let us know if this is not exactly what you're looking for, or if you have trouble implementing this method in your experiment.

    Best wishes,

    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • edited 8:39PM

    Hi Lotje,

    thank you soo much! And my excuses that I did not find the existing threat myself. Now Im half there. The logger tells me the number of presses, but it does not give me the times. Is that also possible? Now only the first (or last?) press is shown.
    Kind regards,

  • edited October 2013

    Hi,

    Saving the time stamps corresponding to all key presses within a current trial could be done like so:

    # Determine the timeout in ms:
    timeout = 3000
    
    # Create keyboard_response item:
    from openexp.keyboard import keyboard
    my_keyboard = keyboard(exp, keylist=['space'], timeout = 0)
    
    # Determine the timestamp of the start of the response
    # interval:
    start_time = self.time()
    
    # Give the number of spacebar presses a starting
    # value, namely 0.
    nPresses = 0
    
    # Collect keyboard response until 3000 ms (or whatever
    # you set the timeout to) passed:
    
    # Define the maximum number of responses:
    maxResp = 20
    
    # Make variables for time stamps, that have 'None' as 
    # starting value:
    for i in range(maxResp):
    
        # Create variable name (i.e. column header
        # in output file):
        varName = "time%.2d" % i
    
        # Assign the value 'None' :
        exp.set(varName, "None")
    
    
    while True:
    
        # Get new timestamp:
        current_time = self.time()
    
        # Continue only if the duration is still
        # smaller than timeout:
        if current_time - start_time < timeout:
    
            # Collect keyboard response:
            key, end_time = my_keyboard.get_key()
    
            # Add to the number of presses if response was not 
            # 'None' (meaning no key was pressed):
            if key != None:
                nPresses +=1
    
                # Create variable containing current time stamp
                # (called 'time01', 'time02', etc.)
                varName = "time%.2d" % nPresses
    
                # Set the new variable and give it the 
                # corresponding value:
                exp.set(varName, end_time)
    
        # If (more than) 3000 ms have passed, advance to the 
        # next part of your experiment:
        else:
            break
    
    # Set the number of spacebar presses for future use in the 
    # user interface (notably, the logger item).
    self.experiment.set('nPresses', nPresses)
    
    

    Now your output file should contain column headers called 'time01', 'time02', etc., containing the time stamps corresponding to the first and the second button press, etc.

    Does this help? Please let us know if you have any further questions!

    Good luck!

    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • edited 8:39PM

    yeees! Thank you soo much!

    It is really amazing that you spend your time and effort to help us!

    big hug!

  • edited 8:39PM

    Dear Lotje!

    It works like a charm, thank you so much!
    Now I would like to show my participants a video while they have to detect certain features. So i could use exacly the same experiment, only now "while" playing the video. I tried the built in vlc player but it seems to only first play the video and then collect the resonses, but not collect responses until the video stops.

    Kind regards,

  • edited 8:39PM

    Yeah, the event detection system is not really well implemented for the vlc plugin. I will have a look at it soon. It however is tested and it works for the gst variant of the media_player, so you might want to try that!

    Buy Me A Coffee

Sign In or Register to comment.