Ejemplo n.º 1
0
def test_getFirstLevelEVs_realdata():
    featdir = op.join(datadir, '1stlevel_realdata.feat')
    settings = featanalysis.loadSettings(featdir)
    matrix = featdesign.loadDesignMat(op.join(featdir, 'design.mat'))
    expected = [(featdesign.NormalEV, {
        'index': 0,
        'origIndex': 0
    }), (featdesign.TemporalDerivativeEV, {
        'index': 1
    }), (featdesign.NormalEV, {
        'index': 2,
        'origIndex': 1
    }), (featdesign.TemporalDerivativeEV, {
        'index': 3
    })]

    evs = featdesign.getFirstLevelEVs(featdir, settings, matrix)

    assert len(evs) == 4

    for i, (evtype, atts) in enumerate(expected):

        assert isinstance(evs[i], evtype)
        for k, v in atts.items():
            assert getattr(evs[i], k) == v
    del evs
    evs = None
Ejemplo n.º 2
0
def test_loadDesignMat():

    for featdir in TEST_ANALYSES.keys():
        shape = TEST_ANALYSES[featdir]['designShape']
        featdir = op.join(datadir, featdir)
        fname = op.join(featdir, 'design.mat')
        mat = featdesign.loadDesignMat(fname)

        assert mat.shape == shape

    nonfile = op.join(datadir, 'non-existent-file')
    badfile = op.join(datadir, '1stlevel_1.feat', 'design.fsf')
    with pytest.raises(Exception):
        featdesign.loadDesignMat(nonfile)

    with pytest.raises(Exception):
        featdesign.loadDesignMat(badfile)
Ejemplo n.º 3
0
def test_getHigherLevelEVs_1():

    featdir = op.join(datadir, '2ndlevel_1.gfeat')
    settings = featanalysis.loadSettings(featdir)
    matrix = featdesign.loadDesignMat(op.join(featdir, 'design.mat'))

    evs = featdesign.getHigherLevelEVs(featdir, settings, matrix)

    assert len(evs) == 1
    assert isinstance(evs[0], featdesign.NormalEV)
    assert evs[0].index == 0
    assert evs[0].origIndex == 0
Ejemplo n.º 4
0
def test_getFirstLevelEVs_2():
    featdir = op.join(datadir, '1stlevel_2.feat')
    settings = featanalysis.loadSettings(featdir)
    matrix = featdesign.loadDesignMat(op.join(featdir, 'design.mat'))

    expected = [(featdesign.NormalEV, {
        'index': 0,
        'origIndex': 0
    }), (featdesign.TemporalDerivativeEV, {
        'index': 1
    }), (featdesign.NormalEV, {
        'index': 2,
        'origIndex': 1
    }), (featdesign.TemporalDerivativeEV, {
        'index': 3
    }), (featdesign.VoxelwiseEV, {
        'index': 4,
        'origIndex': 2
    }), (featdesign.MotionParameterEV, {
        'index': 5,
        'motionIndex': 0
    }), (featdesign.MotionParameterEV, {
        'index': 6,
        'motionIndex': 1
    }), (featdesign.MotionParameterEV, {
        'index': 7,
        'motionIndex': 2
    }), (featdesign.MotionParameterEV, {
        'index': 8,
        'motionIndex': 3
    }), (featdesign.MotionParameterEV, {
        'index': 9,
        'motionIndex': 4
    }), (featdesign.MotionParameterEV, {
        'index': 10,
        'motionIndex': 5
    })]

    evs = featdesign.getFirstLevelEVs(featdir, settings, matrix)
    assert len(evs) == 11

    for i, (evtype, atts) in enumerate(expected):

        assert isinstance(evs[i], evtype)
        for k, v in atts.items():
            assert getattr(evs[i], k) == v
    del evs
    evs = None
Ejemplo n.º 5
0
def test_getFirstLevelEVs_3():
    featdir = op.join(datadir, '1stlevel_3.feat')
    settings = featanalysis.loadSettings(featdir)
    matrix = featdesign.loadDesignMat(op.join(featdir, 'design.mat'))

    expected = [(featdesign.NormalEV, {
        'index': 0,
        'origIndex': 0
    }), (featdesign.TemporalDerivativeEV, {
        'index': 1
    }), (featdesign.NormalEV, {
        'index': 2,
        'origIndex': 1
    }), (featdesign.BasisFunctionEV, {
        'index': 3
    }), (featdesign.BasisFunctionEV, {
        'index': 4
    }), (featdesign.VoxelwiseConfoundEV, {
        'index': 5,
        'voxIndex': 0
    }), (featdesign.MotionParameterEV, {
        'index': 6,
        'motionIndex': 0
    }), (featdesign.MotionParameterEV, {
        'index': 7,
        'motionIndex': 1
    }), (featdesign.MotionParameterEV, {
        'index': 8,
        'motionIndex': 2
    }), (featdesign.MotionParameterEV, {
        'index': 9,
        'motionIndex': 3
    }), (featdesign.MotionParameterEV, {
        'index': 10,
        'motionIndex': 4
    }), (featdesign.MotionParameterEV, {
        'index': 11,
        'motionIndex': 5
    }), (featdesign.MotionParameterEV, {
        'index': 12,
        'motionIndex': 6
    }), (featdesign.MotionParameterEV, {
        'index': 13,
        'motionIndex': 7
    }), (featdesign.MotionParameterEV, {
        'index': 14,
        'motionIndex': 8
    }), (featdesign.MotionParameterEV, {
        'index': 15,
        'motionIndex': 9
    }), (featdesign.MotionParameterEV, {
        'index': 16,
        'motionIndex': 10
    }), (featdesign.MotionParameterEV, {
        'index': 17,
        'motionIndex': 11
    }), (featdesign.MotionParameterEV, {
        'index': 18,
        'motionIndex': 12
    }), (featdesign.MotionParameterEV, {
        'index': 19,
        'motionIndex': 13
    }), (featdesign.MotionParameterEV, {
        'index': 20,
        'motionIndex': 14
    }), (featdesign.MotionParameterEV, {
        'index': 21,
        'motionIndex': 15
    }), (featdesign.MotionParameterEV, {
        'index': 22,
        'motionIndex': 16
    }), (featdesign.MotionParameterEV, {
        'index': 23,
        'motionIndex': 17
    }), (featdesign.MotionParameterEV, {
        'index': 24,
        'motionIndex': 18
    }), (featdesign.MotionParameterEV, {
        'index': 25,
        'motionIndex': 19
    }), (featdesign.MotionParameterEV, {
        'index': 26,
        'motionIndex': 20
    }), (featdesign.MotionParameterEV, {
        'index': 27,
        'motionIndex': 21
    }), (featdesign.MotionParameterEV, {
        'index': 28,
        'motionIndex': 22
    }), (featdesign.MotionParameterEV, {
        'index': 29,
        'motionIndex': 23
    }), (featdesign.ConfoundEV, {
        'index': 30,
        'confIndex': 0
    }), (featdesign.ConfoundEV, {
        'index': 31,
        'confIndex': 1
    })]

    evs = featdesign.getFirstLevelEVs(featdir, settings, matrix)

    assert len(evs) == 32

    for i, (evtype, atts) in enumerate(expected):

        assert isinstance(evs[i], evtype)
        for k, v in atts.items():
            assert getattr(evs[i], k) == v

    del evs
    evs = None