morphology_workflows.clone

Cloning functions.

Attributes

Category

COL_Y

SEGMENT_TO_NEURITE

MorphDBTransformRules

Classes

PlacementAnnotation

Dict like class to handle placement annotations.

Functions

get_cellcounts_from_recipe(recipe_path)

Get the number of cells needed, by category from the BBP recipe.

get_category_overlap(category_to_cellcount, candidates)

Finds the overlap of categories between the recipe and the neurondb.

make_clones(task, clone_counts, axon_hardlimit_name, ...)

Generate the clones.

graft_axons(df, output_path, input_neurondb, ...)

Graft axons from donors to recipient morphologies, but only ones of cross_mtypes.

filter_missing_perimeter_morphs(df)

Remove morphologies with perimeters.

calculate_y_extent(morph, neurite_type)

Find min/max y value of morphology based on neurite_type.

convert_to_json_type(dict_)

Convert to json's corresponding type when possible.

read_placement_rules(rule_contents)

Convert an placement_rules xml string to a dictionary of rules.

apply_scaling(name, input_path, output_path, y_scales, ...)

Worker function for parallelized computations.

parse_morphdb_transform_rules(rules_path)

Parse rules in XML file that describe morphdb transformations.

expand_mtype_to_layers(mtype)

Return a list of layers encoded in the mtype.

parse_annotations(filepath)

Parse XML with morphology annotations.

collect_annotations(annotation_dir)

Collect all annotations from a directory.

clone_release(df, data_dir, clone_path, extensions, ...)

Make a clone release.

Module Contents

morphology_workflows.clone.Category
morphology_workflows.clone.COL_Y = 1
morphology_workflows.clone.get_cellcounts_from_recipe(recipe_path)

Get the number of cells needed, by category from the BBP recipe.

morphology_workflows.clone.get_category_overlap(category_to_cellcount, candidates)

Finds the overlap of categories between the recipe and the neurondb.

morphology_workflows.clone.make_clones(task, clone_counts, axon_hardlimit_name, dendrite_hardlimit_name, input_path, output_path, input_annotation, output_annotation, placement_rules, std_angle=10.0, std_scale=0.2)

Generate the clones.

It also creates the clone annotations if placement_rules is not None.

morphology_workflows.clone.graft_axons(df, output_path, input_neurondb, cross_mtypes, placement_rules, axon_hardlimit_name, dendrite_hardlimit_name)

Graft axons from donors to recipient morphologies, but only ones of cross_mtypes.

Parameters:
  • df (DataFrame) – input df

  • input_path (str) – path to input files

  • output_path (str) – path to output directory

  • input_neurondb (MorphDB) – the input (previous phase) morphdb

  • cross_mtypes (list) – names of mytpes to be used for crossing, ex: [‘L23_PC’, ‘L4_PC’, …]

  • placement_rules (dict) – mapping of placement_rules as returned by read_placement_rules

  • axon_hardlimit_name (str) – named used in xml annotation file for axon y-extent

  • dendrite_hardlimit_name (str) – named used in xml annotation file for dendrites y-extent

Returns:

The output neurondb

morphology_workflows.clone.filter_missing_perimeter_morphs(df)

Remove morphologies with perimeters.

morphology_workflows.clone.SEGMENT_TO_NEURITE
morphology_workflows.clone.calculate_y_extent(morph, neurite_type)

Find min/max y value of morphology based on neurite_type.

morphology_workflows.clone.convert_to_json_type(dict_)

Convert to json’s corresponding type when possible.

Note: original dict is modified in place

morphology_workflows.clone.read_placement_rules(rule_contents)

Convert an placement_rules xml string to a dictionary of rules.

Format of dict is:
{‘L1_HAC’:
{‘L1_HAC, axon, Layer_1’:

{‘old_id’: ‘L1_HAC_axon_target’, ‘segment_type’: ‘axon’, ‘type’: ‘region_target’, ‘y_max_fraction’: ‘1.00’, ‘y_max_layer’: ‘1’, ‘y_min_fraction’: ‘0.00’, ‘y_min_layer’: ‘1’}},

class morphology_workflows.clone.PlacementAnnotation(name, rules=None)

Bases: collections.abc.MutableMapping

Dict like class to handle placement annotations.

name
__str__()

Str.

__delitem__(key)

Del.

__getitem__(key)

Get.

__iter__()

Iter.

__len__()

Len.

__setitem__(key, value)

Set.

add_rule(name, properties)

Adds rule name w/ properties.

Note: this overwrites an old rule of the same name

xml()

Return the xml representation of a placement annotation.

add_scale_bias(percentage)

Add the scale bias rule.

update_y_extent(rule, y_min, y_max)

Given rule, update the y_min and y_max.

if previous values exist, add the y_change value

calculate_axon_hard_limit(morph, name)

Given a neuron.fst morphology, update the axon y_extent.

calculate_dendrite_hard_limit(morph, name)

Given a neuron.fst morphology, update the dendrites y_extent.

classmethod load(file_path)

Load a set of annotations created for a particular morphology from an xml file.

If the file is missing, an rule-less annotation is returned

classmethod from_xml_string(annotations_string)

Load a set of annotations created for a particular morphology from a string.

path(output_path)

Build annotation path.

save(output_path)

Save the annotations XML to the output_path/name.

morphology_workflows.clone.apply_scaling(name, input_path, output_path, y_scales, parents, annotation_path, output_annotation_path)

Worker function for parallelized computations.

Note: the 2nd argument is unused to respect Phase.parallel_map expected signature

morphology_workflows.clone.MorphDBTransformRules
morphology_workflows.clone.parse_morphdb_transform_rules(rules_path)

Parse rules in XML file that describe morphdb transformations.

Format:

<rules>
    <exclude name="Excluded0"/>  <!-- name of morphology to exclude -->
    ...
    <substitute from="L5_MC" to="L6_MC"/>
        <!-- mtype in 'from' are duplicated with and saved with mtype of 'to' -->
    ...
    <mtype_copy_to_layer mtype="L23_CHC" src_layer="2" dst_layer="3" />
        <!-- for all mtypes=L23_CHC in layer 2, copy them to layer 2 -->
</rules>

Note: this is a replication of the ‘exclude_and_substitute.py’ algorithm, so the XML format was re-used for continuity.

morphology_workflows.clone.expand_mtype_to_layers(mtype)

Return a list of layers encoded in the mtype.

morphology_workflows.clone.parse_annotations(filepath)

Parse XML with morphology annotations.

morphology_workflows.clone.collect_annotations(annotation_dir)

Collect all annotations from a directory.

morphology_workflows.clone.clone_release(df, data_dir, clone_path, extensions, clone_data_path)

Make a clone release.