Howdy, Stranger!

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

Supported by

[solved] Subtracting Duration using Python (ISI sequence)

edited December 2014 in OpenSesame

Hello! I am currently trying to code an ISI sequence. The sequence is Fixation dot (400ms-800ms duration) -> word (response duration) -> Blank page (2000ms - Fixation dot duration - word response duration). For a total of 2000ms per trial.

This is what I have for my python code so far, I borrowed from previous advice given on this forum and kept the explanations for future reference
For the fixation dot I used:

import random

# Use the function random.randint() to randomly draw
# an integer (i.e. a whole number) between a certain
# minimum and maximum.
# See also: http://docs.python.org/2/library/random.html#random.randint

# Set the minimum and maximum:
minimum = 400
maximum = 800

# Determine the ISI for the current trial like so:
fix = random.randint(minimum, maximum)

exp.set("fix", fix)

Now the response duration to the "word" section I get from "response_time_Response"

....and that is where I am stuck trying to figure out how to subtract both of the previous ms from the total 2000ms I was thinking something like the following code would best describe what I am trying to achieve

exp.get("ISI")
exp.get("fix")
exp.get("response_time_Response")

ISI = 2000-"fix"-"response_time_Response"

exp.set("ISI", ISI)

Any suggestions/feedback would be greatly appreciated.

Comments

  • edited 8:31PM

    Hi Felix,

    Have you tried your code? The general idea seems to make sense. With a little bit of experimenting, I am sure you can find the setup you want to achieve.
    Btw, I changed your code a bit that will make it run without giving error messages (provided that there is no error earlier)


    fix = exp.get("fix") RT = exp.get("response_time_Response") ISI = 2000-fix-RT exp.set("ISI", ISI)

    Give it a shot, if you get stuck again, feel free to post the specific issue you encountered again.

    Good luck,

    Eduard

    Buy Me A Coffee

  • edited 8:31PM

    Thank you Eduard that seems to have worked! Apologies for the late response I've been swamped with finals.

    Best,
    Felix

Sign In or Register to comment.