noise = rng.randn(design.shape[0])
        scale_factor = np.linalg.norm(ys) / np.linalg.norm(noise)
        ys_acquired = ys + noise * scale_factor * sigma_noise

        snr = 20 * (np.log10(np.linalg.norm(ys_acquired) / np.linalg.norm(ys - ys_acquired)))
        print 'SNR = ', snr, ' dB'


        # Estimation with 1 hrf. Uses glover as mean GP
        hrf_model = 'glover'
        hrf_0 = _get_hrf_model(hrf_model, hrf_length=hrf_length + dt,
                               dt=dt, normalize=True)
        f_hrf = interp1d(x_0, hrf_0)
        gp = SuperDuperGP(hrf_length=hrf_length, t_r=t_r, oversampling=1./dt, gamma=gamma,
                    modulation=modulation, fmin_max_iter=fmin_max_iter, sigma_noise=1.,
                    time_offset=time_offset, n_iter=n_iter, normalize_y=normalize_y, verbose=True,
                    optimize=optimize, n_restarts_optimizer=n_restarts_optimizer,
                    zeros_extremes=zeros_extremes, f_mean=f_hrf)
        (hx, hy, hrf_var,
         resid_norm_sq,
         sigma_sq_resid) = gp.fit(ys_acquired, paradigm)
        print 'residual norm square = ', resid_norm_sq

        hy *= np.sign(hy[np.argmax(np.abs(hy))]) / np.abs(hy).max()
        hrf_0 /= hrf_0.max()
        hrf_sim /= hrf_sim.max()

        # Plotting each HRF simulated vs estimated
        if len(range_peak)==5 or len(range_peak)==6:
            plt.subplot(2, 3, i + 1)
            plt.tight_layout()
        # GP parameters
        time_offset = 10
        gamma = 10.
        fmin_max_iter = 50
        n_restarts_optimizer = 10
        n_iter = 3
        normalize_y = False
        optimize = True
        zeros_extremes = True

        # Estimation
        gp = SuperDuperGP(hrf_length=hrf_length, t_r=t_r, oversampling=1./dt,
                          gamma=gamma, modulation=modulation,
                          fmin_max_iter=fmin_max_iter, sigma_noise=1.0,
                          time_offset=time_offset, n_iter=n_iter,
                          normalize_y=normalize_y, verbose=True,
                          optimize=optimize,
                          n_restarts_optimizer=n_restarts_optimizer,
                          zeros_extremes=zeros_extremes, f_mean=f_hrf)

        (hx, hy, hrf_var, resid_norm_sq, sigma_sq_resid) = gp.fit(ys, paradigm)

        print 'residual norm square = ', resid_norm_sq

        # Testing with a GLM
        mask_img = nb.Nifti1Image(np.ones((2, 2, 2)), affine=np.eye(4))
        masker = NiftiMasker(mask_img=mask_img)
        masker.fit()
        ys2 = np.ones((2, 2, 2, ys.shape[0])) * ys[np.newaxis, np.newaxis, np.newaxis, :]
        niimgs = nb.Nifti1Image(ys2, affine=np.eye(4))
        glm = FirstLevelGLM(mask=mask_img, t_r=t_r, standardize=True, noise_model='ols')