Ejemplo n.º 1
0
 def summary_table(cls, ):
     summary_data = []
     for ((modelsrc, celltype), functor) in sorted(cls._cells.iteritems()):
         summary_data.append((modelsrc, celltype))  # , functor.__file__)
     summary_table = mredoc.VerticalColTable(('Model', 'CellType'),
                                             summary_data)
     return mredoc.Section('Cell Library Summary', summary_table)
Ejemplo n.º 2
0
    def summarise_operators(cls):

        all_types = cls._get_all_operator_types()
        trace_types = cls._trace_types
        summary_matrix = empty_str_matrix(N=len(all_types) + 1,
                                          M=len(all_types) + 1)

        for (i, tp1) in enumerate(all_types):
            summary_matrix[0][i + 1] = tp1.__name__
            summary_matrix[i + 1][0] = tp1.__name__
            for (j, tp2) in enumerate(all_types):

                # Neither of the operand is a trace_type:
                if tp1 not in trace_types and tp2 not in trace_types:
                    summary_matrix[i + 1][j + 1] = '==='
                    continue

                for (op, sym) in operators:
                    if (op, tp1, tp2) in TraceOperatorCtrl.trace_operators_all:
                        summary_matrix[i + 1][j + 1] += sym

        return mrd.Section(
            'TraceOperators',
            mrd.VerticalColTable(summary_matrix[0],
                                 summary_matrix[1:],
                                 caption='Operators'))
Ejemplo n.º 3
0
 def _build_singlecell_overview_stimtable(self, stims):
     data = [(
         stim.name,
         stim.location_summary_str,
         stim.get_summary_description(),
     ) for stim in stims]
     tbl = mrd.VerticalColTable('Name|Location|Description', data)
     return tbl
Ejemplo n.º 4
0
 def build_comp_section(param):
     fig = figures[param]
     trcs = sorted( trace_comp_res[param] )
     comp_tbl_header, comp_tbl_data= zip( *[ ('%s.max_ptp' %c, trace_comp_res[param][c].max_ptp) for c in trcs])
     return mrd.Section('Parameters: %s' % str(param),
         mrd.VerticalColTable(comp_tbl_header, [comp_tbl_data] ),
         mrd.Figure( mrd.Image(fig, auto_adjust=False), caption='Comparison'),
         )
Ejemplo n.º 5
0
 def _create_neuron_details_2b_pta(self, nrn):
     passives = nrn.biophysics.get_applied_passives()
     return mrd.VerticalColTable('PassiveProp|Priority|Targetter|Value', [(
         pta.passiveproperty,
         pta.targetter.get_priority(),
         pta.targetter.get_description(),
         str(pta.value),
     ) for pta in passives],
                                 caption='%s:Passive Properties' % nrn.name)
Ejemplo n.º 6
0
 def _create_neuron_details_2_mta(self, nrn):
     mechs = nrn.biophysics.get_applied_mtas()
     return mrd.VerticalColTable('Mechanism|Priority|Targetter|Applicator',
                                 [(
                                     '%s ' % (mta.mechanism.name, ),
                                     mta.targetter.get_priority(),
                                     mta.targetter.get_description(),
                                     mta.applicator.get_description(),
                                 ) for mta in mechs],
                                 caption='%s:Channels' % nrn.name)
Ejemplo n.º 7
0
    def build_population_overview(self):

        if not self.sim.neuron_populations:
            return None

        table = mrd.VerticalColTable(
            "Population | Size | Type "
            "", [(pop.pop_name, len(pop), ",".join(pop.cell_types))
                 for pop in self.sim.neuron_populations])
        table2 = mrd.VerticalColTable(
            "Population | Size | Type "
            "", [(pop.synapse_pop_name, len(pop), ",".join(pop.synapse_types))
                 for pop in self.sim.synapse_populations])

        return mrd.Section(
            "Population Overview",
            table,
            table2,
            #self.build_population_overview_dot(),
            self.build_population_complete_dot())
Ejemplo n.º 8
0
 def summarise_channels(cls):
     mech_types = cls.get_all_chls()
     col1 = ['Channel Name'] + [mech.__name__ for mech in mech_types]
     cols = [[env._env_name] +
             [to_symbol(mech, env.channels) for mech in mech_types]
             for env in cls._environments]
     col_ = ['Summary'] + [
         to_symbol(mech, SummariserLibrary.summarisers)
         for mech in mech_types
     ]
     cols = [col1] + cols + [col_]
     rows = zip(*cols)
     return mrd.Section('Channels', mrd.VerticalColTable(rows[0], rows[1:]))
Ejemplo n.º 9
0
 def summarise_postsynapticmechs(cls):
     mech_types = cls.get_all_postsynmechs()
     col1 = ['PostSynMech'] + [mech.__name__ for mech in mech_types]
     cols = [[env._env_name] + [
         to_symbol(mech, env.postsynapticmechanisms) for mech in mech_types
     ] for env in cls._environments]
     col_ = ['Summary'] + [
         to_symbol(mech, SummariserLibrary.summarisers)
         for mech in mech_types
     ]
     cols = [col1] + cols + [col_]
     rows = zip(*cols)
     return mrd.Section('Postsynaptic Mechanisms',
                        mrd.VerticalColTable(rows[0], rows[1:]))
Ejemplo n.º 10
0
    def summarise_methods(cls):
        trace_types = cls._trace_types
        method_names = cls._get_all_trace_method_names()

        def get_argments(method, trace_type):
            if not TraceMethodCtrl.has_method(trace_type, method):
                return None
            functor = TraceMethodCtrl.get_method(trace_type, method)
            (args, varargs, varkw, defaults) = inspect.getargspec(functor)
            return inspect.formatargspec(args=args[1:],
                                         varargs=varargs,
                                         varkw=varkw,
                                         defaults=defaults)

        def get_argments_TraceFixedDT(method):
            return str(get_argments(method, TraceFixedDT))

        def get_docstring(method):
            trace_type = TraceFixedDT
            if not TraceMethodCtrl.has_method(trace_type, method):
                return '<None>'
            func = TraceMethodCtrl.get_method(trace_type, method)
            return inspect.getdoc(func)

        def _support_for_method(trace_type, method_name):
            if (trace_type, method_name) in TraceMethodCtrl.registered_methods:
                return 'X'
            if method_name in TraceMethodCtrl.fallback_to_fixedtrace_methods:
                return '<via fixed>'

        arguments = [
            get_argments_TraceFixedDT(method_name)
            for method_name in method_names
        ]
        docstrings = [
            get_docstring(method_name) for method_name in method_names
        ]

        col1 = [''] + method_names
        col2 = [[trace_type.__name__] + [
            _support_for_method(trace_type, method_name)
            for method_name in method_names
        ] for trace_type in trace_types]
        col_args = ['args'] + arguments
        col_docstrings = ['docstring'] + docstrings
        cols = [col1] + col2 + [col_args] + [col_docstrings]
        rows = zip(*cols)
        tbl = mrd.VerticalColTable(rows[0], rows[1:], caption='Operators')
        return mrd.Section('TraceMethods', tbl)
Ejemplo n.º 11
0
    def _create_neuron_details_1_morphology(self, nrn):
        morph = nrn.morphology
        section_indexer = SectionIndexerDF(morph)
        section_table = mrd.VerticalColTable(
            'ID|Tags|Lateral Surface Area (um2)|Region|nseg|L|diam (prox/dist)',
            [(section_indexer[sec], sec.idtag, '%.0f' % sec.area,
              (sec.region.name if sec.region else ''),
              nrn.cell_segmenter.get_num_segments(sec), sec.length,
              '%.1f/%.1f' % (sec.p_r * 2., sec.d_r * 2.)) for sec in morph],
            caption='%s:Morphology (Sections)' % nrn.name)

        region_table = mrd.VerticalColTable(
            'Region|Surface Area|\#Sections',
            [(rgn.name, rgn.surface_area, len(rgn))
             for rgn in nrn.morphology.regions],
            caption='%s:Morphology (Regions)' % nrn.name)

        from morphforge.morphology.ui import MatPlotLibViewer
        fig = MatPlotLibViewer(nrn.morphology, fig_kwargs={
            'figsize': (7, 7)
        }).fig

        return mrd.HierachyScope(section_table, region_table, mrd.Image(fig),
                                 'tada')
Ejemplo n.º 12
0
def check_scenarios(**kwargs):
    import waf_util
    scen_filenames = waf_util.get_all_scenarios()

    # Run the individual comparisons, and produce a section for
    # each:
    all_summary_results = []
    results_sections = []
    for tgt_scen in waf_util.get_target_scenarios():
        tgt_scen_fname = scen_filenames[tgt_scen]
        results_section, summary_results = check_scenario( tgt_scen_fname, **kwargs )
        results_sections.append(results_section)
        all_summary_results.extend(summary_results)
    sim_details =  mrd.Section('Simulation Details', *results_sections)


    # Produce an overall results table
    print 'Summary Results'
    for sum_res in all_summary_results:
        print sum_res


    sims = sorted( set( [ res.sim_name for res in all_summary_results] ) )
    scens = sorted( set( [ res.scen_name for res in all_summary_results]) )
    sim_scen_lut = dict([ ((res.sim_name, res.scen_name),res) for res in all_summary_results])

    def table_entry(scen,sim):
        key = (sim, scen)
        res = sim_scen_lut.get(key , None)
        #assert res is not None
        if res is None:
            return ":warning:[None Found]"
        prefix = ':success:' if not res.nmissing and not res.nfails else ''
        if res.nmissing:
            prefix = ':warning:'
        if res.nfails:
            prefix = ':err:'
        return prefix + res.summary_str()
        return str(res)

    header = [''] + sims
    res = [ ]
    for scen in scens:
        res.append( [scen] + [ table_entry(scen,sim) for sim in sims ] )

    overview_table = mrd.VerticalColTable( header, res)
    sim_overview = mrd.Section('Results Overview', overview_table )
    return (sim_details,sim_overview)
Ejemplo n.º 13
0
def test_trace_method_scalarout(src_trace, method_name, method_functor):

    res = []
    for (conv_type, conv_functor) in conversions:
        tr_new = conv_functor(src_trace)

        if not mf.TraceMethodCtrl.has_method(conv_type, method_name):
            res.append([conv_type.__name__, '--'])
            continue

        else:
            res_new = method_functor(tr_new)
            res.append([conv_type.__name__, str(res_new)])
        #ax2.plotTrace(method_functor(tr_new), label='%s:%s' % (conv_type.__name__, method_name) )

    print res
    (header, data) = zip(*res)
    print 'header', header
    print 'data', data
    return mrd.Section('Tesing Method: %s' % method_name,
                       mrd.VerticalColTable(header, [data]))
Ejemplo n.º 14
0
def build_mredoc_results_table(impl, validators, table_results, missing_parameter_sets, expected_variables):
        import mredoc as mrd

        output_cols = set(itertools.chain(*[[v.test_expr for v in V] for V in validators.values()]))
        input_cols = sorted(expected_variables)
        output_cols = sorted(output_cols)

        tbl_res = []
        for param in sorted(validators.keys()):
            in_vals = [ str(getattr(param,c)) for c in input_cols]
            out_vals = []
            for output_col_index, output_col in enumerate(output_cols):
                key = (impl, param, output_col)
                if key in table_results:
                    R = table_results[key]

                    prefix = ''
                    if table_results[key][0]:
                        prefix=':success:'
                        res = 'OK %f (%s [eps:%s])' % ( R[2],R[3].expected_value, R[3].eps  )
                    else:
                        prefix=':err:'
                        res = '***ERROR %f (%s [eps:%s]) ***' % ( R[2],R[3].expected_value, R[3].eps  )
                else:

                    prefix = ''
                    if (impl,param) in missing_parameter_sets:
                        prefix=':warning:'
                        res = ' *** MISSING! *** '
                    else:
                        res = '-'
                out_vals.append(prefix + str(res))

            tbl_res.append(in_vals+out_vals)


        headers = input_cols + output_cols

        res_tbl = mrd.VerticalColTable( headers, tbl_res,caption='Results for: %s' % impl,)
        return res_tbl
Ejemplo n.º 15
0
    def _build_cell_table(cls, cell_list):

        table = mrd.VerticalColTable(
            'Name|Type|SA(um2)|\#sections/segments|Regions(SA(um2):nseg)|\#Pre/Post-Synapse|\#GapJunctions|Chls',
            [(
                cell.name,
                cell.cell_type_str,
                "%.0f" % (cell.morphology.surface_area),
                "%d:%d" %
                (len(cell.morphology), cell.segmenter.get_num_segment_total()),
                " ".join([
                    "%s(%d:%d)" % (rgn.name, rgn.surface_area,
                                   cell.segmenter.get_num_segment_region(rgn))
                    for rgn in cell.morphology.regions
                ]),
                "%d %d" % (len(cell.presynaptic_connections),
                           len(cell.postsynaptic_connections)),
                "%d" % len(cell.electrical_connections),
                " ".join([chl.name for chl in cell.biophysics.get_channels()]),
            ) for cell in cell_list])

        return table
Ejemplo n.º 16
0
 def _create_neuron_details_4_stimulation(self, nrn):
     return mrd.VerticalColTable('Type|Distance From Soma', [],
                                 caption='%s:Stimulation' % nrn.name)
Ejemplo n.º 17
0
 def _create_neuron_details_3b_postsynapses(self, nrn):
     return mrd.VerticalColTable('Type|Distance From Soma', [],
                                 caption='%s:Postsynaptic Connections' %
                                 nrn.name)
Ejemplo n.º 18
0
 def _create_neuron_details_3c_gapjunctions(self, nrn):
     return mrd.VerticalColTable('Type|Distance From Soma', [],
                                 caption='%s:Gap Junctions' % nrn.name)