[pymvpa] Rapid ER design

Michael Hanke mih at debian.org
Mon Mar 30 12:05:01 UTC 2015


Hi,

On Sun, Mar 29, 2015 at 03:53:53PM -0400, Jeffrey Bloch wrote:
> MAKING THE DATASET
> >>> path = os.path.join('/home/bloch/data_for_Jeff')
> >>> bold_fname = os.path.join(path, 'sub001', 'BOLD', 'task001_run001',
> 'bold.nii.gz')
> >>> attr_fname = os.path.join(path, 'sub001', 'BOLD', 'task001_run001',
> 'Attributes_by_volume.txt'
> >>> attr = SampleAttributes(attr_fname)
> >>> ds1 = fmri_dataset(samples=bold_fname, targets=attr.targets,
> chunks=attr.chunks)
> 
> [Attribute list above has 179 items.  If I try to give it only the 110
> events with associated time stamps, it fails]

Ah code, no need for long descriptions if you have code...

The culprit is in the last line. You are trying to assign conditions to
a dataset where samples are fmri volumnes, but, as you said, you cannot
do that -- so don't ;-) Leave out the `targets=attr.targets`

Given your code it is strange that your dataset doesnt not contain a
time_coords attribute. Do you NIfTI files have the pixdim[4] value set
properly?

> >>> evds = eventrelated_dataset(ds1,
> ...                             events,
> ...                             model='hrf',
> ...                             time_attr='time_coords'
> ...                             condition_attr=('targets', 'chunks'))
> 
> [I'm not able to give appropriate time coords here -- for 110 events.
> Also, the information about the included events is not accurate due to
> timing]

Even if your dataset has no 'time_coords' (for whatever reason), just
add them:

ds.sa['time_coords'] = np.arange(0,???, 2.0) or something like that.


> EXAMPLE OF EVENTS:
> {'chunks': 0.0, 'duration': 5.8, 'onset': 20.0, 'targets': 'Monkey'}
> {'chunks': 0.0, 'duration': 8.7, 'onset': 24.0, 'targets': 'Wrench'}
> {'chunks': 0.0, 'duration': 2.9, 'onset': 30.0, 'targets': 'Monkey'}
> {'chunks': 0.0, 'duration': 5.8, 'onset': 32.0, 'targets': 'Screwdriver'}
> {'chunks': 0.0, 'duration': 8.7, 'onset': 36.0, 'targets': 'Elephant'}
> {'chunks': 0.0, 'duration': 5.8, 'onset': 42.0, 'targets': 'Hammer'}
> 
> [The onsets/durations above aren't correct.  I had to guess how long they
> would be by extrapolating my 110 events into the 179 volumes.  E.G., there
> was only 1 monkey stimulus, but in my attribute file I put it twice two
> "cover" the TRs during which it occurred.  Find_events interprets this as 2
> events, and thus doubles the duration time I give it.  The onsets
> themselves take on multiples of TR value, which in itself is incorrect]

If they aren't correct -- just make them ;-)

With 'time_coords' properly set, the 'onset' property of an event is
interpreted as onset in $(unit of your time_coords attribute). Things
will just work as you want them after this change.

The key is to NOT have an attributes file. Just build the list of dicts
you show above with the correct values from your design.

HTH,

Michael



More information about the Pkg-ExpPsy-PyMVPA mailing list