Ejemplo n.º 1
0
    def test_plot_cuboid_as_curve(self):
        from pyhrf.ndarray import xndarray

        sh = (10, 10, 5, 3)
        data = np.zeros(sh)
        data[:, :, :, 0] = 1.0
        data[:, :, :, 1] = 2.0
        data[:, :, :, 2] = 3.0
        c1 = xndarray(
            data,
            axes_names=["sagittal", "coronal", "axial", "condition"],
            axes_domains={"condition": ["audio1", "audio2", "video"]},
        )

        f = plt.figure()
        ax = f.add_subplot(111)

        ori = ["condition", "sagittal"]
        plot_cub_as_curve(
            c1.sub_cuboid(axial=0, coronal=0).reorient(ori),
            colors={"audio1": "red", "audio2": "orange", "video": "blue"},
            axes=ax,
        )
        if 0:
            plt.show()
Ejemplo n.º 2
0
    def test_plot_cuboid1d_as_curve(self):
        from pyhrf.ndarray import xndarray
        sh = (3,)
        conds = np.array(['audio1', 'audio2', 'video'])
        c2 = xndarray(np.arange(np.prod(sh)).reshape(sh),
                      axes_names=['condition'],
                      axes_domains={'condition': conds})

        f = plt.figure()
        ax = f.add_subplot(111)

        plot_cub_as_curve(c2, axes=ax, show_axis_labels=True)
Ejemplo n.º 3
0
    def test_plot_cuboid1d_as_curve(self):
        from pyhrf.ndarray import xndarray

        sh = (3,)
        conds = np.array(["audio1", "audio2", "video"])
        c2 = xndarray(np.arange(np.prod(sh)).reshape(sh), axes_names=["condition"], axes_domains={"condition": conds})

        f = plt.figure()
        ax = f.add_subplot(111)

        plot_cub_as_curve(c2, axes=ax, show_axis_labels=True)
        if 0:
            plt.show()
Ejemplo n.º 4
0
    def test_plot_cuboid_as_curve(self):
        from pyhrf.ndarray import xndarray
        sh = (10, 10, 5, 3)
        data = np.zeros(sh)
        data[:, :, :, 0] = 1.
        data[:, :, :, 1] = 2.
        data[:, :, :, 2] = 3.
        c1 = xndarray(data, axes_names=['sagittal', 'coronal', 'axial', 'condition'],
                      axes_domains={'condition': ['audio1', 'audio2', 'video']})

        f = plt.figure()
        ax = f.add_subplot(111)

        ori = ['condition', 'sagittal']
        plot_cub_as_curve(c1.sub_cuboid(axial=0, coronal=0).reorient(ori),
                          colors={'audio1': 'red', 'audio2': 'orange',
                                  'video': 'blue'}, axes=ax)
Ejemplo n.º 5
0
def plot_estimation_results(fig_dir, poi, jde_roi, cond, plot_label,
                            glm_fir_output_dir, rfir_output_dir,
                            jde_output_dir, ymin=-1.55, ymax=1.05,
                            plot_fontsize=25):


    ## HRF plots

    fn = op.join(glm_fir_output_dir, 'glm_fir_hrf.nii.gz')
    fir = xndarray.load(fn).sub_cuboid(condition=cond, **poi)
    #fir /= (fir**2).sum()**.5
    fir /= fir.max()

    fn = op.join(rfir_output_dir, 'rfir_ehrf.nii.gz')
    rfir = xndarray.load(fn).sub_cuboid(condition=cond, **poi)
    #rfir /= (rfir**2).sum()**.5
    rfir /= rfir.max()

    fn = op.join(jde_output_dir, 'jde_mcmc_hrf_pm.nii.gz')
    jde = xndarray.load(fn).sub_cuboid(ROI=jde_roi)
    jde /= jde.max()

    plt.figure()
    pargs = {'linewidth' : 2.7}
    plot_cub_as_curve(fir, show_axis_labels=False, plot_kwargs=pargs)
    plot_cub_as_curve(rfir, show_axis_labels=False, plot_kwargs=pargs)
    plot_cub_as_curve(jde, show_axis_labels=False, plot_kwargs=pargs)

    from pyhrf.boldsynth.hrf import getCanoHRF
    time_points, hcano = getCanoHRF()
    hcano /= hcano.max()
    plt.plot(time_points, hcano, 'k.-',linewidth=1.5)

    set_ticks_fontsize(plot_fontsize)
    plt.xlim(0,25)
    plt.ylim(ymin, ymax)

    plt.gca().xaxis.grid(True, 'major', linestyle='--', linewidth=1.2,
                         color='gray')

    hrf_fig_fn = op.join(fig_dir, 'real_data_hrfs_%s.png' %plot_label)
    print 'hrf_fig_fn:', hrf_fig_fn
    plt.savefig(hrf_fig_fn)
    autocrop(hrf_fig_fn)