Working with optseq2 (for Jitter in fMRI)

605 views
Skip to first unread message

or duek

unread,
Dec 20, 2010, 9:41:08 AM12/20/10
to psychopy-users
Hi,
I need to translate my experiment to an fMRI one.
We use optseq2 in order to create the jitter.
It output a file with the name of each condition, duration of each
condition (specifically NULL ones who are blank screen).
I want to use this file in order to run my experiment.
Did anyone used it here?

or duek

unread,
Dec 20, 2010, 12:12:20 PM12/20/10
to psychopy-users
I want to be a bit clearer about my specific problem:
The optseq2 software generates a text file with 5 columns from which I
need two. One column should become the list of conditions I use in
each trial and the second, a list of the time per trial.
the file looks like that:
0.0000 1 4.000 1.0000 RewardA
4.0000 5 4.000 1.0000 DistractorR
8.0000 2 4.000 1.0000 RewardB
12.0000 3 4.000 1.0000 PunishmentA
16.0000 2 4.000 1.0000 RewardB
20.0000 2 4.000 1.0000 RewardB
24.0000 1 4.000 1.0000 RewardA
28.0000 4 4.000 1.0000 PunishmentB
32.0000 0 2.000 1.0000 NULL
34.0000 1 4.000 1.0000 RewardA
38.0000 1 4.000 1.0000 RewardA
42.0000 5 4.000 1.0000 DistractorR
46.0000 2 4.000 1.0000 RewardB
50.0000 6 4.000 1.0000 DistractorP

I need the 3rd and the 5th columns.
Is there an easy way to do that?

Jeremy Gray

unread,
Dec 20, 2010, 12:40:22 PM12/20/10
to psychop...@googlegroups.com
yes -- you can read each line as a string, use .split() to convert the string into an array, then select the elements you want.

--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To post to this group, send email to psychop...@googlegroups.com.
To unsubscribe from this group, send email to psychopy-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/psychopy-users?hl=en.


Ariel Rokem

unread,
Dec 20, 2010, 12:45:04 PM12/20/10
to psychop...@googlegroups.com
Hi,

As an alternative, you can open this in excel (or open office...) and then save it as a csv (comma separated) file. Then, you could use mlab.csv2rec to easily get the different columns in a numpy recarray:

In [43]: from matplotlib.mlab import csv2rec

In [44]: a = csv2rec('stuff.csv',names=['0','1','2','3','4'])

In [45]: a
Out[45]:
rec.array([(0, 1, 4, 1, 'RewardA'), (4, 5, 4, 1, 'DistractorR'),
       (8, 2, 4, 1, 'RewardB'), (12, 3, 4, 1, 'PunishmentA'),
       (16, 2, 4, 1, 'RewardB'), (20, 2, 4, 1, 'RewardB'),
       (24, 1, 4, 1, 'RewardA'), (28, 4, 4, 1, 'PunishmentB'),
       (32, 0, 2, 1, 'NULL'), (34, 1, 4, 1, 'RewardA'),
       (38, 1, 4, 1, 'RewardA'), (42, 5, 4, 1, 'DistractorR'),
       (46, 2, 4, 1, 'RewardB'), (50, 6, 4, 1, 'DistractorP')],
      dtype=[('0', '<i4'), ('1', '<i4'), ('2', '<i4'), ('3', '<i4'), ('4', '|S11')])

In [46]: a['2']
Out[46]: array([4, 4, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 4])

In [47]: a['4']
Out[47]:
rec.array(['RewardA', 'DistractorR', 'RewardB', 'PunishmentA', 'RewardB',
       'RewardB', 'RewardA', 'PunishmentB', 'NULL', 'RewardA', 'RewardA',
       'DistractorR', 'RewardB', 'DistractorP'],
      dtype='|S11')


Cheers,

Ariel
--
Ariel Rokem
Helen Wills Neuroscience Institute
University of California, Berkeley
http://argentum.ucbso.berkeley.edu/ariel

or duek

unread,
Dec 21, 2010, 4:49:07 AM12/21/10
to psychopy-users
great :)
thank you very much.
> >> psychopy-user...@googlegroups.com<psychopy-users%2Bunsu...@googlegroups.com>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/psychopy-users?hl=en.
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "psychopy-users" group.
> > To post to this group, send email to psychop...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > psychopy-user...@googlegroups.com<psychopy-users%2Bunsu...@googlegroups.com>
> > .

Jonathan Peirce

unread,
Dec 21, 2010, 4:05:13 PM12/21/10
to psychop...@googlegroups.com
...or add a header row, save as either csv (I think) or xlsx (for sure) and then use importTrialList():
http://www.psychopy.org/api/data.html#psychopy.data.importTrialList

That will give you a list of dictionaries where each dictionary specifies the way the trial should work. This is all ready to provide as a trial list to the TrialHandler to make life easy.

Jon
-- 
Dr. Jonathan Peirce
Nottingham Visual Neuroscience

http://www.peirce.org.uk/
Reply all
Reply to author
Forward
0 new messages