emodel_generalisation.utils

Other util functions.

Functions

cluster_matrix(df[, distance])

Return sorted labels to cluster a matrix with linkage.

get_combo_hash(combo)

Convert combo values to hash for saving traces.

get_feature_df(df[, filters])

Get feature df from complete df.

get_score_df(df[, filters])

Get score df from complete df.

get_scores(morphs_combos_df[, ...])

compute the median and max scores from computations on filtered features.

isolate(func[, timeout])

Isolate a generic function for independent NEURON instances.

load_json(filepath, **kwargs)

Load from JSON file.

plot_traces(trace_df[, trace_path, pdf_filename])

Plot traces from df, with highlights on rows with trace_highlight = True.

write_json(filepath, data, **kwargs)

Write json file.

emodel_generalisation.utils.cluster_matrix(df, distance=False)

Return sorted labels to cluster a matrix with linkage.

If distance matrix already set distance=True.

emodel_generalisation.utils.get_combo_hash(combo)

Convert combo values to hash for saving traces.

emodel_generalisation.utils.get_feature_df(df, filters=None)

Get feature df from complete df.

emodel_generalisation.utils.get_score_df(df, filters=None)

Get score df from complete df.

emodel_generalisation.utils.get_scores(morphs_combos_df, features_to_ignore=None, features_to_keep=None, clip=250)

compute the median and max scores from computations on filtered features.

emodel_generalisation.utils.isolate(func, timeout=None)

Isolate a generic function for independent NEURON instances.

It must be used in conjunction with NestedPool.

Example:

def _to_be_isolated(morphology_path, point):
    cell = nrnhines.get_NRN_cell(morphology_path)
    return nrnhines.point_to_section_end(cell.icell.all, point)

def _isolated(morph_data):
    return nrnhines.isolate(_to_be_isolated)(*morph_data)

with nrnhines.NestedPool(processes=n_workers) as pool:
    result = pool.imap_unordered(_isolated, data)
Parameters:

func (function) – function to isolate

Returns:

the isolated function

Note: it does not work as decorator.

emodel_generalisation.utils.load_json(filepath, **kwargs)

Load from JSON file.

emodel_generalisation.utils.plot_traces(trace_df, trace_path='traces', pdf_filename='traces.pdf')

Plot traces from df, with highlights on rows with trace_highlight = True.

Parameters:
  • trace_df (DataFrame) – contains list of combos with traces to plot

  • trace_path (str) – path to folder with traces in .pkl

  • pdf_filename (str) – name of pdf to save

emodel_generalisation.utils.write_json(filepath, data, **kwargs)

Write json file.