<div dir="ltr">Dear Michael,<div><br></div><div>I really appreciate your time getting back to me.  You comments were indeed helpful, at least conceptually.  :)   I've spent the past 5 hours trying to get this to work, but it seems there are still some problems.  Getting pretty frustrated, so I thought I'd reply and hope you aren't too annoyed.  My apologies if I've repeated myself below, I just want to be sure I'm understanding you.<br><span><br><br>>>> ds1 = fmri_dataset(samples=bold_fname, targets=attr.targets,<br>
> chunks=attr.chunks)</span><br></div><div><br></div><div>The culprit is in the last line. You are trying to assign conditions to<br>a dataset where samples are fmri volumnes, but, as you said, you cannot<br>do that -- so don't ;-) Leave out the `targets=attr.targets`<br></div><div><br></div><div><i>          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).  <br></i></div><div><br></div><div>Even if your dataset has no 'time_coords' (for whatever reason), just<br>add them:  <a href="http://ds.sa/" target="_blank">ds.sa</a>['time_coords'] = np.arange(0,???, 2.0) or something like that.<br><br><i>             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).<br>            <br>            >>> ds1 = fmri_dataset(bold_fname)<br>            >>> <a href="http://ds1.sa">ds1.sa</a>['time_coords'] = np.arange(20,339,2.9)<br>            
 ValueError: Collectable 'time_coords' with length [110] does not match 
the required length [179] of collection '<SampleAttributesCollection:
 time_coords,time_indices>'.<br><br></i><i>               
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).<br><br>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.<br><br></i><i>>>> <a href="http://ds1.sa">ds1.sa</a>['time_coords'] = np.arange(0,518,2.9)<br>{'duration': 1, 'onset': 1, 'time_attr': 2.8999999999999999}<br>{'duration': 1, 'onset': 2, 'time_attr': 5.7999999999999998}<br>{'duration': 1, 'onset': 3, 'time_attr': 8.6999999999999993}<br></i></div><div><br></div><div>With 'time_coords' properly set, the 'onset' property of an event is<br>interpreted as onset in $(unit of your time_coords attribute). Things<br>will just work as you want them after this change.</div><div><br></div><div>          <i>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.</i><br></div><div>          <br><br>If they aren't correct -- just make them ;-)<br></div><div><br></div><div>          <i>Even if I build my events by hand, the time_coords necessary for eventrelated_dataset won't match up with the events or the dataset.  Is there an easy way to make dictionaries from attribute lists?  Or, is find_event the only way?  <br><br><br></i></div><div>The key is to NOT have an attributes file. Just build the list of dicts<br>you show above with the correct values from your design.</div><div><br><div class="gmail_extra">         <i>How do I get information from my dicts into the event list?  Are they attributes of something?  I'm not sure what to put for "condition_attr" if I don't have any attributes with the dataset from the outset.  The file loaded below with ColumnData has 5 columns with each data on of the parameters I'm interested in.  <br><br><br>>>> events = ColumnData('/home/bloch/data_for_Jeff/sub001/BOLD/Attributes_All.txt', header=True)<br>>>> print(events)<br>ColumnData 220 rows, 5 columns [subcat chunk oddball word cat]<br>>>> print len(events)<br>5<br></i><br><br><i><span>evds = eventrelated_dataset(ds1,                                                 <br></span></i></div><div class="gmail_extra"><i><span>> ...                             events,                                                        [list of 110 events]<br>
> ...                             model='hrf',<br>
> ...                             time_attr='time_coords'                              <br>
> ...                             condition_attr=('X', 'Y'))</span></i>                             <i>[e.g., 'subcat', 'chunk']</i><br><br><br><br></div><div class="gmail_extra">Cheers,<br></div><div class="gmail_extra">Jeff<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 30, 2015 at 8:05 AM, Michael Hanke <span dir="ltr"><<a href="mailto:mih@debian.org" target="_blank">mih@debian.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<span><br>
On Sun, Mar 29, 2015 at 03:53:53PM -0400, Jeffrey Bloch wrote:<br>
> MAKING THE DATASET<br>
> >>> path = os.path.join('/home/bloch/data_for_Jeff')<br>
> >>> bold_fname = os.path.join(path, 'sub001', 'BOLD', 'task001_run001',<br>
> 'bold.nii.gz')<br>
> >>> attr_fname = os.path.join(path, 'sub001', 'BOLD', 'task001_run001',<br>
> 'Attributes_by_volume.txt'<br>
> >>> attr = SampleAttributes(attr_fname)<br>
> >>> ds1 = fmri_dataset(samples=bold_fname, targets=attr.targets,<br>
> chunks=attr.chunks)<br>
><br>
> [Attribute list above has 179 items.  If I try to give it only the 110<br>
> events with associated time stamps, it fails]<br>
<br>
</span>Ah code, no need for long descriptions if you have code...<br>
<br>
The culprit is in the last line. You are trying to assign conditions to<br>
a dataset where samples are fmri volumnes, but, as you said, you cannot<br>
do that -- so don't ;-) Leave out the `targets=attr.targets`<br>
<br>
Given your code it is strange that your dataset doesnt not contain a<br>
time_coords attribute. Do you NIfTI files have the pixdim[4] value set<br>
properly?<br>
<span><br>
> >>> evds = eventrelated_dataset(ds1,<br>
> ...                             events,<br>
> ...                             model='hrf',<br>
> ...                             time_attr='time_coords'<br>
> ...                             condition_attr=('targets', 'chunks'))<br>
><br>
> [I'm not able to give appropriate time coords here -- for 110 events.<br>
> Also, the information about the included events is not accurate due to<br>
> timing]<br>
<br>
</span>Even if your dataset has no 'time_coords' (for whatever reason), just<br>
add them:<br>
<br>
<a href="http://ds.sa" target="_blank">ds.sa</a>['time_coords'] = np.arange(0,???, 2.0) or something like that.<br>
<span><br>
<br>
> EXAMPLE OF EVENTS:<br>
> {'chunks': 0.0, 'duration': 5.8, 'onset': 20.0, 'targets': 'Monkey'}<br>
> {'chunks': 0.0, 'duration': 8.7, 'onset': 24.0, 'targets': 'Wrench'}<br>
> {'chunks': 0.0, 'duration': 2.9, 'onset': 30.0, 'targets': 'Monkey'}<br>
> {'chunks': 0.0, 'duration': 5.8, 'onset': 32.0, 'targets': 'Screwdriver'}<br>
> {'chunks': 0.0, 'duration': 8.7, 'onset': 36.0, 'targets': 'Elephant'}<br>
> {'chunks': 0.0, 'duration': 5.8, 'onset': 42.0, 'targets': 'Hammer'}<br>
><br>
> [The onsets/durations above aren't correct.  I had to guess how long they<br>
> would be by extrapolating my 110 events into the 179 volumes.  E.G., there<br>
> was only 1 monkey stimulus, but in my attribute file I put it twice two<br>
> "cover" the TRs during which it occurred.  Find_events interprets this as 2<br>
> events, and thus doubles the duration time I give it.  The onsets<br>
> themselves take on multiples of TR value, which in itself is incorrect]<br>
<br>
</span>If they aren't correct -- just make them ;-)<br>
<br>
With 'time_coords' properly set, the 'onset' property of an event is<br>
interpreted as onset in $(unit of your time_coords attribute). Things<br>
will just work as you want them after this change.<br>
<br>
The key is to NOT have an attributes file. Just build the list of dicts<br>
you show above with the correct values from your design.<br>
<br>
HTH,<br>
<div><div><br>
Michael<br>
<br>
_______________________________________________<br>
Pkg-ExpPsy-PyMVPA mailing list<br>
<a href="mailto:Pkg-ExpPsy-PyMVPA@lists.alioth.debian.org" target="_blank">Pkg-ExpPsy-PyMVPA@lists.alioth.debian.org</a><br>
<a href="http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-exppsy-pymvpa" target="_blank">http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-exppsy-pymvpa</a><br>
</div></div></blockquote></div><br></div></div></div>