def test_create_evoked_physio_signal(self): import pyhrf.paradigm phy_params = phy.PHY_PARAMS_FRISTON00 tr = 1. duration = 20. ne = np.array([[10., 5.]]) nb_conds, nb_vox = ne.shape # one single stimulation at the begining paradigm = pyhrf.paradigm.Paradigm({'c': [np.array([0.])]}, [duration], {'c': [np.array([1.])]}) s, f, hbr, cbv = phy.create_evoked_physio_signals(phy_params, paradigm, ne, tr) # shape of a signal: (nb_vox, nb_scans) if 0: import matplotlib.pyplot as plt t = np.arange(f[0].size) * tr plt.plot(t, f[0]) plt.title('inflow') plt.show() self.assertEqual(s.shape, (paradigm.get_rastered(tr)['c'][0].size, nb_vox)) # check signal causality: self.assertEqual(f[0, 0], 1.) npt.assert_approx_equal(f[-1, 0], 1., significant=2) # non-regression test: self.assertEqual(np.argmax(f[:, 0]) * tr, 2)
def rasterize_paradigm(paradigm, dt, condition_defs): """ Return binary sequences of onsets approximated on temporal grid of temporal resolution dt, for all conditions. 'paradigm' is expected to be an instance of 'pyhrf.paradigm.mpar.Paradigm' """ rparadigm = paradigm.get_rastered(dt) return np.vstack([rparadigm[c.name][0] for c in condition_defs])
def test_create_evoked_physio_signal(self): import pyhrf.paradigm phy_params = phy.PHY_PARAMS_FRISTON00 tr = 1. duration = 20. ne = np.array([[10., 5.]]) nb_conds, nb_vox = ne.shape # one single stimulation at the begining paradigm = pyhrf.paradigm.Paradigm({'c': [np.array([0.])]}, [duration], {'c': [np.array([1.])]}) s, f, hbr, cbv = phy.create_evoked_physio_signals( phy_params, paradigm, ne, tr) # shape of a signal: (nb_vox, nb_scans) if 0: import matplotlib.pyplot as plt t = np.arange(f[0].size) * tr plt.plot(t, f[0]) plt.title('inflow') plt.show() self.assertEqual(s.shape, (paradigm.get_rastered(tr)['c'][0].size, nb_vox)) # check signal causality: self.assertEqual(f[0, 0], 1.) npt.assert_approx_equal(f[-1, 0], 1., significant=2) # non-regression test: self.assertEqual(np.argmax(f[:, 0]) * tr, 2)