def run(self):
        self.create_dir_in_workspace('reports')

        frequency_plot_data = self.get_passed_object('frequency_plot')
        centralized_frequency_plot_data = self.get_passed_object('centralized_frequency_plot')
        frequency_region_plot_data = self.get_passed_object('frequency_region_plot')
        frequency_frequency_plot_data = self.get_passed_object('frequency_frequency_plot')

        panel_plot = PanelPlot(xfigsize=11, yfigsize=11, i_max=1, j_max=1, title='', ytitle=self.params.output_title, ytitle_fontsize=16, wspace=0.3, hspace=0.3)

        pdc = PlotDataCollection(legend_on=True)
        pdc.xlabel = 'Burst Frequency (Hz)'
        pdc.xlabel_fontsize = 16
        for v,p in frequency_plot_data.iteritems():
            p.xhline_pos=0.0
            pdc.add_plot_data(p)
        panel_plot.add_plot_data_collection(0, 0, plot_data_collection=pdc)

        plot = panel_plot.generate_plot()

        plot_out_fname = self.get_path_to_resource_in_workspace('reports/ps3_frequency_aggregate_plots.pdf')

        plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

        panel_plot = PanelPlot(xfigsize=15, yfigsize=7.5, i_max=1, j_max=2, title='', ytitle=self.params.output_title, wspace=0.3, hspace=0.3)
        panel_plot.add_plot_data(0, 0, plot_data=frequency_region_plot_data)
        panel_plot.add_plot_data(0, 1, plot_data=frequency_frequency_plot_data)
        plot = panel_plot.generate_plot()
        plot_out_fname = self.get_path_to_resource_in_workspace('reports/ps3_frequency_projection_plots.pdf')
        plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')
    def run(self):
        subject = self.pipeline.subject
        task = self.pipeline.task

        self.create_dir_in_workspace('reports')

        session_summary_array = self.get_passed_object('session_summary_array')

        serial_positions = np.arange(1,13)

        for session_summary in session_summary_array:
            panel_plot = PanelPlot(xfigsize=15, yfigsize=7.5, i_max=1, j_max=2, title='', wspace=0.3, hspace=0.3)

            pd1 = PlotData(x=serial_positions, y=session_summary.prob_recall, xlim=(0,12), ylim=(0.0, 1.0), xlabel='Serial position\n(a)', ylabel='Probability of recall')
            pd2 = PlotData(x=serial_positions, y=session_summary.prob_first_recall, xlim=(0,12), ylim=(0.0, 1.0), xlabel='Serial position\n(b)', ylabel='Probability of first recall')

            panel_plot.add_plot_data(0, 0, plot_data=pd1)
            panel_plot.add_plot_data(0, 1, plot_data=pd2)

            plot = panel_plot.generate_plot()

            plot_out_fname = self.get_path_to_resource_in_workspace('reports/' + task + '-' + subject + '-prob_recall_plot_' + session_summary.name + '.pdf')

            plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

            if task == 'RAM_CatFR1':
                panel_plot = PanelPlot(xfigsize=6.0, yfigsize=6.0, i_max=1, j_max=1, title='', wspace=0.3, hspace=0.3)
                pd = BarPlotData(x=[0,1], y=[session_summary.irt_within_cat,  session_summary.irt_between_cat], ylabel='IRT (msec)', x_tick_labels=['Within Cat', 'Between Cat'], barcolors=['grey','grey'], barwidth=0.5)
                panel_plot.add_plot_data(0, 0, plot_data=pd)
                plot = panel_plot.generate_plot()
                plot_out_fname = self.get_path_to_resource_in_workspace('reports/' + task + '-' + subject + '-irt_plot_' + session_summary.name + '.pdf')
                plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

            panel_plot = PanelPlot(xfigsize=10.0, yfigsize=10.0, i_max=1, j_max=1, title='', xlabel='List', ylabel='# of items')

            pdc = PlotDataCollection()

            n_lists = len(session_summary.n_stims_per_list)

            print 'Number of lists', n_lists

            bpd_1 = BarPlotData(x=np.arange(n_lists), y=session_summary.n_stims_per_list, title='', alpha=0.1)
            pd_1 = PlotData(x=np.where(session_summary.is_stim_list)[0], y=session_summary.n_recalls_per_list[session_summary.is_stim_list],
                    title='', linestyle='', color='red', marker='o')
            pd_2 = PlotData(x=np.where(~session_summary.is_stim_list)[0], y=session_summary.n_recalls_per_list[~session_summary.is_stim_list],
                    title='', linestyle='', color='blue', marker='o')

            pdc.add_plot_data(pd_1)
            pdc.add_plot_data(pd_2)
            pdc.add_plot_data(bpd_1)

            panel_plot.add_plot_data_collection(0, 0, plot_data_collection=pdc)

            plot = panel_plot.generate_plot()

            plot_out_fname = self.get_path_to_resource_in_workspace('reports/' + task + '-' + subject + '-stim_and_recall_plot_' + session_summary.name + '.pdf')

            plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

        cumulative_summary = self.get_passed_object('cumulative_summary')

        panel_plot = PanelPlot(xfigsize=15, yfigsize=7.5, i_max=1, j_max=2, title='', wspace=0.3, hspace=0.3)

        pd1 = PlotData(x=serial_positions, y=cumulative_summary.prob_recall, xlim=(0, 12), ylim=(0.0, 1.0), xlabel='Serial position\n(a)', ylabel='Probability of recall')
        pd2 = PlotData(x=serial_positions, y=cumulative_summary.prob_first_recall, xlim=(0, 12), ylim=(0.0, 1.0), xlabel='Serial position\n(b)', ylabel='Probability of first recall')

        panel_plot.add_plot_data(0, 0, plot_data=pd1)
        panel_plot.add_plot_data(0, 1, plot_data=pd2)

        plot = panel_plot.generate_plot()

        plot_out_fname = self.get_path_to_resource_in_workspace('reports/' + task + '-' + subject + '-prob_recall_plot_combined.pdf')

        plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

        if task == 'RAM_CatFR1':
            panel_plot = PanelPlot(xfigsize=6.0, yfigsize=6.0, i_max=1, j_max=1, title='', wspace=0.3, hspace=0.3)
            pd = BarPlotData(x=[0,1], y=[cumulative_summary.irt_within_cat, cumulative_summary.irt_between_cat], ylabel='IRT (msec)', x_tick_labels=['Within Cat', 'Between Cat'], barcolors=['grey','grey'], barwidth=0.5)
            panel_plot.add_plot_data(0, 0, plot_data=pd)
            plot = panel_plot.generate_plot()
            plot_out_fname = self.get_path_to_resource_in_workspace('reports/' + task + '-' + subject + '-irt_plot_combined.pdf')
            plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')
    def run(self):
        subject = self.pipeline.subject
        task = self.pipeline.task

        self.create_dir_in_workspace("reports")

        session_summary_array = self.get_passed_object("session_summary_array")

        serial_positions = np.arange(1, 13)

        for session_summary in session_summary_array:
            panel_plot = PanelPlot(xfigsize=15, yfigsize=7.5, i_max=1, j_max=2, title="", wspace=0.3, hspace=0.3)

            pd1 = PlotData(
                x=serial_positions,
                y=session_summary.prob_recall,
                xlim=(0, 12),
                ylim=(0.0, 1.0),
                xlabel="Serial position\n(a)",
                ylabel="Probability of recall",
            )
            pd2 = PlotData(
                x=serial_positions,
                y=session_summary.prob_first_recall,
                xlim=(0, 12),
                ylim=(0.0, 1.0),
                xlabel="Serial position\n(b)",
                ylabel="Probability of first recall",
            )

            panel_plot.add_plot_data(0, 0, plot_data=pd1)
            panel_plot.add_plot_data(0, 1, plot_data=pd2)

            plot = panel_plot.generate_plot()

            plot_out_fname = self.get_path_to_resource_in_workspace(
                "reports/" + task + "-" + subject + "-prob_recall_plot_" + session_summary.name + ".pdf"
            )

            plot.savefig(plot_out_fname, dpi=300, bboxinches="tight")

            if task == "RAM_CatFR1":
                panel_plot = PanelPlot(xfigsize=6.0, yfigsize=6.0, i_max=1, j_max=1, title="", wspace=0.3, hspace=0.3)
                pd = BarPlotData(
                    x=[0, 1],
                    y=[session_summary.irt_within_cat, session_summary.irt_between_cat],
                    ylabel="IRT (msec)",
                    x_tick_labels=["Within Cat", "Between Cat"],
                    barcolors=["grey", "grey"],
                    barwidth=0.5,
                )
                panel_plot.add_plot_data(0, 0, plot_data=pd)
                plot = panel_plot.generate_plot()
                plot_out_fname = self.get_path_to_resource_in_workspace(
                    "reports/" + task + "-" + subject + "-irt_plot_" + session_summary.name + ".pdf"
                )
                plot.savefig(plot_out_fname, dpi=300, bboxinches="tight")

            panel_plot = PanelPlot(xfigsize=15, yfigsize=7.5, i_max=1, j_max=2, title="", wspace=0.3, hspace=0.3)

            pd1 = PlotData(
                x=session_summary.fpr,
                y=session_summary.tpr,
                xlim=[0.0, 1.0],
                ylim=[0.0, 1.0],
                xlabel="False Alarm Rate\n(a)",
                ylabel="Hit Rate",
                levelline=((0.0, 1.0), (0.0, 1.0)),
            )

            ylim = np.max(np.abs(session_summary.pc_diff_from_mean)) + 5.0
            if ylim > 100.0:
                ylim = 100.0
            pd2 = BarPlotData(
                x=(0, 1, 2),
                y=session_summary.pc_diff_from_mean,
                ylim=[-ylim, ylim],
                xlabel="Tercile of Classifier Estimate\n(b)",
                ylabel="Recall Change From Mean (%)",
                x_tick_labels=["Low", "Middle", "High"],
                xhline_pos=0.0,
                barcolors=["grey", "grey", "grey"],
                barwidth=0.5,
            )

            panel_plot.add_plot_data(0, 0, plot_data=pd1)
            panel_plot.add_plot_data(0, 1, plot_data=pd2)

            plot = panel_plot.generate_plot()

            plot_out_fname = self.get_path_to_resource_in_workspace(
                "reports/" + task + "-" + subject + "-roc_and_terc_plot_" + session_summary.name + ".pdf"
            )

            plot.savefig(plot_out_fname, dpi=300, bboxinches="tight")

        cumulative_summary = self.get_passed_object("cumulative_summary")

        panel_plot = PanelPlot(xfigsize=15, yfigsize=7.5, i_max=1, j_max=2, title="", wspace=0.3, hspace=0.3)

        pd1 = PlotData(
            x=serial_positions,
            y=cumulative_summary.prob_recall,
            xlim=(0, 12),
            ylim=(0.0, 1.0),
            xlabel="Serial position\n(a)",
            ylabel="Probability of recall",
        )
        pd2 = PlotData(
            x=serial_positions,
            y=cumulative_summary.prob_first_recall,
            xlim=(0, 12),
            ylim=(0.0, 1.0),
            xlabel="Serial position\n(b)",
            ylabel="Probability of first recall",
        )

        panel_plot.add_plot_data(0, 0, plot_data=pd1)
        panel_plot.add_plot_data(0, 1, plot_data=pd2)

        plot = panel_plot.generate_plot()

        plot_out_fname = self.get_path_to_resource_in_workspace(
            "reports/" + task + "-" + subject + "-prob_recall_plot_combined.pdf"
        )

        plot.savefig(plot_out_fname, dpi=300, bboxinches="tight")

        if task == "RAM_CatFR1":
            panel_plot = PanelPlot(xfigsize=6.0, yfigsize=6.0, i_max=1, j_max=1, title="", wspace=0.3, hspace=0.3)
            pd = BarPlotData(
                x=[0, 1],
                y=[cumulative_summary.irt_within_cat, cumulative_summary.irt_between_cat],
                ylabel="IRT (msec)",
                x_tick_labels=["Within Cat", "Between Cat"],
                barcolors=["grey", "grey"],
                barwidth=0.5,
            )
            panel_plot.add_plot_data(0, 0, plot_data=pd)
            plot = panel_plot.generate_plot()
            plot_out_fname = self.get_path_to_resource_in_workspace(
                "reports/" + task + "-" + subject + "-irt_plot_combined.pdf"
            )
            plot.savefig(plot_out_fname, dpi=300, bboxinches="tight")

        panel_plot = PanelPlot(xfigsize=15, yfigsize=7.5, i_max=1, j_max=2, title="", wspace=0.3, hspace=0.3)

        pd1 = PlotData(
            x=cumulative_summary.fpr,
            y=cumulative_summary.tpr,
            xlim=[0.0, 1.0],
            ylim=[0.0, 1.0],
            xlabel="False Alarm Rate\n(a)",
            ylabel="Hit Rate",
            levelline=((0.001, 0.999), (0.001, 0.999)),
        )

        ylim = np.max(np.abs(cumulative_summary.pc_diff_from_mean)) + 5.0
        if ylim > 100.0:
            ylim = 100.0
        pd2 = BarPlotData(
            x=(0, 1, 2),
            y=cumulative_summary.pc_diff_from_mean,
            ylim=[-ylim, ylim],
            xlabel="Tercile of Classifier Estimate\n(b)",
            ylabel="Recall Change From Mean (%)",
            x_tick_labels=["Low", "Middle", "High"],
            xhline_pos=0.0,
            barcolors=["grey", "grey", "grey"],
            barwidth=0.5,
        )

        panel_plot.add_plot_data(0, 0, plot_data=pd1)
        panel_plot.add_plot_data(0, 1, plot_data=pd2)

        plot = panel_plot.generate_plot()

        plot_out_fname = self.get_path_to_resource_in_workspace(
            "reports/" + task + "-" + subject + "-roc_and_terc_plot_combined.pdf"
        )

        plot.savefig(plot_out_fname, dpi=300, bboxinches="tight")
    def run(self):
        #experiment = self.pipeline.experiment

        self.create_dir_in_workspace('reports')

        xval_output = self.get_passed_object('xval_output')
        fr1_summary = xval_output[-1]

        panel_plot = PanelPlot(xfigsize=15, yfigsize=7.5, i_max=1, j_max=2, title='', wspace=0.3, hspace=0.3)

        pd1 = PlotData(x=fr1_summary.fpr, y=fr1_summary.tpr, xlim=[0.0,1.0], ylim=[0.0,1.0], xlabel='False Alarm Rate\n(a)', ylabel='Hit Rate', levelline=((0.0,1.0),(0.0,1.0)))

        pc_diff_from_mean = (fr1_summary.low_pc_diff_from_mean, fr1_summary.mid_pc_diff_from_mean, fr1_summary.high_pc_diff_from_mean)

        ylim = np.max(np.abs(pc_diff_from_mean)) + 5.0
        if ylim > 100.0:
            ylim = 100.0
        # pd2 = BarPlotData(x=(0,1,2), y=pc_diff_from_mean, ylim=[-ylim,ylim], xlabel='Tercile of Classifier Estimate\n(b)', ylabel='Recall Change From Mean (%)', x_tick_labels=['Low', 'Middle', 'High'], xhline_pos=0.0, barcolors=['grey','grey', 'grey'], barwidth=0.5)
        pd2 = BarPlotData(x=(0,1,2), y=pc_diff_from_mean, ylim=[-ylim,ylim], xlabel='Tercile of Classifier Estimate\n(b)', ylabel='Recall Change From Mean (%)', x_tick_labels=['Low', 'Middle', 'High'], xhline_pos=0.0, barcolors=['grey','grey', 'grey'], barwidth=0.5)

        panel_plot.add_plot_data(0, 0, plot_data=pd1)
        panel_plot.add_plot_data(0, 1, plot_data=pd2)

        plot = panel_plot.generate_plot()

        plot_out_fname = self.get_path_to_resource_in_workspace('reports/' + self.pipeline.subject + '-roc_and_terc_plot_combined.pdf')

        plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

        session_summary_array = self.get_passed_object('session_summary_array')
        param1_name = self.get_passed_object('param1_name')
        param1_unit = self.get_passed_object('param1_unit')
        param1_title = '%s (%s)' % (param1_name,param1_unit)


        for session_summary in session_summary_array:
            # panel_plot = PanelPlot(i_max=1, j_max=1, title='', xtitle=param1_title, xtitle_fontsize=24, ytitle='$\Delta$ Post-Pre Classifier Output',ytitle_fontsize=24, wspace=0.3, hspace=0.3)

            panel_plot = PanelPlot(i_max=1, j_max=1, title='', ytitle='$\Delta$ Post-Pre Classifier Output',ytitle_fontsize=24, wspace=0.3, hspace=0.3)

            pdc = PlotDataCollection(legend_on=True)
            pdc.xlabel = param1_title
            pdc.xlabel_fontsize = 24

            for v,p in session_summary.plots.iteritems():
                p.xhline_pos=0.0
                pdc.add_plot_data(p)


            panel_plot.add_plot_data_collection(0, 0, plot_data_collection=pdc)

            plot = panel_plot.generate_plot()

            plot_out_fname = self.get_path_to_resource_in_workspace('reports/' + self.pipeline.experiment + '-' + self.pipeline.subject + '-report_plot_' + session_summary.name + '.pdf')

            plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

        cumulative_plots = self.get_passed_object('cumulative_plots')



        # panel_plot = PanelPlot(i_max=1, j_max=1, title='', xtitle=param1_title, y_axis_title='$\Delta$ Post-Pre Classifier Output')
        panel_plot = PanelPlot(i_max=1, j_max=1, title='',ytitle='$\Delta$ Post-Pre Classifier Output', ytitle_fontsize=24)

        pdc = PlotDataCollection(legend_on=True)
        pdc.xlabel = param1_title
        pdc.xlabel_fontsize = 24

        for v,p in cumulative_plots.iteritems():
            p.xhline_pos=0.0
            pdc.add_plot_data(p)

        panel_plot.add_plot_data_collection(0, 0, plot_data_collection=pdc)

        plot = panel_plot.generate_plot()

        plot_out_fname = self.get_path_to_resource_in_workspace('reports/' + self.pipeline.experiment + '-' + self.pipeline.subject + '-report_plot_Cumulative.pdf')

        plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')
    def run(self):
        experiment = self.pipeline.experiment

        self.create_dir_in_workspace('reports')

        session_summary_array = self.get_passed_object('session_summary_array')

        from PlotUtils import PanelPlot
        for session_summary in session_summary_array:
            panel_plot = PanelPlot(i_max=3, j_max=2, title='',xtitle='', ytitle='$\Delta$ Post-Pre Classifier Output', wspace=0.3,hspace=0.3)



            for plot_panel_index, pd in session_summary.plot_data_dict.iteritems():
                plot_letter = chr(ord('a') + 2 * plot_panel_index[0] + plot_panel_index[1])
                pd.xlabel = '(' + plot_letter + ')\n'
                if plot_panel_index[0]==2 and plot_panel_index[1]==0:
                    pd.xlabel += 'Pulse Frequency (Hz)'

                if plot_panel_index[0]==2 and plot_panel_index[1]==1:
                    pd.xlabel += 'Duration (ms)' if experiment=='PS1' else 'Amplitude (mA)' if experiment=='PS2' else 'Burst Frequency (Hz)'

                if plot_panel_index[1]==0:
                    pd.ylabel = '$\Delta$ Post-Pre Classifier Output'

                pd.xhline_pos=0.0
                panel_plot.add_plot_data(plot_panel_index[0], plot_panel_index[1],plot_data=pd)

                # panel_plot.add_plot_data(plot_panel_index[0], plot_panel_index[1], x=pd.x, y=pd.y, yerr=pd.yerr,
                #                          x_tick_labels=pd.x_tick_labels, title='(' + plot_letter + ')', ylim=pd.ylim)

            plot = panel_plot.generate_plot()
            # plot.subplots_adjust(wspace=0.3, hspace=0.3)
            # plt.savefig(join(plotsDir, quantity_name+'.png'), dpi=300,bboxinches='tight')

            plot_out_fname = self.get_path_to_resource_in_workspace('reports/' + self.pipeline.experiment + '-' + self.pipeline.subject + '-report_plot_' + session_summary.name + '.pdf')

            plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

        cumulative_plot_data_dict = self.get_passed_object('cumulative_plot_data_dict')

        panel_plot = PanelPlot(i_max=3, j_max=2, title='', y_axis_title='$\Delta$ Post-Pre Classifier Output')

        for plot_panel_index, pd in cumulative_plot_data_dict.iteritems():
            # print 'plot_panel_index=', plot_panel_index
            # print 'pd.x=', pd.x
            # print 'pd.y=', pd.y
            plot_letter = chr(ord('a') + 2 * plot_panel_index[0] + plot_panel_index[1])
            pd.xlabel = '(' + plot_letter + ')\n'
            if plot_panel_index[0]==2 and plot_panel_index[1]==0:
                pd.xlabel += 'Pulse Frequency (Hz)'

            if plot_panel_index[0]==2 and plot_panel_index[1]==1:
                pd.xlabel += 'Duration (ms)' if experiment=='PS1' else 'Amplitude (mA)' if experiment=='PS2' else 'Burst Frequency (Hz)'

            if plot_panel_index[1]==0:
                pd.ylabel = '$\Delta$ Post-Pre Classifier Output'

            pd.xhline_pos=0.0

            panel_plot.add_plot_data(plot_panel_index[0], plot_panel_index[1], plot_data=pd)

            # panel_plot.add_plot_data(plot_panel_index[0], plot_panel_index[1], x=pd.x, y=pd.y, yerr=pd.yerr,
            #                          x_tick_labels=pd.x_tick_labels, title='(' + plot_letter + ')', ylim=pd.ylim)

        plot = panel_plot.generate_plot()
        plot.subplots_adjust(wspace=0.3, hspace=0.3)
        # plt.savefig(join(plotsDir, quantity_name+'.png'), dpi=300,bboxinches='tight')

        plot_out_fname = self.get_path_to_resource_in_workspace('reports/' + self.pipeline.experiment + '-' + self.pipeline.subject + '-report_plot_Cumulative.pdf')

        plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')
Beispiel #6
0
    def run(self):
        subject = self.pipeline.subject
        task = self.pipeline.task

        self.create_dir_in_workspace('reports')

        session_summary_array = self.get_passed_object('session_summary_array')

        serial_positions = np.arange(1, 13)

        for session_summary in session_summary_array:
            panel_plot = PanelPlot(xfigsize=15,
                                   yfigsize=7.5,
                                   i_max=1,
                                   j_max=2,
                                   title='',
                                   wspace=0.3,
                                   hspace=0.3)

            pd1 = PlotData(x=serial_positions,
                           y=session_summary.prob_recall,
                           xlim=(0, 12),
                           ylim=(0.0, 1.0),
                           xlabel='Serial position\n(a)',
                           ylabel='Probability of recall')
            pd2 = PlotData(x=serial_positions,
                           y=session_summary.prob_first_recall,
                           xlim=(0, 12),
                           ylim=(0.0, 1.0),
                           xlabel='Serial position\n(b)',
                           ylabel='Probability of first recall')

            panel_plot.add_plot_data(0, 0, plot_data=pd1)
            panel_plot.add_plot_data(0, 1, plot_data=pd2)

            plot = panel_plot.generate_plot()

            plot_out_fname = self.get_path_to_resource_in_workspace(
                'reports/' + task + '-' + subject + '-prob_recall_plot_' +
                session_summary.name + '.pdf')

            plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

            if task == 'RAM_CatFR1':
                panel_plot = PanelPlot(xfigsize=6.0,
                                       yfigsize=6.0,
                                       i_max=1,
                                       j_max=1,
                                       title='',
                                       xtitle='',
                                       wspace=0.3,
                                       hspace=0.3)
                pd = BarPlotData(x=[0, 1],
                                 y=[
                                     session_summary.irt_within_cat,
                                     session_summary.irt_between_cat
                                 ],
                                 ylabel='IRT (msec)',
                                 xlabel='',
                                 x_tick_labels=['Within Cat', 'Between Cat'],
                                 barcolors=['grey', 'grey'],
                                 barwidth=0.5)
                panel_plot.add_plot_data(0, 0, plot_data=pd)
                plot = panel_plot.generate_plot()
                plot_out_fname = self.get_path_to_resource_in_workspace(
                    'reports/' + task + '-' + subject + '-irt_plot_' +
                    session_summary.name + '.pdf')
                plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

            panel_plot = PanelPlot(xfigsize=15,
                                   yfigsize=7.5,
                                   i_max=1,
                                   j_max=2,
                                   title='',
                                   wspace=0.3,
                                   hspace=0.3)

            pd1 = PlotData(x=session_summary.fpr,
                           y=session_summary.tpr,
                           xlim=[0.0, 1.0],
                           ylim=[0.0, 1.0],
                           xlabel='False Alarm Rate\n(a)',
                           ylabel='Hit Rate',
                           levelline=((0.0, 1.0), (0.0, 1.0)))

            ylim = np.max(np.abs(session_summary.pc_diff_from_mean)) + 5.0
            if ylim > 100.0:
                ylim = 100.0
            pd2 = BarPlotData(x=(0, 1, 2),
                              y=session_summary.pc_diff_from_mean,
                              ylim=[-ylim, ylim],
                              xlabel='Tercile of Classifier Estimate\n(b)',
                              ylabel='Recall Change From Mean (%)',
                              x_tick_labels=['Low', 'Middle', 'High'],
                              xhline_pos=0.0,
                              barcolors=['grey', 'grey', 'grey'],
                              barwidth=0.5)

            panel_plot.add_plot_data(0, 0, plot_data=pd1)
            panel_plot.add_plot_data(0, 1, plot_data=pd2)

            plot = panel_plot.generate_plot()

            plot_out_fname = self.get_path_to_resource_in_workspace(
                'reports/' + task + '-' + subject + '-roc_and_terc_plot_' +
                session_summary.name + '.pdf')

            plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

        cumulative_summary = self.get_passed_object('cumulative_summary')

        panel_plot = PanelPlot(xfigsize=15,
                               yfigsize=7.5,
                               i_max=1,
                               j_max=2,
                               title='',
                               wspace=0.3,
                               hspace=0.3)

        pd1 = PlotData(x=serial_positions,
                       y=cumulative_summary.prob_recall,
                       xlim=(0, 12),
                       ylim=(0.0, 1.0),
                       xlabel='Serial position\n(a)',
                       ylabel='Probability of recall')
        pd2 = PlotData(x=serial_positions,
                       y=cumulative_summary.prob_first_recall,
                       xlim=(0, 12),
                       ylim=(0.0, 1.0),
                       xlabel='Serial position\n(b)',
                       ylabel='Probability of first recall')

        panel_plot.add_plot_data(0, 0, plot_data=pd1)
        panel_plot.add_plot_data(0, 1, plot_data=pd2)

        plot = panel_plot.generate_plot()

        plot_out_fname = self.get_path_to_resource_in_workspace(
            'reports/' + task + '-' + subject +
            '-prob_recall_plot_combined.pdf')

        plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

        if task == 'RAM_CatFR1':
            panel_plot = PanelPlot(xfigsize=6.0,
                                   yfigsize=6.0,
                                   i_max=1,
                                   j_max=1,
                                   title='',
                                   xtitle='',
                                   wspace=0.3,
                                   hspace=0.3)
            pd = BarPlotData(x=[0, 1],
                             y=[
                                 cumulative_summary.irt_within_cat,
                                 cumulative_summary.irt_between_cat
                             ],
                             ylabel='IRT (msec)',
                             xlabel='',
                             x_tick_labels=['Within Cat', 'Between Cat'],
                             barcolors=['grey', 'grey'],
                             barwidth=0.5)
            panel_plot.add_plot_data(0, 0, plot_data=pd)
            plot = panel_plot.generate_plot()
            plot_out_fname = self.get_path_to_resource_in_workspace(
                'reports/' + task + '-' + subject + '-irt_plot_combined.pdf')
            plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

        panel_plot = PanelPlot(xfigsize=15,
                               yfigsize=7.5,
                               i_max=1,
                               j_max=2,
                               title='',
                               wspace=0.3,
                               hspace=0.3)

        pd1 = PlotData(x=cumulative_summary.fpr,
                       y=cumulative_summary.tpr,
                       xlim=[0.0, 1.0],
                       ylim=[0.0, 1.0],
                       xlabel='False Alarm Rate\n(a)',
                       ylabel='Hit Rate',
                       levelline=((0.001, 0.999), (0.001, 0.999)))

        ylim = np.max(np.abs(cumulative_summary.pc_diff_from_mean)) + 5.0
        if ylim > 100.0:
            ylim = 100.0
        pd2 = BarPlotData(x=(0, 1, 2),
                          y=cumulative_summary.pc_diff_from_mean,
                          ylim=[-ylim, ylim],
                          xlabel='Tercile of Classifier Estimate\n(b)',
                          ylabel='Recall Change From Mean (%)',
                          x_tick_labels=['Low', 'Middle', 'High'],
                          xhline_pos=0.0,
                          barcolors=['grey', 'grey', 'grey'],
                          barwidth=0.5)

        panel_plot.add_plot_data(0, 0, plot_data=pd1)
        panel_plot.add_plot_data(0, 1, plot_data=pd2)

        plot = panel_plot.generate_plot()

        plot_out_fname = self.get_path_to_resource_in_workspace(
            'reports/' + task + '-' + subject +
            '-roc_and_terc_plot_combined.pdf')

        plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')
    def run(self):
        subject = self.pipeline.subject
        task = self.pipeline.task

        self.create_dir_in_workspace("reports")

        session_summary_array = self.get_passed_object("session_summary_array")

        serial_positions = np.arange(1, 13)

        for session_summary in session_summary_array:
            panel_plot = PanelPlot(
                xfigsize=15, yfigsize=7.5, i_max=1, j_max=2, title="", wspace=0.3, hspace=0.3, labelsize=20
            )

            pd1 = PlotData(
                x=serial_positions,
                y=session_summary.prob_recall,
                xlim=(0, 12),
                ylim=(0.0, 1.0),
                xlabel="Serial position\n(a)",
                ylabel="Probability of recall",
            )
            pd1.xlabel_fontsize = 20
            pd1.ylabel_fontsize = 20
            pd2 = PlotData(
                x=serial_positions,
                y=session_summary.prob_first_recall,
                xlim=(0, 12),
                ylim=(0.0, 1.0),
                xlabel="Serial position\n(b)",
                ylabel="Probability of first recall",
            )
            pd2.xlabel_fontsize = 20
            pd2.ylabel_fontsize = 20

            # panel_plot.add_plot_data(0, 0, plot_data=pd1)
            # panel_plot.add_plot_data(0, 1, plot_data=pd2)
            #
            # plot = panel_plot.generate_plot()

            panel_plot.add_plot_data(0, 0, plot_data=pd1)

            panel_plot.add_plot_data(0, 1, plot_data=pd2)

            plot = panel_plot.generate_plot()

            plot_out_fname = self.get_path_to_resource_in_workspace(
                "reports/" + task + "-" + subject + "-prob_recall_plot_" + session_summary.name + ".pdf"
            )

            plot.savefig(plot_out_fname, dpi=300, bboxinches="tight")

            if task == "RAM_CatFR1":
                panel_plot = PanelPlot(xfigsize=6.0, yfigsize=6.0, i_max=1, j_max=1, title="", wspace=0.3, hspace=0.3)
                pd = BarPlotData(
                    x=[0, 1],
                    y=[session_summary.irt_within_cat, session_summary.irt_between_cat],
                    ylabel="IRT (msec)",
                    x_tick_labels=["Within Cat", "Between Cat"],
                    barcolors=["grey", "grey"],
                    barwidth=0.5,
                )
                panel_plot.add_plot_data(0, 0, plot_data=pd)
                plot = panel_plot.generate_plot()
                plot_out_fname = self.get_path_to_resource_in_workspace(
                    "reports/" + task + "-" + subject + "-irt_plot_" + session_summary.name + ".pdf"
                )
                plot.savefig(plot_out_fname, dpi=300, bboxinches="tight")

            panel_plot = PanelPlot(
                xfigsize=10.0,
                yfigsize=10.0,
                i_max=1,
                j_max=1,
                title="",
                xlabel="List",
                ylabel="# of items",
                labelsize=20,
            )

            pdc = PlotDataCollection()
            # ----------------- FORMATTING
            pdc.xlabel = "List number"
            pdc.xlabel_fontsize = 20
            pdc.ylabel = "# recalled words"
            pdc.ylabel_fontsize = 20

            n_lists = len(session_summary.n_stims_per_list)

            print "Number of lists", n_lists

            bpd_1 = BarPlotData(x=np.arange(n_lists), y=session_summary.n_stims_per_list, title="", alpha=0.1)
            pd_1 = PlotData(
                x=np.where(session_summary.is_stim_list)[0],
                y=session_summary.n_recalls_per_list[session_summary.is_stim_list],
                title="",
                linestyle="",
                color="red",
                marker="o",
                markersize=20,
            )
            pd_2 = PlotData(
                x=np.where(~session_summary.is_stim_list)[0],
                y=session_summary.n_recalls_per_list[~session_summary.is_stim_list],
                title="",
                linestyle="",
                color="blue",
                marker="o",
                markersize=20,
            )
            print "np.where(session_summary.is_stim_list)[0]=", np.where(session_summary.is_stim_list)[0]
            print "np.where(~session_summary.is_stim_list)[0]=", np.where(~session_summary.is_stim_list)[0]
            pdc.add_plot_data(pd_1)
            pdc.add_plot_data(pd_2)
            pdc.add_plot_data(bpd_1)

            panel_plot.add_plot_data_collection(0, 0, plot_data_collection=pdc)

            plot = panel_plot.generate_plot()

            plot_out_fname = self.get_path_to_resource_in_workspace(
                "reports/" + task + "-" + subject + "-stim_and_recall_plot_" + session_summary.name + ".pdf"
            )

            plot.savefig(plot_out_fname, dpi=300, bboxinches="tight")

        cumulative_summary = self.get_passed_object("cumulative_summary")

        panel_plot = PanelPlot(xfigsize=15, yfigsize=7.5, i_max=1, j_max=2, title="", wspace=0.3, hspace=0.3)

        pd1 = PlotData(
            x=serial_positions,
            y=cumulative_summary.prob_recall,
            xlim=(0, 12),
            ylim=(0.0, 1.0),
            xlabel="Serial position\n(a)",
            ylabel="Probability of recall",
        )
        pd2 = PlotData(
            x=serial_positions,
            y=cumulative_summary.prob_first_recall,
            xlim=(0, 12),
            ylim=(0.0, 1.0),
            xlabel="Serial position\n(b)",
            ylabel="Probability of first recall",
        )

        panel_plot.add_plot_data(0, 0, plot_data=pd1)
        panel_plot.add_plot_data(0, 1, plot_data=pd2)

        plot = panel_plot.generate_plot()

        plot_out_fname = self.get_path_to_resource_in_workspace(
            "reports/" + task + "-" + subject + "-prob_recall_plot_combined.pdf"
        )

        plot.savefig(plot_out_fname, dpi=300, bboxinches="tight")

        if task == "RAM_CatFR1":
            panel_plot = PanelPlot(xfigsize=6.0, yfigsize=6.0, i_max=1, j_max=1, title="", wspace=0.3, hspace=0.3)
            pd = BarPlotData(
                x=[0, 1],
                y=[cumulative_summary.irt_within_cat, cumulative_summary.irt_between_cat],
                ylabel="IRT (msec)",
                x_tick_labels=["Within Cat", "Between Cat"],
                barcolors=["grey", "grey"],
                barwidth=0.5,
            )
            panel_plot.add_plot_data(0, 0, plot_data=pd)
            plot = panel_plot.generate_plot()
            plot_out_fname = self.get_path_to_resource_in_workspace(
                "reports/" + task + "-" + subject + "-irt_plot_combined.pdf"
            )
            plot.savefig(plot_out_fname, dpi=300, bboxinches="tight")
Beispiel #8
0
    def run(self):
        #experiment = self.pipeline.experiment

        self.create_dir_in_workspace('reports')

        xval_output = self.get_passed_object('xval_output')
        fr1_summary = xval_output[-1]

        panel_plot = PanelPlot(xfigsize=15,
                               yfigsize=7.5,
                               i_max=1,
                               j_max=2,
                               title='',
                               wspace=0.3,
                               hspace=0.3)

        pd1 = PlotData(x=fr1_summary.fpr,
                       y=fr1_summary.tpr,
                       xlim=[0.0, 1.0],
                       ylim=[0.0, 1.0],
                       xlabel='False Alarm Rate\n(a)',
                       ylabel='Hit Rate',
                       levelline=((0.0, 1.0), (0.0, 1.0)))

        pc_diff_from_mean = (fr1_summary.low_pc_diff_from_mean,
                             fr1_summary.mid_pc_diff_from_mean,
                             fr1_summary.high_pc_diff_from_mean)

        ylim = np.max(np.abs(pc_diff_from_mean)) + 5.0
        if ylim > 100.0:
            ylim = 100.0
        # pd2 = BarPlotData(x=(0,1,2), y=pc_diff_from_mean, ylim=[-ylim,ylim], xlabel='Tercile of Classifier Estimate\n(b)', ylabel='Recall Change From Mean (%)', x_tick_labels=['Low', 'Middle', 'High'], xhline_pos=0.0, barcolors=['grey','grey', 'grey'], barwidth=0.5)
        pd2 = BarPlotData(x=(0, 1, 2),
                          y=pc_diff_from_mean,
                          ylim=[-ylim, ylim],
                          xlabel='Tercile of Classifier Estimate\n(b)',
                          ylabel='Recall Change From Mean (%)',
                          x_tick_labels=['Low', 'Middle', 'High'],
                          xhline_pos=0.0,
                          barcolors=['grey', 'grey', 'grey'],
                          barwidth=0.5)

        panel_plot.add_plot_data(0, 0, plot_data=pd1)
        panel_plot.add_plot_data(0, 1, plot_data=pd2)

        plot = panel_plot.generate_plot()

        plot_out_fname = self.get_path_to_resource_in_workspace(
            'reports/' + self.pipeline.subject +
            '-roc_and_terc_plot_combined.pdf')

        plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

        session_summary_array = self.get_passed_object('session_summary_array')
        param1_name = self.get_passed_object('param1_name')
        param1_unit = self.get_passed_object('param1_unit')
        param1_title = '%s (%s)' % (param1_name, param1_unit)

        for session_summary in session_summary_array:
            # panel_plot = PanelPlot(i_max=1, j_max=1, title='', xtitle=param1_title, xtitle_fontsize=24, ytitle='$\Delta$ Post-Pre Classifier Output',ytitle_fontsize=24, wspace=0.3, hspace=0.3)

            panel_plot = PanelPlot(
                i_max=1,
                j_max=1,
                title='',
                ytitle='$\Delta$ Post-Pre Classifier Output',
                ytitle_fontsize=24,
                wspace=0.3,
                hspace=0.3)

            pdc = PlotDataCollection(legend_on=True)
            pdc.xlabel = param1_title
            pdc.xlabel_fontsize = 24

            for v, p in session_summary.plots.iteritems():
                p.xhline_pos = 0.0
                pdc.add_plot_data(p)

            panel_plot.add_plot_data_collection(0, 0, plot_data_collection=pdc)

            plot = panel_plot.generate_plot()

            plot_out_fname = self.get_path_to_resource_in_workspace(
                'reports/' + self.pipeline.experiment + '-' +
                self.pipeline.subject + '-report_plot_' +
                session_summary.name + '.pdf')

            plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

        cumulative_plots = self.get_passed_object('cumulative_plots')

        # panel_plot = PanelPlot(i_max=1, j_max=1, title='', xtitle=param1_title, y_axis_title='$\Delta$ Post-Pre Classifier Output')
        panel_plot = PanelPlot(i_max=1,
                               j_max=1,
                               title='',
                               ytitle='$\Delta$ Post-Pre Classifier Output',
                               ytitle_fontsize=24)

        pdc = PlotDataCollection(legend_on=True)
        pdc.xlabel = param1_title
        pdc.xlabel_fontsize = 24

        for v, p in cumulative_plots.iteritems():
            p.xhline_pos = 0.0
            pdc.add_plot_data(p)

        panel_plot.add_plot_data_collection(0, 0, plot_data_collection=pdc)

        plot = panel_plot.generate_plot()

        plot_out_fname = self.get_path_to_resource_in_workspace(
            'reports/' + self.pipeline.experiment + '-' +
            self.pipeline.subject + '-report_plot_Cumulative.pdf')

        plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')
Beispiel #9
0
    def run(self):
        self.create_dir_in_workspace('reports')

        frequency_plot_data = self.get_passed_object('frequency_plot')
        centralized_frequency_plot_data = self.get_passed_object('centralized_frequency_plot')
        frequency_region_plot_data = self.get_passed_object('frequency_region_plot')
        frequency_frequency_plot_data = self.get_passed_object('frequency_frequency_plot')

        low_freq_duration_plot_data = self.get_passed_object('low_freq_duration_plot')
        high_freq_duration_plot_data = self.get_passed_object('high_freq_duration_plot')
        low_freq_amplitude_plot_data = self.get_passed_object('low_freq_amplitude_plot')
        high_freq_amplitude_plot_data = self.get_passed_object('high_freq_amplitude_plot')


        # panel_plot = PanelPlot(xfigsize=11, yfigsize=11, i_max=1, j_max=1, title='', ytitle=self.params.output_title, ytitle_fontsize=16, wspace=0.3, hspace=0.3)
        #
        # panel_plot.add_plot_data_collection(0, 0, plot_data_collection=pdc)
        #
        # plot = panel_plot.generate_plot()
        #
        # plot_out_fname = self.get_path_to_resource_in_workspace('reports/ps_frequency_aggregate_plots.pdf')
        #
        # plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

        pdc = PlotDataCollection(legend_on=True)
        pdc.xlabel = 'Pulse Frequency (Hz)'
        pdc.xlabel_fontsize = 16
        for v,p in frequency_plot_data.iteritems():
            p.xhline_pos=0.0
            pdc.add_plot_data(p)


        # panel_plot = PanelPlot(xfigsize=15, yfigsize=7.5, i_max=1, j_max=3, title='', ytitle=self.params.output_title, wspace=0.3, hspace=0.3)
        panel_plot = PanelPlot(xfigsize=18.5, yfigsize=7.5, i_max=1, j_max=3, title='', ytitle=self.params.output_title, labelsize=20, ytitle_fontsize = 20)
        min_y_list =[]
        max_y_list =[]

        r =pdc.get_yrange()
        min_y_list.append(r[0])
        max_y_list.append(r[1])

        r =frequency_region_plot_data.get_yrange()
        min_y_list.append(r[0])
        max_y_list.append(r[1])

        r =frequency_frequency_plot_data.get_yrange()
        min_y_list.append(r[0])
        max_y_list.append(r[1])

        y_min = np.min(min_y_list)
        y_max = np.max(max_y_list)
        r = y_max - y_min
        y_min -= 0.05*r
        y_max += 0.15*r

        pdc.ylim=[y_min,y_max]
        frequency_region_plot_data.ylim=[y_min,y_max]
        frequency_frequency_plot_data.ylim=[y_min,y_max]

        pdc.xhline_pos = 0.0
        frequency_region_plot_data.xhline_pos = 0.0
        frequency_frequency_plot_data.xhline_pos = 0.0

        # label fontsize
        pdc.xlabel_fontsize = 20
        pdc.ylabel_fontsize = 20
        frequency_region_plot_data.xlabel_fontsize = 20
        frequency_region_plot_data.ylabel_fontsize = 20
        frequency_frequency_plot_data.xlabel_fontsize = 20
        frequency_frequency_plot_data.ylabel_fontsize = 20


        print '[y_min,y_max]=',[y_min,y_max]



        panel_plot.add_plot_data_collection(0, 0, plot_data_collection=pdc)
        panel_plot.add_plot_data(0, 1, plot_data=frequency_region_plot_data)
        panel_plot.add_plot_data(0, 2, plot_data=frequency_frequency_plot_data)


        plot = panel_plot.generate_plot()
        plot_out_fname = self.get_path_to_resource_in_workspace('reports/ps_frequency_projection_plots.pdf')
        plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

        panel_plot = PanelPlot(i_max=1, j_max=1, title='', ytitle=self.params.output_title, ytitle_fontsize=24, wspace=0.3, hspace=0.3)

        pdc = PlotDataCollection(legend_on=True)
        pdc.xlabel = 'Duration (ms)'
        pdc.xlabel_fontsize = 24
        for v,p in low_freq_duration_plot_data.iteritems():
            p.xhline_pos=0.0
            pdc.add_plot_data(p)
        panel_plot.add_plot_data_collection(0, 0, plot_data_collection=pdc)

        plot = panel_plot.generate_plot()

        plot_out_fname = self.get_path_to_resource_in_workspace('reports/ps_duration_low_aggregate_plots.pdf')

        plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')


        panel_plot = PanelPlot(i_max=1, j_max=1, title='', ytitle=self.params.output_title, ytitle_fontsize=24, wspace=0.3, hspace=0.3)

        pdc = PlotDataCollection(legend_on=True)
        pdc.xlabel = 'Duration (ms)'
        pdc.xlabel_fontsize = 24
        for v,p in high_freq_duration_plot_data.iteritems():
            p.xhline_pos=0.0
            pdc.add_plot_data(p)
        panel_plot.add_plot_data_collection(0, 0, plot_data_collection=pdc)

        plot = panel_plot.generate_plot()

        plot_out_fname = self.get_path_to_resource_in_workspace('reports/ps_duration_high_aggregate_plots.pdf')

        plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')


        panel_plot = PanelPlot(i_max=1, j_max=1, title='', ytitle=self.params.output_title, ytitle_fontsize=24, wspace=0.3, hspace=0.3)

        pdc = PlotDataCollection(legend_on=True)
        pdc.xlabel = 'Amplitude (mA)'
        pdc.xlabel_fontsize = 24
        for v,p in low_freq_amplitude_plot_data.iteritems():
            p.xhline_pos=0.0
            pdc.add_plot_data(p)
        panel_plot.add_plot_data_collection(0, 0, plot_data_collection=pdc)

        plot = panel_plot.generate_plot()

        plot_out_fname = self.get_path_to_resource_in_workspace('reports/ps_amplitude_low_aggregate_plots.pdf')

        plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')


        panel_plot = PanelPlot(i_max=1, j_max=1, title='', ytitle=self.params.output_title, ytitle_fontsize=24, wspace=0.3, hspace=0.3)

        pdc = PlotDataCollection(legend_on=True)
        pdc.xlabel = 'Amplitude (mA)'
        pdc.xlabel_fontsize = 24
        for v,p in high_freq_amplitude_plot_data.iteritems():
            p.xhline_pos=0.0
            pdc.add_plot_data(p)
        panel_plot.add_plot_data_collection(0, 0, plot_data_collection=pdc)

        plot = panel_plot.generate_plot()

        plot_out_fname = self.get_path_to_resource_in_workspace('reports/ps_amplitude_high_aggregate_plots.pdf')

        plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')
Beispiel #10
0
    def run(self):
        xval_results = self.get_passed_object('xval_results')
        auc_results = xval_results.auc_results

        threshold_values = np.unique(auc_results.t_thresh)

        x = threshold_values
        y = np.empty_like(x)
        yerr = np.empty_like(x)
        y_features = np.empty_like(x)
        y_features_err = np.empty_like(x)

        for i,t_thresh in enumerate(threshold_values):
            auc_results_t_thresh = auc_results[auc_results.t_thresh == t_thresh]

            auc_mean = np.mean(auc_results_t_thresh.auc)
            auc_median = np.median(auc_results_t_thresh.auc)
            auc_min = np.min(auc_results_t_thresh.auc)
            auc_max = np.max(auc_results_t_thresh.auc)

            y[i] = auc_median
            yerr[i] = auc_max-auc_median


            num_features_mean = np.mean(auc_results_t_thresh.num_features)
            num_features_median = np.median(auc_results_t_thresh.num_features)
            num_features_min = np.min(auc_results_t_thresh.num_features)
            num_features_max = np.max(auc_results_t_thresh.num_features)
            
            y_features[i] = num_features_median
            y_features_err[i] = num_features_max - num_features_median


        pd = PlotData(x=x, y=y, yerr=yerr, xhline_pos=0.5, ylim=(0.0, 1.0),ylabel='AUC', xlabel='t-threshold')
        pd_features = PlotData(x=x, y=y_features,yerr=y_features_err,ylabel='Number of features', xlabel='t-threshold')

        pd1 = PlotData(x=x, y=y, yerr=yerr, xhline_pos=0.5, ylim=(0.0, 1.0),ylabel='AUC', xlabel='t-threshold_1')
        pd_features1 = PlotData(x=x, y=y_features,yerr=y_features_err,ylabel='Number of features', xlabel='t-threshold_1')



        # pd_dict={(0,0):pd, (0,1):pd_features,(1,0):pd1, (1,1):pd_features1}

        pd_dict={(0,0):pd, (0,1):pd_features}

        panel_plot = PanelPlot(i_max=2, j_max=2, title='', ytitle='AUC',wspace=0.3,hspace=0.3)

        for plot_panel_index, pd in pd_dict.iteritems():
            print 'plot_panel_index=', plot_panel_index
            print 'pd.x=', pd.x
            print 'pd.y=', pd.y
            # plot_letter = chr(ord('a') + 2 * plot_panel_index[0] + plot_panel_index[1])
            panel_plot.add_plot_data(plot_panel_index[0], plot_panel_index[1], plot_data=pd)
                # ,
                #                      x_tick_labels=pd.x_tick_labels, title='(' + plot_letter + ')', ylim=pd.ylim)

        plot = panel_plot.generate_plot()
        # plot.subplots_adjust(wspace=0.3, hspace=0.3)
        # # plt.savefig(join(plotsDir, quantity_name+'.png'), dpi=300,bboxinches='tight')
        #
        # plot_out_fname = self.get_path_to_resource_in_workspace('reports/' + self.pipeline.experiment + '-' + self.pipeline.subject + '-report_plot_' + session_summary.name + '.pdf')
        #
        # plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')
        #
        # cumulative_plot_data_dict = self.get_passed_object('cumulative_plot_data_dict')
        #
        # panel_plot = PanelPlot(i_max=3, j_max=2, title='', y_axis_title='$\Delta$ Post-Pre Classifier Output')
        #
        # for plot_panel_index, pd in cumulative_plot_data_dict.iteritems():
        #     # print 'plot_panel_index=', plot_panel_index
        #     # print 'pd.x=', pd.x
        #     # print 'pd.y=', pd.y
        #     plot_letter = chr(ord('a') + 2 * plot_panel_index[0] + plot_panel_index[1])
        #     panel_plot.add_plot_data(plot_panel_index[0], plot_panel_index[1], x=pd.x, y=pd.y, yerr=pd.yerr,
        #                              x_tick_labels=pd.x_tick_labels, title='(' + plot_letter + ')', ylim=pd.ylim)
        #
        # plot = panel_plot.generate_plot()
        # plot.subplots_adjust(wspace=0.3, hspace=0.3)
        # # plt.savefig(join(plotsDir, quantity_name+'.png'), dpi=300,bboxinches='tight')
        #
        # plot_out_fname = self.get_path_to_resource_in_workspace('reports/' + self.pipeline.experiment + '-' + self.pipeline.subject + '-report_plot_Cumulative.pdf')

        plot_out_fname = join(self.pipeline.output_dir, 'plot_'+self.pipeline.subject+'.pdf')
        plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')
    def run(self):
        subject = self.pipeline.subject
        task = self.pipeline.task

        self.create_dir_in_workspace('reports')

        session_summary_array = self.get_passed_object('session_summary_array')

        serial_positions = np.arange(1,13)

        for session_summary in session_summary_array:
            panel_plot = PanelPlot(xfigsize=15, yfigsize=7.5, i_max=1, j_max=2, title='', wspace=0.3, hspace=0.3)

            pd1 = PlotData(x=serial_positions, y=session_summary.prob_recall, xlim=(0,12), ylim=(0.0, 1.0), xlabel='Serial position\n(a)', ylabel='Probability of recall')
            pd2 = PlotData(x=serial_positions, y=session_summary.prob_first_recall, xlim=(0,12), ylim=(0.0, 1.0), xlabel='Serial position\n(b)', ylabel='Probability of first recall')

            panel_plot.add_plot_data(0, 0, plot_data=pd1)
            panel_plot.add_plot_data(0, 1, plot_data=pd2)

            plot = panel_plot.generate_plot()

            plot_out_fname = self.get_path_to_resource_in_workspace('reports/' + task + '-' + subject + '-prob_recall_plot_' + session_summary.name + '.pdf')

            plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

            if task == 'RAM_CatFR1':
                panel_plot = PanelPlot(xfigsize=6.0, yfigsize=6.0, i_max=1, j_max=1, title='', xtitle='',wspace=0.3, hspace=0.3)
                pd = BarPlotData(x=[0,1], y=[session_summary.irt_within_cat,  session_summary.irt_between_cat], ylabel='IRT (msec)',xlabel='', x_tick_labels=['Within Cat', 'Between Cat'], barcolors=['grey','grey'], barwidth=0.5)
                panel_plot.add_plot_data(0, 0, plot_data=pd)
                plot = panel_plot.generate_plot()
                plot_out_fname = self.get_path_to_resource_in_workspace('reports/' + task + '-' + subject + '-irt_plot_' + session_summary.name + '.pdf')
                plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

            panel_plot = PanelPlot(xfigsize=15, yfigsize=7.5, i_max=1, j_max=2, title='', wspace=0.3, hspace=0.3)

            pd1 = PlotData(x=session_summary.fpr, y=session_summary.tpr, xlim=[0.0,1.0], ylim=[0.0,1.0], xlabel='False Alarm Rate\n(a)', ylabel='Hit Rate', levelline=((0.0,1.0),(0.0,1.0)))

            ylim = np.max(np.abs(session_summary.pc_diff_from_mean)) + 5.0
            if ylim > 100.0:
                ylim = 100.0
            pd2 = BarPlotData(x=(0,1,2), y=session_summary.pc_diff_from_mean, ylim=[-ylim,ylim], xlabel='Tercile of Classifier Estimate\n(b)', ylabel='Recall Change From Mean (%)', x_tick_labels=['Low', 'Middle', 'High'], xhline_pos=0.0, barcolors=['grey','grey', 'grey'], barwidth=0.5)

            panel_plot.add_plot_data(0, 0, plot_data=pd1)
            panel_plot.add_plot_data(0, 1, plot_data=pd2)

            plot = panel_plot.generate_plot()

            plot_out_fname = self.get_path_to_resource_in_workspace('reports/' + task + '-' + subject + '-roc_and_terc_plot_' + session_summary.name + '.pdf')

            plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

        cumulative_summary = self.get_passed_object('cumulative_summary')

        panel_plot = PanelPlot(xfigsize=15, yfigsize=7.5, i_max=1, j_max=2, title='', wspace=0.3, hspace=0.3)

        pd1 = PlotData(x=serial_positions, y=cumulative_summary.prob_recall, xlim=(0, 12), ylim=(0.0, 1.0), xlabel='Serial position\n(a)', ylabel='Probability of recall')
        pd2 = PlotData(x=serial_positions, y=cumulative_summary.prob_first_recall, xlim=(0, 12), ylim=(0.0, 1.0), xlabel='Serial position\n(b)', ylabel='Probability of first recall')

        panel_plot.add_plot_data(0, 0, plot_data=pd1)
        panel_plot.add_plot_data(0, 1, plot_data=pd2)

        plot = panel_plot.generate_plot()

        plot_out_fname = self.get_path_to_resource_in_workspace('reports/' + task + '-' + subject + '-prob_recall_plot_combined.pdf')

        plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

        if task == 'RAM_CatFR1':
            panel_plot = PanelPlot(xfigsize=6.0, yfigsize=6.0, i_max=1, j_max=1, title='',xtitle='', wspace=0.3, hspace=0.3)
            pd = BarPlotData(x=[0,1], y=[cumulative_summary.irt_within_cat, cumulative_summary.irt_between_cat], ylabel='IRT (msec)', xlabel='',x_tick_labels=['Within Cat', 'Between Cat'], barcolors=['grey','grey'], barwidth=0.5)
            panel_plot.add_plot_data(0, 0, plot_data=pd)
            plot = panel_plot.generate_plot()
            plot_out_fname = self.get_path_to_resource_in_workspace('reports/' + task + '-' + subject + '-irt_plot_combined.pdf')
            plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

        panel_plot = PanelPlot(xfigsize=15, yfigsize=7.5, i_max=1, j_max=2, title='', wspace=0.3, hspace=0.3)

        pd1 = PlotData(x=cumulative_summary.fpr, y=cumulative_summary.tpr, xlim=[0.0,1.0], ylim=[0.0,1.0], xlabel='False Alarm Rate\n(a)', ylabel='Hit Rate', levelline=((0.001,0.999),(0.001,0.999)))

        ylim = np.max(np.abs(cumulative_summary.pc_diff_from_mean)) + 5.0
        if ylim > 100.0:
            ylim = 100.0
        pd2 = BarPlotData(x=(0,1,2), y=cumulative_summary.pc_diff_from_mean, ylim=[-ylim,ylim], xlabel='Tercile of Classifier Estimate\n(b)', ylabel='Recall Change From Mean (%)', x_tick_labels=['Low', 'Middle', 'High'], xhline_pos=0.0, barcolors=['grey','grey', 'grey'],barwidth=0.5)

        panel_plot.add_plot_data(0, 0, plot_data=pd1)
        panel_plot.add_plot_data(0, 1, plot_data=pd2)

        plot = panel_plot.generate_plot()

        plot_out_fname = self.get_path_to_resource_in_workspace('reports/' + task + '-' + subject + '-roc_and_terc_plot_combined.pdf')

        plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')
Beispiel #12
0
    def run(self):
        xval_results = self.get_passed_object('xval_results')
        auc_results = xval_results.auc_results

        threshold_values = np.unique(auc_results.t_thresh)

        x = threshold_values
        y = np.empty_like(x)
        yerr = np.empty_like(x)
        y_features = np.empty_like(x)
        y_features_err = np.empty_like(x)

        for i, t_thresh in enumerate(threshold_values):
            auc_results_t_thresh = auc_results[auc_results.t_thresh ==
                                               t_thresh]

            auc_mean = np.mean(auc_results_t_thresh.auc)
            auc_median = np.median(auc_results_t_thresh.auc)
            auc_min = np.min(auc_results_t_thresh.auc)
            auc_max = np.max(auc_results_t_thresh.auc)

            y[i] = auc_median
            yerr[i] = auc_max - auc_median

            num_features_mean = np.mean(auc_results_t_thresh.num_features)
            num_features_median = np.median(auc_results_t_thresh.num_features)
            num_features_min = np.min(auc_results_t_thresh.num_features)
            num_features_max = np.max(auc_results_t_thresh.num_features)

            y_features[i] = num_features_median
            y_features_err[i] = num_features_max - num_features_median

        pd = PlotData(x=x,
                      y=y,
                      yerr=yerr,
                      xhline_pos=0.5,
                      ylim=(0.0, 1.0),
                      ylabel='AUC',
                      xlabel='t-threshold')
        pd_features = PlotData(x=x,
                               y=y_features,
                               yerr=y_features_err,
                               ylabel='Number of features',
                               xlabel='t-threshold')

        pd1 = PlotData(x=x,
                       y=y,
                       yerr=yerr,
                       xhline_pos=0.5,
                       ylim=(0.0, 1.0),
                       ylabel='AUC',
                       xlabel='t-threshold_1')
        pd_features1 = PlotData(x=x,
                                y=y_features,
                                yerr=y_features_err,
                                ylabel='Number of features',
                                xlabel='t-threshold_1')

        # pd_dict={(0,0):pd, (0,1):pd_features,(1,0):pd1, (1,1):pd_features1}

        pd_dict = {(0, 0): pd, (0, 1): pd_features}

        panel_plot = PanelPlot(i_max=2,
                               j_max=2,
                               title='',
                               ytitle='AUC',
                               wspace=0.3,
                               hspace=0.3)

        for plot_panel_index, pd in pd_dict.iteritems():
            print 'plot_panel_index=', plot_panel_index
            print 'pd.x=', pd.x
            print 'pd.y=', pd.y
            # plot_letter = chr(ord('a') + 2 * plot_panel_index[0] + plot_panel_index[1])
            panel_plot.add_plot_data(plot_panel_index[0],
                                     plot_panel_index[1],
                                     plot_data=pd)
            # ,
            #                      x_tick_labels=pd.x_tick_labels, title='(' + plot_letter + ')', ylim=pd.ylim)

        plot = panel_plot.generate_plot()
        # plot.subplots_adjust(wspace=0.3, hspace=0.3)
        # # plt.savefig(join(plotsDir, quantity_name+'.png'), dpi=300,bboxinches='tight')
        #
        # plot_out_fname = self.get_path_to_resource_in_workspace('reports/' + self.pipeline.experiment + '-' + self.pipeline.subject + '-report_plot_' + session_summary.name + '.pdf')
        #
        # plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')
        #
        # cumulative_plot_data_dict = self.get_passed_object('cumulative_plot_data_dict')
        #
        # panel_plot = PanelPlot(i_max=3, j_max=2, title='', y_axis_title='$\Delta$ Post-Pre Classifier Output')
        #
        # for plot_panel_index, pd in cumulative_plot_data_dict.iteritems():
        #     # print 'plot_panel_index=', plot_panel_index
        #     # print 'pd.x=', pd.x
        #     # print 'pd.y=', pd.y
        #     plot_letter = chr(ord('a') + 2 * plot_panel_index[0] + plot_panel_index[1])
        #     panel_plot.add_plot_data(plot_panel_index[0], plot_panel_index[1], x=pd.x, y=pd.y, yerr=pd.yerr,
        #                              x_tick_labels=pd.x_tick_labels, title='(' + plot_letter + ')', ylim=pd.ylim)
        #
        # plot = panel_plot.generate_plot()
        # plot.subplots_adjust(wspace=0.3, hspace=0.3)
        # # plt.savefig(join(plotsDir, quantity_name+'.png'), dpi=300,bboxinches='tight')
        #
        # plot_out_fname = self.get_path_to_resource_in_workspace('reports/' + self.pipeline.experiment + '-' + self.pipeline.subject + '-report_plot_Cumulative.pdf')

        plot_out_fname = join(self.pipeline.output_dir,
                              'plot_' + self.pipeline.subject + '.pdf')
        plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')
    def run(self):
        subject = self.pipeline.subject
        task = self.pipeline.task

        self.create_dir_in_workspace('reports')

        session_summary_array = self.get_passed_object('session_summary_array')

        serial_positions = np.arange(1,13)

        for session_summary in session_summary_array:
            panel_plot = PanelPlot(xfigsize=15, yfigsize=7.5, i_max=1, j_max=2, title='', wspace=0.3, hspace=0.3, labelsize=20)

            pd1 = PlotData(x=serial_positions, y=session_summary.prob_recall, xlim=(0,12), ylim=(0.0, 1.0), xlabel='Serial position\n(a)', ylabel='Probability of recall')
            pd1.xlabel_fontsize = 20
            pd1.ylabel_fontsize = 20
            pd2 = PlotData(x=serial_positions, y=session_summary.prob_first_recall, xlim=(0,12), ylim=(0.0, 1.0), xlabel='Serial position\n(b)', ylabel='Probability of first recall')
            pd2.xlabel_fontsize = 20
            pd2.ylabel_fontsize = 20

            # panel_plot.add_plot_data(0, 0, plot_data=pd1)
            # panel_plot.add_plot_data(0, 1, plot_data=pd2)
            #
            # plot = panel_plot.generate_plot()

            panel_plot.add_plot_data(0, 0, plot_data=pd1)

            panel_plot.add_plot_data(0, 1, plot_data=pd2)

            plot = panel_plot.generate_plot()




            plot_out_fname = self.get_path_to_resource_in_workspace('reports/' + task + '-' + subject + '-prob_recall_plot_' + session_summary.name + '.pdf')

            plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

            if task == 'RAM_CatFR1':
                panel_plot = PanelPlot(xfigsize=6.0, yfigsize=6.0, i_max=1, j_max=1, title='', wspace=0.3, hspace=0.3)
                pd = BarPlotData(x=[0,1], y=[session_summary.irt_within_cat,  session_summary.irt_between_cat], ylabel='IRT (msec)', x_tick_labels=['Within Cat', 'Between Cat'], barcolors=['grey','grey'], barwidth=0.5)
                panel_plot.add_plot_data(0, 0, plot_data=pd)
                plot = panel_plot.generate_plot()
                plot_out_fname = self.get_path_to_resource_in_workspace('reports/' + task + '-' + subject + '-irt_plot_' + session_summary.name + '.pdf')
                plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

            panel_plot = PanelPlot(xfigsize=10.0, yfigsize=10.0, i_max=1, j_max=1, title='', xlabel='List', ylabel='# of items', labelsize=20)

            pdc = PlotDataCollection()
            #----------------- FORMATTING
            pdc.xlabel = 'List number'
            pdc.xlabel_fontsize = 20
            pdc.ylabel ='# recalled words'
            pdc.ylabel_fontsize = 20

            n_lists = len(session_summary.n_stims_per_list)

            print 'Number of lists', n_lists

            bpd_1 = BarPlotData(x=np.arange(n_lists), y=session_summary.n_stims_per_list, title='', alpha=0.1)
            pd_1 = PlotData(x=np.where(session_summary.is_stim_list)[0], y=session_summary.n_recalls_per_list[session_summary.is_stim_list],
                    title='', linestyle='', color='red', marker='o',markersize=20)
            pd_2 = PlotData(x=np.where(~session_summary.is_stim_list)[0], y=session_summary.n_recalls_per_list[~session_summary.is_stim_list],
                    title='', linestyle='', color='blue', marker='o',markersize=20)
            print 'np.where(session_summary.is_stim_list)[0]=',np.where(session_summary.is_stim_list)[0]
            print 'np.where(~session_summary.is_stim_list)[0]=',np.where(~session_summary.is_stim_list)[0]
            pdc.add_plot_data(pd_1)
            pdc.add_plot_data(pd_2)
            pdc.add_plot_data(bpd_1)

            panel_plot.add_plot_data_collection(0, 0, plot_data_collection=pdc)

            plot = panel_plot.generate_plot()



            plot_out_fname = self.get_path_to_resource_in_workspace('reports/' + task + '-' + subject + '-stim_and_recall_plot_' + session_summary.name + '.pdf')

            plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

        cumulative_summary = self.get_passed_object('cumulative_summary')

        panel_plot = PanelPlot(xfigsize=15, yfigsize=7.5, i_max=1, j_max=2, title='', wspace=0.3, hspace=0.3)

        pd1 = PlotData(x=serial_positions, y=cumulative_summary.prob_recall, xlim=(0, 12), ylim=(0.0, 1.0), xlabel='Serial position\n(a)', ylabel='Probability of recall')
        pd2 = PlotData(x=serial_positions, y=cumulative_summary.prob_first_recall, xlim=(0, 12), ylim=(0.0, 1.0), xlabel='Serial position\n(b)', ylabel='Probability of first recall')

        panel_plot.add_plot_data(0, 0, plot_data=pd1)
        panel_plot.add_plot_data(0, 1, plot_data=pd2)

        plot = panel_plot.generate_plot()

        plot_out_fname = self.get_path_to_resource_in_workspace('reports/' + task + '-' + subject + '-prob_recall_plot_combined.pdf')

        plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')

        if task == 'RAM_CatFR1':
            panel_plot = PanelPlot(xfigsize=6.0, yfigsize=6.0, i_max=1, j_max=1, title='', wspace=0.3, hspace=0.3)
            pd = BarPlotData(x=[0,1], y=[cumulative_summary.irt_within_cat, cumulative_summary.irt_between_cat], ylabel='IRT (msec)', x_tick_labels=['Within Cat', 'Between Cat'], barcolors=['grey','grey'], barwidth=0.5)
            panel_plot.add_plot_data(0, 0, plot_data=pd)
            plot = panel_plot.generate_plot()
            plot_out_fname = self.get_path_to_resource_in_workspace('reports/' + task + '-' + subject + '-irt_plot_combined.pdf')
            plot.savefig(plot_out_fname, dpi=300, bboxinches='tight')