示例#1
0
    def convolution(self, regressor, step_size=2):
        """
        Computes the predicted convolved hemodynamic response function signals
        for a given regressor.

        Parameters
        ----------
        regressor : str
            Name of the regressor whose predicted neural time course and whose
            hemodynamic response function will be convolved: select from "gain",
            "loss", "dist2indiff"
        step_size : float
            Size of temporal steps (in seconds) at which to generate signals

        Return
        ------
        convolution : np.ndarray
            Array containing the predicted hemodynamic response function values
            for the given regressor
        """
        time_course = self.time_course(regressor, step_size)
        # Hemodynamic responses typically last 30 seconds
        hr_func = hrf(np.arange(0, 30, step_size))
        convolution = np.convolve(time_course, hr_func)[:len(time_course)]
        return convolution
示例#2
0
def test_hrf():
	# Define the only two parameters of interest
    times = np.arange(30)
    hr = hrf(times)

    # They should contain the same number of elements
    assert_equal(len(times), len(hr))

    # The hemodynamic response is 0 at onset
    assert hr[0] == 0

    # HRF initially increases, then decreases, then increases/stabilizes to 0
    for i in range(0, 4): assert hr[i] < hr[i + 1]
    for i in range(5, 10): assert hr[i] > hr[i + 1]
    for i in range(15, 29): assert hr[i] < hr[i + 1]