コード例 #1
0
def test_io():

    refdm = DataMatrix(length=3)
    refdm[u'tést'] = 1, 2, u''
    refdm.B = u'mathôt', u'b', u'x'
    refdm.C = u'a,\\b"\'c', 8, u''

    testdm = io.readtxt('testcases/data/data.csv')
    check_dm(refdm, testdm)
    io.writetxt(testdm, 'tmp.csv')
    testdm = io.readtxt('tmp.csv')
    check_dm(refdm, testdm)

    refdm = io.readtxt('testcases/data/line-ending-cr.csv')
    check_dm(refdm, testdm)
    refdm = io.readtxt('testcases/data/line-ending-crlf.csv')
    check_dm(refdm, testdm)
    refdm = io.readtxt('testcases/data/data-with-bom.csv')
    check_dm(refdm, testdm)

    io.writepickle(testdm, 'tmp.pickle')
    testdm = io.readpickle('tmp.pickle')
    check_dm(refdm, testdm)

    io.writexlsx(testdm, 'tmp.xlsx')
    with pytest.warns(UserWarning):  # Not all rows have column C
        testdm = io.readxlsx('tmp.xlsx')
    check_dm(refdm, testdm)
    io.writexlsx(testdm, 'tmp.xlsx')
    with pytest.warns(UserWarning):  # Not all rows have column C
        testdm = io.readxlsx('tmp.xlsx')
    check_dm(refdm, testdm)
コード例 #2
0
def test_io():

    refdm = DataMatrix(length=3)
    refdm[u'tést'] = 1, 2, u''
    refdm.B = u'mathôt', u'b', u'x'
    refdm.C = u'a,\\b"\'c', 8, u''

    testdm = io.readtxt('testcases/data/data.csv')
    check_dm(refdm, testdm)
    io.writetxt(testdm, 'tmp.csv')
    testdm = io.readtxt('tmp.csv')
    check_dm(refdm, testdm)

    refdm = io.readtxt('testcases/data/line-ending-cr.csv')
    check_dm(refdm, testdm)
    refdm = io.readtxt('testcases/data/line-ending-crlf.csv')
    check_dm(refdm, testdm)

    io.writepickle(testdm, 'tmp.pickle')
    testdm = io.readpickle('tmp.pickle')
    check_dm(refdm, testdm)

    io.writexlsx(testdm, 'tmp.xlsx')
    testdm = io.readxlsx('tmp.xlsx')
    check_dm(refdm, testdm)
コード例 #3
0
 def inner(dm, *arglist, **kwdict):
     print("Running with gaze data")
     dm = io.readpickle(".cache/gaze-data-%s.pkl" % analysis.exp)
     print("All experiments: Keeping only correct trials")
     dm = dm.correct == 1
     if analysis.exp == "exp2":
         print("Exp 2: Keeping only memory trials")
         dm = dm.trialType == "memory"
     return fnc(dm)
コード例 #4
0
def realdata():

    dm = io.readpickle('data/real-data.pkl')
    # If the buffered DataMatrix still uses a list-style row index, we convert
    # it to the new Index object with this hack.
    if isinstance(dm._rowid, list):
        from datamatrix._datamatrix._index import Index
        object.__setattr__(dm, u'_rowid', Index(dm._rowid))
    print(len(dm))
    return dm
コード例 #5
0
ファイル: test_io.py プロジェクト: smathot/python-datamatrix
def test_io():

	refdm = DataMatrix(length=3)
	refdm[u'tést'] = 1, 2, u''
	refdm.B = u'mathôt', u'b', u'x'
	refdm.C = u'a,\\b"\'c', 8, u''

	testdm = io.readtxt('testcases/data/data.csv')
	check_dm(refdm, testdm)
	io.writetxt(testdm, 'tmp.csv')
	testdm = io.readtxt('tmp.csv')
	check_dm(refdm, testdm)

	io.writepickle(testdm, 'tmp.pickle')
	testdm = io.readpickle('tmp.pickle')
	check_dm(refdm, testdm)

	io.writexlsx(testdm, 'tmp.xlsx')
	testdm = io.readxlsx('tmp.xlsx')
	check_dm(refdm, testdm)
コード例 #6
0
# <markdowncell>
"""
## Data parsing

The data is stored in separate DataMatrix objects, one for each participant,
where each row corresponds to one video fragment. We merge these objects such
that we get a big DataMatrix where each row corresponds to a single
participant, and the cells are averaged across video fragments.
"""
# </markdowncell>

# <codecell>
dm = DataMatrix(length=NSUB)
for row, basename in zip(dm, os.listdir(COR_SRC)):
    path = os.path.join(COR_SRC, basename)
    sdm = io.readpickle(path)
    for colname, col in sdm.columns:
        if colname not in dm:
            dm[colname] = type(col)
        row[colname] = col.mean
# </codecell>

# <markdowncell>
"""
For some analyses it's more convient to have the data in long format such that
each row corresponds to a single voxel. That's what we do here. We also merge
the PRF data into this long format, such that we know the PRF properties for
each voxel.
"""
# </markdowncell>