Exemplo n.º 1
0
    def run(self):
        tex_template = 'ps3_aggregator.tex.tpl'

        report_tex_file_name = 'ps3_aggregator.tex'
        self.pass_object('report_tex_file_name',report_tex_file_name)

        self.set_file_resources_to_move(report_tex_file_name, dst='reports')

        region_total = self.get_passed_object('region_session_total')
        area_total = self.get_passed_object('area_session_total')

        region_total = sorted(zip(region_total.keys(), region_total.values()))
        region_total.append(('Total',sum([v[1] for v in region_total])))

        area_total = sorted(zip(area_total.keys(), area_total.values()))

        replace_dict = {
            '<DATE>': datetime.date.today(),
            '<FREQUENCY_PLOT_FILE>': 'ps3_frequency_aggregate_plots.pdf',
            '<FREQUENCY_PROJECTION_PLOT_FILE>': 'ps3_frequency_projection_plots.pdf',
            '<REGION_FREQUENCY_EXPERIMENT_COUNT_TABLE>': latex_table(self.get_passed_object('n_region_frequency_experiment')),
            '<REGION_SESSION_TOTAL_DATA>': latex_table(region_total, hlines=False)
        }

        TextTemplateUtils.replace_template(template_file_name=tex_template, out_file_name=report_tex_file_name, replace_dict=replace_dict)
Exemplo n.º 2
0
    def run(self):
        import TextTemplateUtils
        import datetime
        tex_template = 'ps_report.tex.tpl'
        tex_session_template = 'ps_session.tex.tpl'

        report_tex_file_name = self.pipeline.experiment + '-' + self.pipeline.subject + '-' + 'report.tex'
        self.pass_object('report_tex_file_name',report_tex_file_name)

        self.set_file_resources_to_move(report_tex_file_name, dst='reports')

        tex_session_pages_str = ''
        session_summary_array = self.get_passed_object('session_summary_array')

        for session_summary in session_summary_array:
            replace_dict = {'<SESS_NUM>': session_summary.sess_num,
                            '<PLOT_FILE>': self.pipeline.experiment + '-' + self.pipeline.subject + '-report_plot_' + session_summary.name + '.pdf',
                            '<STIMTAG>': session_summary.stimtag,
                            '<CONSTANT_NAME>': session_summary.constant_name,
                            '<CONSTANT_VALUE>': session_summary.constant_value,
                            '<CONSTANT_UNIT>': session_summary.constant_unit,
                            '<ISI_MID>': session_summary.isi_mid,
                            '<ISI_HALF_RANGE>': session_summary.isi_half_range,
                            '<PARAMETER1>': session_summary.parameter1,
                            '<PARAMETER2>': session_summary.parameter2,
                            '<FVALUE1>': '%.4f' % session_summary.anova_fvalues[0],
                            '<FVALUE2>': '%.4f' % session_summary.anova_fvalues[1],
                            '<FVALUE12>': '%.4f' % session_summary.anova_fvalues[2],
                            '<PVALUE1>': '%.4f' % session_summary.anova_pvalues[0],
                            '<PVALUE2>': '%.4f' % session_summary.anova_pvalues[1],
                            '<PVALUE12>': '%.4f' % session_summary.anova_pvalues[2]
                            }

            tex_session_pages_str += TextTemplateUtils.replace_template_to_string(tex_session_template, replace_dict)
            tex_session_pages_str += '\n'


        session_data_tex_table = latex_table(self.get_passed_object('SESSION_DATA'))

        replace_dict = {
            '<SUBJECT>': self.pipeline.subject.replace('_', '\\textunderscore'),
            '<EXPERIMENT>': self.pipeline.experiment,
            '<DATE>': datetime.date.today(),
            '<SESSION_DATA>': session_data_tex_table,
            '<NUMBER_OF_SESSIONS>': self.get_passed_object('NUMBER_OF_SESSIONS'),
            '<NUMBER_OF_ELECTRODES>': self.get_passed_object('NUMBER_OF_ELECTRODES'),
            '<REPORT_PAGES>': tex_session_pages_str,
            '<CUMULATIVE_ISI_MID>': self.get_passed_object('CUMULATIVE_ISI_MID'),
            '<CUMULATIVE_ISI_HALF_RANGE>': self.get_passed_object('CUMULATIVE_ISI_HALF_RANGE'),
            '<CUMULATIVE_PLOT_FILE>': self.pipeline.experiment + '-' + self.pipeline.subject + '-report_plot_Cumulative.pdf',
            '<CUMULATIVE_PARAMETER1>': self.get_passed_object('CUMULATIVE_PARAMETER1'),
            '<CUMULATIVE_PARAMETER2>': self.get_passed_object('CUMULATIVE_PARAMETER2')
        }


        TextTemplateUtils.replace_template(template_file_name=tex_template, out_file_name=report_tex_file_name, replace_dict=replace_dict)
Exemplo n.º 3
0
    def run(self):
        subject = self.pipeline.subject
        task = self.pipeline.task

        tex_session_template = task + '_session.tex.tpl'

        n_sess = self.get_passed_object('NUMBER_OF_SESSIONS')
        n_bps = self.get_passed_object('NUMBER_OF_ELECTRODES')

        session_summary_array = self.get_passed_object('session_summary_array')

        report_tex_file_names = []
        for i_sess in xrange(n_sess):
            session_summary = session_summary_array[i_sess]
            sess = session_summary.number
            report_tex_file_name = '%s-%s-s%02d-report.tex' % (task,subject,sess)
            report_tex_file_names.append(report_tex_file_name)

            self.set_file_resources_to_move(report_tex_file_name, dst='reports')

            replace_dict = {'<PROB_RECALL_PLOT_FILE>': self.pipeline.task + '-' + self.pipeline.subject + '-prob_recall_plot_' + session_summary.name + '.pdf',
                            '<STIM_AND_RECALL_PLOT_FILE>': self.pipeline.task + '-' + self.pipeline.subject + '-stim_and_recall_plot_' + session_summary.name + '.pdf',
                            '<IRT_PLOT_FILE>': self.pipeline.task + '-' + self.pipeline.subject + '-irt_plot_' + session_summary.name + '.pdf',
                            '<DATE>': datetime.date.today(),
                            '<SUBJECT>': subject.replace('_','\\textunderscore'),
                            '<NUMBER_OF_ELECTRODES>': n_bps,
                            '<SESSION_NUMBER>': sess,
                            '<SESSION_DATE>': session_summary.date,
                            '<SESSION_LENGTH>': session_summary.length,
                            '<N_WORDS>': session_summary.n_words,
                            '<N_CORRECT_WORDS>': session_summary.n_correct_words,
                            '<PC_CORRECT_WORDS>': '%.2f' % session_summary.pc_correct_words,
                            '<N_PLI>': session_summary.n_pli,
                            '<PC_PLI>': '%.2f' % session_summary.pc_pli,
                            '<N_ELI>': session_summary.n_eli,
                            '<PC_ELI>': '%.2f' % session_summary.pc_eli,
                            '<N_MATH>': session_summary.n_math,
                            '<N_CORRECT_MATH>': session_summary.n_correct_math,
                            '<PC_CORRECT_MATH>': '%.2f' % session_summary.pc_correct_math,
                            '<MATH_PER_LIST>': '%.2f' % session_summary.math_per_list,
                            '<N_CORRECT_STIM>': session_summary.n_correct_stim,
                            '<N_TOTAL_STIM>': session_summary.n_total_stim,
                            '<PC_FROM_STIM>': '%.2f' % session_summary.pc_from_stim,
                            '<N_CORRECT_NONSTIM>': session_summary.n_correct_nonstim,
                            '<N_TOTAL_NONSTIM>': session_summary.n_total_nonstim,
                            '<PC_FROM_NONSTIM>': '%.2f' % session_summary.pc_from_nonstim,
                            '<CHISQR>': '%.2f' % session_summary.chisqr,
                            '<PVALUE>': '%.2f' % session_summary.pvalue,
                            '<N_STIM_INTR>': session_summary.n_stim_intr,
                            '<PC_FROM_STIM_INTR>': '%.2f' % session_summary.pc_from_stim_intr,
                            '<N_NONSTIM_INTR>': session_summary.n_nonstim_intr,
                            '<PC_FROM_NONSTIM_INTR>': '%.2f' % session_summary.pc_from_nonstim_intr,
                            '<CHISQR_INTR>': '%.2f' % session_summary.chisqr_intr,
                            '<PVALUE_INTR>': '%.2f' % session_summary.pvalue_intr
                            }

            TextTemplateUtils.replace_template(template_file_name=tex_session_template, out_file_name=report_tex_file_name, replace_dict=replace_dict)

        self.pass_object('report_tex_file_names', report_tex_file_names)

        tex_combined_template = task + '_combined.tex.tpl'
        combined_report_tex_file_name = '%s-%s-combined-report.tex' % (task,subject)

        self.set_file_resources_to_move(combined_report_tex_file_name, dst='reports')

        cumulative_summary = self.get_passed_object('cumulative_summary')

        cumulative_data_tex_table = latex_table(self.get_passed_object('SESSION_DATA'))

        replace_dict = {'<PROB_RECALL_PLOT_FILE>': self.pipeline.task + '-' + self.pipeline.subject + '-prob_recall_plot_combined.pdf',
                        '<IRT_PLOT_FILE>': self.pipeline.task + '-' + self.pipeline.subject + '-irt_plot_combined.pdf',
                        '<DATE>': datetime.date.today(),
                        '<SESSION_DATA>': cumulative_data_tex_table,
                        '<SUBJECT>': subject.replace('_','\\textunderscore'),
                        '<NUMBER_OF_SESSIONS>': n_sess,
                        '<NUMBER_OF_ELECTRODES>': n_bps,
                        '<N_WORDS>': cumulative_summary.n_words,
                        '<N_CORRECT_WORDS>': cumulative_summary.n_correct_words,
                        '<PC_CORRECT_WORDS>': '%.2f' % cumulative_summary.pc_correct_words,
                        '<N_PLI>': cumulative_summary.n_pli,
                        '<PC_PLI>': '%.2f' % cumulative_summary.pc_pli,
                        '<N_ELI>': cumulative_summary.n_eli,
                        '<PC_ELI>': '%.2f' % cumulative_summary.pc_eli,
                        '<N_MATH>': cumulative_summary.n_math,
                        '<N_CORRECT_MATH>': cumulative_summary.n_correct_math,
                        '<PC_CORRECT_MATH>': '%.2f' % cumulative_summary.pc_correct_math,
                        '<MATH_PER_LIST>': '%.2f' % cumulative_summary.math_per_list,
                        '<N_CORRECT_STIM>': cumulative_summary.n_correct_stim,
                        '<N_TOTAL_STIM>': cumulative_summary.n_total_stim,
                        '<PC_FROM_STIM>': '%.2f' % cumulative_summary.pc_from_stim,
                        '<N_CORRECT_NONSTIM>': cumulative_summary.n_correct_nonstim,
                        '<N_TOTAL_NONSTIM>': cumulative_summary.n_total_nonstim,
                        '<PC_FROM_NONSTIM>': '%.2f' % cumulative_summary.pc_from_nonstim,
                        '<CHISQR>': '%.2f' % cumulative_summary.chisqr,
                        '<PVALUE>': '%.2f' % cumulative_summary.pvalue,
                        '<N_STIM_INTR>': cumulative_summary.n_stim_intr,
                        '<PC_FROM_STIM_INTR>': '%.2f' % cumulative_summary.pc_from_stim_intr,
                        '<N_NONSTIM_INTR>': cumulative_summary.n_nonstim_intr,
                        '<PC_FROM_NONSTIM_INTR>': '%.2f' % cumulative_summary.pc_from_nonstim_intr,
                        '<CHISQR_INTR>': '%.2f' % cumulative_summary.chisqr_intr,
                        '<PVALUE_INTR>': '%.2f' % cumulative_summary.pvalue_intr
                        }

        TextTemplateUtils.replace_template(template_file_name=tex_combined_template, out_file_name=combined_report_tex_file_name, replace_dict=replace_dict)

        self.pass_object('combined_report_tex_file_name', combined_report_tex_file_name)
Exemplo n.º 4
0
    def run(self):
        subject = self.pipeline.subject
        task = self.pipeline.task

        tex_session_template = task + "_session.tex.tpl"

        n_sess = self.get_passed_object("NUMBER_OF_SESSIONS")
        n_bps = self.get_passed_object("NUMBER_OF_ELECTRODES")

        session_summary_array = self.get_passed_object("session_summary_array")
        session_ttest_data = self.get_passed_object("session_ttest_data")

        ttable_format = self.get_passed_object("ttable_format")
        ttable_header = self.get_passed_object("ttable_header")

        report_tex_file_names = []
        for i_sess in xrange(n_sess):
            session_summary = session_summary_array[i_sess]
            sess = session_summary.number
            report_tex_file_name = "%s-%s-s%02d-report.tex" % (task, subject, sess)
            report_tex_file_names.append(report_tex_file_name)

            self.set_file_resources_to_move(report_tex_file_name, dst="reports")

            session_ttest_tex_table = latex_table(session_ttest_data[i_sess])

            replace_dict = {
                "<PROB_RECALL_PLOT_FILE>": self.pipeline.task
                + "-"
                + self.pipeline.subject
                + "-prob_recall_plot_"
                + session_summary.name
                + ".pdf",
                "<IRT_PLOT_FILE>": self.pipeline.task
                + "-"
                + self.pipeline.subject
                + "-irt_plot_"
                + session_summary.name
                + ".pdf",
                "<DATE>": datetime.date.today(),
                "<SUBJECT>": subject.replace("_", "\\textunderscore"),
                "<NUMBER_OF_ELECTRODES>": n_bps,
                "<SESSION_NUMBER>": sess,
                "<SESSION_DATE>": session_summary.date,
                "<SESSION_LENGTH>": session_summary.length,
                "<N_WORDS>": session_summary.n_words,
                "<N_CORRECT_WORDS>": session_summary.n_correct_words,
                "<PC_CORRECT_WORDS>": "%.2f" % session_summary.pc_correct_words,
                "<N_PLI>": session_summary.n_pli,
                "<PC_PLI>": "%.2f" % session_summary.pc_pli,
                "<N_ELI>": session_summary.n_eli,
                "<PC_ELI>": "%.2f" % session_summary.pc_eli,
                "<N_MATH>": session_summary.n_math,
                "<N_CORRECT_MATH>": session_summary.n_correct_math,
                "<PC_CORRECT_MATH>": "%.2f" % session_summary.pc_correct_math,
                "<MATH_PER_LIST>": "%.2f" % session_summary.math_per_list,
                "<TABLE_FORMAT>": ttable_format,
                "<TABLE_HEADER>": ttable_header,
                "<SIGNIFICANT_ELECTRODES>": session_ttest_tex_table,
                "<AUC>": session_summary.auc,
                "<ROC_AND_TERC_PLOT_FILE>": self.pipeline.task
                + "-"
                + self.pipeline.subject
                + "-roc_and_terc_plot_"
                + session_summary.name
                + ".pdf",
            }

            TextTemplateUtils.replace_template(
                template_file_name=tex_session_template, out_file_name=report_tex_file_name, replace_dict=replace_dict
            )

        self.pass_object("report_tex_file_names", report_tex_file_names)

        tex_combined_template = task + "_combined.tex.tpl"
        combined_report_tex_file_name = "%s-%s-combined-report.tex" % (task, subject)

        self.set_file_resources_to_move(combined_report_tex_file_name, dst="reports")

        cumulative_summary = self.get_passed_object("cumulative_summary")

        cumulative_data_tex_table = latex_table(self.get_passed_object("SESSION_DATA"))

        cumulative_ttest_tex_table = latex_table(self.get_passed_object("cumulative_ttest_data"))

        replace_dict = {
            "<PROB_RECALL_PLOT_FILE>": self.pipeline.task
            + "-"
            + self.pipeline.subject
            + "-prob_recall_plot_combined.pdf",
            "<IRT_PLOT_FILE>": self.pipeline.task + "-" + self.pipeline.subject + "-irt_plot_combined.pdf",
            "<DATE>": datetime.date.today(),
            "<SESSION_DATA>": cumulative_data_tex_table,
            "<SUBJECT>": subject.replace("_", "\\textunderscore"),
            "<NUMBER_OF_SESSIONS>": n_sess,
            "<NUMBER_OF_ELECTRODES>": n_bps,
            "<N_WORDS>": cumulative_summary.n_words,
            "<N_CORRECT_WORDS>": cumulative_summary.n_correct_words,
            "<PC_CORRECT_WORDS>": "%.2f" % cumulative_summary.pc_correct_words,
            "<N_PLI>": cumulative_summary.n_pli,
            "<PC_PLI>": "%.2f" % cumulative_summary.pc_pli,
            "<N_ELI>": cumulative_summary.n_eli,
            "<PC_ELI>": "%.2f" % cumulative_summary.pc_eli,
            "<N_MATH>": cumulative_summary.n_math,
            "<N_CORRECT_MATH>": cumulative_summary.n_correct_math,
            "<PC_CORRECT_MATH>": "%.2f" % cumulative_summary.pc_correct_math,
            "<MATH_PER_LIST>": "%.2f" % cumulative_summary.math_per_list,
            "<TABLE_FORMAT>": ttable_format,
            "<TABLE_HEADER>": ttable_header,
            "<SIGNIFICANT_ELECTRODES>": cumulative_ttest_tex_table,
            "<AUC>": cumulative_summary.auc,
            "<PERM-P-VALUE>": cumulative_summary.perm_test_pvalue,
            "<J-THRESH>": cumulative_summary.jstat_thresh,
            "<J-PERC>": cumulative_summary.jstat_percentile,
            "<ROC_AND_TERC_PLOT_FILE>": self.pipeline.task
            + "-"
            + self.pipeline.subject
            + "-roc_and_terc_plot_combined.pdf",
        }

        TextTemplateUtils.replace_template(
            template_file_name=tex_combined_template,
            out_file_name=combined_report_tex_file_name,
            replace_dict=replace_dict,
        )

        self.pass_object("combined_report_tex_file_name", combined_report_tex_file_name)
Exemplo n.º 5
0
    def run(self):
        tex_template = 'ps_report.tex.tpl'
        tex_session_template = 'ps_session.tex.tpl'
        tex_ttest_table1_template = 'ttest_table1.tex.tpl'
        tex_ttest_table2_template = 'ttest_table2.tex.tpl'

        report_tex_file_name = self.pipeline.experiment + '-' + self.pipeline.subject + '-' + 'report.tex'
        self.pass_object('report_tex_file_name',report_tex_file_name)

        self.set_file_resources_to_move(report_tex_file_name, dst='reports')

        param1_name = self.get_passed_object('param1_name')
        param1_unit = self.get_passed_object('param1_unit')

        param2_name = self.get_passed_object('param2_name')
        param2_unit = self.get_passed_object('param2_unit')

        const_param_name = self.get_passed_object('const_param_name')
        const_unit = self.get_passed_object('const_unit')

        cumulative_anova_fvalues = self.get_passed_object('CUMULATIVE_ANOVA_FVALUES')
        cumulative_anova_pvalues = self.get_passed_object('CUMULATIVE_ANOVA_PVALUES')

        cumulative_param1_ttest_table = self.get_passed_object('CUMULATIVE_PARAM1_TTEST_TABLE')
        cumulative_param2_ttest_table = self.get_passed_object('CUMULATIVE_PARAM2_TTEST_TABLE')
        cumulative_param12_ttest_table = self.get_passed_object('CUMULATIVE_PARAM12_TTEST_TABLE')

        session_summary_array = self.get_passed_object('session_summary_array')

        tex_session_pages_str = ''

        for session_summary in session_summary_array:
            n_ttest_tables = 0

            param1_ttest_table = ''
            if session_summary.param1_ttest_table is not None:
                ttest_replace_dict = {'<PARAMETER>': param1_name,
                                      '<UNIT>': param1_unit,
                                      '<TABLE>': latex_table(session_summary.param1_ttest_table, hlines=False)
                                     }
                param1_ttest_table = TextTemplateUtils.replace_template_to_string(tex_ttest_table1_template, ttest_replace_dict)
                n_ttest_tables += 1

            param2_ttest_table = ''
            if session_summary.param2_ttest_table is not None:
                ttest_replace_dict = {'<PARAMETER>': param2_name,
                                      '<UNIT>': param2_unit,
                                      '<TABLE>': latex_table(session_summary.param2_ttest_table, hlines=False)
                                      }
                param2_ttest_table = TextTemplateUtils.replace_template_to_string(tex_ttest_table1_template, ttest_replace_dict)
                n_ttest_tables += 1

            param12_ttest_table = ''
            if session_summary.param12_ttest_table is not None:
                ttest_replace_dict = {'<PARAMETER1>': param1_name,
                                      '<UNIT1>': param1_unit,
                                      '<PARAMETER2>': param2_name,
                                      '<UNIT2>': param2_unit,
                                      '<TABLE>': latex_table(session_summary.param12_ttest_table, hlines=False)
                                      }
                param12_ttest_table = TextTemplateUtils.replace_template_to_string(tex_ttest_table2_template, ttest_replace_dict)
                n_ttest_tables += 1

            conditional_clearpage = '\\clearpage\n' if n_ttest_tables>0 else ''

            replace_dict = {'<SESS_NUM>': session_summary.sess_num,
                            '<PLOT_FILE>': self.pipeline.experiment + '-' + self.pipeline.subject + '-report_plot_' + session_summary.name + '.pdf',
                            '<STIMTAG>': session_summary.stimtag,
                            '<REGION>': session_summary.region_of_interest,
                            '<CONSTANT_NAME>': const_param_name,
                            '<CONSTANT_VALUE>': session_summary.const_param_value,
                            '<CONSTANT_UNIT>': const_unit,
                            '<ISI_MID>': session_summary.isi_mid,
                            '<ISI_HALF_RANGE>': session_summary.isi_half_range,
                            '<PARAMETER1>': param1_name,
                            '<PARAMETER2>': param2_name,
                            '<FVALUE1>': '%.2f' % session_summary.anova_fvalues[0],
                            '<FVALUE2>': '%.2f' % session_summary.anova_fvalues[1],
                            '<FVALUE12>': '%.2f' % session_summary.anova_fvalues[2],
                            '<PVALUE1>': pvalue_formatting(session_summary.anova_pvalues[0]),
                            '<PVALUE2>': pvalue_formatting(session_summary.anova_pvalues[1]),
                            '<PVALUE12>': pvalue_formatting(session_summary.anova_pvalues[2]),
                            '<PARAM1_TTEST_TABLE>': param1_ttest_table,
                            '<PARAM2_TTEST_TABLE>': param2_ttest_table,
                            '<PARAM12_TTEST_TABLE>': param12_ttest_table,
                            'CONDITIONAL_CLEARPAGE': conditional_clearpage
                            }

            tex_session_pages_str += TextTemplateUtils.replace_template_to_string(tex_session_template, replace_dict)
            tex_session_pages_str += '\n'


        session_data_tex_table = latex_table(self.get_passed_object('SESSION_DATA'))

        xval_output = self.get_passed_object('xval_output')
        perm_test_pvalue = self.get_passed_object('pvalue')

        param1_ttest_table = ''
        if cumulative_param1_ttest_table is not None:
            ttest_replace_dict = {'<PARAMETER>': param1_name,
                                  '<UNIT>': param1_unit,
                                  '<TABLE>': latex_table(cumulative_param1_ttest_table, hlines=False)
                                 }
            param1_ttest_table = TextTemplateUtils.replace_template_to_string(tex_ttest_table1_template, ttest_replace_dict)

        param2_ttest_table = ''
        if cumulative_param2_ttest_table is not None:
            ttest_replace_dict = {'<PARAMETER>': param2_name,
                                  '<UNIT>': param2_unit,
                                  '<TABLE>': latex_table(cumulative_param2_ttest_table, hlines=False)
                                  }
            param2_ttest_table = TextTemplateUtils.replace_template_to_string(tex_ttest_table1_template, ttest_replace_dict)

        param12_ttest_table = ''
        if cumulative_param12_ttest_table is not None:
            ttest_replace_dict = {'<PARAMETER1>': param1_name,
                                  '<UNIT1>': param1_unit,
                                  '<PARAMETER2>': param2_name,
                                  '<UNIT2>': param2_unit,
                                  '<TABLE>': latex_table(cumulative_param12_ttest_table, hlines=False)
                                  }
            param12_ttest_table = TextTemplateUtils.replace_template_to_string(tex_ttest_table2_template, ttest_replace_dict)

        replace_dict = {
            '<SUBJECT>': self.pipeline.subject.replace('_', '\\textunderscore'),
            '<EXPERIMENT>': self.pipeline.experiment,
            '<DATE>': datetime.date.today(),
            '<SESSION_DATA>': session_data_tex_table,
            '<NUMBER_OF_SESSIONS>': self.get_passed_object('NUMBER_OF_SESSIONS'),
            '<NUMBER_OF_ELECTRODES>': self.get_passed_object('NUMBER_OF_ELECTRODES'),
            '<REPORT_PAGES>': tex_session_pages_str,
            '<CUMULATIVE_ISI_MID>': self.get_passed_object('CUMULATIVE_ISI_MID'),
            '<CUMULATIVE_ISI_HALF_RANGE>': self.get_passed_object('CUMULATIVE_ISI_HALF_RANGE'),
            '<CUMULATIVE_PLOT_FILE>': self.pipeline.experiment + '-' + self.pipeline.subject + '-report_plot_Cumulative.pdf',
            '<CUMULATIVE_PARAMETER1>': param1_name,
            '<CUMULATIVE_PARAMETER2>': param2_name,
            '<CUMULATIVE_FVALUE1>': '%.2f' % cumulative_anova_fvalues[0],
            '<CUMULATIVE_FVALUE2>': '%.2f' % cumulative_anova_fvalues[1],
            '<CUMULATIVE_FVALUE12>': '%.2f' % cumulative_anova_fvalues[2],
            '<CUMULATIVE_PVALUE1>': pvalue_formatting(cumulative_anova_pvalues[0]),
            '<CUMULATIVE_PVALUE2>': pvalue_formatting(cumulative_anova_pvalues[1]),
            '<CUMULATIVE_PVALUE12>': pvalue_formatting(cumulative_anova_pvalues[2]),
            '<CUMULATIVE_PARAM1_TTEST_TABLE>': param1_ttest_table,
            '<CUMULATIVE_PARAM2_TTEST_TABLE>': param2_ttest_table,
            '<CUMULATIVE_PARAM12_TTEST_TABLE>': param12_ttest_table,
            '<AUC>': '%.2f' % (100*xval_output[-1].auc),
            '<PERM-P-VALUE>': pvalue_formatting(perm_test_pvalue),
            '<J-THRESH>': '%.3f' % xval_output[-1].jstat_thresh,
            '<ROC_AND_TERC_PLOT_FILE>': self.pipeline.subject + '-roc_and_terc_plot_combined.pdf'
        }

        TextTemplateUtils.replace_template(template_file_name=tex_template, out_file_name=report_tex_file_name, replace_dict=replace_dict)
Exemplo n.º 6
0
    def run(self):
        subject = self.pipeline.subject
        task = self.pipeline.task

        tex_session_template = task + '_session.tex.tpl'

        n_sess = self.get_passed_object('NUMBER_OF_SESSIONS')
        n_bps = self.get_passed_object('NUMBER_OF_ELECTRODES')

        session_summary_array = self.get_passed_object('session_summary_array')
        session_ttest_data = self.get_passed_object('session_ttest_data')

        ttable_format = self.get_passed_object('ttable_format')
        ttable_header = self.get_passed_object('ttable_header')

        report_tex_file_names = []
        for i_sess in xrange(n_sess):
            session_summary = session_summary_array[i_sess]
            sess = session_summary.number
            report_tex_file_name = '%s-%s-s%02d-report.tex' % (task, subject,
                                                               sess)
            report_tex_file_names.append(report_tex_file_name)

            self.set_file_resources_to_move(report_tex_file_name,
                                            dst='reports')

            session_ttest_tex_table = latex_table(session_ttest_data[i_sess])

            replace_dict = {
                '<PROB_RECALL_PLOT_FILE>':
                self.pipeline.task + '-' + self.pipeline.subject +
                '-prob_recall_plot_' + session_summary.name + '.pdf',
                '<IRT_PLOT_FILE>':
                self.pipeline.task + '-' + self.pipeline.subject +
                '-irt_plot_' + session_summary.name + '.pdf',
                '<DATE>':
                datetime.date.today(),
                '<SUBJECT>':
                subject.replace('_', '\\textunderscore'),
                '<NUMBER_OF_ELECTRODES>':
                n_bps,
                '<SESSION_NUMBER>':
                sess,
                '<SESSION_DATE>':
                session_summary.date,
                '<SESSION_LENGTH>':
                session_summary.length,
                '<N_WORDS>':
                session_summary.n_words,
                '<N_CORRECT_WORDS>':
                session_summary.n_correct_words,
                '<PC_CORRECT_WORDS>':
                '%.2f' % session_summary.pc_correct_words,
                '<N_PLI>':
                session_summary.n_pli,
                '<PC_PLI>':
                '%.2f' % session_summary.pc_pli,
                '<N_ELI>':
                session_summary.n_eli,
                '<PC_ELI>':
                '%.2f' % session_summary.pc_eli,
                '<N_MATH>':
                session_summary.n_math,
                '<N_CORRECT_MATH>':
                session_summary.n_correct_math,
                '<PC_CORRECT_MATH>':
                '%.2f' % session_summary.pc_correct_math,
                '<MATH_PER_LIST>':
                '%.2f' % session_summary.math_per_list,
                '<TABLE_FORMAT>':
                ttable_format,
                '<TABLE_HEADER>':
                ttable_header,
                '<SIGNIFICANT_ELECTRODES>':
                session_ttest_tex_table,
                '<AUC>':
                session_summary.auc,
                '<ROC_AND_TERC_PLOT_FILE>':
                self.pipeline.task + '-' + self.pipeline.subject +
                '-roc_and_terc_plot_' + session_summary.name + '.pdf'
            }

            TextTemplateUtils.replace_template(
                template_file_name=tex_session_template,
                out_file_name=report_tex_file_name,
                replace_dict=replace_dict)

        self.pass_object('report_tex_file_names', report_tex_file_names)

        tex_combined_template = task + '_combined.tex.tpl'
        combined_report_tex_file_name = '%s-%s-combined-report.tex' % (task,
                                                                       subject)

        self.set_file_resources_to_move(combined_report_tex_file_name,
                                        dst='reports')

        cumulative_summary = self.get_passed_object('cumulative_summary')

        cumulative_data_tex_table = latex_table(
            self.get_passed_object('SESSION_DATA'))

        cumulative_ttest_tex_table = latex_table(
            self.get_passed_object('cumulative_ttest_data'))

        replace_dict = {
            '<PROB_RECALL_PLOT_FILE>':
            self.pipeline.task + '-' + self.pipeline.subject +
            '-prob_recall_plot_combined.pdf',
            '<IRT_PLOT_FILE>':
            self.pipeline.task + '-' + self.pipeline.subject +
            '-irt_plot_combined.pdf',
            '<DATE>':
            datetime.date.today(),
            '<SESSION_DATA>':
            cumulative_data_tex_table,
            '<SUBJECT>':
            subject.replace('_', '\\textunderscore'),
            '<NUMBER_OF_SESSIONS>':
            n_sess,
            '<NUMBER_OF_ELECTRODES>':
            n_bps,
            '<N_WORDS>':
            cumulative_summary.n_words,
            '<N_CORRECT_WORDS>':
            cumulative_summary.n_correct_words,
            '<PC_CORRECT_WORDS>':
            '%.2f' % cumulative_summary.pc_correct_words,
            '<N_PLI>':
            cumulative_summary.n_pli,
            '<PC_PLI>':
            '%.2f' % cumulative_summary.pc_pli,
            '<N_ELI>':
            cumulative_summary.n_eli,
            '<PC_ELI>':
            '%.2f' % cumulative_summary.pc_eli,
            '<N_MATH>':
            cumulative_summary.n_math,
            '<N_CORRECT_MATH>':
            cumulative_summary.n_correct_math,
            '<PC_CORRECT_MATH>':
            '%.2f' % cumulative_summary.pc_correct_math,
            '<MATH_PER_LIST>':
            '%.2f' % cumulative_summary.math_per_list,
            '<TABLE_FORMAT>':
            ttable_format,
            '<TABLE_HEADER>':
            ttable_header,
            '<SIGNIFICANT_ELECTRODES>':
            cumulative_ttest_tex_table,
            '<AUC>':
            cumulative_summary.auc,
            '<PERM-P-VALUE>':
            cumulative_summary.perm_test_pvalue,
            '<J-THRESH>':
            cumulative_summary.jstat_thresh,
            '<J-PERC>':
            cumulative_summary.jstat_percentile,
            '<ROC_AND_TERC_PLOT_FILE>':
            self.pipeline.task + '-' + self.pipeline.subject +
            '-roc_and_terc_plot_combined.pdf'
        }

        TextTemplateUtils.replace_template(
            template_file_name=tex_combined_template,
            out_file_name=combined_report_tex_file_name,
            replace_dict=replace_dict)

        self.pass_object('combined_report_tex_file_name',
                         combined_report_tex_file_name)
Exemplo n.º 7
0
    def run(self):
        subject = self.pipeline.subject
        task = self.pipeline.task

        tex_session_template = task + "_session.tex.tpl"

        n_sess = self.get_passed_object("NUMBER_OF_SESSIONS")
        n_bps = self.get_passed_object("NUMBER_OF_ELECTRODES")

        session_summary_array = self.get_passed_object("session_summary_array")

        report_tex_file_names = []
        for i_sess in xrange(n_sess):
            session_summary = session_summary_array[i_sess]
            sess = session_summary.number
            report_tex_file_name = "%s-%s-s%02d-report.tex" % (task, subject, sess)
            report_tex_file_names.append(report_tex_file_name)

            self.set_file_resources_to_move(report_tex_file_name, dst="reports")

            replace_dict = {
                "<PROB_RECALL_PLOT_FILE>": self.pipeline.task
                + "-"
                + self.pipeline.subject
                + "-prob_recall_plot_"
                + session_summary.name
                + ".pdf",
                "<STIM_AND_RECALL_PLOT_FILE>": self.pipeline.task
                + "-"
                + self.pipeline.subject
                + "-stim_and_recall_plot_"
                + session_summary.name
                + ".pdf",
                "<IRT_PLOT_FILE>": self.pipeline.task
                + "-"
                + self.pipeline.subject
                + "-irt_plot_"
                + session_summary.name
                + ".pdf",
                "<DATE>": datetime.date.today(),
                "<SUBJECT>": subject.replace("_", "\\textunderscore"),
                "<NUMBER_OF_ELECTRODES>": n_bps,
                "<SESSION_NUMBER>": sess,
                "<SESSION_DATE>": session_summary.date,
                "<SESSION_LENGTH>": session_summary.length,
                "<N_WORDS>": session_summary.n_words,
                "<N_CORRECT_WORDS>": session_summary.n_correct_words,
                "<PC_CORRECT_WORDS>": "%.2f" % session_summary.pc_correct_words,
                "<N_PLI>": session_summary.n_pli,
                "<PC_PLI>": "%.2f" % session_summary.pc_pli,
                "<N_ELI>": session_summary.n_eli,
                "<PC_ELI>": "%.2f" % session_summary.pc_eli,
                "<N_MATH>": session_summary.n_math,
                "<N_CORRECT_MATH>": session_summary.n_correct_math,
                "<PC_CORRECT_MATH>": "%.2f" % session_summary.pc_correct_math,
                "<MATH_PER_LIST>": "%.2f" % session_summary.math_per_list,
                "<N_CORRECT_STIM>": session_summary.n_correct_stim,
                "<N_TOTAL_STIM>": session_summary.n_total_stim,
                "<PC_FROM_STIM>": "%.2f" % session_summary.pc_from_stim,
                "<N_CORRECT_NONSTIM>": session_summary.n_correct_nonstim,
                "<N_TOTAL_NONSTIM>": session_summary.n_total_nonstim,
                "<PC_FROM_NONSTIM>": "%.2f" % session_summary.pc_from_nonstim,
                "<CHISQR>": "%.2f" % session_summary.chisqr,
                "<PVALUE>": "%.2f" % session_summary.pvalue,
                "<N_STIM_INTR>": session_summary.n_stim_intr,
                "<PC_FROM_STIM_INTR>": "%.2f" % session_summary.pc_from_stim_intr,
                "<N_NONSTIM_INTR>": session_summary.n_nonstim_intr,
                "<PC_FROM_NONSTIM_INTR>": "%.2f" % session_summary.pc_from_nonstim_intr,
                "<CHISQR_INTR>": "%.2f" % session_summary.chisqr_intr,
                "<PVALUE_INTR>": "%.2f" % session_summary.pvalue_intr,
            }

            TextTemplateUtils.replace_template(
                template_file_name=tex_session_template, out_file_name=report_tex_file_name, replace_dict=replace_dict
            )

        self.pass_object("report_tex_file_names", report_tex_file_names)

        tex_combined_template = task + "_combined.tex.tpl"
        combined_report_tex_file_name = "%s-%s-combined-report.tex" % (task, subject)

        self.set_file_resources_to_move(combined_report_tex_file_name, dst="reports")

        cumulative_summary = self.get_passed_object("cumulative_summary")

        cumulative_data_tex_table = latex_table(self.get_passed_object("SESSION_DATA"))

        replace_dict = {
            "<PROB_RECALL_PLOT_FILE>": self.pipeline.task
            + "-"
            + self.pipeline.subject
            + "-prob_recall_plot_combined.pdf",
            "<IRT_PLOT_FILE>": self.pipeline.task + "-" + self.pipeline.subject + "-irt_plot_combined.pdf",
            "<DATE>": datetime.date.today(),
            "<SESSION_DATA>": cumulative_data_tex_table,
            "<SUBJECT>": subject.replace("_", "\\textunderscore"),
            "<NUMBER_OF_SESSIONS>": n_sess,
            "<NUMBER_OF_ELECTRODES>": n_bps,
            "<N_WORDS>": cumulative_summary.n_words,
            "<N_CORRECT_WORDS>": cumulative_summary.n_correct_words,
            "<PC_CORRECT_WORDS>": "%.2f" % cumulative_summary.pc_correct_words,
            "<N_PLI>": cumulative_summary.n_pli,
            "<PC_PLI>": "%.2f" % cumulative_summary.pc_pli,
            "<N_ELI>": cumulative_summary.n_eli,
            "<PC_ELI>": "%.2f" % cumulative_summary.pc_eli,
            "<N_MATH>": cumulative_summary.n_math,
            "<N_CORRECT_MATH>": cumulative_summary.n_correct_math,
            "<PC_CORRECT_MATH>": "%.2f" % cumulative_summary.pc_correct_math,
            "<MATH_PER_LIST>": "%.2f" % cumulative_summary.math_per_list,
            "<N_CORRECT_STIM>": cumulative_summary.n_correct_stim,
            "<N_TOTAL_STIM>": cumulative_summary.n_total_stim,
            "<PC_FROM_STIM>": "%.2f" % cumulative_summary.pc_from_stim,
            "<N_CORRECT_NONSTIM>": cumulative_summary.n_correct_nonstim,
            "<N_TOTAL_NONSTIM>": cumulative_summary.n_total_nonstim,
            "<PC_FROM_NONSTIM>": "%.2f" % cumulative_summary.pc_from_nonstim,
            "<CHISQR>": "%.2f" % cumulative_summary.chisqr,
            "<PVALUE>": "%.2f" % cumulative_summary.pvalue,
            "<N_STIM_INTR>": cumulative_summary.n_stim_intr,
            "<PC_FROM_STIM_INTR>": "%.2f" % cumulative_summary.pc_from_stim_intr,
            "<N_NONSTIM_INTR>": cumulative_summary.n_nonstim_intr,
            "<PC_FROM_NONSTIM_INTR>": "%.2f" % cumulative_summary.pc_from_nonstim_intr,
            "<CHISQR_INTR>": "%.2f" % cumulative_summary.chisqr_intr,
            "<PVALUE_INTR>": "%.2f" % cumulative_summary.pvalue_intr,
        }

        TextTemplateUtils.replace_template(
            template_file_name=tex_combined_template,
            out_file_name=combined_report_tex_file_name,
            replace_dict=replace_dict,
        )

        self.pass_object("combined_report_tex_file_name", combined_report_tex_file_name)
Exemplo n.º 8
0
    def run(self):
        tex_template = 'ps_report.tex.tpl'
        tex_session_template = 'ps_session.tex.tpl'
        tex_ttest_table1_template = 'ttest_table1.tex.tpl'
        tex_ttest_table2_template = 'ttest_table2.tex.tpl'

        report_tex_file_name = self.pipeline.experiment + '-' + self.pipeline.subject + '-' + 'report.tex'
        self.pass_object('report_tex_file_name', report_tex_file_name)

        self.set_file_resources_to_move(report_tex_file_name, dst='reports')

        param1_name = self.get_passed_object('param1_name')
        param1_unit = self.get_passed_object('param1_unit')

        param2_name = self.get_passed_object('param2_name')
        param2_unit = self.get_passed_object('param2_unit')

        const_param_name = self.get_passed_object('const_param_name')
        const_unit = self.get_passed_object('const_unit')

        cumulative_anova_fvalues = self.get_passed_object(
            'CUMULATIVE_ANOVA_FVALUES')
        cumulative_anova_pvalues = self.get_passed_object(
            'CUMULATIVE_ANOVA_PVALUES')

        cumulative_param1_ttest_table = self.get_passed_object(
            'CUMULATIVE_PARAM1_TTEST_TABLE')
        cumulative_param2_ttest_table = self.get_passed_object(
            'CUMULATIVE_PARAM2_TTEST_TABLE')
        cumulative_param12_ttest_table = self.get_passed_object(
            'CUMULATIVE_PARAM12_TTEST_TABLE')

        session_summary_array = self.get_passed_object('session_summary_array')

        tex_session_pages_str = ''

        for session_summary in session_summary_array:
            n_ttest_tables = 0

            param1_ttest_table = ''
            if session_summary.param1_ttest_table is not None:
                ttest_replace_dict = {
                    '<PARAMETER>':
                    param1_name,
                    '<UNIT>':
                    param1_unit,
                    '<TABLE>':
                    latex_table(session_summary.param1_ttest_table,
                                hlines=False)
                }
                param1_ttest_table = TextTemplateUtils.replace_template_to_string(
                    tex_ttest_table1_template, ttest_replace_dict)
                n_ttest_tables += 1

            param2_ttest_table = ''
            if session_summary.param2_ttest_table is not None:
                ttest_replace_dict = {
                    '<PARAMETER>':
                    param2_name,
                    '<UNIT>':
                    param2_unit,
                    '<TABLE>':
                    latex_table(session_summary.param2_ttest_table,
                                hlines=False)
                }
                param2_ttest_table = TextTemplateUtils.replace_template_to_string(
                    tex_ttest_table1_template, ttest_replace_dict)
                n_ttest_tables += 1

            param12_ttest_table = ''
            if session_summary.param12_ttest_table is not None:
                ttest_replace_dict = {
                    '<PARAMETER1>':
                    param1_name,
                    '<UNIT1>':
                    param1_unit,
                    '<PARAMETER2>':
                    param2_name,
                    '<UNIT2>':
                    param2_unit,
                    '<TABLE>':
                    latex_table(session_summary.param12_ttest_table,
                                hlines=False)
                }
                param12_ttest_table = TextTemplateUtils.replace_template_to_string(
                    tex_ttest_table2_template, ttest_replace_dict)
                n_ttest_tables += 1

            conditional_clearpage = '\\clearpage\n' if n_ttest_tables > 0 else ''

            replace_dict = {
                '<SESS_NUM>':
                session_summary.sess_num,
                '<PLOT_FILE>':
                self.pipeline.experiment + '-' + self.pipeline.subject +
                '-report_plot_' + session_summary.name + '.pdf',
                '<STIMTAG>':
                session_summary.stimtag,
                '<REGION>':
                session_summary.region_of_interest,
                '<CONSTANT_NAME>':
                const_param_name,
                '<CONSTANT_VALUE>':
                session_summary.const_param_value,
                '<CONSTANT_UNIT>':
                const_unit,
                '<ISI_MID>':
                session_summary.isi_mid,
                '<ISI_HALF_RANGE>':
                session_summary.isi_half_range,
                '<PARAMETER1>':
                param1_name,
                '<PARAMETER2>':
                param2_name,
                '<FVALUE1>':
                '%.2f' % session_summary.anova_fvalues[0],
                '<FVALUE2>':
                '%.2f' % session_summary.anova_fvalues[1],
                '<FVALUE12>':
                '%.2f' % session_summary.anova_fvalues[2],
                '<PVALUE1>':
                pvalue_formatting(session_summary.anova_pvalues[0]),
                '<PVALUE2>':
                pvalue_formatting(session_summary.anova_pvalues[1]),
                '<PVALUE12>':
                pvalue_formatting(session_summary.anova_pvalues[2]),
                '<PARAM1_TTEST_TABLE>':
                param1_ttest_table,
                '<PARAM2_TTEST_TABLE>':
                param2_ttest_table,
                '<PARAM12_TTEST_TABLE>':
                param12_ttest_table,
                'CONDITIONAL_CLEARPAGE':
                conditional_clearpage
            }

            tex_session_pages_str += TextTemplateUtils.replace_template_to_string(
                tex_session_template, replace_dict)
            tex_session_pages_str += '\n'

        session_data_tex_table = latex_table(
            self.get_passed_object('SESSION_DATA'))

        xval_output = self.get_passed_object('xval_output')
        perm_test_pvalue = self.get_passed_object('pvalue')

        param1_ttest_table = ''
        if cumulative_param1_ttest_table is not None:
            ttest_replace_dict = {
                '<PARAMETER>': param1_name,
                '<UNIT>': param1_unit,
                '<TABLE>': latex_table(cumulative_param1_ttest_table,
                                       hlines=False)
            }
            param1_ttest_table = TextTemplateUtils.replace_template_to_string(
                tex_ttest_table1_template, ttest_replace_dict)

        param2_ttest_table = ''
        if cumulative_param2_ttest_table is not None:
            ttest_replace_dict = {
                '<PARAMETER>': param2_name,
                '<UNIT>': param2_unit,
                '<TABLE>': latex_table(cumulative_param2_ttest_table,
                                       hlines=False)
            }
            param2_ttest_table = TextTemplateUtils.replace_template_to_string(
                tex_ttest_table1_template, ttest_replace_dict)

        param12_ttest_table = ''
        if cumulative_param12_ttest_table is not None:
            ttest_replace_dict = {
                '<PARAMETER1>':
                param1_name,
                '<UNIT1>':
                param1_unit,
                '<PARAMETER2>':
                param2_name,
                '<UNIT2>':
                param2_unit,
                '<TABLE>':
                latex_table(cumulative_param12_ttest_table, hlines=False)
            }
            param12_ttest_table = TextTemplateUtils.replace_template_to_string(
                tex_ttest_table2_template, ttest_replace_dict)

        replace_dict = {
            '<SUBJECT>':
            self.pipeline.subject.replace('_', '\\textunderscore'),
            '<EXPERIMENT>':
            self.pipeline.experiment,
            '<DATE>':
            datetime.date.today(),
            '<SESSION_DATA>':
            session_data_tex_table,
            '<NUMBER_OF_SESSIONS>':
            self.get_passed_object('NUMBER_OF_SESSIONS'),
            '<NUMBER_OF_ELECTRODES>':
            self.get_passed_object('NUMBER_OF_ELECTRODES'),
            '<REPORT_PAGES>':
            tex_session_pages_str,
            '<CUMULATIVE_ISI_MID>':
            self.get_passed_object('CUMULATIVE_ISI_MID'),
            '<CUMULATIVE_ISI_HALF_RANGE>':
            self.get_passed_object('CUMULATIVE_ISI_HALF_RANGE'),
            '<CUMULATIVE_PLOT_FILE>':
            self.pipeline.experiment + '-' + self.pipeline.subject +
            '-report_plot_Cumulative.pdf',
            '<CUMULATIVE_PARAMETER1>':
            param1_name,
            '<CUMULATIVE_PARAMETER2>':
            param2_name,
            '<CUMULATIVE_FVALUE1>':
            '%.2f' % cumulative_anova_fvalues[0],
            '<CUMULATIVE_FVALUE2>':
            '%.2f' % cumulative_anova_fvalues[1],
            '<CUMULATIVE_FVALUE12>':
            '%.2f' % cumulative_anova_fvalues[2],
            '<CUMULATIVE_PVALUE1>':
            pvalue_formatting(cumulative_anova_pvalues[0]),
            '<CUMULATIVE_PVALUE2>':
            pvalue_formatting(cumulative_anova_pvalues[1]),
            '<CUMULATIVE_PVALUE12>':
            pvalue_formatting(cumulative_anova_pvalues[2]),
            '<CUMULATIVE_PARAM1_TTEST_TABLE>':
            param1_ttest_table,
            '<CUMULATIVE_PARAM2_TTEST_TABLE>':
            param2_ttest_table,
            '<CUMULATIVE_PARAM12_TTEST_TABLE>':
            param12_ttest_table,
            '<AUC>':
            '%.2f' % (100 * xval_output[-1].auc),
            '<PERM-P-VALUE>':
            pvalue_formatting(perm_test_pvalue),
            '<J-THRESH>':
            '%.3f' % xval_output[-1].jstat_thresh,
            '<ROC_AND_TERC_PLOT_FILE>':
            self.pipeline.subject + '-roc_and_terc_plot_combined.pdf'
        }

        TextTemplateUtils.replace_template(template_file_name=tex_template,
                                           out_file_name=report_tex_file_name,
                                           replace_dict=replace_dict)
Exemplo n.º 9
0
    def run(self):
        tex_template = 'ps_aggregator.tex.tpl'

        report_tex_file_name = 'ps_aggregator.tex'
        self.pass_object('report_tex_file_name',report_tex_file_name)

        self.set_file_resources_to_move(report_tex_file_name, dst='reports')

        region_total = self.get_passed_object('region_session_total')
        area_total = self.get_passed_object('area_session_total')

        region_total = sorted(zip(region_total.keys(), region_total.values()))
        region_total.append(('Total',sum([v[1] for v in region_total])))

        area_total = sorted(zip(area_total.keys(), area_total.values()))

        # fvalue_rf = self.get_passed_object('fvalue_rf')
        # pvalue_rf = self.get_passed_object('pvalue_rf')
        #
        # fvalue_ra_low = self.get_passed_object('fvalue_ra_low')
        # pvalue_ra_low = self.get_passed_object('pvalue_ra_low')
        #
        # fvalue_ra_high = self.get_passed_object('fvalue_ra_high')
        # pvalue_ra_high = self.get_passed_object('pvalue_ra_high')
        #
        # fvalue_rd_low = self.get_passed_object('fvalue_rd_low')
        # pvalue_rd_low = self.get_passed_object('pvalue_rd_low')
        #
        # fvalue_rd_high = self.get_passed_object('fvalue_rd_high')
        # pvalue_rd_high = self.get_passed_object('pvalue_rd_high')

        # replace_dict = {
        #     '<DATE>': datetime.date.today(),
        #     '<FREQUENCY_PLOT_FILE>': 'ps_frequency_aggregate_plots.pdf',
        #     '<FVALUERF1>': '%.2f' % fvalue_rf[0],
        #     '<FVALUERF2>': '%.2f' % fvalue_rf[1],
        #     '<FVALUERF12>': '%.2f' % fvalue_rf[2],
        #     '<PVALUERF1>': pvalue_formatting(pvalue_rf[0]),
        #     '<PVALUERF2>': pvalue_formatting(pvalue_rf[1]),
        #     '<PVALUERF12>': pvalue_formatting(pvalue_rf[2]),
        #     '<AMPLITUDE_LOW_PLOT_FILE>': 'ps_amplitude_low_aggregate_plots.pdf',
        #     '<FVALUERALOW1>': '%.2f' % fvalue_ra_low[0],
        #     '<FVALUERALOW2>': '%.2f' % fvalue_ra_low[1],
        #     '<FVALUERALOW12>': '%.2f' % fvalue_ra_low[2],
        #     '<PVALUERALOW1>': pvalue_formatting(pvalue_ra_low[0]),
        #     '<PVALUERALOW2>': pvalue_formatting(pvalue_ra_low[1]),
        #     '<PVALUERALOW12>': pvalue_formatting(pvalue_ra_low[2]),
        #     '<AMPLITUDE_HIGH_PLOT_FILE>': 'ps_amplitude_high_aggregate_plots.pdf',
        #     '<FVALUERAHIGH1>': '%.2f' % fvalue_ra_high[0],
        #     '<FVALUERAHIGH2>': '%.2f' % fvalue_ra_high[1],
        #     '<FVALUERAHIGH12>': '%.2f' % fvalue_ra_high[2],
        #     '<PVALUERAHIGH1>': pvalue_formatting(pvalue_ra_high[0]),
        #     '<PVALUERAHIGH2>': pvalue_formatting(pvalue_ra_high[1]),
        #     '<PVALUERAHIGH12>': pvalue_formatting(pvalue_ra_high[2]),
        #     '<DURATION_LOW_PLOT_FILE>': 'ps_duration_low_aggregate_plots.pdf',
        #     '<FVALUERDLOW1>': '%.2f' % fvalue_rd_low[0],
        #     '<FVALUERDLOW2>': '%.2f' % fvalue_rd_low[1],
        #     '<FVALUERDLOW12>': '%.2f' % fvalue_rd_low[2],
        #     '<PVALUERDLOW1>': pvalue_formatting(pvalue_rd_low[0]),
        #     '<PVALUERDLOW2>': pvalue_formatting(pvalue_rd_low[1]),
        #     '<PVALUERDLOW12>': pvalue_formatting(pvalue_rd_low[2]),
        #     '<DURATION_HIGH_PLOT_FILE>': 'ps_duration_high_aggregate_plots.pdf',
        #     '<FVALUERDHIGH1>': '%.2f' % fvalue_rd_high[0],
        #     '<FVALUERDHIGH2>': '%.2f' % fvalue_rd_high[1],
        #     '<FVALUERDHIGH12>': '%.2f' % fvalue_rd_high[2],
        #     '<PVALUERDHIGH1>': pvalue_formatting(pvalue_rd_high[0]),
        #     '<PVALUERDHIGH2>': pvalue_formatting(pvalue_rd_high[1]),
        #     '<PVALUERDHIGH12>': pvalue_formatting(pvalue_rd_high[2]),
        #     '<REGION_SESSION_TOTAL_DATA>': latex_table(region_total, hlines=False)
        # }

        replace_dict = {
            '<DATE>': datetime.date.today(),
            # '<FREQUENCY_PLOT_FILE>': 'ps_frequency_aggregate_plots.pdf',
            '<CENTRALIZED_FREQUENCY_PLOT_FILE>': 'ps_centralized_frequency_aggregate_plots.pdf',
            '<FREQUENCY_PROJECTION_PLOT_FILE>': 'ps_frequency_projection_plots.pdf',
            '<REGION_FREQUENCY_EXPERIMENT_COUNT_TABLE>': latex_table(self.get_passed_object('n_region_frequency_experiment')),
            '<FVALUERF1>': '%.2f' % np.nan,
            '<FVALUERF2>': '%.2f' % np.nan,
            '<FVALUERF12>': '%.2f' % np.nan,
            '<PVALUERF1>': pvalue_formatting(np.nan),
            '<PVALUERF2>': pvalue_formatting(np.nan),
            '<PVALUERF12>': pvalue_formatting(np.nan),
            '<AMPLITUDE_LOW_PLOT_FILE>': 'ps_amplitude_low_aggregate_plots.pdf',
            '<FVALUERALOW1>': '%.2f' % np.nan,
            '<FVALUERALOW2>': '%.2f' % np.nan,
            '<FVALUERALOW12>': '%.2f' % np.nan,
            '<PVALUERALOW1>': pvalue_formatting(np.nan),
            '<PVALUERALOW2>': pvalue_formatting(np.nan),
            '<PVALUERALOW12>': pvalue_formatting(np.nan),
            '<AMPLITUDE_HIGH_PLOT_FILE>': 'ps_amplitude_high_aggregate_plots.pdf',
            '<FVALUERAHIGH1>': '%.2f' % np.nan,
            '<FVALUERAHIGH2>': '%.2f' % np.nan,
            '<FVALUERAHIGH12>': '%.2f' % np.nan,
            '<PVALUERAHIGH1>': pvalue_formatting(np.nan),
            '<PVALUERAHIGH2>': pvalue_formatting(np.nan),
            '<PVALUERAHIGH12>': pvalue_formatting(np.nan),
            '<DURATION_LOW_PLOT_FILE>': 'ps_duration_low_aggregate_plots.pdf',
            '<FVALUERDLOW1>': '%.2f' % np.nan,
            '<FVALUERDLOW2>': '%.2f' % np.nan,
            '<FVALUERDLOW12>': '%.2f' % np.nan,
            '<PVALUERDLOW1>': pvalue_formatting(np.nan),
            '<PVALUERDLOW2>': pvalue_formatting(np.nan),
            '<PVALUERDLOW12>': pvalue_formatting(np.nan),
            '<DURATION_HIGH_PLOT_FILE>': 'ps_duration_high_aggregate_plots.pdf',
            '<FVALUERDHIGH1>': '%.2f' % np.nan,
            '<FVALUERDHIGH2>': '%.2f' % np.nan,
            '<FVALUERDHIGH12>': '%.2f' % np.nan,
            '<PVALUERDHIGH1>': pvalue_formatting(np.nan),
            '<PVALUERDHIGH2>': pvalue_formatting(np.nan),
            '<PVALUERDHIGH12>': pvalue_formatting(np.nan),
            '<REGION_SESSION_TOTAL_DATA>': latex_table(region_total, hlines=False)
        }

        TextTemplateUtils.replace_template(template_file_name=tex_template, out_file_name=report_tex_file_name, replace_dict=replace_dict)
Exemplo n.º 10
0
    def run(self):
        subject = self.pipeline.subject
        task = self.pipeline.task

        events = self.get_passed_object(task + '_events')

        tal_info = self.get_passed_object('tal_info')
        #channels = self.get_passed_object('channels')

        n_bps = len(tal_info)
        n_chs = 128  #len(channels)

        bpmat = np.zeros(shape=(n_chs, n_bps), dtype=np.float)
        for i,bp in enumerate(tal_info):
            e1, e2 = bp['channel_str']
            bpmat[int(e1)-1, i] = 1
            bpmat[int(e2)-1, i] = -1

        lr_classifier = self.get_passed_object('lr_classifier')
        xval_output = self.get_passed_object('xval_output')[-1]
        probs = xval_output.probs
        thresh = xval_output.jstat_thresh

        mat_filename = '%s_%s_%s.biomarker.mat' % (subject, datetime.date.today(), task)

        mdict = {'Bio': {'Subject': subject,
                         'Version': self.params.version,
                         'Sessions': np.unique(events.session),
                         'W': lr_classifier.coef_[0],
                         'W0': lr_classifier.intercept_[0],
                         'trainingProb': probs[:,None],
                         'thresh': thresh,
                         'bpmat': bpmat,
                         'freqs': self.params.freqs,
                         'fs': self.get_passed_object('samplerate'),
                         'StimParams': {'elec1': self.params.stim_params.elec1,
                                        'elec2': self.params.stim_params.elec2,
                                        'amplitude': self.params.stim_params.amplitude,
                                        'duration': self.params.stim_params.duration,
                                        'trainFrequency': self.params.stim_params.trainFrequency,
                                        'trainCount' : self.params.stim_params.trainCount,
                                        'pulseFrequency': self.params.stim_params.pulseFrequency,
                                        'pulseCount': self.params.stim_params.pulseCount},
                         'filename': mat_filename}}

        mat_filename_in_workspace = self.get_path_to_resource_in_workspace(mat_filename)
        savemat(mat_filename_in_workspace, mdict)

        replace_dict = {
            'load FILL_IN': 'load ' + mat_filename
        }

        #stat_accum_in_workspace = self.get_path_to_resource_in_workspace('StatAccum.m')
        #TextTemplateUtils.replace_template(template_file_name='StatAccum.m', out_file_name=stat_accum_in_workspace, replace_dict=replace_dict)

        stim_control_in_workspace = self.get_path_to_resource_in_workspace('StimControl.m')
        TextTemplateUtils.replace_template(template_file_name='StimControl.m', out_file_name=stim_control_in_workspace, replace_dict=replace_dict)

        self.biomarker_components += [stim_control_in_workspace, mat_filename_in_workspace]
        zip_list = ' '.join(self.biomarker_components)

        biomarker_filename_in_workspace = mat_filename_in_workspace[:-4]  # cutoff .mat

        print 'Zipping biomarker file', biomarker_filename_in_workspace

        zip_command_str = 'zip -9 -j %s %s' % (biomarker_filename_in_workspace, zip_list)

        call([zip_command_str], shell=True)
Exemplo n.º 11
0
    def run(self):
        subject = self.pipeline.subject
        task = self.pipeline.task

        tex_session_template = task + '_session.tex.tpl'

        n_sess = self.get_passed_object('NUMBER_OF_SESSIONS')
        n_bps = self.get_passed_object('NUMBER_OF_ELECTRODES')

        session_summary_array = self.get_passed_object('session_summary_array')
        session_ttest_data = self.get_passed_object('session_ttest_data')

        ttable_format = self.get_passed_object('ttable_format')
        ttable_header = self.get_passed_object('ttable_header')

        report_tex_file_names = []
        for i_sess in xrange(n_sess):
            session_summary = session_summary_array[i_sess]
            sess = session_summary.number
            report_tex_file_name = '%s-%s-s%02d-report.tex' % (task,subject,sess)
            report_tex_file_names.append(report_tex_file_name)

            self.set_file_resources_to_move(report_tex_file_name, dst='reports')

            session_ttest_tex_table = latex_table(session_ttest_data[i_sess])

            replace_dict = {'<PROB_RECALL_PLOT_FILE>': self.pipeline.task + '-' + self.pipeline.subject + '-prob_recall_plot_' + session_summary.name + '.pdf',
                            '<IRT_PLOT_FILE>': self.pipeline.task + '-' + self.pipeline.subject + '-irt_plot_' + session_summary.name + '.pdf',
                            '<DATE>': datetime.date.today(),
                            '<SUBJECT>': subject.replace('_','\\textunderscore'),
                            '<NUMBER_OF_ELECTRODES>': n_bps,
                            '<SESSION_NUMBER>': sess,
                            '<SESSION_DATE>': session_summary.date,
                            '<SESSION_LENGTH>': session_summary.length,
                            '<N_WORDS>': session_summary.n_words,
                            '<N_CORRECT_WORDS>': session_summary.n_correct_words,
                            '<PC_CORRECT_WORDS>': '%.2f' % session_summary.pc_correct_words,
                            '<N_PLI>': session_summary.n_pli,
                            '<PC_PLI>': '%.2f' % session_summary.pc_pli,
                            '<N_ELI>': session_summary.n_eli,
                            '<PC_ELI>': '%.2f' % session_summary.pc_eli,
                            '<N_MATH>': session_summary.n_math,
                            '<N_CORRECT_MATH>': session_summary.n_correct_math,
                            '<PC_CORRECT_MATH>': '%.2f' % session_summary.pc_correct_math,
                            '<MATH_PER_LIST>': '%.2f' % session_summary.math_per_list,
                            '<TABLE_FORMAT>': ttable_format,
                            '<TABLE_HEADER>': ttable_header,
                            '<SIGNIFICANT_ELECTRODES>': session_ttest_tex_table,
                            '<AUC>': session_summary.auc,
                            '<ROC_AND_TERC_PLOT_FILE>': self.pipeline.task + '-' + self.pipeline.subject + '-roc_and_terc_plot_' + session_summary.name + '.pdf'
                            }

            TextTemplateUtils.replace_template(template_file_name=tex_session_template, out_file_name=report_tex_file_name, replace_dict=replace_dict)

        self.pass_object('report_tex_file_names', report_tex_file_names)

        tex_combined_template = task + '_combined.tex.tpl'
        combined_report_tex_file_name = '%s-%s-combined-report.tex' % (task,subject)

        self.set_file_resources_to_move(combined_report_tex_file_name, dst='reports')

        cumulative_summary = self.get_passed_object('cumulative_summary')

        cumulative_data_tex_table = latex_table(self.get_passed_object('SESSION_DATA'))

        cumulative_ttest_tex_table = latex_table(self.get_passed_object('cumulative_ttest_data'))

        replace_dict = {'<PROB_RECALL_PLOT_FILE>': self.pipeline.task + '-' + self.pipeline.subject + '-prob_recall_plot_combined.pdf',
                        '<IRT_PLOT_FILE>': self.pipeline.task + '-' + self.pipeline.subject + '-irt_plot_combined.pdf',
                        '<DATE>': datetime.date.today(),
                        '<SESSION_DATA>': cumulative_data_tex_table,
                        '<SUBJECT>': subject.replace('_','\\textunderscore'),
                        '<NUMBER_OF_SESSIONS>': n_sess,
                        '<NUMBER_OF_ELECTRODES>': n_bps,
                        '<N_WORDS>': cumulative_summary.n_words,
                        '<N_CORRECT_WORDS>': cumulative_summary.n_correct_words,
                        '<PC_CORRECT_WORDS>': '%.2f' % cumulative_summary.pc_correct_words,
                        '<N_PLI>': cumulative_summary.n_pli,
                        '<PC_PLI>': '%.2f' % cumulative_summary.pc_pli,
                        '<N_ELI>': cumulative_summary.n_eli,
                        '<PC_ELI>': '%.2f' % cumulative_summary.pc_eli,
                        '<N_MATH>': cumulative_summary.n_math,
                        '<N_CORRECT_MATH>': cumulative_summary.n_correct_math,
                        '<PC_CORRECT_MATH>': '%.2f' % cumulative_summary.pc_correct_math,
                        '<MATH_PER_LIST>': '%.2f' % cumulative_summary.math_per_list,
                        '<TABLE_FORMAT>': ttable_format,
                        '<TABLE_HEADER>': ttable_header,
                        '<SIGNIFICANT_ELECTRODES>': cumulative_ttest_tex_table,
                        '<AUC>': cumulative_summary.auc,
                        '<PERM-P-VALUE>': cumulative_summary.perm_test_pvalue,
                        '<J-THRESH>': cumulative_summary.jstat_thresh,
                        '<J-PERC>': cumulative_summary.jstat_percentile,
                        '<ROC_AND_TERC_PLOT_FILE>': self.pipeline.task + '-' + self.pipeline.subject + '-roc_and_terc_plot_combined.pdf'
                        }

        TextTemplateUtils.replace_template(template_file_name=tex_combined_template, out_file_name=combined_report_tex_file_name, replace_dict=replace_dict)

        self.pass_object('combined_report_tex_file_name', combined_report_tex_file_name)
Exemplo n.º 12
0
    def run(self):
        subject = self.pipeline.subject
        task = self.pipeline.task

        tex_session_template = task + '_session.tex.tpl'

        n_sess = self.get_passed_object('NUMBER_OF_SESSIONS')
        n_bps = self.get_passed_object('NUMBER_OF_ELECTRODES')

        session_summary_array = self.get_passed_object('session_summary_array')

        report_tex_file_names = []
        for i_sess in xrange(n_sess):
            session_summary = session_summary_array[i_sess]
            sess = session_summary.number
            report_tex_file_name = '%s-%s-s%02d-report.tex' % (task,subject,sess)
            report_tex_file_names.append(report_tex_file_name)

            self.set_file_resources_to_move(report_tex_file_name, dst='reports')

            replace_dict = {'<PROB_RECALL_PLOT_FILE>': self.pipeline.task + '-' + self.pipeline.subject + '-prob_recall_plot_' + session_summary.name + '.pdf',
                            '<STIM_AND_RECALL_PLOT_FILE>': self.pipeline.task + '-' + self.pipeline.subject + '-stim_and_recall_plot_' + session_summary.name + '.pdf',
                            '<IRT_PLOT_FILE>': self.pipeline.task + '-' + self.pipeline.subject + '-irt_plot_' + session_summary.name + '.pdf',
                            '<DATE>': datetime.date.today(),
                            '<SUBJECT>': subject.replace('_','\\textunderscore'),
                            '<NUMBER_OF_ELECTRODES>': n_bps,
                            '<SESSION_NUMBER>': sess,
                            '<SESSION_DATE>': session_summary.date,
                            '<SESSION_LENGTH>': session_summary.length,
                            '<N_WORDS>': session_summary.n_words,
                            '<N_CORRECT_WORDS>': session_summary.n_correct_words,
                            '<PC_CORRECT_WORDS>': '%.2f' % session_summary.pc_correct_words,
                            '<N_PLI>': session_summary.n_pli,
                            '<PC_PLI>': '%.2f' % session_summary.pc_pli,
                            '<N_ELI>': session_summary.n_eli,
                            '<PC_ELI>': '%.2f' % session_summary.pc_eli,
                            '<N_MATH>': session_summary.n_math,
                            '<N_CORRECT_MATH>': session_summary.n_correct_math,
                            '<PC_CORRECT_MATH>': '%.2f' % session_summary.pc_correct_math,
                            '<MATH_PER_LIST>': '%.2f' % session_summary.math_per_list,
                            '<N_CORRECT_STIM>': session_summary.n_correct_stim,
                            '<N_TOTAL_STIM>': session_summary.n_total_stim,
                            '<PC_FROM_STIM>': '%.2f' % session_summary.pc_from_stim,
                            '<N_CORRECT_NONSTIM>': session_summary.n_correct_nonstim,
                            '<N_TOTAL_NONSTIM>': session_summary.n_total_nonstim,
                            '<PC_FROM_NONSTIM>': '%.2f' % session_summary.pc_from_nonstim,
                            '<CHISQR>': '%.2f' % session_summary.chisqr,
                            '<PVALUE>': '%.2f' % session_summary.pvalue,
                            '<N_STIM_INTR>': session_summary.n_stim_intr,
                            '<PC_FROM_STIM_INTR>': '%.2f' % session_summary.pc_from_stim_intr,
                            '<N_NONSTIM_INTR>': session_summary.n_nonstim_intr,
                            '<PC_FROM_NONSTIM_INTR>': '%.2f' % session_summary.pc_from_nonstim_intr,
                            '<CHISQR_INTR>': '%.2f' % session_summary.chisqr_intr,
                            '<PVALUE_INTR>': '%.2f' % session_summary.pvalue_intr
                            }

            TextTemplateUtils.replace_template(template_file_name=tex_session_template, out_file_name=report_tex_file_name, replace_dict=replace_dict)

        self.pass_object('report_tex_file_names', report_tex_file_names)

        tex_combined_template = task + '_combined.tex.tpl'
        combined_report_tex_file_name = '%s-%s-combined-report.tex' % (task,subject)

        self.set_file_resources_to_move(combined_report_tex_file_name, dst='reports')

        cumulative_summary = self.get_passed_object('cumulative_summary')

        cumulative_data_tex_table = latex_table(self.get_passed_object('SESSION_DATA'))

        replace_dict = {'<PROB_RECALL_PLOT_FILE>': self.pipeline.task + '-' + self.pipeline.subject + '-prob_recall_plot_combined.pdf',
                        '<IRT_PLOT_FILE>': self.pipeline.task + '-' + self.pipeline.subject + '-irt_plot_combined.pdf',
                        '<DATE>': datetime.date.today(),
                        '<SESSION_DATA>': cumulative_data_tex_table,
                        '<SUBJECT>': subject.replace('_','\\textunderscore'),
                        '<NUMBER_OF_SESSIONS>': n_sess,
                        '<NUMBER_OF_ELECTRODES>': n_bps,
                        '<N_WORDS>': cumulative_summary.n_words,
                        '<N_CORRECT_WORDS>': cumulative_summary.n_correct_words,
                        '<PC_CORRECT_WORDS>': '%.2f' % cumulative_summary.pc_correct_words,
                        '<N_PLI>': cumulative_summary.n_pli,
                        '<PC_PLI>': '%.2f' % cumulative_summary.pc_pli,
                        '<N_ELI>': cumulative_summary.n_eli,
                        '<PC_ELI>': '%.2f' % cumulative_summary.pc_eli,
                        '<N_MATH>': cumulative_summary.n_math,
                        '<N_CORRECT_MATH>': cumulative_summary.n_correct_math,
                        '<PC_CORRECT_MATH>': '%.2f' % cumulative_summary.pc_correct_math,
                        '<MATH_PER_LIST>': '%.2f' % cumulative_summary.math_per_list,
                        '<N_CORRECT_STIM>': cumulative_summary.n_correct_stim,
                        '<N_TOTAL_STIM>': cumulative_summary.n_total_stim,
                        '<PC_FROM_STIM>': '%.2f' % cumulative_summary.pc_from_stim,
                        '<N_CORRECT_NONSTIM>': cumulative_summary.n_correct_nonstim,
                        '<N_TOTAL_NONSTIM>': cumulative_summary.n_total_nonstim,
                        '<PC_FROM_NONSTIM>': '%.2f' % cumulative_summary.pc_from_nonstim,
                        '<CHISQR>': '%.2f' % cumulative_summary.chisqr,
                        '<PVALUE>': '%.2f' % cumulative_summary.pvalue,
                        '<N_STIM_INTR>': cumulative_summary.n_stim_intr,
                        '<PC_FROM_STIM_INTR>': '%.2f' % cumulative_summary.pc_from_stim_intr,
                        '<N_NONSTIM_INTR>': cumulative_summary.n_nonstim_intr,
                        '<PC_FROM_NONSTIM_INTR>': '%.2f' % cumulative_summary.pc_from_nonstim_intr,
                        '<CHISQR_INTR>': '%.2f' % cumulative_summary.chisqr_intr,
                        '<PVALUE_INTR>': '%.2f' % cumulative_summary.pvalue_intr
                        }

        TextTemplateUtils.replace_template(template_file_name=tex_combined_template, out_file_name=combined_report_tex_file_name, replace_dict=replace_dict)

        self.pass_object('combined_report_tex_file_name', combined_report_tex_file_name)