[pymvpa] Rapid ER design

Michael Hanke mih at debian.org
Tue Apr 7 09:23:53 UTC 2015


On Mon, Mar 30, 2015 at 03:01:18PM -0400, Jeffrey Bloch wrote:
> >>> ds1 = fmri_dataset(samples=bold_fname, targets=attr.targets,
> > chunks=attr.chunks)
> 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`
> *          Good point.  :)   Should I also remove chunks?  Regardless, even
> when I load the dataset without any attributes
> (ds1=fmri_dataset(bold_fname), the 179 volumes of the time_series still
> causes me some problems (see below).  *

You haven't mentioned what your chunks are. For most fMRI designs chunks
would represent runs, i.e. separate scans performed back to back without
participants leaving the scanner. However, arbitrary assignment of
samples to chunks is possible and can be meaningful.

The fact that the number of samples in your 'fmri_dataset' is identical
to the number of volumes is intended. This is a timeseries dataset. The
number of volumes is the number of timepoints.

> 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.
> *             When I set up my time_coords with np.arange, it still wants
> 179 time points (even though I only want to model 110 events).

Again, your 'events' have nothing to do with the sampling of the
timeseries. time_coords assigns a time stamp to each point of the time
series -- nothing more, nothing less.

>           >>> ds1 = fmri_dataset(bold_fname)            >>> ds1.sa

> <http://ds1.sa>['time_coords'] = np.arange(20,339,2.9)
> ValueError: Collectable 'time_coords' with length [110] does not match the
> required length [179] of collection '<SampleAttributesCollection:
> time_coords,time_indices>'.*
> *               As you can see, I want my events to be 2.9s apart.  If I
> put 2.0 instead of 2.9, my events will be 2s apart (which is the TR).Here's
> an example of some time points when I complied with the 179 volumes and
> allowed 2.9s.  Of course, my time_attr went up to 520 in this case.*

For time_coords the TR (repetition time) of your fMRI scan is relevant
-- not your event spacing.

> *>>> ds1.sa <http://ds1.sa>['time_coords'] =
> np.arange(0,518,2.9){'duration': 1, 'onset': 1, 'time_attr':
> 2.8999999999999999}{'duration': 1, 'onset': 2, 'time_attr':
> 5.7999999999999998}{'duration': 1, 'onset': 3, 'time_attr':
> 8.6999999999999993}*
> 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.
>           *How can I build an event list from only a time_coords file?  I'm
> not sure where the other items in the dictionary come from.*

Now I am confused. There is usually no time_coords file (unless you are
doing a sparse sampling fMRI scan with irregular volume spacing were
this would make sense).

All information that needs to go into the list of event dictionaries
comes from your experiment design. The list should have 110 items (your
number of events), each dictionary needs 'onset' (time of event onset),
'duration' (duration of an event) and a 'target' attribute (condition
label; actual name of the attribute is arbitrary).

You need to build this list of dictionaries in Python code. If you load
this information from a file, hard code in the script, or conjure it up
is completely up to you ;-)

> *How do I get information from my dicts into the event list?
> Are they attributes of something?

Not sure what you mean.

> I'm not sure what to put for "condition_attr" if I don't have any
> attributes with the dataset from the outset.

Every item in your event dictionary (except for onset and duration) is
converted into a sample attribute.

> The file loaded below with ColumnData has 5 columns with each data on
> of the parameters I'm interested in.  >>> events =
> ColumnData('/home/bloch/data_for_Jeff/sub001/BOLD/Attributes_All.txt',
> header=True)>>> print(events)ColumnData 220 rows, 5 columns [subcat
> chunk oddball word cat]>>> print len(events)5*
> *evds = eventrelated_dataset(ds1, *
> *> ...  events, [list of 110 events] > ...  model='hrf', > ...
> time_attr='time_coords'
> > ...  condition_attr=('X', 'Y'))* *[e.g., 'subcat', 'chunk']*

This file sounds like a good starting point, but it seems that this file
doesn't have information on the timing of the events, right? Maybe you
could add them.


More information about the Pkg-ExpPsy-PyMVPA mailing list