Ejemplo n.º 1
0
def test_spm_hrf():

    # set the TR length ... this affects the HRF sampling rate ...
    tr_length = 1.0

    # compute the difference in area under curve for hrf_delays of -1 and 0
    diff_1 = np.abs(np.sum(utils.spm_hrf(-1, tr_length))-np.sum(utils.spm_hrf(0, tr_length)))

    # compute the difference in area under curver for hrf_delays of 0 and 1
    diff_2 = np.abs(np.sum(utils.spm_hrf(1, tr_length))-np.sum(utils.spm_hrf(0, tr_length)))

    npt.assert_almost_equal(diff_1, diff_2, 2)
Ejemplo n.º 2
0
def test_spm_hrf():

    # set the TR length ... this affects the HRF sampling rate ...
    tr_length = 1.0

    # compute the difference in area under curve for hrf_delays of -1 and 0
    diff_1 = np.abs(
        np.sum(utils.spm_hrf(-1, tr_length)) -
        np.sum(utils.spm_hrf(0, tr_length)))

    # compute the difference in area under curver for hrf_delays of 0 and 1
    diff_2 = np.abs(
        np.sum(utils.spm_hrf(1, tr_length)) -
        np.sum(utils.spm_hrf(0, tr_length)))

    npt.assert_almost_equal(diff_1, diff_2, 2)
Ejemplo n.º 3
0
    prf_dm = prf_dm.T  # then it'll be (x, y, t)

    # change DM to see if fit is better like that
    # do new one which is average of every 2 TRs

    prf_dm = shift_DM(prf_dm)

    prf_dm = prf_dm[:, :, analysis_params[
        'crop_pRF_TR']:]  # crop DM because functional data also cropped now

    # define model params
    fit_model = analysis_params["fit_model"]

    TR = analysis_params["TR"]

    hrf = utilities.spm_hrf(0, TR)

    # make stimulus object, which takes an input design matrix and sets up its real-world dimensions
    prf_stim = PRFStimulus2D(
        screen_size_cm=analysis_params["screen_width"],
        screen_distance_cm=analysis_params["screen_distance"],
        design_matrix=prf_dm,
        TR=TR)

    # sets up stimulus and hrf for this gridder
    gg = Iso2DGaussianGridder(
        stimulus=prf_stim,
        hrf=hrf,
        filter_predictions=False,
        window_length=analysis_params["sg_filt_window_length"],
        polyorder=analysis_params["sg_filt_polyorder"],
Ejemplo n.º 4
0
dms = []

for ix, row in df.iterrows():
    dm = create_visual_designmatrix_all(
        bar_width=0.125,
        iti_duration=0,
        thetas=[row.direction],
        n_pixels=n_pixels,
        nr_timepoints=row.bar_pass_duration
    )  # Note that we make a design matrix at level of seconds

    dms.append(dm)

dm = np.concatenate(dms, -1)

stimulus = VisualStimulus(dm, distance_screen, size_cm, 0.50, 1.0,
                          ctypes.c_int16)

hrf = utils.spm_hrf(0, 1.)
bold_dm = fftconvolve(stimulus.stim_arr, hrf[np.newaxis, np.newaxis, :],
                      'full')

bold_dm = np.moveaxis(bold_dm, -1, 0)[:total_duration]
bold_dm = resample(bold_dm, int(total_duration / TR), axis=0)

np.savetxt('/data/odc/derivatives/prf/dm.txt', dm.reshape(-1, n_pixels**2))
np.savetxt('/data/odc/derivatives/prf/bold_dm.txt',
           bold_dm.reshape(-1, n_pixels**2))

np.save('/data/odc/derivatives/prf/dm.npy', dm)