[pymvpa] design matrix identical across sessions

Wolfgang Pauli wolfgang.m.pauli at gmail.com
Tue May 17 23:41:38 UTC 2016


Quick update. Yaroslav and I were discussing this offline. It turned out
that it was necessary to adjust the time_coords of all events in all
sessions (chunks) after the first session. Basically, the time_coords have
to be relative to the beginning of the first session, rather than relative
to the beginning of the current session.

Thanks,

Wolfgang

On Mon, May 9, 2016 at 6:27 PM, Yaroslav Halchenko <debian at onerussian.com>
wrote:

> sorry Wolfgang, I have no mental capacity left to parse those outputs...
> it kinda looks ok, but you better just h5save sample dataset
> (ds[:,0] should be enough) and those events and then accompany with the
> code operating on those which would demonstrate the problem.  you can
> send directly to my email (ml will not allow for large attachments)
> That would be the best way to reproduce and understand (tomorrow morning
> I guess)
>
>
> On Mon, 09 May 2016, Wolfgang Pauli wrote:
>
> >    Hi,A
> >    Thank you for the quick response. I did infact have
> >    condition_attr=['targets', 'chunks'], sorry about the typo. Have been
> >    trying to debug this for too long ...
> >    Regarding the even definitions. Please see below the event definitions
> >    according to.A
> >    onsets = []
> >    targets = []
> >    chunks = []
> >    for ev in events:
> >    A  A  onsets.append(ev['onset'])
> >    A  A  targets.append(ev['targets'])
> >    A  A  chunks.append(ev['chunks'])
> >    >>> targets
> >    ['csA', 'csX_j_1', 'csB', 'csY_n_1', 'csA', 'csX_j_1', 'csB',
> 'csY_n_1',
> >    'csA', 'csX_j_1', 'csB', 'csY_n_1', 'csA', 'csX_j_1', 'csB',
> 'csY_n_1',
> >    'csB', 'csA', 'csX_j_1', 'csB', 'csY_n_1', 'csA', 'csX_j_1', 'csB',\
> >    A 'csY_n_1', 'csA', 'csX_j_1', 'csB', 'csY_n_1', 'csA', 'csX_j_1',
> 'csB',
> >    'csY_n_1', 'csA', 'csX_j_1', 'csB', 'csB', 'csY_n_1', 'csA', 'csA',
> >    'csX_j_1', 'csB', 'csY_n_1', 'csB', 'csA', 'csX_j_1', 'csA',
> 'csX_j_1',\
> >    A 'csB', 'csY_n_1', 'csA', 'csB', 'csY_n_1', 'csA', 'csC', 'csX_n_1',
> >    'csD', 'csY_j_1', 'csD', 'csY_j_1', 'csC', 'csX_n_1', 'csD',
> 'csY_j_1',
> >    'csC', 'csX_n_1', 'csD', 'csY_j_1', 'csC', 'csX_n_1', 'csD',
> 'csY_j_1',\
> >    A 'csC', 'csC', 'csX_n_1', 'csC', 'csX_n_1', 'csD', 'csY_j_1', 'csC',
> >    'csX_n_1', 'csC', 'csC', 'csX_n_1', 'csD', 'csD', 'csY_j_1', 'csC',
> >    'csX_n_1', 'csD', 'csY_j_1', 'csC', 'csX_n_1', 'csD', 'csY_j_1',
> 'csD',
> >    'cs\
> >    D', 'csY_j_1', 'csC', 'csX_n_1', 'csD', 'csY_j_1', 'csC', 'csD',
> >    'csY_j_1', 'csD', 'csC', 'csX_n_1', 'csE', 'csX_j_2', 'csE',
> 'csX_j_2',
> >    'csE', 'csX_j_2', 'csF', 'csY_n_2', 'csE', 'csX_j_2', 'csF',
> 'csY_n_2',
> >    'cs\
> >    E', 'csX_j_2', 'csF', 'csY_n_2', 'csE', 'csX_j_2', 'csF', 'csY_n_2',
> >    'csF', 'csF', 'csY_n_2', 'csE', 'csX_j_2', 'csF', 'csY_n_2', 'csE',
> 'csF',
> >    'csY_n_2', 'csE', 'csX_j_2', 'csF', 'csY_n_2', 'csE', 'csX_j_2', 'cs\
> >    F', 'csY_n_2', 'csE', 'csX_j_2', 'csF', 'csY_n_2', 'csE', 'csX_j_2',
> >    'csF', 'csY_n_2', 'csE', 'csF', 'csY_n_2', 'csF', 'csE', 'csF', 'csE',
> >    'csX_j_2', 'csH', 'csY_j_2', 'csH', 'csY_j_2', 'csH', 'csY_j_2',
> 'csG', \
> >    'csX_n_2', 'csH', 'csY_j_2', 'csG', 'csX_n_2', 'csH', 'csY_j_2',
> 'csG',
> >    'csX_n_2', 'csH', 'csY_j_2', 'csG', 'csX_n_2', 'csH', 'csY_j_2',
> 'csH',
> >    'csH', 'csY_j_2', 'csG', 'csX_n_2', 'csH', 'csY_j_2', 'csG', 'csX_n_\
> >    2', 'csG', 'csG', 'csX_n_2', 'csH', 'csG', 'csX_n_2', 'csH',
> 'csY_j_2',
> >    'csG', 'csX_n_2', 'csG', 'csG', 'csX_n_2', 'csH', 'csY_j_2', 'csG',
> >    'csX_n_2', 'csH', 'csY_j_2', 'csH', 'csG', 'csX_n_2', 'csG']
> >    >>> onsets
> >    [4.2000001668930054, 7.2000002861022949, 20.400000810623169,
> >    25.200001001358032, 39.600001573562622, 45.600001811981201,
> >    61.800002455711365, 66.600002646446228, 80.40000319480896,
> >    84.000003337860107, 94.800003767\
> >    01355, 98.400003910064697, 114.000004529953, 117.00000464916229,
> >    127.20000505447388, 132.00000524520874, 144.0000057220459,
> >    162.00000643730164, 166.20000660419464, 178.80000710487366,
> >    184.20000731945038, 199.8000\
> >    0793933868, 203.40000808238983, 216.00000858306885, 219.60000872612,
> >    230.40000915527344, 235.80000936985016, 249.60000991821289,
> >    254.40001010894775, 270.00001072883606, 275.40001094341278,
> >    291.00001156330109, 295\
> >    .20001173019409, 306.00001215934753, 310.8000123500824,
> >    327.00001299381256, 346.20001375675201, 351.60001397132874,
> >    367.8000146150589, 386.40001535415649, 392.40001559257507,
> >    409.80001628398895, 415.2000164985656\
> >    7, 432.60001718997955, 451.80001795291901, 456.00001811981201,
> >    469.20001864433289, 473.40001881122589, 487.80001938343048,
> >    492.60001957416534, 507.00002014636993, 528.00002098083496,
> >    532.80002117156982, 548.40002\
> >    179145813, 606.60002410411835, 610.80002427101135, 624.00002479553223,
> >    628.80002498626709, 640.20002543926239, 644.4000256061554,
> >    658.20002615451813, 661.80002629756927, 673.80002677440643,
> >    676.80002689361572, 68\
> >    8.20002734661102, 693.00002753734589, 703.20002794265747,
> >    707.40002810955048, 720.00002861022949, 725.40002882480621,
> >    737.40002930164337, 740.40002942085266, 755.40003001689911,
> >    777.00003087520599, 781.2000310420\
> >    99, 793.20003151893616, 798.60003173351288, 811.20003223419189,
> >    815.4000324010849, 828.60003292560577, 834.0000331401825,
> >    846.00003361701965, 862.80003428459167, 867.00003445148468,
> >    878.40003490447998, 897.000035\
> >    64357758, 901.20003581047058, 917.40003645420074, 922.20003664493561,
> >    939.60003733634949, 943.80003750324249, 955.20003795623779,
> >    958.80003809928894, 972.60003864765167, 976.20003879070282,
> >    989.40003931522369, 10\
> >    08.0000400543213, 1012.2000402212143, 1025.4000407457352,
> >    1030.8000409603119, 1043.4000414609909, 1047.0000416040421,
> >    1062.0000422000885, 1083.0000430345535, 1087.8000432252884,
> >    1100.4000437259674, 1119.000044465\
> >    065, 1122.0000445842743, 1206.6000479459763, 1210.8000481128693,
> >    1225.8000487089157, 1230.6000488996506, 1243.2000494003296,
> >    1247.4000495672226, 1260.0000500679016, 1266.0000503063202,
> >    1279.8000508546829, 1284.00\
> >    00510215759, 1299.0000516176224, 1304.4000518321991,
> 1318.2000523805618,
> >    1323.6000525951385, 1335.6000530719757, 1339.2000532150269,
> >    1354.2000538110733, 1358.4000539779663, 1369.2000544071198,
> >    1374.0000545978546,\
> >    A 1390.2000552415848, 1407.6000559329987, 1412.4000561237335,
> >    1428.0000567436218, 1434.0000569820404, 1448.400057554245,
> >    1453.8000577688217, 1470.0000584125519, 1485.0000590085983,
> >    1488.0000591278076, 1504.8000597\
> >    953796, 1510.8000600337982, 1523.4000605344772, 1527.6000607013702,
> >    1543.2000613212585, 1547.4000614881516, 1559.4000619649887,
> >    1564.8000621795654, 1579.20006275177, 1584.6000629663467,
> >    1600.200063586235, 1603.20\
> >    00637054443, 1615.2000641822815, 1618.2000643014908,
> 1630.8000648021698,
> >    1634.4000649452209, 1647.6000654697418, 1662.0000660419464,
> >    1666.2000662088394, 1679.4000667333603, 1696.2000674009323,
> >    1714.200068116188, \
> >    1735.2000689506531, 1741.2000691890717, 1806.6000717878342,
> >    1809.6000719070435, 1824.000072479248, 1830.0000727176666,
> >    1842.0000731945038, 1848.0000734329224, 1860.0000739097595,
> >    1865.4000741243362, 1879.80007469\
> >    65408, 1884.6000748872757, 1900.200075507164, 1904.400075674057,
> >    1919.4000762701035, 1923.0000764131546, 1937.4000769853592,
> >    1943.4000772237778, 1956.0000777244568, 1960.8000779151917,
> >    1974.6000784635544, 1977.60\
> >    00785827637, 1993.200079202652, 1998.6000794172287,
> 2011.2000799179077,
> >    2026.2000805139542, 2030.4000806808472, 2042.4000811576843,
> >    2047.800081372261, 2059.8000818490982, 2065.2000820636749,
> >    2077.2000825405121, 2\
> >    080.8000826835632, 2092.8000831604004, 2107.8000837564468,
> >    2112.6000839471817, 2125.8000844717026, 2140.800085067749,
> >    2145.000085234642, 2158.8000857830048, 2164.2000859975815,
> >    2176.8000864982605, 2179.8000866174\
> >    698, 2195.4000872373581, 2212.2000879049301, 2217.000088095665,
> >    2232.6000887155533, 2235.6000888347626, 2250.0000894069672,
> >    2254.2000895738602, 2269.8000901937485, 2274.6000903844833,
> >    2289.0000909566879, 2306.400\
> >    0916481018, 2311.8000918626785, 2322.0000922679901]
> >    >>> chunksA
> >    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
> 0,
> >    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
> 0, 0,
> >    0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1\
> >    , 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> 1, 1,
> >    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
> 2, 2,
> >    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
> >    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3,
> 3, 3,
> >    3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
> 3, 3,
> >    3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,\
> >    A 3, 3, 3, 3]
> >    This looks correct, no? I am trying to attach the image plot of the
> design
> >    matrix, split into the 4 sessions.A
> >    Best,
> >    Wolfganga**
> >    [IMG]A figure_1.png
> >    a**
> >    On Mon, May 9, 2016 at 5:50 PM, Yaroslav Halchenko <
> debian at onerussian.com>
> >    wrote:
>
> >      On Mon, 09 May 2016, Wolfgang Pauli wrote:
>
> >      > Hi,
>
> >      > I am trying to perform an mvpa analysis of an experiment in which
> I
> >      have 16
> >      > different trial types and 4 sessions, 4 trial types in each
> session
> >      (run).
> >      > Based on the tutorial, I was getting started by using
> >      fit_event_hrf_model,
> >      > like so:
>
> >      > evds = fit_event_hrf_model(ds, events, time_attr='time_coords',
> >      > condition_attr=('onset'), return_model=True)
>
> >      > where ds is an openfmri dataset (get_model_bold_dataset).
>
> >      > I was trying to figure out why I would always get the warning
> that the
> >      > design matrix was singular, and eventually ended up investigating
> the
> >      > design matrix of the model.
>
> >      > I used matplotlib to plot the design matrix, split it up into the
> four
> >      > session, and found that the four parts were IDENTICAL. What could
> I be
> >      > doing wrong? Obviously, it shouldn't be the same, because there
> are
> >      > different trial types in the four sessions, and the trial order is
> >      also
> >      > randomized.
>
> >      > Furthermore, the design matrix has 26 regressors. I don't quite
> >      understand
> >      > where that number is coming from, as I have 16 unique event
> types, and
> >      4
> >      > sessions.
>
> >      most probably that events definition was was the same in each of the
> >      chunks... but also note that if you do it in a dataset which has
> >      multiple chunks, you want to have condition_attr=['onset',
> 'chunks'] if
> >      you want to make a model per each onset x chunk pair as was demoed
> e.g.
> >      atA
> http://www.pymvpa.org/tutorial_eventrelated.html#response-modeling
>
> >      if you share your data, and ideally your investigation script then
> we
> >      could may be look deeper
> --
> Yaroslav O. Halchenko
> Center for Open Neuroscience     http://centerforopenneuroscience.org
> Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
> Phone: +1 (603) 646-9834                       Fax: +1 (603) 646-1419
> WWW:   http://www.linkedin.com/in/yarik
>
> _______________________________________________
> Pkg-ExpPsy-PyMVPA mailing list
> Pkg-ExpPsy-PyMVPA at lists.alioth.debian.org
> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-exppsy-pymvpa
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-exppsy-pymvpa/attachments/20160517/86b813af/attachment-0001.html>


More information about the Pkg-ExpPsy-PyMVPA mailing list