예제 #1
0
def fir(timeseries, design):
    """
    Calculate the FIR (finite impulse response) HRF, according to [Burock2000]_

    Parameters
    ----------

    timeseries : float array
            timeseries data

    design : int array
          This is a design matrix.  It has to have shape = (number
          of TRS, number of conditions * length of HRF)

          The form of the matrix is:

              A B C ...

          where A is a (number of TRs) x (length of HRF) matrix with a unity
          matrix placed with its top left corner placed in each TR in which
          event of type A occured in the design. B is the equivalent for
          events of type B, etc.

    Returns
    -------

    HRF: float array
        HRF is a numpy array of 1X(length of HRF * number of conditions)
        with the HRFs for the different conditions concatenated. This is an
        estimate of the linear filters between the time-series and the events
        described in design.

    Notes
    -----

    Implements equation 4 in Burock(2000):

    .. math::

        \hat{h} = (X^T X)^{-1} X^T y

    M.A. Burock and A.M.Dale (2000). Estimation and Detection of Event-Related
    fMRI Signals with Temporally Correlated Noise: A Statistically Efficient
    and Unbiased Approach. Human Brain Mapping, 11:249-260

    """
    X = np.matrix(design)
    y = np.matrix(timeseries)
    h = np.array(linalg.pinv(X.T * X) * X.T * y.T)
    return h
예제 #2
0
def fir(timeseries, design):
    """
    Calculate the FIR (finite impulse response) HRF, according to [Burock2000]_

    Parameters
    ----------

    timeseries : float array
            timeseries data

    design : int array
          This is a design matrix.  It has to have shape = (number
          of TRS, number of conditions * length of HRF)

          The form of the matrix is:

              A B C ...

          where A is a (number of TRs) x (length of HRF) matrix with a unity
          matrix placed with its top left corner placed in each TR in which
          event of type A occured in the design. B is the equivalent for
          events of type B, etc.

    Returns
    -------

    HRF: float array
        HRF is a numpy array of 1X(length of HRF * number of conditions)
        with the HRFs for the different conditions concatenated. This is an
        estimate of the linear filters between the time-series and the events
        described in design.

    Notes
    -----

    Implements equation 4 in Burock(2000):

    .. math::

        \hat{h} = (X^T X)^{-1} X^T y

    M.A. Burock and A.M.Dale (2000). Estimation and Detection of Event-Related
    fMRI Signals with Temporally Correlated Noise: A Statistically Efficient
    and Unbiased Approach. Human Brain Mapping, 11:249-260

    """
    X = np.matrix(design)
    y = np.matrix(timeseries)
    h = np.array(linalg.pinv(X.T * X) * X.T * y.T)
    return h