def fir_design_matrix(events, len_hrf):
    event_types = np.unique(events)[np.unique(events) != 0]
    fir_matrix = np.zeros((events.shape[0], len_hrf * event_types.shape[0]))

    for t in event_types:
        idx_h_a = (np.array(np.where(event_types == t)[0]) * len_hrf)[0]
        idx_h_b = idx_h_a + len_hrf
        idx_v = np.where(events == t)[0]
        for idx_v_a in idx_v:
            idx_v_b = idx_v_a + len_hrf
            fir_matrix[idx_v_a:idx_v_b, idx_h_a:idx_h_b] += (np.eye(len_hrf) *
                                                             np.sign(t))

    return fir_matrix


#---------- MAR utilities ----------------------------------------

# These utilities are used in the computation of multivariate autoregressive
# models (used in computing Granger causality):
Returns a list of all the metadata types.
dataset/ETHPy150Open nipy/nitime/nitime/utils.py/fir_design_matrix--crossover with--dataset/ETHPy150Open mayan-edms/mayan-edms/mayan/apps/metadata/api_views.py/APIMetadataTypeListView.get