bluepymm.select_combos package

Submodules

bluepymm.select_combos.main module

Analyse scores

bluepymm.select_combos.main.add_parser(action)[source]

Add parser

bluepymm.select_combos.main.select_combos(conf_filename, n_processes)[source]

Parse conf file and run select combos

bluepymm.select_combos.main.select_combos_from_conf(conf_dict, n_processes=None)[source]

Compare scores of me-combinations to thresholds, select successful combinations, and write results out to file.

Parameters:
  • conf_filename – filename of configuration (.json file)

  • n_processes – integer number of processes, None will use all of them

bluepymm.select_combos.megate_output module

BluePyMM megate output.

bluepymm.select_combos.megate_output.save_megate_results(extneurondb, output_dir, extneurondb_filename='extneurondb.dat', mecombo_emodel_filename='mecombo_emodel.tsv', sort_key=None, make_names_neuron_compliant=False, extra_value_errors=True)[source]

Write results of megating to two files.

Parameters:
  • extneurondb – pandas.DataFrame with result of me-gating

  • output_dir – path to output directory

  • extneurondb_filename – filename of extended neuron database. The columns of this file are ordered as ‘morph_name’, ‘layer’, ‘fullmtype’, ‘etype’, ‘combo_name’. Values are separated by a space. Default filename is ‘extneurondb.dat’.

  • mecombo_emodel_filename – filename of ‘mecombo_emodel’ file. Values are separated with a tab. Default filename is ‘mecombo_emodel.tsv’.

  • sort_key – key to sort database in ascending order before writing out to file. Default is None.

  • make_names_neuron_compliant – boolean indicating whether the combo name should be made NEURON-compliant. Default is False. If set to True, a log file with the conversion info is written out to <output_dir>/log_neuron_compliance.csv

bluepymm.select_combos.megate_output.write_mecomboreleasejson(output_dir, emodels_hoc_path, extneurondb_path, mecombo_emodel_path)[source]

Write json file contain info about release

bluepymm.select_combos.process_megate_config module

Process megate configuration file.

bluepymm.select_combos.process_megate_config.join_regex(list_regex)[source]

Create regular expresssion that matches one of a given list of regular expressions.

bluepymm.select_combos.process_megate_config.read_megate_thresholds(conf_dict)[source]

Parse megate thresholds from configuraiton and return list of compiled regular expressions.

Parameters:

conf_dict – dictionary, value of conf_dict[‘megate_thresholds’] is processed if available.

Returns:

A tuple (<list_of_dicts>, <conf_dict[‘megate_thresholds’]>)

bluepymm.select_combos.process_megate_config.read_to_skip_features(conf_dict)[source]

Parse features to skip from configuration and return list of compiled regular expressions.

Parameters:

conf_dict – dictionary, value of conf_dict[‘to_skip_features’] is processed if available.

Returns:

A tuple (<list_of_compiled_reg_exprs>, <conf_dict[‘to_skip_features’]>)

bluepymm.select_combos.reporting module

Functions for BluePyMM reporting.

bluepymm.select_combos.reporting.add_plot_to_report(pp, plot_function, *args)[source]

Add a plot to a given report.

Parameters:
  • pp – pdf file

  • plot_function – function that returns figure

  • args – arguments to plot_function

bluepymm.select_combos.reporting.create_final_db_and_write_report(pdf_filename, to_skip_features, to_skip_patterns, megate_thresholds, megate_patterns, skip_repaired_exemplar, check_opt_scores, scores, score_values, enable_plot_emodels_per_morphology, output_dir, select_perc_best, n_processes=None)[source]

Create the final output files and report

bluepymm.select_combos.reporting.create_metype(x)[source]

Create me-type from m-type and e-type

bluepymm.select_combos.reporting.create_morphology_label(data_frame)[source]

Create label for morphology.

Parameters:

data_frame – pandas.DataFrame with columns ‘morph_name’, ‘fullmtype’, and ‘etype’

Returns:

A label (string), based on the contents of the first row of data_frame: <morph_name> (<fullmtype>, <etype>).

bluepymm.select_combos.reporting.pdf_file(pdf_filename)[source]

Create and return a PDF file.

Parameters:

pdf_filename – path to PDF file

Returns:

A multi-page PDF file.

bluepymm.select_combos.reporting.plot_dict(dict_data, title)[source]

Plot a dictionary.

Parameters:
  • dict_data – a dictionary

  • title – string with plot title

Returns:

Figure with plotted dictionary

bluepymm.select_combos.reporting.plot_emodels_per_metype(data, final_db)[source]

Display result of tested e-model / morphology combinations per me-type.

Parameters:
  • data – pandas.DataFrame with data on run combos

  • final_db – pandas.DataFrame with data on selected combos

Returns:

Figure with plot of stacked bars. Simulations that passed, threw an error, and failed are colored blue, yellow and red, respectively.

bluepymm.select_combos.reporting.plot_emodels_per_morphology(data, final_db)[source]

Display result of tested e-models for each morphology.

Parameters:
  • data – pandas.DataFrame with data on run combos

  • final_db – pandas.DataFrame with data on selected combos

Returns:

Figure with plot of stacked bars. Simulations that passed, threw an error, and failed are colored blue, yellow and red, respectively.

bluepymm.select_combos.reporting.plot_median_per_metype(combos, passed_median_scores, csv_path)[source]

Display result median score per me-type

bluepymm.select_combos.reporting.plot_morphs_per_feature_for_emodel(emodel, megate_scores, emodel_score_values)[source]

Display number of tested morphologies per feature for a given e-model.

Parameters:
  • emodel – string representing e-model, used for plot title

  • megate_scores – pandas.DataFrame with megate scores, one entry per run combo

  • emodel_score_values – pandas.DataFrame with score values, one entry per run combo

Returns:

Figure with plot of stacked bars. Passed and failed simulations are colored blue and red, respectively.

bluepymm.select_combos.reporting.plot_morphs_per_mtype_for_emodel(emodel, fullmtypes, megate_scores)[source]

Display number of tested morphologies per m-type for a given e-model.

Parameters:
  • emodel – string representing e-model, used for plot title

  • fullmtypes – pandas.DataFrame with m-types, one entry per run combo

  • megate_scores – pandas.DataFrame with megate scores, one entry per run combo

Returns:

Figure with plot of stacked bars. Passed and failed simulations are colored blue and red, respectively.

bluepymm.select_combos.reporting.plot_stacked_bars(data, xlabel, ylabel, title, color_map, log=False, yticksize=None)[source]

Plot stacked bars.

Parameters:
  • data – a pandas.DataFrame

  • xlabel – string with label for x-axis

  • ylabel – string with label for y-axis

  • title – string with plot title

  • color_map – list of colors

Returns:

Figure with plot of stacked bars

bluepymm.select_combos.sqlite_io module

BluePyMM select_combos sqlite input

bluepymm.select_combos.sqlite_io.read_and_process_sqlite_score_tables(scores_sqlite_filename)[source]

Read score and score values tables from score sqlite dabatase.

Parameters:

scores_sqlite_filename – path to sqlite database

Returns:

A tuple of two pandas.DataFrames, as loaded from the tables ‘scores’ and ‘score_values’ respectively, If present, the column ‘index’ is dropped from score_values.

Raises:
  • Exception if the number of rows in the 'scores' table does not equal

  • the number of rows in the 'score_values' table.

bluepymm.select_combos.table_processing module

Functions to process tables produced by BluePyMM.

bluepymm.select_combos.table_processing.calc_median_scores(emodel_score_values, to_skip_patterns)[source]

Calculate scores for every me-combo

bluepymm.select_combos.table_processing.check_opt_scores(emodel, scores)[source]

Check if opt_scores match with unrepaired exemplar runs.

Parameters:
  • emodel – e-model name

  • scores – pandas.DataFrame with scores

Raises:

Exception

  • if the keys of the opt_scores do not match the unrepaired exemplar runs, - if the scores values of the opt_scores do not match the scores of the unrepaired exemplar runs.

bluepymm.select_combos.table_processing.convert_extra_values(row)[source]

Extract ‘threshold_current’ and ‘holding_current’ information from key ‘extra_values’ and convert to new (key, value)-pairs in given row data.

Parameters:

row – contains key ‘extra_values’, with string value

Returns:

row, with extra keys ‘threshold_current’ and/or ‘holding_current’, and associated value, as extracted from row[‘extra_values’]

bluepymm.select_combos.table_processing.process_combo_name(data, log_filename)[source]

Make value corresponding to key ‘combo_name’ compliant with NEURON rules for template names. A log file is written out in csv format.

Parameters:
  • data – pandas.DataFrame with key ‘combo_name’

  • log_filename – path to log file

bluepymm.select_combos.table_processing.process_emodel(args)[source]

Process scores and score values for indicated e-model and return data on the e-model performance as well as the selected combinations.

Parameters:
  • emodel – e-model name

  • combos – pandas.DataFrame with combo data

  • score_values – pandas.DataFrame with score values

  • to_skip_patterns – list of compiled regular expressions

  • megate_patterns – list of dictionaries with megate patterns

  • skip_repaired_exemplar – boolean

  • enable_check_opt_scores – boolean

Returns:

  • emodel_ext_neurondb: pandas.DataFrame with database rows

  • emodel_megate_pass: pandas.DataFrame with megate fail/success

  • emodel_score_values: pandas.DataFrame with score values

  • mtypes: pandas.DataFrame with tested m-types

None: - if boolean skip_repaired_exemplar is set to False, and no repaired exemplars are available - if the e-model was not run on any released morphology

Return type:

4-tuple with megate results for the e-model

Raises:
  • Exception, skip_repaired_exemplar is set to False and more than one

  • exemplars are found.

bluepymm.select_combos.table_processing.process_emodels(emodels, scores, score_values, to_skip_patterns, megate_patterns, skip_repaired_exemplar, enable_check_opt_scores, select_perc_best, n_processes=None)[source]
bluepymm.select_combos.table_processing.row_threshold_transform(row, megate_patterns)[source]

Transform threshold row based on me-gate rule: add matching me-gate patterns to row data.

Parameters:
  • row – has keys ‘emodel’, ‘fullmtype’, ‘etype’, and ‘megate_feature_threshold’

  • megate_patterns – a list of megate patterns

Returns:

for all me-gate patterns that match the row data, the corresponding megate feature threshold is appended to row[‘megate_feature_threshold’].

Return type:

Processed row data

bluepymm.select_combos.table_processing.select_passed_combos(emodel, emodel_combos, emodel_megate_pass, emodel_megate_scores, select_perc_best=None)[source]

Select which combos pass

Module contents

Init select combos