Looping image/audio stimuli and randomizing fixation cross timings

209 views
Skip to first unread message

Aaron Lee

unread,
Jan 10, 2014, 5:26:52 PM1/10/14
to psychop...@googlegroups.com
Hello everyone,

We are setting up an fMRI experiment using the Builder mode, but I am unable to figure out how to do certain things. The experiment has six parts, Study1-Test1-Study2-Test2-Study3-Test3. We would like to use picture stimulus, and later on audio stimuli, but both study and test phases will use the same format.

The first challenge is that I am unable to link the image files (stored on a local disk) in the same way one would with text using an Excel conditions file. Our goal is to have the program draw from a sequence of images (75-100 in each phase). As of now, the only way I am able to do that is to link them with their individual location paths, which seems too arduous to be the only way. I would greatly appreciate it if someone could point towards an alternative method.

The second challenge is to randomize the timings of the fixation crosses (inter stimulus intervals) between each image. Our goal is to have an average ISI of 3 seconds, with a minimum of 1s and max of 5s. I see from another post in this forum that pre-generating fixed randomized timings may be the way to go, and have gathered that this will be done by inserting code into the 'code' section of the ISI component. However, I am not very experienced in Python, and thus do not know where to begin.

I apologize for the long post, but would certainly appreciate your help. If anything is unclear or more information is needed, let me know and I will be happy to add more.


Cheers,
Aaron

Mahiko Konishi

unread,
Jan 11, 2014, 7:42:57 PM1/11/14
to psychop...@googlegroups.com
Hey Aaron,

I'm not sure I can help you with your first problem as linking to the individual location paths is the only solution I know, but I think I can help you with the second problem, as I had the same some time ago. Basically for the jittering you just add the code component to the fixation stimuli and then in the "Begin Routine" section you put a code that looks something like this:

FixTime = [1.0, 1.1, 1.2, 1.3, ...... 4.9, 5.0][randint(0,X)]
loop.addData('FixTime', FixTime)

So "FixTime" is the name of the variable that you're creating that will have the random fixation time. Inside the square parentheses you should put all the times that you want to be selected, I put the dots between 1.3 and 4.9 but you should manually input all the times in between. Then the "randint" part basically tells the machine to select one between the times that you have given him, I put an X there but you should put there the number of all the times you have given him. e.g: if you just want a random jittering time between 1 second and 1.2, you would put [1.0,1.1,1.2][randint(0,3)].
Then the second line tells the program to save the random chosen time into your data, so you can keep track of what was randomly chosen for each trial. In this case, in place of "loop" you should put the name of the most external loop surrounding your fixations.

Now I'm no expert, so this is probably not the most elegant way to do it but it seems to work for me. If I'm getting something wrong I hope someone will correct me, but anyway I guess you can try and see if this works, and if it's actually saving the times in your data.

Hope it helps,


Mahiko

Mahiko Konishi

unread,
Jan 11, 2014, 7:46:21 PM1/11/14
to psychop...@googlegroups.com
Oh by the way, I forgot a very important part. After you've added this code, in the actual fixation stimuli component, you should put 0.0 in the START time section, and in the STOP section you should choose duration and in the empty box you should put $FixTime, the dollar sign telling the machine to use the variable that you've specified in the code. You can of course change the name of the variable to whatever you like, but make sure it's the same that you've specified in the code.

Aaron Lee

unread,
Jan 11, 2014, 10:10:56 PM1/11/14
to psychop...@googlegroups.com
Hi Mahiko,

Thank you so much for your help. The code worked perfectly. Coincidentally, the "another post in this forum" I mentioned in my original post was yours! Additionally, in case you were wondering, I learned that we can use location paths in Excel condition files to "link" images to experiments, so my first problem is solved too.

Once again, thank you!
Aaron

Olivia Twist

unread,
Feb 22, 2018, 7:58:55 AM2/22/18
to psychopy-users
Thank you Mahiko

It's four years later, but your great explanation solved my question perfectly :)

Olivia
Reply all
Reply to author
Forward
0 new messages