id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
sequence
docstring
stringlengths
3
17.3k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
87
242
2,600
BlueBrain/NeuroM
neurom/check/neuron_checks.py
has_axon
def has_axon(neuron, treefun=_read_neurite_type): '''Check if a neuron has an axon Arguments: neuron(Neuron): The neuron object to test treefun: Optional function to calculate the tree type of neuron's neurites Returns: CheckResult with result ''' return CheckResult(NeuriteType.axon in (treefun(n) for n in neuron.neurites))
python
def has_axon(neuron, treefun=_read_neurite_type): '''Check if a neuron has an axon Arguments: neuron(Neuron): The neuron object to test treefun: Optional function to calculate the tree type of neuron's neurites Returns: CheckResult with result ''' return CheckResult(NeuriteType.axon in (treefun(n) for n in neuron.neurites))
[ "def", "has_axon", "(", "neuron", ",", "treefun", "=", "_read_neurite_type", ")", ":", "return", "CheckResult", "(", "NeuriteType", ".", "axon", "in", "(", "treefun", "(", "n", ")", "for", "n", "in", "neuron", ".", "neurites", ")", ")" ]
Check if a neuron has an axon Arguments: neuron(Neuron): The neuron object to test treefun: Optional function to calculate the tree type of neuron's neurites Returns: CheckResult with result
[ "Check", "if", "a", "neuron", "has", "an", "axon" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/neuron_checks.py#L54-L65
2,601
BlueBrain/NeuroM
neurom/check/neuron_checks.py
has_apical_dendrite
def has_apical_dendrite(neuron, min_number=1, treefun=_read_neurite_type): '''Check if a neuron has apical dendrites Arguments: neuron(Neuron): The neuron object to test min_number: minimum number of apical dendrites required treefun: Optional function to calculate the tree type of neuron's neurites Returns: CheckResult with result ''' types = [treefun(n) for n in neuron.neurites] return CheckResult(types.count(NeuriteType.apical_dendrite) >= min_number)
python
def has_apical_dendrite(neuron, min_number=1, treefun=_read_neurite_type): '''Check if a neuron has apical dendrites Arguments: neuron(Neuron): The neuron object to test min_number: minimum number of apical dendrites required treefun: Optional function to calculate the tree type of neuron's neurites Returns: CheckResult with result ''' types = [treefun(n) for n in neuron.neurites] return CheckResult(types.count(NeuriteType.apical_dendrite) >= min_number)
[ "def", "has_apical_dendrite", "(", "neuron", ",", "min_number", "=", "1", ",", "treefun", "=", "_read_neurite_type", ")", ":", "types", "=", "[", "treefun", "(", "n", ")", "for", "n", "in", "neuron", ".", "neurites", "]", "return", "CheckResult", "(", "types", ".", "count", "(", "NeuriteType", ".", "apical_dendrite", ")", ">=", "min_number", ")" ]
Check if a neuron has apical dendrites Arguments: neuron(Neuron): The neuron object to test min_number: minimum number of apical dendrites required treefun: Optional function to calculate the tree type of neuron's neurites Returns: CheckResult with result
[ "Check", "if", "a", "neuron", "has", "apical", "dendrites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/neuron_checks.py#L68-L81
2,602
BlueBrain/NeuroM
neurom/check/neuron_checks.py
has_basal_dendrite
def has_basal_dendrite(neuron, min_number=1, treefun=_read_neurite_type): '''Check if a neuron has basal dendrites Arguments: neuron(Neuron): The neuron object to test min_number: minimum number of basal dendrites required treefun: Optional function to calculate the tree type of neuron's neurites Returns: CheckResult with result ''' types = [treefun(n) for n in neuron.neurites] return CheckResult(types.count(NeuriteType.basal_dendrite) >= min_number)
python
def has_basal_dendrite(neuron, min_number=1, treefun=_read_neurite_type): '''Check if a neuron has basal dendrites Arguments: neuron(Neuron): The neuron object to test min_number: minimum number of basal dendrites required treefun: Optional function to calculate the tree type of neuron's neurites Returns: CheckResult with result ''' types = [treefun(n) for n in neuron.neurites] return CheckResult(types.count(NeuriteType.basal_dendrite) >= min_number)
[ "def", "has_basal_dendrite", "(", "neuron", ",", "min_number", "=", "1", ",", "treefun", "=", "_read_neurite_type", ")", ":", "types", "=", "[", "treefun", "(", "n", ")", "for", "n", "in", "neuron", ".", "neurites", "]", "return", "CheckResult", "(", "types", ".", "count", "(", "NeuriteType", ".", "basal_dendrite", ")", ">=", "min_number", ")" ]
Check if a neuron has basal dendrites Arguments: neuron(Neuron): The neuron object to test min_number: minimum number of basal dendrites required treefun: Optional function to calculate the tree type of neuron's neurites Returns: CheckResult with result
[ "Check", "if", "a", "neuron", "has", "basal", "dendrites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/neuron_checks.py#L84-L97
2,603
BlueBrain/NeuroM
neurom/check/neuron_checks.py
has_no_flat_neurites
def has_no_flat_neurites(neuron, tol=0.1, method='ratio'): '''Check that a neuron has no flat neurites Arguments: neuron(Neuron): The neuron object to test tol(float): tolerance method(string): way of determining flatness, 'tolerance', 'ratio' \ as described in :meth:`neurom.check.morphtree.get_flat_neurites` Returns: CheckResult with result ''' return CheckResult(len(get_flat_neurites(neuron, tol, method)) == 0)
python
def has_no_flat_neurites(neuron, tol=0.1, method='ratio'): '''Check that a neuron has no flat neurites Arguments: neuron(Neuron): The neuron object to test tol(float): tolerance method(string): way of determining flatness, 'tolerance', 'ratio' \ as described in :meth:`neurom.check.morphtree.get_flat_neurites` Returns: CheckResult with result ''' return CheckResult(len(get_flat_neurites(neuron, tol, method)) == 0)
[ "def", "has_no_flat_neurites", "(", "neuron", ",", "tol", "=", "0.1", ",", "method", "=", "'ratio'", ")", ":", "return", "CheckResult", "(", "len", "(", "get_flat_neurites", "(", "neuron", ",", "tol", ",", "method", ")", ")", "==", "0", ")" ]
Check that a neuron has no flat neurites Arguments: neuron(Neuron): The neuron object to test tol(float): tolerance method(string): way of determining flatness, 'tolerance', 'ratio' \ as described in :meth:`neurom.check.morphtree.get_flat_neurites` Returns: CheckResult with result
[ "Check", "that", "a", "neuron", "has", "no", "flat", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/neuron_checks.py#L100-L112
2,604
BlueBrain/NeuroM
neurom/check/neuron_checks.py
has_all_nonzero_segment_lengths
def has_all_nonzero_segment_lengths(neuron, threshold=0.0): '''Check presence of neuron segments with length not above threshold Arguments: neuron(Neuron): The neuron object to test threshold(float): value above which a segment length is considered to be non-zero Returns: CheckResult with result including list of (section_id, segment_id) of zero length segments ''' bad_ids = [] for sec in _nf.iter_sections(neuron): p = sec.points for i, s in enumerate(zip(p[:-1], p[1:])): if segment_length(s) <= threshold: bad_ids.append((sec.id, i)) return CheckResult(len(bad_ids) == 0, bad_ids)
python
def has_all_nonzero_segment_lengths(neuron, threshold=0.0): '''Check presence of neuron segments with length not above threshold Arguments: neuron(Neuron): The neuron object to test threshold(float): value above which a segment length is considered to be non-zero Returns: CheckResult with result including list of (section_id, segment_id) of zero length segments ''' bad_ids = [] for sec in _nf.iter_sections(neuron): p = sec.points for i, s in enumerate(zip(p[:-1], p[1:])): if segment_length(s) <= threshold: bad_ids.append((sec.id, i)) return CheckResult(len(bad_ids) == 0, bad_ids)
[ "def", "has_all_nonzero_segment_lengths", "(", "neuron", ",", "threshold", "=", "0.0", ")", ":", "bad_ids", "=", "[", "]", "for", "sec", "in", "_nf", ".", "iter_sections", "(", "neuron", ")", ":", "p", "=", "sec", ".", "points", "for", "i", ",", "s", "in", "enumerate", "(", "zip", "(", "p", "[", ":", "-", "1", "]", ",", "p", "[", "1", ":", "]", ")", ")", ":", "if", "segment_length", "(", "s", ")", "<=", "threshold", ":", "bad_ids", ".", "append", "(", "(", "sec", ".", "id", ",", "i", ")", ")", "return", "CheckResult", "(", "len", "(", "bad_ids", ")", "==", "0", ",", "bad_ids", ")" ]
Check presence of neuron segments with length not above threshold Arguments: neuron(Neuron): The neuron object to test threshold(float): value above which a segment length is considered to be non-zero Returns: CheckResult with result including list of (section_id, segment_id) of zero length segments
[ "Check", "presence", "of", "neuron", "segments", "with", "length", "not", "above", "threshold" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/neuron_checks.py#L128-L147
2,605
BlueBrain/NeuroM
neurom/check/neuron_checks.py
has_all_nonzero_section_lengths
def has_all_nonzero_section_lengths(neuron, threshold=0.0): '''Check presence of neuron sections with length not above threshold Arguments: neuron(Neuron): The neuron object to test threshold(float): value above which a section length is considered to be non-zero Returns: CheckResult with result including list of ids of bad sections ''' bad_ids = [s.id for s in _nf.iter_sections(neuron.neurites) if section_length(s.points) <= threshold] return CheckResult(len(bad_ids) == 0, bad_ids)
python
def has_all_nonzero_section_lengths(neuron, threshold=0.0): '''Check presence of neuron sections with length not above threshold Arguments: neuron(Neuron): The neuron object to test threshold(float): value above which a section length is considered to be non-zero Returns: CheckResult with result including list of ids of bad sections ''' bad_ids = [s.id for s in _nf.iter_sections(neuron.neurites) if section_length(s.points) <= threshold] return CheckResult(len(bad_ids) == 0, bad_ids)
[ "def", "has_all_nonzero_section_lengths", "(", "neuron", ",", "threshold", "=", "0.0", ")", ":", "bad_ids", "=", "[", "s", ".", "id", "for", "s", "in", "_nf", ".", "iter_sections", "(", "neuron", ".", "neurites", ")", "if", "section_length", "(", "s", ".", "points", ")", "<=", "threshold", "]", "return", "CheckResult", "(", "len", "(", "bad_ids", ")", "==", "0", ",", "bad_ids", ")" ]
Check presence of neuron sections with length not above threshold Arguments: neuron(Neuron): The neuron object to test threshold(float): value above which a section length is considered to be non-zero Returns: CheckResult with result including list of ids of bad sections
[ "Check", "presence", "of", "neuron", "sections", "with", "length", "not", "above", "threshold" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/neuron_checks.py#L150-L164
2,606
BlueBrain/NeuroM
neurom/check/neuron_checks.py
has_all_nonzero_neurite_radii
def has_all_nonzero_neurite_radii(neuron, threshold=0.0): '''Check presence of neurite points with radius not above threshold Arguments: neuron(Neuron): The neuron object to test threshold: value above which a radius is considered to be non-zero Returns: CheckResult with result including list of (section ID, point ID) pairs of zero-radius points ''' bad_ids = [] seen_ids = set() for s in _nf.iter_sections(neuron): for i, p in enumerate(s.points): info = (s.id, i) if p[COLS.R] <= threshold and info not in seen_ids: seen_ids.add(info) bad_ids.append(info) return CheckResult(len(bad_ids) == 0, bad_ids)
python
def has_all_nonzero_neurite_radii(neuron, threshold=0.0): '''Check presence of neurite points with radius not above threshold Arguments: neuron(Neuron): The neuron object to test threshold: value above which a radius is considered to be non-zero Returns: CheckResult with result including list of (section ID, point ID) pairs of zero-radius points ''' bad_ids = [] seen_ids = set() for s in _nf.iter_sections(neuron): for i, p in enumerate(s.points): info = (s.id, i) if p[COLS.R] <= threshold and info not in seen_ids: seen_ids.add(info) bad_ids.append(info) return CheckResult(len(bad_ids) == 0, bad_ids)
[ "def", "has_all_nonzero_neurite_radii", "(", "neuron", ",", "threshold", "=", "0.0", ")", ":", "bad_ids", "=", "[", "]", "seen_ids", "=", "set", "(", ")", "for", "s", "in", "_nf", ".", "iter_sections", "(", "neuron", ")", ":", "for", "i", ",", "p", "in", "enumerate", "(", "s", ".", "points", ")", ":", "info", "=", "(", "s", ".", "id", ",", "i", ")", "if", "p", "[", "COLS", ".", "R", "]", "<=", "threshold", "and", "info", "not", "in", "seen_ids", ":", "seen_ids", ".", "add", "(", "info", ")", "bad_ids", ".", "append", "(", "info", ")", "return", "CheckResult", "(", "len", "(", "bad_ids", ")", "==", "0", ",", "bad_ids", ")" ]
Check presence of neurite points with radius not above threshold Arguments: neuron(Neuron): The neuron object to test threshold: value above which a radius is considered to be non-zero Returns: CheckResult with result including list of (section ID, point ID) pairs of zero-radius points
[ "Check", "presence", "of", "neurite", "points", "with", "radius", "not", "above", "threshold" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/neuron_checks.py#L167-L187
2,607
BlueBrain/NeuroM
neurom/check/neuron_checks.py
has_no_fat_ends
def has_no_fat_ends(neuron, multiple_of_mean=2.0, final_point_count=5): '''Check if leaf points are too large Arguments: neuron(Neuron): The neuron object to test multiple_of_mean(float): how many times larger the final radius has to be compared to the mean of the final points final_point_count(int): how many points to include in the mean Returns: CheckResult with result list of ids of bad sections Note: A fat end is defined as a leaf segment whose last point is larger by a factor of `multiple_of_mean` than the mean of the points in `final_point_count` ''' bad_ids = [] for leaf in _nf.iter_sections(neuron.neurites, iterator_type=Tree.ileaf): mean_radius = np.mean(leaf.points[1:][-final_point_count:, COLS.R]) if mean_radius * multiple_of_mean <= leaf.points[-1, COLS.R]: bad_ids.append((leaf.id, leaf.points[-1:])) return CheckResult(len(bad_ids) == 0, bad_ids)
python
def has_no_fat_ends(neuron, multiple_of_mean=2.0, final_point_count=5): '''Check if leaf points are too large Arguments: neuron(Neuron): The neuron object to test multiple_of_mean(float): how many times larger the final radius has to be compared to the mean of the final points final_point_count(int): how many points to include in the mean Returns: CheckResult with result list of ids of bad sections Note: A fat end is defined as a leaf segment whose last point is larger by a factor of `multiple_of_mean` than the mean of the points in `final_point_count` ''' bad_ids = [] for leaf in _nf.iter_sections(neuron.neurites, iterator_type=Tree.ileaf): mean_radius = np.mean(leaf.points[1:][-final_point_count:, COLS.R]) if mean_radius * multiple_of_mean <= leaf.points[-1, COLS.R]: bad_ids.append((leaf.id, leaf.points[-1:])) return CheckResult(len(bad_ids) == 0, bad_ids)
[ "def", "has_no_fat_ends", "(", "neuron", ",", "multiple_of_mean", "=", "2.0", ",", "final_point_count", "=", "5", ")", ":", "bad_ids", "=", "[", "]", "for", "leaf", "in", "_nf", ".", "iter_sections", "(", "neuron", ".", "neurites", ",", "iterator_type", "=", "Tree", ".", "ileaf", ")", ":", "mean_radius", "=", "np", ".", "mean", "(", "leaf", ".", "points", "[", "1", ":", "]", "[", "-", "final_point_count", ":", ",", "COLS", ".", "R", "]", ")", "if", "mean_radius", "*", "multiple_of_mean", "<=", "leaf", ".", "points", "[", "-", "1", ",", "COLS", ".", "R", "]", ":", "bad_ids", ".", "append", "(", "(", "leaf", ".", "id", ",", "leaf", ".", "points", "[", "-", "1", ":", "]", ")", ")", "return", "CheckResult", "(", "len", "(", "bad_ids", ")", "==", "0", ",", "bad_ids", ")" ]
Check if leaf points are too large Arguments: neuron(Neuron): The neuron object to test multiple_of_mean(float): how many times larger the final radius has to be compared to the mean of the final points final_point_count(int): how many points to include in the mean Returns: CheckResult with result list of ids of bad sections Note: A fat end is defined as a leaf segment whose last point is larger by a factor of `multiple_of_mean` than the mean of the points in `final_point_count`
[ "Check", "if", "leaf", "points", "are", "too", "large" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/neuron_checks.py#L226-L250
2,608
BlueBrain/NeuroM
neurom/check/neuron_checks.py
has_no_narrow_start
def has_no_narrow_start(neuron, frac=0.9): '''Check if neurites have a narrow start Arguments: neuron(Neuron): The neuron object to test frac(float): Ratio that the second point must be smaller than the first Returns: CheckResult with a list of all first segments of neurites with a narrow start ''' bad_ids = [(neurite.root_node.id, [neurite.root_node.points[1]]) for neurite in neuron.neurites if neurite.root_node.points[1][COLS.R] < frac * neurite.root_node.points[2][COLS.R]] return CheckResult(len(bad_ids) == 0, bad_ids)
python
def has_no_narrow_start(neuron, frac=0.9): '''Check if neurites have a narrow start Arguments: neuron(Neuron): The neuron object to test frac(float): Ratio that the second point must be smaller than the first Returns: CheckResult with a list of all first segments of neurites with a narrow start ''' bad_ids = [(neurite.root_node.id, [neurite.root_node.points[1]]) for neurite in neuron.neurites if neurite.root_node.points[1][COLS.R] < frac * neurite.root_node.points[2][COLS.R]] return CheckResult(len(bad_ids) == 0, bad_ids)
[ "def", "has_no_narrow_start", "(", "neuron", ",", "frac", "=", "0.9", ")", ":", "bad_ids", "=", "[", "(", "neurite", ".", "root_node", ".", "id", ",", "[", "neurite", ".", "root_node", ".", "points", "[", "1", "]", "]", ")", "for", "neurite", "in", "neuron", ".", "neurites", "if", "neurite", ".", "root_node", ".", "points", "[", "1", "]", "[", "COLS", ".", "R", "]", "<", "frac", "*", "neurite", ".", "root_node", ".", "points", "[", "2", "]", "[", "COLS", ".", "R", "]", "]", "return", "CheckResult", "(", "len", "(", "bad_ids", ")", "==", "0", ",", "bad_ids", ")" ]
Check if neurites have a narrow start Arguments: neuron(Neuron): The neuron object to test frac(float): Ratio that the second point must be smaller than the first Returns: CheckResult with a list of all first segments of neurites with a narrow start
[ "Check", "if", "neurites", "have", "a", "narrow", "start" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/neuron_checks.py#L253-L266
2,609
BlueBrain/NeuroM
neurom/check/neuron_checks.py
has_no_dangling_branch
def has_no_dangling_branch(neuron): '''Check if the neuron has dangling neurites''' soma_center = neuron.soma.points[:, COLS.XYZ].mean(axis=0) recentered_soma = neuron.soma.points[:, COLS.XYZ] - soma_center radius = np.linalg.norm(recentered_soma, axis=1) soma_max_radius = radius.max() def is_dangling(neurite): '''Is the neurite dangling ?''' starting_point = neurite.points[1][COLS.XYZ] if np.linalg.norm(starting_point - soma_center) - soma_max_radius <= 12.: return False if neurite.type != NeuriteType.axon: return True all_points = list(chain.from_iterable(n.points[1:] for n in iter_neurites(neurite) if n.type != NeuriteType.axon)) res = [np.linalg.norm(starting_point - p[COLS.XYZ]) >= 2 * p[COLS.R] + 2 for p in all_points] return all(res) bad_ids = [(n.root_node.id, [n.root_node.points[1]]) for n in iter_neurites(neuron) if is_dangling(n)] return CheckResult(len(bad_ids) == 0, bad_ids)
python
def has_no_dangling_branch(neuron): '''Check if the neuron has dangling neurites''' soma_center = neuron.soma.points[:, COLS.XYZ].mean(axis=0) recentered_soma = neuron.soma.points[:, COLS.XYZ] - soma_center radius = np.linalg.norm(recentered_soma, axis=1) soma_max_radius = radius.max() def is_dangling(neurite): '''Is the neurite dangling ?''' starting_point = neurite.points[1][COLS.XYZ] if np.linalg.norm(starting_point - soma_center) - soma_max_radius <= 12.: return False if neurite.type != NeuriteType.axon: return True all_points = list(chain.from_iterable(n.points[1:] for n in iter_neurites(neurite) if n.type != NeuriteType.axon)) res = [np.linalg.norm(starting_point - p[COLS.XYZ]) >= 2 * p[COLS.R] + 2 for p in all_points] return all(res) bad_ids = [(n.root_node.id, [n.root_node.points[1]]) for n in iter_neurites(neuron) if is_dangling(n)] return CheckResult(len(bad_ids) == 0, bad_ids)
[ "def", "has_no_dangling_branch", "(", "neuron", ")", ":", "soma_center", "=", "neuron", ".", "soma", ".", "points", "[", ":", ",", "COLS", ".", "XYZ", "]", ".", "mean", "(", "axis", "=", "0", ")", "recentered_soma", "=", "neuron", ".", "soma", ".", "points", "[", ":", ",", "COLS", ".", "XYZ", "]", "-", "soma_center", "radius", "=", "np", ".", "linalg", ".", "norm", "(", "recentered_soma", ",", "axis", "=", "1", ")", "soma_max_radius", "=", "radius", ".", "max", "(", ")", "def", "is_dangling", "(", "neurite", ")", ":", "'''Is the neurite dangling ?'''", "starting_point", "=", "neurite", ".", "points", "[", "1", "]", "[", "COLS", ".", "XYZ", "]", "if", "np", ".", "linalg", ".", "norm", "(", "starting_point", "-", "soma_center", ")", "-", "soma_max_radius", "<=", "12.", ":", "return", "False", "if", "neurite", ".", "type", "!=", "NeuriteType", ".", "axon", ":", "return", "True", "all_points", "=", "list", "(", "chain", ".", "from_iterable", "(", "n", ".", "points", "[", "1", ":", "]", "for", "n", "in", "iter_neurites", "(", "neurite", ")", "if", "n", ".", "type", "!=", "NeuriteType", ".", "axon", ")", ")", "res", "=", "[", "np", ".", "linalg", ".", "norm", "(", "starting_point", "-", "p", "[", "COLS", ".", "XYZ", "]", ")", ">=", "2", "*", "p", "[", "COLS", ".", "R", "]", "+", "2", "for", "p", "in", "all_points", "]", "return", "all", "(", "res", ")", "bad_ids", "=", "[", "(", "n", ".", "root_node", ".", "id", ",", "[", "n", ".", "root_node", ".", "points", "[", "1", "]", "]", ")", "for", "n", "in", "iter_neurites", "(", "neuron", ")", "if", "is_dangling", "(", "n", ")", "]", "return", "CheckResult", "(", "len", "(", "bad_ids", ")", "==", "0", ",", "bad_ids", ")" ]
Check if the neuron has dangling neurites
[ "Check", "if", "the", "neuron", "has", "dangling", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/neuron_checks.py#L269-L295
2,610
BlueBrain/NeuroM
neurom/check/neuron_checks.py
has_no_narrow_neurite_section
def has_no_narrow_neurite_section(neuron, neurite_filter, radius_threshold=0.05, considered_section_min_length=50): '''Check if the neuron has dendrites with narrow sections Arguments: neuron(Neuron): The neuron object to test neurite_filter(callable): filter the neurites by this callable radius_threshold(float): radii below this are considered narro considered_section_min_length(float): sections with length below this are not taken into account Returns: CheckResult with result. result.info contains the narrow section ids and their first point ''' considered_sections = (sec for sec in iter_sections(neuron, neurite_filter=neurite_filter) if sec.length > considered_section_min_length) def narrow_section(section): '''Select narrow sections''' return section.points[:, COLS.R].mean() < radius_threshold bad_ids = [(section.id, section.points[1]) for section in considered_sections if narrow_section(section)] return CheckResult(len(bad_ids) == 0, bad_ids)
python
def has_no_narrow_neurite_section(neuron, neurite_filter, radius_threshold=0.05, considered_section_min_length=50): '''Check if the neuron has dendrites with narrow sections Arguments: neuron(Neuron): The neuron object to test neurite_filter(callable): filter the neurites by this callable radius_threshold(float): radii below this are considered narro considered_section_min_length(float): sections with length below this are not taken into account Returns: CheckResult with result. result.info contains the narrow section ids and their first point ''' considered_sections = (sec for sec in iter_sections(neuron, neurite_filter=neurite_filter) if sec.length > considered_section_min_length) def narrow_section(section): '''Select narrow sections''' return section.points[:, COLS.R].mean() < radius_threshold bad_ids = [(section.id, section.points[1]) for section in considered_sections if narrow_section(section)] return CheckResult(len(bad_ids) == 0, bad_ids)
[ "def", "has_no_narrow_neurite_section", "(", "neuron", ",", "neurite_filter", ",", "radius_threshold", "=", "0.05", ",", "considered_section_min_length", "=", "50", ")", ":", "considered_sections", "=", "(", "sec", "for", "sec", "in", "iter_sections", "(", "neuron", ",", "neurite_filter", "=", "neurite_filter", ")", "if", "sec", ".", "length", ">", "considered_section_min_length", ")", "def", "narrow_section", "(", "section", ")", ":", "'''Select narrow sections'''", "return", "section", ".", "points", "[", ":", ",", "COLS", ".", "R", "]", ".", "mean", "(", ")", "<", "radius_threshold", "bad_ids", "=", "[", "(", "section", ".", "id", ",", "section", ".", "points", "[", "1", "]", ")", "for", "section", "in", "considered_sections", "if", "narrow_section", "(", "section", ")", "]", "return", "CheckResult", "(", "len", "(", "bad_ids", ")", "==", "0", ",", "bad_ids", ")" ]
Check if the neuron has dendrites with narrow sections Arguments: neuron(Neuron): The neuron object to test neurite_filter(callable): filter the neurites by this callable radius_threshold(float): radii below this are considered narro considered_section_min_length(float): sections with length below this are not taken into account Returns: CheckResult with result. result.info contains the narrow section ids and their first point
[ "Check", "if", "the", "neuron", "has", "dendrites", "with", "narrow", "sections" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/neuron_checks.py#L298-L325
2,611
BlueBrain/NeuroM
examples/synthesis_json.py
transform_header
def transform_header(mtype_name): '''Add header to json output to wrap around distribution data. ''' head_dict = OrderedDict() head_dict["m-type"] = mtype_name head_dict["components"] = defaultdict(OrderedDict) return head_dict
python
def transform_header(mtype_name): '''Add header to json output to wrap around distribution data. ''' head_dict = OrderedDict() head_dict["m-type"] = mtype_name head_dict["components"] = defaultdict(OrderedDict) return head_dict
[ "def", "transform_header", "(", "mtype_name", ")", ":", "head_dict", "=", "OrderedDict", "(", ")", "head_dict", "[", "\"m-type\"", "]", "=", "mtype_name", "head_dict", "[", "\"components\"", "]", "=", "defaultdict", "(", "OrderedDict", ")", "return", "head_dict" ]
Add header to json output to wrap around distribution data.
[ "Add", "header", "to", "json", "output", "to", "wrap", "around", "distribution", "data", "." ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/synthesis_json.py#L92-L100
2,612
BlueBrain/NeuroM
neurom/view/plotly.py
draw
def draw(obj, plane='3d', inline=False, **kwargs): '''Draw the morphology using in the given plane plane (str): a string representing the 2D plane (example: 'xy') or '3d', '3D' for a 3D view inline (bool): must be set to True for interactive ipython notebook plotting ''' if plane.lower() == '3d': return _plot_neuron3d(obj, inline, **kwargs) return _plot_neuron(obj, plane, inline, **kwargs)
python
def draw(obj, plane='3d', inline=False, **kwargs): '''Draw the morphology using in the given plane plane (str): a string representing the 2D plane (example: 'xy') or '3d', '3D' for a 3D view inline (bool): must be set to True for interactive ipython notebook plotting ''' if plane.lower() == '3d': return _plot_neuron3d(obj, inline, **kwargs) return _plot_neuron(obj, plane, inline, **kwargs)
[ "def", "draw", "(", "obj", ",", "plane", "=", "'3d'", ",", "inline", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "plane", ".", "lower", "(", ")", "==", "'3d'", ":", "return", "_plot_neuron3d", "(", "obj", ",", "inline", ",", "*", "*", "kwargs", ")", "return", "_plot_neuron", "(", "obj", ",", "plane", ",", "inline", ",", "*", "*", "kwargs", ")" ]
Draw the morphology using in the given plane plane (str): a string representing the 2D plane (example: 'xy') or '3d', '3D' for a 3D view inline (bool): must be set to True for interactive ipython notebook plotting
[ "Draw", "the", "morphology", "using", "in", "the", "given", "plane" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/view/plotly.py#L21-L31
2,613
BlueBrain/NeuroM
neurom/view/plotly.py
_make_trace
def _make_trace(neuron, plane): '''Create the trace to be plotted''' for neurite in iter_neurites(neuron): segments = list(iter_segments(neurite)) segs = [(s[0][COLS.XYZ], s[1][COLS.XYZ]) for s in segments] coords = dict(x=list(chain.from_iterable((p1[0], p2[0], None) for p1, p2 in segs)), y=list(chain.from_iterable((p1[1], p2[1], None) for p1, p2 in segs)), z=list(chain.from_iterable((p1[2], p2[2], None) for p1, p2 in segs))) color = TREE_COLOR.get(neurite.root_node.type, 'black') if plane.lower() == '3d': plot_fun = go.Scatter3d else: plot_fun = go.Scatter coords = dict(x=coords[plane[0]], y=coords[plane[1]]) yield plot_fun( line=dict(color=color, width=2), mode='lines', **coords )
python
def _make_trace(neuron, plane): '''Create the trace to be plotted''' for neurite in iter_neurites(neuron): segments = list(iter_segments(neurite)) segs = [(s[0][COLS.XYZ], s[1][COLS.XYZ]) for s in segments] coords = dict(x=list(chain.from_iterable((p1[0], p2[0], None) for p1, p2 in segs)), y=list(chain.from_iterable((p1[1], p2[1], None) for p1, p2 in segs)), z=list(chain.from_iterable((p1[2], p2[2], None) for p1, p2 in segs))) color = TREE_COLOR.get(neurite.root_node.type, 'black') if plane.lower() == '3d': plot_fun = go.Scatter3d else: plot_fun = go.Scatter coords = dict(x=coords[plane[0]], y=coords[plane[1]]) yield plot_fun( line=dict(color=color, width=2), mode='lines', **coords )
[ "def", "_make_trace", "(", "neuron", ",", "plane", ")", ":", "for", "neurite", "in", "iter_neurites", "(", "neuron", ")", ":", "segments", "=", "list", "(", "iter_segments", "(", "neurite", ")", ")", "segs", "=", "[", "(", "s", "[", "0", "]", "[", "COLS", ".", "XYZ", "]", ",", "s", "[", "1", "]", "[", "COLS", ".", "XYZ", "]", ")", "for", "s", "in", "segments", "]", "coords", "=", "dict", "(", "x", "=", "list", "(", "chain", ".", "from_iterable", "(", "(", "p1", "[", "0", "]", ",", "p2", "[", "0", "]", ",", "None", ")", "for", "p1", ",", "p2", "in", "segs", ")", ")", ",", "y", "=", "list", "(", "chain", ".", "from_iterable", "(", "(", "p1", "[", "1", "]", ",", "p2", "[", "1", "]", ",", "None", ")", "for", "p1", ",", "p2", "in", "segs", ")", ")", ",", "z", "=", "list", "(", "chain", ".", "from_iterable", "(", "(", "p1", "[", "2", "]", ",", "p2", "[", "2", "]", ",", "None", ")", "for", "p1", ",", "p2", "in", "segs", ")", ")", ")", "color", "=", "TREE_COLOR", ".", "get", "(", "neurite", ".", "root_node", ".", "type", ",", "'black'", ")", "if", "plane", ".", "lower", "(", ")", "==", "'3d'", ":", "plot_fun", "=", "go", ".", "Scatter3d", "else", ":", "plot_fun", "=", "go", ".", "Scatter", "coords", "=", "dict", "(", "x", "=", "coords", "[", "plane", "[", "0", "]", "]", ",", "y", "=", "coords", "[", "plane", "[", "1", "]", "]", ")", "yield", "plot_fun", "(", "line", "=", "dict", "(", "color", "=", "color", ",", "width", "=", "2", ")", ",", "mode", "=", "'lines'", ",", "*", "*", "coords", ")" ]
Create the trace to be plotted
[ "Create", "the", "trace", "to", "be", "plotted" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/view/plotly.py#L46-L67
2,614
BlueBrain/NeuroM
neurom/view/plotly.py
get_figure
def get_figure(neuron, plane, title): '''Returns the plotly figure containing the neuron''' data = list(_make_trace(neuron, plane)) axis = dict( gridcolor='rgb(255, 255, 255)', zerolinecolor='rgb(255, 255, 255)', showbackground=True, backgroundcolor='rgb(230, 230,230)' ) if plane != '3d': soma_2d = [ # filled circle { 'type': 'circle', 'xref': 'x', 'yref': 'y', 'fillcolor': 'rgba(50, 171, 96, 0.7)', 'x0': neuron.soma.center[0] - neuron.soma.radius, 'y0': neuron.soma.center[1] - neuron.soma.radius, 'x1': neuron.soma.center[0] + neuron.soma.radius, 'y1': neuron.soma.center[1] + neuron.soma.radius, 'line': { 'color': 'rgba(50, 171, 96, 1)', }, }, ] else: soma_2d = [] theta = np.linspace(0, 2 * np.pi, 100) phi = np.linspace(0, np.pi, 100) z = np.outer(np.ones(100), np.cos(phi)) + neuron.soma.center[2] r = neuron.soma.radius data.append( go.Surface( x=(np.outer(np.cos(theta), np.sin(phi)) + neuron.soma.center[0]) * r, y=(np.outer(np.sin(theta), np.sin(phi)) + neuron.soma.center[1]) * r, z=z * r, cauto=False, surfacecolor=['black'] * len(z), showscale=False, ) ) layout = dict( autosize=True, title=title, scene=dict( # This is used for 3D plots xaxis=axis, yaxis=axis, zaxis=axis, camera=dict(up=dict(x=0, y=0, z=1), eye=dict(x=-1.7428, y=1.0707, z=0.7100,)), aspectmode='data' ), yaxis=dict(scaleanchor="x"), # This is used for 2D plots shapes=soma_2d, ) res = dict(data=data, layout=layout) return res
python
def get_figure(neuron, plane, title): '''Returns the plotly figure containing the neuron''' data = list(_make_trace(neuron, plane)) axis = dict( gridcolor='rgb(255, 255, 255)', zerolinecolor='rgb(255, 255, 255)', showbackground=True, backgroundcolor='rgb(230, 230,230)' ) if plane != '3d': soma_2d = [ # filled circle { 'type': 'circle', 'xref': 'x', 'yref': 'y', 'fillcolor': 'rgba(50, 171, 96, 0.7)', 'x0': neuron.soma.center[0] - neuron.soma.radius, 'y0': neuron.soma.center[1] - neuron.soma.radius, 'x1': neuron.soma.center[0] + neuron.soma.radius, 'y1': neuron.soma.center[1] + neuron.soma.radius, 'line': { 'color': 'rgba(50, 171, 96, 1)', }, }, ] else: soma_2d = [] theta = np.linspace(0, 2 * np.pi, 100) phi = np.linspace(0, np.pi, 100) z = np.outer(np.ones(100), np.cos(phi)) + neuron.soma.center[2] r = neuron.soma.radius data.append( go.Surface( x=(np.outer(np.cos(theta), np.sin(phi)) + neuron.soma.center[0]) * r, y=(np.outer(np.sin(theta), np.sin(phi)) + neuron.soma.center[1]) * r, z=z * r, cauto=False, surfacecolor=['black'] * len(z), showscale=False, ) ) layout = dict( autosize=True, title=title, scene=dict( # This is used for 3D plots xaxis=axis, yaxis=axis, zaxis=axis, camera=dict(up=dict(x=0, y=0, z=1), eye=dict(x=-1.7428, y=1.0707, z=0.7100,)), aspectmode='data' ), yaxis=dict(scaleanchor="x"), # This is used for 2D plots shapes=soma_2d, ) res = dict(data=data, layout=layout) return res
[ "def", "get_figure", "(", "neuron", ",", "plane", ",", "title", ")", ":", "data", "=", "list", "(", "_make_trace", "(", "neuron", ",", "plane", ")", ")", "axis", "=", "dict", "(", "gridcolor", "=", "'rgb(255, 255, 255)'", ",", "zerolinecolor", "=", "'rgb(255, 255, 255)'", ",", "showbackground", "=", "True", ",", "backgroundcolor", "=", "'rgb(230, 230,230)'", ")", "if", "plane", "!=", "'3d'", ":", "soma_2d", "=", "[", "# filled circle", "{", "'type'", ":", "'circle'", ",", "'xref'", ":", "'x'", ",", "'yref'", ":", "'y'", ",", "'fillcolor'", ":", "'rgba(50, 171, 96, 0.7)'", ",", "'x0'", ":", "neuron", ".", "soma", ".", "center", "[", "0", "]", "-", "neuron", ".", "soma", ".", "radius", ",", "'y0'", ":", "neuron", ".", "soma", ".", "center", "[", "1", "]", "-", "neuron", ".", "soma", ".", "radius", ",", "'x1'", ":", "neuron", ".", "soma", ".", "center", "[", "0", "]", "+", "neuron", ".", "soma", ".", "radius", ",", "'y1'", ":", "neuron", ".", "soma", ".", "center", "[", "1", "]", "+", "neuron", ".", "soma", ".", "radius", ",", "'line'", ":", "{", "'color'", ":", "'rgba(50, 171, 96, 1)'", ",", "}", ",", "}", ",", "]", "else", ":", "soma_2d", "=", "[", "]", "theta", "=", "np", ".", "linspace", "(", "0", ",", "2", "*", "np", ".", "pi", ",", "100", ")", "phi", "=", "np", ".", "linspace", "(", "0", ",", "np", ".", "pi", ",", "100", ")", "z", "=", "np", ".", "outer", "(", "np", ".", "ones", "(", "100", ")", ",", "np", ".", "cos", "(", "phi", ")", ")", "+", "neuron", ".", "soma", ".", "center", "[", "2", "]", "r", "=", "neuron", ".", "soma", ".", "radius", "data", ".", "append", "(", "go", ".", "Surface", "(", "x", "=", "(", "np", ".", "outer", "(", "np", ".", "cos", "(", "theta", ")", ",", "np", ".", "sin", "(", "phi", ")", ")", "+", "neuron", ".", "soma", ".", "center", "[", "0", "]", ")", "*", "r", ",", "y", "=", "(", "np", ".", "outer", "(", "np", ".", "sin", "(", "theta", ")", ",", "np", ".", "sin", "(", "phi", ")", ")", "+", "neuron", ".", "soma", ".", "center", "[", "1", "]", ")", "*", "r", ",", "z", "=", "z", "*", "r", ",", "cauto", "=", "False", ",", "surfacecolor", "=", "[", "'black'", "]", "*", "len", "(", "z", ")", ",", "showscale", "=", "False", ",", ")", ")", "layout", "=", "dict", "(", "autosize", "=", "True", ",", "title", "=", "title", ",", "scene", "=", "dict", "(", "# This is used for 3D plots", "xaxis", "=", "axis", ",", "yaxis", "=", "axis", ",", "zaxis", "=", "axis", ",", "camera", "=", "dict", "(", "up", "=", "dict", "(", "x", "=", "0", ",", "y", "=", "0", ",", "z", "=", "1", ")", ",", "eye", "=", "dict", "(", "x", "=", "-", "1.7428", ",", "y", "=", "1.0707", ",", "z", "=", "0.7100", ",", ")", ")", ",", "aspectmode", "=", "'data'", ")", ",", "yaxis", "=", "dict", "(", "scaleanchor", "=", "\"x\"", ")", ",", "# This is used for 2D plots", "shapes", "=", "soma_2d", ",", ")", "res", "=", "dict", "(", "data", "=", "data", ",", "layout", "=", "layout", ")", "return", "res" ]
Returns the plotly figure containing the neuron
[ "Returns", "the", "plotly", "figure", "containing", "the", "neuron" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/view/plotly.py#L70-L129
2,615
BlueBrain/NeuroM
neurom/geom/transform.py
rotate
def rotate(obj, axis, angle, origin=None): ''' Rotation around unit vector following the right hand rule Parameters: obj : obj to be rotated (e.g. neurite, neuron). Must implement a transform method. axis : unit vector for the axis of rotation angle : rotation angle in rads Returns: A copy of the object with the applied translation. ''' R = _rodrigues_to_dcm(axis, angle) try: return obj.transform(PivotRotation(R, origin)) except AttributeError: raise NotImplementedError
python
def rotate(obj, axis, angle, origin=None): ''' Rotation around unit vector following the right hand rule Parameters: obj : obj to be rotated (e.g. neurite, neuron). Must implement a transform method. axis : unit vector for the axis of rotation angle : rotation angle in rads Returns: A copy of the object with the applied translation. ''' R = _rodrigues_to_dcm(axis, angle) try: return obj.transform(PivotRotation(R, origin)) except AttributeError: raise NotImplementedError
[ "def", "rotate", "(", "obj", ",", "axis", ",", "angle", ",", "origin", "=", "None", ")", ":", "R", "=", "_rodrigues_to_dcm", "(", "axis", ",", "angle", ")", "try", ":", "return", "obj", ".", "transform", "(", "PivotRotation", "(", "R", ",", "origin", ")", ")", "except", "AttributeError", ":", "raise", "NotImplementedError" ]
Rotation around unit vector following the right hand rule Parameters: obj : obj to be rotated (e.g. neurite, neuron). Must implement a transform method. axis : unit vector for the axis of rotation angle : rotation angle in rads Returns: A copy of the object with the applied translation.
[ "Rotation", "around", "unit", "vector", "following", "the", "right", "hand", "rule" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/geom/transform.py#L128-L146
2,616
BlueBrain/NeuroM
neurom/geom/transform.py
_sin
def _sin(x): '''sine with case for pi multiples''' return 0. if np.isclose(np.mod(x, np.pi), 0.) else np.sin(x)
python
def _sin(x): '''sine with case for pi multiples''' return 0. if np.isclose(np.mod(x, np.pi), 0.) else np.sin(x)
[ "def", "_sin", "(", "x", ")", ":", "return", "0.", "if", "np", ".", "isclose", "(", "np", ".", "mod", "(", "x", ",", "np", ".", "pi", ")", ",", "0.", ")", "else", "np", ".", "sin", "(", "x", ")" ]
sine with case for pi multiples
[ "sine", "with", "case", "for", "pi", "multiples" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/geom/transform.py#L149-L151
2,617
BlueBrain/NeuroM
neurom/geom/transform.py
_rodrigues_to_dcm
def _rodrigues_to_dcm(axis, angle): ''' Generates transformation matrix from unit vector and rotation angle. The rotation is applied in the direction of the axis which is a unit vector following the right hand rule. Inputs : axis : unit vector of the direction of the rotation angle : angle of rotation in rads Returns : 3x3 Rotation matrix ''' ux, uy, uz = axis / np.linalg.norm(axis) uxx = ux * ux uyy = uy * uy uzz = uz * uz uxy = ux * uy uxz = ux * uz uyz = uy * uz sn = _sin(angle) cs = _sin(np.pi / 2. - angle) cs1 = 1. - cs R = np.zeros([3, 3]) R[0, 0] = cs + uxx * cs1 R[0, 1] = uxy * cs1 - uz * sn R[0, 2] = uxz * cs1 + uy * sn R[1, 0] = uxy * cs1 + uz * sn R[1, 1] = cs + uyy * cs1 R[1, 2] = uyz * cs1 - ux * sn R[2, 0] = uxz * cs1 - uy * sn R[2, 1] = uyz * cs1 + ux * sn R[2, 2] = cs + uzz * cs1 return R
python
def _rodrigues_to_dcm(axis, angle): ''' Generates transformation matrix from unit vector and rotation angle. The rotation is applied in the direction of the axis which is a unit vector following the right hand rule. Inputs : axis : unit vector of the direction of the rotation angle : angle of rotation in rads Returns : 3x3 Rotation matrix ''' ux, uy, uz = axis / np.linalg.norm(axis) uxx = ux * ux uyy = uy * uy uzz = uz * uz uxy = ux * uy uxz = ux * uz uyz = uy * uz sn = _sin(angle) cs = _sin(np.pi / 2. - angle) cs1 = 1. - cs R = np.zeros([3, 3]) R[0, 0] = cs + uxx * cs1 R[0, 1] = uxy * cs1 - uz * sn R[0, 2] = uxz * cs1 + uy * sn R[1, 0] = uxy * cs1 + uz * sn R[1, 1] = cs + uyy * cs1 R[1, 2] = uyz * cs1 - ux * sn R[2, 0] = uxz * cs1 - uy * sn R[2, 1] = uyz * cs1 + ux * sn R[2, 2] = cs + uzz * cs1 return R
[ "def", "_rodrigues_to_dcm", "(", "axis", ",", "angle", ")", ":", "ux", ",", "uy", ",", "uz", "=", "axis", "/", "np", ".", "linalg", ".", "norm", "(", "axis", ")", "uxx", "=", "ux", "*", "ux", "uyy", "=", "uy", "*", "uy", "uzz", "=", "uz", "*", "uz", "uxy", "=", "ux", "*", "uy", "uxz", "=", "ux", "*", "uz", "uyz", "=", "uy", "*", "uz", "sn", "=", "_sin", "(", "angle", ")", "cs", "=", "_sin", "(", "np", ".", "pi", "/", "2.", "-", "angle", ")", "cs1", "=", "1.", "-", "cs", "R", "=", "np", ".", "zeros", "(", "[", "3", ",", "3", "]", ")", "R", "[", "0", ",", "0", "]", "=", "cs", "+", "uxx", "*", "cs1", "R", "[", "0", ",", "1", "]", "=", "uxy", "*", "cs1", "-", "uz", "*", "sn", "R", "[", "0", ",", "2", "]", "=", "uxz", "*", "cs1", "+", "uy", "*", "sn", "R", "[", "1", ",", "0", "]", "=", "uxy", "*", "cs1", "+", "uz", "*", "sn", "R", "[", "1", ",", "1", "]", "=", "cs", "+", "uyy", "*", "cs1", "R", "[", "1", ",", "2", "]", "=", "uyz", "*", "cs1", "-", "ux", "*", "sn", "R", "[", "2", ",", "0", "]", "=", "uxz", "*", "cs1", "-", "uy", "*", "sn", "R", "[", "2", ",", "1", "]", "=", "uyz", "*", "cs1", "+", "ux", "*", "sn", "R", "[", "2", ",", "2", "]", "=", "cs", "+", "uzz", "*", "cs1", "return", "R" ]
Generates transformation matrix from unit vector and rotation angle. The rotation is applied in the direction of the axis which is a unit vector following the right hand rule. Inputs : axis : unit vector of the direction of the rotation angle : angle of rotation in rads Returns : 3x3 Rotation matrix
[ "Generates", "transformation", "matrix", "from", "unit", "vector", "and", "rotation", "angle", ".", "The", "rotation", "is", "applied", "in", "the", "direction", "of", "the", "axis", "which", "is", "a", "unit", "vector", "following", "the", "right", "hand", "rule", "." ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/geom/transform.py#L154-L194
2,618
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
total_length
def total_length(nrn_pop, neurite_type=NeuriteType.all): '''Get the total length of all sections in the group of neurons or neurites''' nrns = _neuronfunc.neuron_population(nrn_pop) return list(sum(section_lengths(n, neurite_type=neurite_type)) for n in nrns)
python
def total_length(nrn_pop, neurite_type=NeuriteType.all): '''Get the total length of all sections in the group of neurons or neurites''' nrns = _neuronfunc.neuron_population(nrn_pop) return list(sum(section_lengths(n, neurite_type=neurite_type)) for n in nrns)
[ "def", "total_length", "(", "nrn_pop", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "nrns", "=", "_neuronfunc", ".", "neuron_population", "(", "nrn_pop", ")", "return", "list", "(", "sum", "(", "section_lengths", "(", "n", ",", "neurite_type", "=", "neurite_type", ")", ")", "for", "n", "in", "nrns", ")" ]
Get the total length of all sections in the group of neurons or neurites
[ "Get", "the", "total", "length", "of", "all", "sections", "in", "the", "group", "of", "neurons", "or", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L45-L48
2,619
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
n_segments
def n_segments(neurites, neurite_type=NeuriteType.all): '''Number of segments in a collection of neurites''' return sum(len(s.points) - 1 for s in iter_sections(neurites, neurite_filter=is_type(neurite_type)))
python
def n_segments(neurites, neurite_type=NeuriteType.all): '''Number of segments in a collection of neurites''' return sum(len(s.points) - 1 for s in iter_sections(neurites, neurite_filter=is_type(neurite_type)))
[ "def", "n_segments", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "sum", "(", "len", "(", "s", ".", "points", ")", "-", "1", "for", "s", "in", "iter_sections", "(", "neurites", ",", "neurite_filter", "=", "is_type", "(", "neurite_type", ")", ")", ")" ]
Number of segments in a collection of neurites
[ "Number", "of", "segments", "in", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L51-L54
2,620
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
n_neurites
def n_neurites(neurites, neurite_type=NeuriteType.all): '''Number of neurites in a collection of neurites''' return sum(1 for _ in iter_neurites(neurites, filt=is_type(neurite_type)))
python
def n_neurites(neurites, neurite_type=NeuriteType.all): '''Number of neurites in a collection of neurites''' return sum(1 for _ in iter_neurites(neurites, filt=is_type(neurite_type)))
[ "def", "n_neurites", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "sum", "(", "1", "for", "_", "in", "iter_neurites", "(", "neurites", ",", "filt", "=", "is_type", "(", "neurite_type", ")", ")", ")" ]
Number of neurites in a collection of neurites
[ "Number", "of", "neurites", "in", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L57-L59
2,621
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
n_sections
def n_sections(neurites, neurite_type=NeuriteType.all, iterator_type=Tree.ipreorder): '''Number of sections in a collection of neurites''' return sum(1 for _ in iter_sections(neurites, iterator_type=iterator_type, neurite_filter=is_type(neurite_type)))
python
def n_sections(neurites, neurite_type=NeuriteType.all, iterator_type=Tree.ipreorder): '''Number of sections in a collection of neurites''' return sum(1 for _ in iter_sections(neurites, iterator_type=iterator_type, neurite_filter=is_type(neurite_type)))
[ "def", "n_sections", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ",", "iterator_type", "=", "Tree", ".", "ipreorder", ")", ":", "return", "sum", "(", "1", "for", "_", "in", "iter_sections", "(", "neurites", ",", "iterator_type", "=", "iterator_type", ",", "neurite_filter", "=", "is_type", "(", "neurite_type", ")", ")", ")" ]
Number of sections in a collection of neurites
[ "Number", "of", "sections", "in", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L62-L66
2,622
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
n_bifurcation_points
def n_bifurcation_points(neurites, neurite_type=NeuriteType.all): '''number of bifurcation points in a collection of neurites''' return n_sections(neurites, neurite_type=neurite_type, iterator_type=Tree.ibifurcation_point)
python
def n_bifurcation_points(neurites, neurite_type=NeuriteType.all): '''number of bifurcation points in a collection of neurites''' return n_sections(neurites, neurite_type=neurite_type, iterator_type=Tree.ibifurcation_point)
[ "def", "n_bifurcation_points", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "n_sections", "(", "neurites", ",", "neurite_type", "=", "neurite_type", ",", "iterator_type", "=", "Tree", ".", "ibifurcation_point", ")" ]
number of bifurcation points in a collection of neurites
[ "number", "of", "bifurcation", "points", "in", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L69-L71
2,623
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
n_forking_points
def n_forking_points(neurites, neurite_type=NeuriteType.all): '''number of forking points in a collection of neurites''' return n_sections(neurites, neurite_type=neurite_type, iterator_type=Tree.iforking_point)
python
def n_forking_points(neurites, neurite_type=NeuriteType.all): '''number of forking points in a collection of neurites''' return n_sections(neurites, neurite_type=neurite_type, iterator_type=Tree.iforking_point)
[ "def", "n_forking_points", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "n_sections", "(", "neurites", ",", "neurite_type", "=", "neurite_type", ",", "iterator_type", "=", "Tree", ".", "iforking_point", ")" ]
number of forking points in a collection of neurites
[ "number", "of", "forking", "points", "in", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L74-L76
2,624
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
n_leaves
def n_leaves(neurites, neurite_type=NeuriteType.all): '''number of leaves points in a collection of neurites''' return n_sections(neurites, neurite_type=neurite_type, iterator_type=Tree.ileaf)
python
def n_leaves(neurites, neurite_type=NeuriteType.all): '''number of leaves points in a collection of neurites''' return n_sections(neurites, neurite_type=neurite_type, iterator_type=Tree.ileaf)
[ "def", "n_leaves", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "n_sections", "(", "neurites", ",", "neurite_type", "=", "neurite_type", ",", "iterator_type", "=", "Tree", ".", "ileaf", ")" ]
number of leaves points in a collection of neurites
[ "number", "of", "leaves", "points", "in", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L79-L81
2,625
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
total_area_per_neurite
def total_area_per_neurite(neurites, neurite_type=NeuriteType.all): '''Surface area in a collection of neurites. The area is defined as the sum of the area of the sections. ''' return [neurite.area for neurite in iter_neurites(neurites, filt=is_type(neurite_type))]
python
def total_area_per_neurite(neurites, neurite_type=NeuriteType.all): '''Surface area in a collection of neurites. The area is defined as the sum of the area of the sections. ''' return [neurite.area for neurite in iter_neurites(neurites, filt=is_type(neurite_type))]
[ "def", "total_area_per_neurite", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "[", "neurite", ".", "area", "for", "neurite", "in", "iter_neurites", "(", "neurites", ",", "filt", "=", "is_type", "(", "neurite_type", ")", ")", "]" ]
Surface area in a collection of neurites. The area is defined as the sum of the area of the sections.
[ "Surface", "area", "in", "a", "collection", "of", "neurites", "." ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L84-L89
2,626
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
map_sections
def map_sections(fun, neurites, neurite_type=NeuriteType.all, iterator_type=Tree.ipreorder): '''Map `fun` to all the sections in a collection of neurites''' return map(fun, iter_sections(neurites, iterator_type=iterator_type, neurite_filter=is_type(neurite_type)))
python
def map_sections(fun, neurites, neurite_type=NeuriteType.all, iterator_type=Tree.ipreorder): '''Map `fun` to all the sections in a collection of neurites''' return map(fun, iter_sections(neurites, iterator_type=iterator_type, neurite_filter=is_type(neurite_type)))
[ "def", "map_sections", "(", "fun", ",", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ",", "iterator_type", "=", "Tree", ".", "ipreorder", ")", ":", "return", "map", "(", "fun", ",", "iter_sections", "(", "neurites", ",", "iterator_type", "=", "iterator_type", ",", "neurite_filter", "=", "is_type", "(", "neurite_type", ")", ")", ")" ]
Map `fun` to all the sections in a collection of neurites
[ "Map", "fun", "to", "all", "the", "sections", "in", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L92-L96
2,627
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
section_lengths
def section_lengths(neurites, neurite_type=NeuriteType.all): '''section lengths in a collection of neurites''' return map_sections(_section_length, neurites, neurite_type=neurite_type)
python
def section_lengths(neurites, neurite_type=NeuriteType.all): '''section lengths in a collection of neurites''' return map_sections(_section_length, neurites, neurite_type=neurite_type)
[ "def", "section_lengths", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "map_sections", "(", "_section_length", ",", "neurites", ",", "neurite_type", "=", "neurite_type", ")" ]
section lengths in a collection of neurites
[ "section", "lengths", "in", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L104-L106
2,628
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
section_term_lengths
def section_term_lengths(neurites, neurite_type=NeuriteType.all): '''Termination section lengths in a collection of neurites''' return map_sections(_section_length, neurites, neurite_type=neurite_type, iterator_type=Tree.ileaf)
python
def section_term_lengths(neurites, neurite_type=NeuriteType.all): '''Termination section lengths in a collection of neurites''' return map_sections(_section_length, neurites, neurite_type=neurite_type, iterator_type=Tree.ileaf)
[ "def", "section_term_lengths", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "map_sections", "(", "_section_length", ",", "neurites", ",", "neurite_type", "=", "neurite_type", ",", "iterator_type", "=", "Tree", ".", "ileaf", ")" ]
Termination section lengths in a collection of neurites
[ "Termination", "section", "lengths", "in", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L109-L112
2,629
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
section_bif_lengths
def section_bif_lengths(neurites, neurite_type=NeuriteType.all): '''Bifurcation section lengths in a collection of neurites''' return map_sections(_section_length, neurites, neurite_type=neurite_type, iterator_type=Tree.ibifurcation_point)
python
def section_bif_lengths(neurites, neurite_type=NeuriteType.all): '''Bifurcation section lengths in a collection of neurites''' return map_sections(_section_length, neurites, neurite_type=neurite_type, iterator_type=Tree.ibifurcation_point)
[ "def", "section_bif_lengths", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "map_sections", "(", "_section_length", ",", "neurites", ",", "neurite_type", "=", "neurite_type", ",", "iterator_type", "=", "Tree", ".", "ibifurcation_point", ")" ]
Bifurcation section lengths in a collection of neurites
[ "Bifurcation", "section", "lengths", "in", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L115-L118
2,630
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
section_branch_orders
def section_branch_orders(neurites, neurite_type=NeuriteType.all): '''section branch orders in a collection of neurites''' return map_sections(sectionfunc.branch_order, neurites, neurite_type=neurite_type)
python
def section_branch_orders(neurites, neurite_type=NeuriteType.all): '''section branch orders in a collection of neurites''' return map_sections(sectionfunc.branch_order, neurites, neurite_type=neurite_type)
[ "def", "section_branch_orders", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "map_sections", "(", "sectionfunc", ".", "branch_order", ",", "neurites", ",", "neurite_type", "=", "neurite_type", ")" ]
section branch orders in a collection of neurites
[ "section", "branch", "orders", "in", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L121-L123
2,631
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
section_bif_branch_orders
def section_bif_branch_orders(neurites, neurite_type=NeuriteType.all): '''Bifurcation section branch orders in a collection of neurites''' return map_sections(sectionfunc.branch_order, neurites, neurite_type=neurite_type, iterator_type=Tree.ibifurcation_point)
python
def section_bif_branch_orders(neurites, neurite_type=NeuriteType.all): '''Bifurcation section branch orders in a collection of neurites''' return map_sections(sectionfunc.branch_order, neurites, neurite_type=neurite_type, iterator_type=Tree.ibifurcation_point)
[ "def", "section_bif_branch_orders", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "map_sections", "(", "sectionfunc", ".", "branch_order", ",", "neurites", ",", "neurite_type", "=", "neurite_type", ",", "iterator_type", "=", "Tree", ".", "ibifurcation_point", ")" ]
Bifurcation section branch orders in a collection of neurites
[ "Bifurcation", "section", "branch", "orders", "in", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L126-L129
2,632
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
section_term_branch_orders
def section_term_branch_orders(neurites, neurite_type=NeuriteType.all): '''Termination section branch orders in a collection of neurites''' return map_sections(sectionfunc.branch_order, neurites, neurite_type=neurite_type, iterator_type=Tree.ileaf)
python
def section_term_branch_orders(neurites, neurite_type=NeuriteType.all): '''Termination section branch orders in a collection of neurites''' return map_sections(sectionfunc.branch_order, neurites, neurite_type=neurite_type, iterator_type=Tree.ileaf)
[ "def", "section_term_branch_orders", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "map_sections", "(", "sectionfunc", ".", "branch_order", ",", "neurites", ",", "neurite_type", "=", "neurite_type", ",", "iterator_type", "=", "Tree", ".", "ileaf", ")" ]
Termination section branch orders in a collection of neurites
[ "Termination", "section", "branch", "orders", "in", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L132-L135
2,633
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
section_path_lengths
def section_path_lengths(neurites, neurite_type=NeuriteType.all): '''Path lengths of a collection of neurites ''' # Calculates and stores the section lengths in one pass, # then queries the lengths in the path length iterations. # This avoids repeatedly calculating the lengths of the # same sections. dist = {} neurite_filter = is_type(neurite_type) for s in iter_sections(neurites, neurite_filter=neurite_filter): dist[s] = s.length def pl2(node): '''Calculate the path length using cached section lengths''' return sum(dist[n] for n in node.iupstream()) return map_sections(pl2, neurites, neurite_type=neurite_type)
python
def section_path_lengths(neurites, neurite_type=NeuriteType.all): '''Path lengths of a collection of neurites ''' # Calculates and stores the section lengths in one pass, # then queries the lengths in the path length iterations. # This avoids repeatedly calculating the lengths of the # same sections. dist = {} neurite_filter = is_type(neurite_type) for s in iter_sections(neurites, neurite_filter=neurite_filter): dist[s] = s.length def pl2(node): '''Calculate the path length using cached section lengths''' return sum(dist[n] for n in node.iupstream()) return map_sections(pl2, neurites, neurite_type=neurite_type)
[ "def", "section_path_lengths", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "# Calculates and stores the section lengths in one pass,", "# then queries the lengths in the path length iterations.", "# This avoids repeatedly calculating the lengths of the", "# same sections.", "dist", "=", "{", "}", "neurite_filter", "=", "is_type", "(", "neurite_type", ")", "for", "s", "in", "iter_sections", "(", "neurites", ",", "neurite_filter", "=", "neurite_filter", ")", ":", "dist", "[", "s", "]", "=", "s", ".", "length", "def", "pl2", "(", "node", ")", ":", "'''Calculate the path length using cached section lengths'''", "return", "sum", "(", "dist", "[", "n", "]", "for", "n", "in", "node", ".", "iupstream", "(", ")", ")", "return", "map_sections", "(", "pl2", ",", "neurites", ",", "neurite_type", "=", "neurite_type", ")" ]
Path lengths of a collection of neurites
[ "Path", "lengths", "of", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L138-L154
2,634
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
map_neurons
def map_neurons(fun, neurites, neurite_type): '''Map `fun` to all the neurites in a single or collection of neurons''' nrns = _neuronfunc.neuron_population(neurites) return [fun(n, neurite_type=neurite_type) for n in nrns]
python
def map_neurons(fun, neurites, neurite_type): '''Map `fun` to all the neurites in a single or collection of neurons''' nrns = _neuronfunc.neuron_population(neurites) return [fun(n, neurite_type=neurite_type) for n in nrns]
[ "def", "map_neurons", "(", "fun", ",", "neurites", ",", "neurite_type", ")", ":", "nrns", "=", "_neuronfunc", ".", "neuron_population", "(", "neurites", ")", "return", "[", "fun", "(", "n", ",", "neurite_type", "=", "neurite_type", ")", "for", "n", "in", "nrns", "]" ]
Map `fun` to all the neurites in a single or collection of neurons
[ "Map", "fun", "to", "all", "the", "neurites", "in", "a", "single", "or", "collection", "of", "neurons" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L157-L160
2,635
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
map_segments
def map_segments(func, neurites, neurite_type): ''' Map `func` to all the segments in a collection of neurites `func` accepts a section and returns list of values corresponding to each segment. ''' neurite_filter = is_type(neurite_type) return [ s for ss in iter_sections(neurites, neurite_filter=neurite_filter) for s in func(ss) ]
python
def map_segments(func, neurites, neurite_type): ''' Map `func` to all the segments in a collection of neurites `func` accepts a section and returns list of values corresponding to each segment. ''' neurite_filter = is_type(neurite_type) return [ s for ss in iter_sections(neurites, neurite_filter=neurite_filter) for s in func(ss) ]
[ "def", "map_segments", "(", "func", ",", "neurites", ",", "neurite_type", ")", ":", "neurite_filter", "=", "is_type", "(", "neurite_type", ")", "return", "[", "s", "for", "ss", "in", "iter_sections", "(", "neurites", ",", "neurite_filter", "=", "neurite_filter", ")", "for", "s", "in", "func", "(", "ss", ")", "]" ]
Map `func` to all the segments in a collection of neurites `func` accepts a section and returns list of values corresponding to each segment.
[ "Map", "func", "to", "all", "the", "segments", "in", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L193-L201
2,636
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
segment_volumes
def segment_volumes(neurites, neurite_type=NeuriteType.all): '''Volumes of the segments in a collection of neurites''' def _func(sec): '''list of segment volumes of a section''' return [morphmath.segment_volume(seg) for seg in zip(sec.points[:-1], sec.points[1:])] return map_segments(_func, neurites, neurite_type)
python
def segment_volumes(neurites, neurite_type=NeuriteType.all): '''Volumes of the segments in a collection of neurites''' def _func(sec): '''list of segment volumes of a section''' return [morphmath.segment_volume(seg) for seg in zip(sec.points[:-1], sec.points[1:])] return map_segments(_func, neurites, neurite_type)
[ "def", "segment_volumes", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "def", "_func", "(", "sec", ")", ":", "'''list of segment volumes of a section'''", "return", "[", "morphmath", ".", "segment_volume", "(", "seg", ")", "for", "seg", "in", "zip", "(", "sec", ".", "points", "[", ":", "-", "1", "]", ",", "sec", ".", "points", "[", "1", ":", "]", ")", "]", "return", "map_segments", "(", "_func", ",", "neurites", ",", "neurite_type", ")" ]
Volumes of the segments in a collection of neurites
[ "Volumes", "of", "the", "segments", "in", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L213-L219
2,637
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
segment_radii
def segment_radii(neurites, neurite_type=NeuriteType.all): '''arithmetic mean of the radii of the points in segments in a collection of neurites''' def _seg_radii(sec): '''vectorized mean radii''' pts = sec.points[:, COLS.R] return np.divide(np.add(pts[:-1], pts[1:]), 2.0) return map_segments(_seg_radii, neurites, neurite_type)
python
def segment_radii(neurites, neurite_type=NeuriteType.all): '''arithmetic mean of the radii of the points in segments in a collection of neurites''' def _seg_radii(sec): '''vectorized mean radii''' pts = sec.points[:, COLS.R] return np.divide(np.add(pts[:-1], pts[1:]), 2.0) return map_segments(_seg_radii, neurites, neurite_type)
[ "def", "segment_radii", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "def", "_seg_radii", "(", "sec", ")", ":", "'''vectorized mean radii'''", "pts", "=", "sec", ".", "points", "[", ":", ",", "COLS", ".", "R", "]", "return", "np", ".", "divide", "(", "np", ".", "add", "(", "pts", "[", ":", "-", "1", "]", ",", "pts", "[", "1", ":", "]", ")", ",", "2.0", ")", "return", "map_segments", "(", "_seg_radii", ",", "neurites", ",", "neurite_type", ")" ]
arithmetic mean of the radii of the points in segments in a collection of neurites
[ "arithmetic", "mean", "of", "the", "radii", "of", "the", "points", "in", "segments", "in", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L222-L229
2,638
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
segment_taper_rates
def segment_taper_rates(neurites, neurite_type=NeuriteType.all): '''taper rates of the segments in a collection of neurites The taper rate is defined as the absolute radii differences divided by length of the section ''' def _seg_taper_rates(sec): '''vectorized taper rates''' pts = sec.points[:, COLS.XYZR] diff = np.diff(pts, axis=0) distance = np.linalg.norm(diff[:, COLS.XYZ], axis=1) return np.divide(2 * np.abs(diff[:, COLS.R]), distance) return map_segments(_seg_taper_rates, neurites, neurite_type)
python
def segment_taper_rates(neurites, neurite_type=NeuriteType.all): '''taper rates of the segments in a collection of neurites The taper rate is defined as the absolute radii differences divided by length of the section ''' def _seg_taper_rates(sec): '''vectorized taper rates''' pts = sec.points[:, COLS.XYZR] diff = np.diff(pts, axis=0) distance = np.linalg.norm(diff[:, COLS.XYZ], axis=1) return np.divide(2 * np.abs(diff[:, COLS.R]), distance) return map_segments(_seg_taper_rates, neurites, neurite_type)
[ "def", "segment_taper_rates", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "def", "_seg_taper_rates", "(", "sec", ")", ":", "'''vectorized taper rates'''", "pts", "=", "sec", ".", "points", "[", ":", ",", "COLS", ".", "XYZR", "]", "diff", "=", "np", ".", "diff", "(", "pts", ",", "axis", "=", "0", ")", "distance", "=", "np", ".", "linalg", ".", "norm", "(", "diff", "[", ":", ",", "COLS", ".", "XYZ", "]", ",", "axis", "=", "1", ")", "return", "np", ".", "divide", "(", "2", "*", "np", ".", "abs", "(", "diff", "[", ":", ",", "COLS", ".", "R", "]", ")", ",", "distance", ")", "return", "map_segments", "(", "_seg_taper_rates", ",", "neurites", ",", "neurite_type", ")" ]
taper rates of the segments in a collection of neurites The taper rate is defined as the absolute radii differences divided by length of the section
[ "taper", "rates", "of", "the", "segments", "in", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L232-L244
2,639
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
segment_midpoints
def segment_midpoints(neurites, neurite_type=NeuriteType.all): '''Return a list of segment mid-points in a collection of neurites''' def _seg_midpoint(sec): '''Return the mid-points of segments in a section''' pts = sec.points[:, COLS.XYZ] return np.divide(np.add(pts[:-1], pts[1:]), 2.0) return map_segments(_seg_midpoint, neurites, neurite_type)
python
def segment_midpoints(neurites, neurite_type=NeuriteType.all): '''Return a list of segment mid-points in a collection of neurites''' def _seg_midpoint(sec): '''Return the mid-points of segments in a section''' pts = sec.points[:, COLS.XYZ] return np.divide(np.add(pts[:-1], pts[1:]), 2.0) return map_segments(_seg_midpoint, neurites, neurite_type)
[ "def", "segment_midpoints", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "def", "_seg_midpoint", "(", "sec", ")", ":", "'''Return the mid-points of segments in a section'''", "pts", "=", "sec", ".", "points", "[", ":", ",", "COLS", ".", "XYZ", "]", "return", "np", ".", "divide", "(", "np", ".", "add", "(", "pts", "[", ":", "-", "1", "]", ",", "pts", "[", "1", ":", "]", ")", ",", "2.0", ")", "return", "map_segments", "(", "_seg_midpoint", ",", "neurites", ",", "neurite_type", ")" ]
Return a list of segment mid-points in a collection of neurites
[ "Return", "a", "list", "of", "segment", "mid", "-", "points", "in", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L253-L260
2,640
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
local_bifurcation_angles
def local_bifurcation_angles(neurites, neurite_type=NeuriteType.all): '''Get a list of local bifurcation angles in a collection of neurites''' return map_sections(_bifurcationfunc.local_bifurcation_angle, neurites, neurite_type=neurite_type, iterator_type=Tree.ibifurcation_point)
python
def local_bifurcation_angles(neurites, neurite_type=NeuriteType.all): '''Get a list of local bifurcation angles in a collection of neurites''' return map_sections(_bifurcationfunc.local_bifurcation_angle, neurites, neurite_type=neurite_type, iterator_type=Tree.ibifurcation_point)
[ "def", "local_bifurcation_angles", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "map_sections", "(", "_bifurcationfunc", ".", "local_bifurcation_angle", ",", "neurites", ",", "neurite_type", "=", "neurite_type", ",", "iterator_type", "=", "Tree", ".", "ibifurcation_point", ")" ]
Get a list of local bifurcation angles in a collection of neurites
[ "Get", "a", "list", "of", "local", "bifurcation", "angles", "in", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L280-L285
2,641
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
remote_bifurcation_angles
def remote_bifurcation_angles(neurites, neurite_type=NeuriteType.all): '''Get a list of remote bifurcation angles in a collection of neurites''' return map_sections(_bifurcationfunc.remote_bifurcation_angle, neurites, neurite_type=neurite_type, iterator_type=Tree.ibifurcation_point)
python
def remote_bifurcation_angles(neurites, neurite_type=NeuriteType.all): '''Get a list of remote bifurcation angles in a collection of neurites''' return map_sections(_bifurcationfunc.remote_bifurcation_angle, neurites, neurite_type=neurite_type, iterator_type=Tree.ibifurcation_point)
[ "def", "remote_bifurcation_angles", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "map_sections", "(", "_bifurcationfunc", ".", "remote_bifurcation_angle", ",", "neurites", ",", "neurite_type", "=", "neurite_type", ",", "iterator_type", "=", "Tree", ".", "ibifurcation_point", ")" ]
Get a list of remote bifurcation angles in a collection of neurites
[ "Get", "a", "list", "of", "remote", "bifurcation", "angles", "in", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L288-L293
2,642
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
bifurcation_partitions
def bifurcation_partitions(neurites, neurite_type=NeuriteType.all): '''Partition at bifurcation points of a collection of neurites''' return map(_bifurcationfunc.bifurcation_partition, iter_sections(neurites, iterator_type=Tree.ibifurcation_point, neurite_filter=is_type(neurite_type)))
python
def bifurcation_partitions(neurites, neurite_type=NeuriteType.all): '''Partition at bifurcation points of a collection of neurites''' return map(_bifurcationfunc.bifurcation_partition, iter_sections(neurites, iterator_type=Tree.ibifurcation_point, neurite_filter=is_type(neurite_type)))
[ "def", "bifurcation_partitions", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "map", "(", "_bifurcationfunc", ".", "bifurcation_partition", ",", "iter_sections", "(", "neurites", ",", "iterator_type", "=", "Tree", ".", "ibifurcation_point", ",", "neurite_filter", "=", "is_type", "(", "neurite_type", ")", ")", ")" ]
Partition at bifurcation points of a collection of neurites
[ "Partition", "at", "bifurcation", "points", "of", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L296-L301
2,643
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
partition_asymmetries
def partition_asymmetries(neurites, neurite_type=NeuriteType.all): '''Partition asymmetry at bifurcation points of a collection of neurites''' return map(_bifurcationfunc.partition_asymmetry, iter_sections(neurites, iterator_type=Tree.ibifurcation_point, neurite_filter=is_type(neurite_type)))
python
def partition_asymmetries(neurites, neurite_type=NeuriteType.all): '''Partition asymmetry at bifurcation points of a collection of neurites''' return map(_bifurcationfunc.partition_asymmetry, iter_sections(neurites, iterator_type=Tree.ibifurcation_point, neurite_filter=is_type(neurite_type)))
[ "def", "partition_asymmetries", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "map", "(", "_bifurcationfunc", ".", "partition_asymmetry", ",", "iter_sections", "(", "neurites", ",", "iterator_type", "=", "Tree", ".", "ibifurcation_point", ",", "neurite_filter", "=", "is_type", "(", "neurite_type", ")", ")", ")" ]
Partition asymmetry at bifurcation points of a collection of neurites
[ "Partition", "asymmetry", "at", "bifurcation", "points", "of", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L304-L309
2,644
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
partition_pairs
def partition_pairs(neurites, neurite_type=NeuriteType.all): '''Partition pairs at bifurcation points of a collection of neurites. Partition pait is defined as the number of bifurcations at the two daughters of the bifurcating section''' return map(_bifurcationfunc.partition_pair, iter_sections(neurites, iterator_type=Tree.ibifurcation_point, neurite_filter=is_type(neurite_type)))
python
def partition_pairs(neurites, neurite_type=NeuriteType.all): '''Partition pairs at bifurcation points of a collection of neurites. Partition pait is defined as the number of bifurcations at the two daughters of the bifurcating section''' return map(_bifurcationfunc.partition_pair, iter_sections(neurites, iterator_type=Tree.ibifurcation_point, neurite_filter=is_type(neurite_type)))
[ "def", "partition_pairs", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "map", "(", "_bifurcationfunc", ".", "partition_pair", ",", "iter_sections", "(", "neurites", ",", "iterator_type", "=", "Tree", ".", "ibifurcation_point", ",", "neurite_filter", "=", "is_type", "(", "neurite_type", ")", ")", ")" ]
Partition pairs at bifurcation points of a collection of neurites. Partition pait is defined as the number of bifurcations at the two daughters of the bifurcating section
[ "Partition", "pairs", "at", "bifurcation", "points", "of", "a", "collection", "of", "neurites", ".", "Partition", "pait", "is", "defined", "as", "the", "number", "of", "bifurcations", "at", "the", "two", "daughters", "of", "the", "bifurcating", "section" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L312-L319
2,645
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
section_term_radial_distances
def section_term_radial_distances(neurites, neurite_type=NeuriteType.all, origin=None): '''Get the radial distances of the termination sections for a collection of neurites''' return section_radial_distances(neurites, neurite_type=neurite_type, origin=origin, iterator_type=Tree.ileaf)
python
def section_term_radial_distances(neurites, neurite_type=NeuriteType.all, origin=None): '''Get the radial distances of the termination sections for a collection of neurites''' return section_radial_distances(neurites, neurite_type=neurite_type, origin=origin, iterator_type=Tree.ileaf)
[ "def", "section_term_radial_distances", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ",", "origin", "=", "None", ")", ":", "return", "section_radial_distances", "(", "neurites", ",", "neurite_type", "=", "neurite_type", ",", "origin", "=", "origin", ",", "iterator_type", "=", "Tree", ".", "ileaf", ")" ]
Get the radial distances of the termination sections for a collection of neurites
[ "Get", "the", "radial", "distances", "of", "the", "termination", "sections", "for", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L336-L339
2,646
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
section_bif_radial_distances
def section_bif_radial_distances(neurites, neurite_type=NeuriteType.all, origin=None): '''Get the radial distances of the bifurcation sections for a collection of neurites''' return section_radial_distances(neurites, neurite_type=neurite_type, origin=origin, iterator_type=Tree.ibifurcation_point)
python
def section_bif_radial_distances(neurites, neurite_type=NeuriteType.all, origin=None): '''Get the radial distances of the bifurcation sections for a collection of neurites''' return section_radial_distances(neurites, neurite_type=neurite_type, origin=origin, iterator_type=Tree.ibifurcation_point)
[ "def", "section_bif_radial_distances", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ",", "origin", "=", "None", ")", ":", "return", "section_radial_distances", "(", "neurites", ",", "neurite_type", "=", "neurite_type", ",", "origin", "=", "origin", ",", "iterator_type", "=", "Tree", ".", "ibifurcation_point", ")" ]
Get the radial distances of the bifurcation sections for a collection of neurites
[ "Get", "the", "radial", "distances", "of", "the", "bifurcation", "sections", "for", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L342-L345
2,647
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
number_of_sections_per_neurite
def number_of_sections_per_neurite(neurites, neurite_type=NeuriteType.all): '''Get the number of sections per neurite in a collection of neurites''' return list(sum(1 for _ in n.iter_sections()) for n in iter_neurites(neurites, filt=is_type(neurite_type)))
python
def number_of_sections_per_neurite(neurites, neurite_type=NeuriteType.all): '''Get the number of sections per neurite in a collection of neurites''' return list(sum(1 for _ in n.iter_sections()) for n in iter_neurites(neurites, filt=is_type(neurite_type)))
[ "def", "number_of_sections_per_neurite", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "list", "(", "sum", "(", "1", "for", "_", "in", "n", ".", "iter_sections", "(", ")", ")", "for", "n", "in", "iter_neurites", "(", "neurites", ",", "filt", "=", "is_type", "(", "neurite_type", ")", ")", ")" ]
Get the number of sections per neurite in a collection of neurites
[ "Get", "the", "number", "of", "sections", "per", "neurite", "in", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L348-L351
2,648
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
total_length_per_neurite
def total_length_per_neurite(neurites, neurite_type=NeuriteType.all): '''Get the path length per neurite in a collection''' return list(sum(s.length for s in n.iter_sections()) for n in iter_neurites(neurites, filt=is_type(neurite_type)))
python
def total_length_per_neurite(neurites, neurite_type=NeuriteType.all): '''Get the path length per neurite in a collection''' return list(sum(s.length for s in n.iter_sections()) for n in iter_neurites(neurites, filt=is_type(neurite_type)))
[ "def", "total_length_per_neurite", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "list", "(", "sum", "(", "s", ".", "length", "for", "s", "in", "n", ".", "iter_sections", "(", ")", ")", "for", "n", "in", "iter_neurites", "(", "neurites", ",", "filt", "=", "is_type", "(", "neurite_type", ")", ")", ")" ]
Get the path length per neurite in a collection
[ "Get", "the", "path", "length", "per", "neurite", "in", "a", "collection" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L354-L357
2,649
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
terminal_path_lengths_per_neurite
def terminal_path_lengths_per_neurite(neurites, neurite_type=NeuriteType.all): '''Get the path lengths to each terminal point per neurite in a collection''' return list(sectionfunc.section_path_length(s) for n in iter_neurites(neurites, filt=is_type(neurite_type)) for s in iter_sections(n, iterator_type=Tree.ileaf))
python
def terminal_path_lengths_per_neurite(neurites, neurite_type=NeuriteType.all): '''Get the path lengths to each terminal point per neurite in a collection''' return list(sectionfunc.section_path_length(s) for n in iter_neurites(neurites, filt=is_type(neurite_type)) for s in iter_sections(n, iterator_type=Tree.ileaf))
[ "def", "terminal_path_lengths_per_neurite", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "list", "(", "sectionfunc", ".", "section_path_length", "(", "s", ")", "for", "n", "in", "iter_neurites", "(", "neurites", ",", "filt", "=", "is_type", "(", "neurite_type", ")", ")", "for", "s", "in", "iter_sections", "(", "n", ",", "iterator_type", "=", "Tree", ".", "ileaf", ")", ")" ]
Get the path lengths to each terminal point per neurite in a collection
[ "Get", "the", "path", "lengths", "to", "each", "terminal", "point", "per", "neurite", "in", "a", "collection" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L360-L364
2,650
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
total_volume_per_neurite
def total_volume_per_neurite(neurites, neurite_type=NeuriteType.all): '''Get the volume per neurite in a collection''' return list(sum(s.volume for s in n.iter_sections()) for n in iter_neurites(neurites, filt=is_type(neurite_type)))
python
def total_volume_per_neurite(neurites, neurite_type=NeuriteType.all): '''Get the volume per neurite in a collection''' return list(sum(s.volume for s in n.iter_sections()) for n in iter_neurites(neurites, filt=is_type(neurite_type)))
[ "def", "total_volume_per_neurite", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "list", "(", "sum", "(", "s", ".", "volume", "for", "s", "in", "n", ".", "iter_sections", "(", ")", ")", "for", "n", "in", "iter_neurites", "(", "neurites", ",", "filt", "=", "is_type", "(", "neurite_type", ")", ")", ")" ]
Get the volume per neurite in a collection
[ "Get", "the", "volume", "per", "neurite", "in", "a", "collection" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L367-L370
2,651
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
neurite_volume_density
def neurite_volume_density(neurites, neurite_type=NeuriteType.all): '''Get the volume density per neurite The volume density is defined as the ratio of the neurite volume and the volume of the neurite's enclosing convex hull ''' def vol_density(neurite): '''volume density of a single neurite''' return neurite.volume / convex_hull(neurite).volume return list(vol_density(n) for n in iter_neurites(neurites, filt=is_type(neurite_type)))
python
def neurite_volume_density(neurites, neurite_type=NeuriteType.all): '''Get the volume density per neurite The volume density is defined as the ratio of the neurite volume and the volume of the neurite's enclosing convex hull ''' def vol_density(neurite): '''volume density of a single neurite''' return neurite.volume / convex_hull(neurite).volume return list(vol_density(n) for n in iter_neurites(neurites, filt=is_type(neurite_type)))
[ "def", "neurite_volume_density", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "def", "vol_density", "(", "neurite", ")", ":", "'''volume density of a single neurite'''", "return", "neurite", ".", "volume", "/", "convex_hull", "(", "neurite", ")", ".", "volume", "return", "list", "(", "vol_density", "(", "n", ")", "for", "n", "in", "iter_neurites", "(", "neurites", ",", "filt", "=", "is_type", "(", "neurite_type", ")", ")", ")" ]
Get the volume density per neurite The volume density is defined as the ratio of the neurite volume and the volume of the neurite's enclosing convex hull
[ "Get", "the", "volume", "density", "per", "neurite" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L373-L384
2,652
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
section_volumes
def section_volumes(neurites, neurite_type=NeuriteType.all): '''section volumes in a collection of neurites''' return map_sections(sectionfunc.section_volume, neurites, neurite_type=neurite_type)
python
def section_volumes(neurites, neurite_type=NeuriteType.all): '''section volumes in a collection of neurites''' return map_sections(sectionfunc.section_volume, neurites, neurite_type=neurite_type)
[ "def", "section_volumes", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "map_sections", "(", "sectionfunc", ".", "section_volume", ",", "neurites", ",", "neurite_type", "=", "neurite_type", ")" ]
section volumes in a collection of neurites
[ "section", "volumes", "in", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L387-L389
2,653
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
section_areas
def section_areas(neurites, neurite_type=NeuriteType.all): '''section areas in a collection of neurites''' return map_sections(sectionfunc.section_area, neurites, neurite_type=neurite_type)
python
def section_areas(neurites, neurite_type=NeuriteType.all): '''section areas in a collection of neurites''' return map_sections(sectionfunc.section_area, neurites, neurite_type=neurite_type)
[ "def", "section_areas", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "map_sections", "(", "sectionfunc", ".", "section_area", ",", "neurites", ",", "neurite_type", "=", "neurite_type", ")" ]
section areas in a collection of neurites
[ "section", "areas", "in", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L392-L394
2,654
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
section_tortuosity
def section_tortuosity(neurites, neurite_type=NeuriteType.all): '''section tortuosities in a collection of neurites''' return map_sections(sectionfunc.section_tortuosity, neurites, neurite_type=neurite_type)
python
def section_tortuosity(neurites, neurite_type=NeuriteType.all): '''section tortuosities in a collection of neurites''' return map_sections(sectionfunc.section_tortuosity, neurites, neurite_type=neurite_type)
[ "def", "section_tortuosity", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "map_sections", "(", "sectionfunc", ".", "section_tortuosity", ",", "neurites", ",", "neurite_type", "=", "neurite_type", ")" ]
section tortuosities in a collection of neurites
[ "section", "tortuosities", "in", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L397-L399
2,655
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
section_end_distances
def section_end_distances(neurites, neurite_type=NeuriteType.all): '''section end to end distances in a collection of neurites''' return map_sections(sectionfunc.section_end_distance, neurites, neurite_type=neurite_type)
python
def section_end_distances(neurites, neurite_type=NeuriteType.all): '''section end to end distances in a collection of neurites''' return map_sections(sectionfunc.section_end_distance, neurites, neurite_type=neurite_type)
[ "def", "section_end_distances", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "map_sections", "(", "sectionfunc", ".", "section_end_distance", ",", "neurites", ",", "neurite_type", "=", "neurite_type", ")" ]
section end to end distances in a collection of neurites
[ "section", "end", "to", "end", "distances", "in", "a", "collection", "of", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L402-L404
2,656
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
principal_direction_extents
def principal_direction_extents(neurites, neurite_type=NeuriteType.all, direction=0): '''Principal direction extent of neurites in neurons''' def _pde(neurite): '''Get the PDE of a single neurite''' # Get the X, Y,Z coordinates of the points in each section points = neurite.points[:, :3] return morphmath.principal_direction_extent(points)[direction] return map(_pde, iter_neurites(neurites, filt=is_type(neurite_type)))
python
def principal_direction_extents(neurites, neurite_type=NeuriteType.all, direction=0): '''Principal direction extent of neurites in neurons''' def _pde(neurite): '''Get the PDE of a single neurite''' # Get the X, Y,Z coordinates of the points in each section points = neurite.points[:, :3] return morphmath.principal_direction_extent(points)[direction] return map(_pde, iter_neurites(neurites, filt=is_type(neurite_type)))
[ "def", "principal_direction_extents", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ",", "direction", "=", "0", ")", ":", "def", "_pde", "(", "neurite", ")", ":", "'''Get the PDE of a single neurite'''", "# Get the X, Y,Z coordinates of the points in each section", "points", "=", "neurite", ".", "points", "[", ":", ",", ":", "3", "]", "return", "morphmath", ".", "principal_direction_extent", "(", "points", ")", "[", "direction", "]", "return", "map", "(", "_pde", ",", "iter_neurites", "(", "neurites", ",", "filt", "=", "is_type", "(", "neurite_type", ")", ")", ")" ]
Principal direction extent of neurites in neurons
[ "Principal", "direction", "extent", "of", "neurites", "in", "neurons" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L407-L415
2,657
BlueBrain/NeuroM
neurom/view/view.py
_get_linewidth
def _get_linewidth(tree, linewidth, diameter_scale): '''calculate the desired linewidth based on tree contents If diameter_scale exists, it is used to scale the diameter of each of the segments in the tree If diameter_scale is None, the linewidth is used. ''' if diameter_scale is not None and tree: linewidth = [2 * segment_radius(s) * diameter_scale for s in iter_segments(tree)] return linewidth
python
def _get_linewidth(tree, linewidth, diameter_scale): '''calculate the desired linewidth based on tree contents If diameter_scale exists, it is used to scale the diameter of each of the segments in the tree If diameter_scale is None, the linewidth is used. ''' if diameter_scale is not None and tree: linewidth = [2 * segment_radius(s) * diameter_scale for s in iter_segments(tree)] return linewidth
[ "def", "_get_linewidth", "(", "tree", ",", "linewidth", ",", "diameter_scale", ")", ":", "if", "diameter_scale", "is", "not", "None", "and", "tree", ":", "linewidth", "=", "[", "2", "*", "segment_radius", "(", "s", ")", "*", "diameter_scale", "for", "s", "in", "iter_segments", "(", "tree", ")", "]", "return", "linewidth" ]
calculate the desired linewidth based on tree contents If diameter_scale exists, it is used to scale the diameter of each of the segments in the tree If diameter_scale is None, the linewidth is used.
[ "calculate", "the", "desired", "linewidth", "based", "on", "tree", "contents" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/view/view.py#L65-L75
2,658
BlueBrain/NeuroM
neurom/view/view.py
plot_tree
def plot_tree(ax, tree, plane='xy', diameter_scale=_DIAMETER_SCALE, linewidth=_LINEWIDTH, color=None, alpha=_ALPHA): '''Plots a 2d figure of the tree's segments Args: ax(matplotlib axes): on what to plot tree(neurom.core.Tree or neurom.core.Neurite): plotted tree plane(str): Any pair of 'xyz' diameter_scale(float): Scale factor multiplied with segment diameters before plotting linewidth(float): all segments are plotted with this width, but only if diameter_scale=None color(str or None): Color of plotted values, None corresponds to default choice alpha(float): Transparency of plotted values Note: If the tree contains one single point the plot will be empty since no segments can be constructed. ''' plane0, plane1 = _plane2col(plane) segs = [((s[0][plane0], s[0][plane1]), (s[1][plane0], s[1][plane1])) for s in iter_segments(tree)] linewidth = _get_linewidth(tree, diameter_scale=diameter_scale, linewidth=linewidth) color = _get_color(color, tree.type) collection = LineCollection(segs, color=color, linewidth=linewidth, alpha=alpha) ax.add_collection(collection)
python
def plot_tree(ax, tree, plane='xy', diameter_scale=_DIAMETER_SCALE, linewidth=_LINEWIDTH, color=None, alpha=_ALPHA): '''Plots a 2d figure of the tree's segments Args: ax(matplotlib axes): on what to plot tree(neurom.core.Tree or neurom.core.Neurite): plotted tree plane(str): Any pair of 'xyz' diameter_scale(float): Scale factor multiplied with segment diameters before plotting linewidth(float): all segments are plotted with this width, but only if diameter_scale=None color(str or None): Color of plotted values, None corresponds to default choice alpha(float): Transparency of plotted values Note: If the tree contains one single point the plot will be empty since no segments can be constructed. ''' plane0, plane1 = _plane2col(plane) segs = [((s[0][plane0], s[0][plane1]), (s[1][plane0], s[1][plane1])) for s in iter_segments(tree)] linewidth = _get_linewidth(tree, diameter_scale=diameter_scale, linewidth=linewidth) color = _get_color(color, tree.type) collection = LineCollection(segs, color=color, linewidth=linewidth, alpha=alpha) ax.add_collection(collection)
[ "def", "plot_tree", "(", "ax", ",", "tree", ",", "plane", "=", "'xy'", ",", "diameter_scale", "=", "_DIAMETER_SCALE", ",", "linewidth", "=", "_LINEWIDTH", ",", "color", "=", "None", ",", "alpha", "=", "_ALPHA", ")", ":", "plane0", ",", "plane1", "=", "_plane2col", "(", "plane", ")", "segs", "=", "[", "(", "(", "s", "[", "0", "]", "[", "plane0", "]", ",", "s", "[", "0", "]", "[", "plane1", "]", ")", ",", "(", "s", "[", "1", "]", "[", "plane0", "]", ",", "s", "[", "1", "]", "[", "plane1", "]", ")", ")", "for", "s", "in", "iter_segments", "(", "tree", ")", "]", "linewidth", "=", "_get_linewidth", "(", "tree", ",", "diameter_scale", "=", "diameter_scale", ",", "linewidth", "=", "linewidth", ")", "color", "=", "_get_color", "(", "color", ",", "tree", ".", "type", ")", "collection", "=", "LineCollection", "(", "segs", ",", "color", "=", "color", ",", "linewidth", "=", "linewidth", ",", "alpha", "=", "alpha", ")", "ax", ".", "add_collection", "(", "collection", ")" ]
Plots a 2d figure of the tree's segments Args: ax(matplotlib axes): on what to plot tree(neurom.core.Tree or neurom.core.Neurite): plotted tree plane(str): Any pair of 'xyz' diameter_scale(float): Scale factor multiplied with segment diameters before plotting linewidth(float): all segments are plotted with this width, but only if diameter_scale=None color(str or None): Color of plotted values, None corresponds to default choice alpha(float): Transparency of plotted values Note: If the tree contains one single point the plot will be empty since no segments can be constructed.
[ "Plots", "a", "2d", "figure", "of", "the", "tree", "s", "segments" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/view/view.py#L85-L112
2,659
BlueBrain/NeuroM
neurom/view/view.py
plot_soma
def plot_soma(ax, soma, plane='xy', soma_outline=True, linewidth=_LINEWIDTH, color=None, alpha=_ALPHA): '''Generates a 2d figure of the soma. Args: ax(matplotlib axes): on what to plot soma(neurom.core.Soma): plotted soma plane(str): Any pair of 'xyz' diameter_scale(float): Scale factor multiplied with segment diameters before plotting linewidth(float): all segments are plotted with this width, but only if diameter_scale=None color(str or None): Color of plotted values, None corresponds to default choice alpha(float): Transparency of plotted values ''' plane0, plane1 = _plane2col(plane) color = _get_color(color, tree_type=NeuriteType.soma) if isinstance(soma, SomaCylinders): plane0, plane1 = _plane2col(plane) for start, end in zip(soma.points, soma.points[1:]): common.project_cylinder_onto_2d(ax, (plane0, plane1), start=start[COLS.XYZ], end=end[COLS.XYZ], start_radius=start[COLS.R], end_radius=end[COLS.R], color=color, alpha=alpha) else: if soma_outline: ax.add_artist(Circle(soma.center[[plane0, plane1]], soma.radius, color=color, alpha=alpha)) else: plane0, plane1 = _plane2col(plane) points = [(p[plane0], p[plane1]) for p in soma.iter()] if points: points.append(points[0]) # close the loop ax.plot(points, color=color, alpha=alpha, linewidth=linewidth) ax.set_xlabel(plane[0]) ax.set_ylabel(plane[1]) bounding_box = geom.bounding_box(soma) ax.dataLim.update_from_data_xy(np.vstack(([bounding_box[0][plane0], bounding_box[0][plane1]], [bounding_box[1][plane0], bounding_box[1][plane1]])), ignore=False)
python
def plot_soma(ax, soma, plane='xy', soma_outline=True, linewidth=_LINEWIDTH, color=None, alpha=_ALPHA): '''Generates a 2d figure of the soma. Args: ax(matplotlib axes): on what to plot soma(neurom.core.Soma): plotted soma plane(str): Any pair of 'xyz' diameter_scale(float): Scale factor multiplied with segment diameters before plotting linewidth(float): all segments are plotted with this width, but only if diameter_scale=None color(str or None): Color of plotted values, None corresponds to default choice alpha(float): Transparency of plotted values ''' plane0, plane1 = _plane2col(plane) color = _get_color(color, tree_type=NeuriteType.soma) if isinstance(soma, SomaCylinders): plane0, plane1 = _plane2col(plane) for start, end in zip(soma.points, soma.points[1:]): common.project_cylinder_onto_2d(ax, (plane0, plane1), start=start[COLS.XYZ], end=end[COLS.XYZ], start_radius=start[COLS.R], end_radius=end[COLS.R], color=color, alpha=alpha) else: if soma_outline: ax.add_artist(Circle(soma.center[[plane0, plane1]], soma.radius, color=color, alpha=alpha)) else: plane0, plane1 = _plane2col(plane) points = [(p[plane0], p[plane1]) for p in soma.iter()] if points: points.append(points[0]) # close the loop ax.plot(points, color=color, alpha=alpha, linewidth=linewidth) ax.set_xlabel(plane[0]) ax.set_ylabel(plane[1]) bounding_box = geom.bounding_box(soma) ax.dataLim.update_from_data_xy(np.vstack(([bounding_box[0][plane0], bounding_box[0][plane1]], [bounding_box[1][plane0], bounding_box[1][plane1]])), ignore=False)
[ "def", "plot_soma", "(", "ax", ",", "soma", ",", "plane", "=", "'xy'", ",", "soma_outline", "=", "True", ",", "linewidth", "=", "_LINEWIDTH", ",", "color", "=", "None", ",", "alpha", "=", "_ALPHA", ")", ":", "plane0", ",", "plane1", "=", "_plane2col", "(", "plane", ")", "color", "=", "_get_color", "(", "color", ",", "tree_type", "=", "NeuriteType", ".", "soma", ")", "if", "isinstance", "(", "soma", ",", "SomaCylinders", ")", ":", "plane0", ",", "plane1", "=", "_plane2col", "(", "plane", ")", "for", "start", ",", "end", "in", "zip", "(", "soma", ".", "points", ",", "soma", ".", "points", "[", "1", ":", "]", ")", ":", "common", ".", "project_cylinder_onto_2d", "(", "ax", ",", "(", "plane0", ",", "plane1", ")", ",", "start", "=", "start", "[", "COLS", ".", "XYZ", "]", ",", "end", "=", "end", "[", "COLS", ".", "XYZ", "]", ",", "start_radius", "=", "start", "[", "COLS", ".", "R", "]", ",", "end_radius", "=", "end", "[", "COLS", ".", "R", "]", ",", "color", "=", "color", ",", "alpha", "=", "alpha", ")", "else", ":", "if", "soma_outline", ":", "ax", ".", "add_artist", "(", "Circle", "(", "soma", ".", "center", "[", "[", "plane0", ",", "plane1", "]", "]", ",", "soma", ".", "radius", ",", "color", "=", "color", ",", "alpha", "=", "alpha", ")", ")", "else", ":", "plane0", ",", "plane1", "=", "_plane2col", "(", "plane", ")", "points", "=", "[", "(", "p", "[", "plane0", "]", ",", "p", "[", "plane1", "]", ")", "for", "p", "in", "soma", ".", "iter", "(", ")", "]", "if", "points", ":", "points", ".", "append", "(", "points", "[", "0", "]", ")", "# close the loop", "ax", ".", "plot", "(", "points", ",", "color", "=", "color", ",", "alpha", "=", "alpha", ",", "linewidth", "=", "linewidth", ")", "ax", ".", "set_xlabel", "(", "plane", "[", "0", "]", ")", "ax", ".", "set_ylabel", "(", "plane", "[", "1", "]", ")", "bounding_box", "=", "geom", ".", "bounding_box", "(", "soma", ")", "ax", ".", "dataLim", ".", "update_from_data_xy", "(", "np", ".", "vstack", "(", "(", "[", "bounding_box", "[", "0", "]", "[", "plane0", "]", ",", "bounding_box", "[", "0", "]", "[", "plane1", "]", "]", ",", "[", "bounding_box", "[", "1", "]", "[", "plane0", "]", ",", "bounding_box", "[", "1", "]", "[", "plane1", "]", "]", ")", ")", ",", "ignore", "=", "False", ")" ]
Generates a 2d figure of the soma. Args: ax(matplotlib axes): on what to plot soma(neurom.core.Soma): plotted soma plane(str): Any pair of 'xyz' diameter_scale(float): Scale factor multiplied with segment diameters before plotting linewidth(float): all segments are plotted with this width, but only if diameter_scale=None color(str or None): Color of plotted values, None corresponds to default choice alpha(float): Transparency of plotted values
[ "Generates", "a", "2d", "figure", "of", "the", "soma", "." ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/view/view.py#L115-L158
2,660
BlueBrain/NeuroM
neurom/view/view.py
plot_neuron
def plot_neuron(ax, nrn, neurite_type=NeuriteType.all, plane='xy', soma_outline=True, diameter_scale=_DIAMETER_SCALE, linewidth=_LINEWIDTH, color=None, alpha=_ALPHA): '''Plots a 2D figure of the neuron, that contains a soma and the neurites Args: ax(matplotlib axes): on what to plot neurite_type(NeuriteType): an optional filter on the neurite type nrn(neuron): neuron to be plotted soma_outline(bool): should the soma be drawn as an outline plane(str): Any pair of 'xyz' diameter_scale(float): Scale factor multiplied with segment diameters before plotting linewidth(float): all segments are plotted with this width, but only if diameter_scale=None color(str or None): Color of plotted values, None corresponds to default choice alpha(float): Transparency of plotted values ''' plot_soma(ax, nrn.soma, plane=plane, soma_outline=soma_outline, linewidth=linewidth, color=color, alpha=alpha) for neurite in iter_neurites(nrn, filt=tree_type_checker(neurite_type)): plot_tree(ax, neurite, plane=plane, diameter_scale=diameter_scale, linewidth=linewidth, color=color, alpha=alpha) ax.set_title(nrn.name) ax.set_xlabel(plane[0]) ax.set_ylabel(plane[1])
python
def plot_neuron(ax, nrn, neurite_type=NeuriteType.all, plane='xy', soma_outline=True, diameter_scale=_DIAMETER_SCALE, linewidth=_LINEWIDTH, color=None, alpha=_ALPHA): '''Plots a 2D figure of the neuron, that contains a soma and the neurites Args: ax(matplotlib axes): on what to plot neurite_type(NeuriteType): an optional filter on the neurite type nrn(neuron): neuron to be plotted soma_outline(bool): should the soma be drawn as an outline plane(str): Any pair of 'xyz' diameter_scale(float): Scale factor multiplied with segment diameters before plotting linewidth(float): all segments are plotted with this width, but only if diameter_scale=None color(str or None): Color of plotted values, None corresponds to default choice alpha(float): Transparency of plotted values ''' plot_soma(ax, nrn.soma, plane=plane, soma_outline=soma_outline, linewidth=linewidth, color=color, alpha=alpha) for neurite in iter_neurites(nrn, filt=tree_type_checker(neurite_type)): plot_tree(ax, neurite, plane=plane, diameter_scale=diameter_scale, linewidth=linewidth, color=color, alpha=alpha) ax.set_title(nrn.name) ax.set_xlabel(plane[0]) ax.set_ylabel(plane[1])
[ "def", "plot_neuron", "(", "ax", ",", "nrn", ",", "neurite_type", "=", "NeuriteType", ".", "all", ",", "plane", "=", "'xy'", ",", "soma_outline", "=", "True", ",", "diameter_scale", "=", "_DIAMETER_SCALE", ",", "linewidth", "=", "_LINEWIDTH", ",", "color", "=", "None", ",", "alpha", "=", "_ALPHA", ")", ":", "plot_soma", "(", "ax", ",", "nrn", ".", "soma", ",", "plane", "=", "plane", ",", "soma_outline", "=", "soma_outline", ",", "linewidth", "=", "linewidth", ",", "color", "=", "color", ",", "alpha", "=", "alpha", ")", "for", "neurite", "in", "iter_neurites", "(", "nrn", ",", "filt", "=", "tree_type_checker", "(", "neurite_type", ")", ")", ":", "plot_tree", "(", "ax", ",", "neurite", ",", "plane", "=", "plane", ",", "diameter_scale", "=", "diameter_scale", ",", "linewidth", "=", "linewidth", ",", "color", "=", "color", ",", "alpha", "=", "alpha", ")", "ax", ".", "set_title", "(", "nrn", ".", "name", ")", "ax", ".", "set_xlabel", "(", "plane", "[", "0", "]", ")", "ax", ".", "set_ylabel", "(", "plane", "[", "1", "]", ")" ]
Plots a 2D figure of the neuron, that contains a soma and the neurites Args: ax(matplotlib axes): on what to plot neurite_type(NeuriteType): an optional filter on the neurite type nrn(neuron): neuron to be plotted soma_outline(bool): should the soma be drawn as an outline plane(str): Any pair of 'xyz' diameter_scale(float): Scale factor multiplied with segment diameters before plotting linewidth(float): all segments are plotted with this width, but only if diameter_scale=None color(str or None): Color of plotted values, None corresponds to default choice alpha(float): Transparency of plotted values
[ "Plots", "a", "2D", "figure", "of", "the", "neuron", "that", "contains", "a", "soma", "and", "the", "neurites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/view/view.py#L162-L191
2,661
BlueBrain/NeuroM
neurom/view/view.py
plot_tree3d
def plot_tree3d(ax, tree, diameter_scale=_DIAMETER_SCALE, linewidth=_LINEWIDTH, color=None, alpha=_ALPHA): '''Generates a figure of the tree in 3d. If the tree contains one single point the plot will be empty \ since no segments can be constructed. Args: ax(matplotlib axes): on what to plot tree(neurom.core.Tree or neurom.core.Neurite): plotted tree diameter_scale(float): Scale factor multiplied with segment diameters before plotting linewidth(float): all segments are plotted with this width, but only if diameter_scale=None color(str or None): Color of plotted values, None corresponds to default choice alpha(float): Transparency of plotted values ''' segs = [(s[0][COLS.XYZ], s[1][COLS.XYZ]) for s in iter_segments(tree)] linewidth = _get_linewidth(tree, diameter_scale=diameter_scale, linewidth=linewidth) color = _get_color(color, tree.type) collection = Line3DCollection(segs, color=color, linewidth=linewidth, alpha=alpha) ax.add_collection3d(collection) _update_3d_datalim(ax, tree)
python
def plot_tree3d(ax, tree, diameter_scale=_DIAMETER_SCALE, linewidth=_LINEWIDTH, color=None, alpha=_ALPHA): '''Generates a figure of the tree in 3d. If the tree contains one single point the plot will be empty \ since no segments can be constructed. Args: ax(matplotlib axes): on what to plot tree(neurom.core.Tree or neurom.core.Neurite): plotted tree diameter_scale(float): Scale factor multiplied with segment diameters before plotting linewidth(float): all segments are plotted with this width, but only if diameter_scale=None color(str or None): Color of plotted values, None corresponds to default choice alpha(float): Transparency of plotted values ''' segs = [(s[0][COLS.XYZ], s[1][COLS.XYZ]) for s in iter_segments(tree)] linewidth = _get_linewidth(tree, diameter_scale=diameter_scale, linewidth=linewidth) color = _get_color(color, tree.type) collection = Line3DCollection(segs, color=color, linewidth=linewidth, alpha=alpha) ax.add_collection3d(collection) _update_3d_datalim(ax, tree)
[ "def", "plot_tree3d", "(", "ax", ",", "tree", ",", "diameter_scale", "=", "_DIAMETER_SCALE", ",", "linewidth", "=", "_LINEWIDTH", ",", "color", "=", "None", ",", "alpha", "=", "_ALPHA", ")", ":", "segs", "=", "[", "(", "s", "[", "0", "]", "[", "COLS", ".", "XYZ", "]", ",", "s", "[", "1", "]", "[", "COLS", ".", "XYZ", "]", ")", "for", "s", "in", "iter_segments", "(", "tree", ")", "]", "linewidth", "=", "_get_linewidth", "(", "tree", ",", "diameter_scale", "=", "diameter_scale", ",", "linewidth", "=", "linewidth", ")", "color", "=", "_get_color", "(", "color", ",", "tree", ".", "type", ")", "collection", "=", "Line3DCollection", "(", "segs", ",", "color", "=", "color", ",", "linewidth", "=", "linewidth", ",", "alpha", "=", "alpha", ")", "ax", ".", "add_collection3d", "(", "collection", ")", "_update_3d_datalim", "(", "ax", ",", "tree", ")" ]
Generates a figure of the tree in 3d. If the tree contains one single point the plot will be empty \ since no segments can be constructed. Args: ax(matplotlib axes): on what to plot tree(neurom.core.Tree or neurom.core.Neurite): plotted tree diameter_scale(float): Scale factor multiplied with segment diameters before plotting linewidth(float): all segments are plotted with this width, but only if diameter_scale=None color(str or None): Color of plotted values, None corresponds to default choice alpha(float): Transparency of plotted values
[ "Generates", "a", "figure", "of", "the", "tree", "in", "3d", "." ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/view/view.py#L206-L230
2,662
BlueBrain/NeuroM
neurom/view/view.py
plot_soma3d
def plot_soma3d(ax, soma, color=None, alpha=_ALPHA): '''Generates a 3d figure of the soma. Args: ax(matplotlib axes): on what to plot soma(neurom.core.Soma): plotted soma color(str or None): Color of plotted values, None corresponds to default choice alpha(float): Transparency of plotted values ''' color = _get_color(color, tree_type=NeuriteType.soma) if isinstance(soma, SomaCylinders): for start, end in zip(soma.points, soma.points[1:]): common.plot_cylinder(ax, start=start[COLS.XYZ], end=end[COLS.XYZ], start_radius=start[COLS.R], end_radius=end[COLS.R], color=color, alpha=alpha) else: common.plot_sphere(ax, center=soma.center[COLS.XYZ], radius=soma.radius, color=color, alpha=alpha) # unlike w/ 2d Axes, the dataLim isn't set by collections, so it has to be updated manually _update_3d_datalim(ax, soma)
python
def plot_soma3d(ax, soma, color=None, alpha=_ALPHA): '''Generates a 3d figure of the soma. Args: ax(matplotlib axes): on what to plot soma(neurom.core.Soma): plotted soma color(str or None): Color of plotted values, None corresponds to default choice alpha(float): Transparency of plotted values ''' color = _get_color(color, tree_type=NeuriteType.soma) if isinstance(soma, SomaCylinders): for start, end in zip(soma.points, soma.points[1:]): common.plot_cylinder(ax, start=start[COLS.XYZ], end=end[COLS.XYZ], start_radius=start[COLS.R], end_radius=end[COLS.R], color=color, alpha=alpha) else: common.plot_sphere(ax, center=soma.center[COLS.XYZ], radius=soma.radius, color=color, alpha=alpha) # unlike w/ 2d Axes, the dataLim isn't set by collections, so it has to be updated manually _update_3d_datalim(ax, soma)
[ "def", "plot_soma3d", "(", "ax", ",", "soma", ",", "color", "=", "None", ",", "alpha", "=", "_ALPHA", ")", ":", "color", "=", "_get_color", "(", "color", ",", "tree_type", "=", "NeuriteType", ".", "soma", ")", "if", "isinstance", "(", "soma", ",", "SomaCylinders", ")", ":", "for", "start", ",", "end", "in", "zip", "(", "soma", ".", "points", ",", "soma", ".", "points", "[", "1", ":", "]", ")", ":", "common", ".", "plot_cylinder", "(", "ax", ",", "start", "=", "start", "[", "COLS", ".", "XYZ", "]", ",", "end", "=", "end", "[", "COLS", ".", "XYZ", "]", ",", "start_radius", "=", "start", "[", "COLS", ".", "R", "]", ",", "end_radius", "=", "end", "[", "COLS", ".", "R", "]", ",", "color", "=", "color", ",", "alpha", "=", "alpha", ")", "else", ":", "common", ".", "plot_sphere", "(", "ax", ",", "center", "=", "soma", ".", "center", "[", "COLS", ".", "XYZ", "]", ",", "radius", "=", "soma", ".", "radius", ",", "color", "=", "color", ",", "alpha", "=", "alpha", ")", "# unlike w/ 2d Axes, the dataLim isn't set by collections, so it has to be updated manually", "_update_3d_datalim", "(", "ax", ",", "soma", ")" ]
Generates a 3d figure of the soma. Args: ax(matplotlib axes): on what to plot soma(neurom.core.Soma): plotted soma color(str or None): Color of plotted values, None corresponds to default choice alpha(float): Transparency of plotted values
[ "Generates", "a", "3d", "figure", "of", "the", "soma", "." ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/view/view.py#L233-L255
2,663
BlueBrain/NeuroM
neurom/view/view.py
_generate_collection
def _generate_collection(group, ax, ctype, colors): '''Render rectangle collection''' color = TREE_COLOR[ctype] # generate segment collection collection = PolyCollection(group, closed=False, antialiaseds=True, edgecolors='face', facecolors=color) # add it to the axes ax.add_collection(collection) # dummy plot for the legend if color not in colors: label = str(ctype).replace('NeuriteType.', '').replace('_', ' ').capitalize() ax.plot((0., 0.), (0., 0.), c=color, label=label) colors.add(color)
python
def _generate_collection(group, ax, ctype, colors): '''Render rectangle collection''' color = TREE_COLOR[ctype] # generate segment collection collection = PolyCollection(group, closed=False, antialiaseds=True, edgecolors='face', facecolors=color) # add it to the axes ax.add_collection(collection) # dummy plot for the legend if color not in colors: label = str(ctype).replace('NeuriteType.', '').replace('_', ' ').capitalize() ax.plot((0., 0.), (0., 0.), c=color, label=label) colors.add(color)
[ "def", "_generate_collection", "(", "group", ",", "ax", ",", "ctype", ",", "colors", ")", ":", "color", "=", "TREE_COLOR", "[", "ctype", "]", "# generate segment collection", "collection", "=", "PolyCollection", "(", "group", ",", "closed", "=", "False", ",", "antialiaseds", "=", "True", ",", "edgecolors", "=", "'face'", ",", "facecolors", "=", "color", ")", "# add it to the axes", "ax", ".", "add_collection", "(", "collection", ")", "# dummy plot for the legend", "if", "color", "not", "in", "colors", ":", "label", "=", "str", "(", "ctype", ")", ".", "replace", "(", "'NeuriteType.'", ",", "''", ")", ".", "replace", "(", "'_'", ",", "' '", ")", ".", "capitalize", "(", ")", "ax", ".", "plot", "(", "(", "0.", ",", "0.", ")", ",", "(", "0.", ",", "0.", ")", ",", "c", "=", "color", ",", "label", "=", "label", ")", "colors", ".", "add", "(", "color", ")" ]
Render rectangle collection
[ "Render", "rectangle", "collection" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/view/view.py#L284-L299
2,664
BlueBrain/NeuroM
neurom/view/view.py
plot_dendrogram
def plot_dendrogram(ax, obj, show_diameters=True): '''Dendrogram of `obj` Args: obj: Neuron or tree \ neurom.Neuron, neurom.Tree show_diameters : boolean \ Determines if node diameters will \ be show or not. ''' # create dendrogram and generate rectangle collection dnd = Dendrogram(obj, show_diameters=show_diameters) dnd.generate() # render dendrogram and take into account neurite displacement which # starts as zero. It is important to avoid overlapping of neurites # and to determine tha limits of the figure. _render_dendrogram(dnd, ax, 0.) ax.set_title('Morphology Dendrogram') ax.set_xlabel('micrometers (um)') ax.set_ylabel('micrometers (um)') ax.set_aspect('auto') ax.legend()
python
def plot_dendrogram(ax, obj, show_diameters=True): '''Dendrogram of `obj` Args: obj: Neuron or tree \ neurom.Neuron, neurom.Tree show_diameters : boolean \ Determines if node diameters will \ be show or not. ''' # create dendrogram and generate rectangle collection dnd = Dendrogram(obj, show_diameters=show_diameters) dnd.generate() # render dendrogram and take into account neurite displacement which # starts as zero. It is important to avoid overlapping of neurites # and to determine tha limits of the figure. _render_dendrogram(dnd, ax, 0.) ax.set_title('Morphology Dendrogram') ax.set_xlabel('micrometers (um)') ax.set_ylabel('micrometers (um)') ax.set_aspect('auto') ax.legend()
[ "def", "plot_dendrogram", "(", "ax", ",", "obj", ",", "show_diameters", "=", "True", ")", ":", "# create dendrogram and generate rectangle collection", "dnd", "=", "Dendrogram", "(", "obj", ",", "show_diameters", "=", "show_diameters", ")", "dnd", ".", "generate", "(", ")", "# render dendrogram and take into account neurite displacement which", "# starts as zero. It is important to avoid overlapping of neurites", "# and to determine tha limits of the figure.", "_render_dendrogram", "(", "dnd", ",", "ax", ",", "0.", ")", "ax", ".", "set_title", "(", "'Morphology Dendrogram'", ")", "ax", ".", "set_xlabel", "(", "'micrometers (um)'", ")", "ax", ".", "set_ylabel", "(", "'micrometers (um)'", ")", "ax", ".", "set_aspect", "(", "'auto'", ")", "ax", ".", "legend", "(", ")" ]
Dendrogram of `obj` Args: obj: Neuron or tree \ neurom.Neuron, neurom.Tree show_diameters : boolean \ Determines if node diameters will \ be show or not.
[ "Dendrogram", "of", "obj" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/view/view.py#L335-L360
2,665
BlueBrain/NeuroM
neurom/fst/_core.py
make_neurites
def make_neurites(rdw): '''Build neurite trees from a raw data wrapper''' post_action = _NEURITE_ACTION[rdw.fmt] trunks = rdw.neurite_root_section_ids() if not trunks: return [], [] # One pass over sections to build nodes nodes = tuple(Section(section_id=i, points=rdw.data_block[sec.ids], section_type=_TREE_TYPES[sec.ntype]) for i, sec in enumerate(rdw.sections)) # One pass over nodes to connect children to parents for i, node in enumerate(nodes): parent_id = rdw.sections[i].pid parent_type = nodes[parent_id].type # only connect neurites if parent_id != ROOT_ID and parent_type != NeuriteType.soma: nodes[parent_id].add_child(node) neurites = tuple(Neurite(nodes[i]) for i in trunks) if post_action is not None: for n in neurites: post_action(n.root_node) return neurites, nodes
python
def make_neurites(rdw): '''Build neurite trees from a raw data wrapper''' post_action = _NEURITE_ACTION[rdw.fmt] trunks = rdw.neurite_root_section_ids() if not trunks: return [], [] # One pass over sections to build nodes nodes = tuple(Section(section_id=i, points=rdw.data_block[sec.ids], section_type=_TREE_TYPES[sec.ntype]) for i, sec in enumerate(rdw.sections)) # One pass over nodes to connect children to parents for i, node in enumerate(nodes): parent_id = rdw.sections[i].pid parent_type = nodes[parent_id].type # only connect neurites if parent_id != ROOT_ID and parent_type != NeuriteType.soma: nodes[parent_id].add_child(node) neurites = tuple(Neurite(nodes[i]) for i in trunks) if post_action is not None: for n in neurites: post_action(n.root_node) return neurites, nodes
[ "def", "make_neurites", "(", "rdw", ")", ":", "post_action", "=", "_NEURITE_ACTION", "[", "rdw", ".", "fmt", "]", "trunks", "=", "rdw", ".", "neurite_root_section_ids", "(", ")", "if", "not", "trunks", ":", "return", "[", "]", ",", "[", "]", "# One pass over sections to build nodes", "nodes", "=", "tuple", "(", "Section", "(", "section_id", "=", "i", ",", "points", "=", "rdw", ".", "data_block", "[", "sec", ".", "ids", "]", ",", "section_type", "=", "_TREE_TYPES", "[", "sec", ".", "ntype", "]", ")", "for", "i", ",", "sec", "in", "enumerate", "(", "rdw", ".", "sections", ")", ")", "# One pass over nodes to connect children to parents", "for", "i", ",", "node", "in", "enumerate", "(", "nodes", ")", ":", "parent_id", "=", "rdw", ".", "sections", "[", "i", "]", ".", "pid", "parent_type", "=", "nodes", "[", "parent_id", "]", ".", "type", "# only connect neurites", "if", "parent_id", "!=", "ROOT_ID", "and", "parent_type", "!=", "NeuriteType", ".", "soma", ":", "nodes", "[", "parent_id", "]", ".", "add_child", "(", "node", ")", "neurites", "=", "tuple", "(", "Neurite", "(", "nodes", "[", "i", "]", ")", "for", "i", "in", "trunks", ")", "if", "post_action", "is", "not", "None", ":", "for", "n", "in", "neurites", ":", "post_action", "(", "n", ".", "root_node", ")", "return", "neurites", ",", "nodes" ]
Build neurite trees from a raw data wrapper
[ "Build", "neurite", "trees", "from", "a", "raw", "data", "wrapper" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_core.py#L78-L105
2,666
BlueBrain/NeuroM
neurom/fst/_core.py
_remove_soma_initial_point
def _remove_soma_initial_point(tree): '''Remove tree's initial point if soma''' if tree.points[0][COLS.TYPE] == POINT_TYPE.SOMA: tree.points = tree.points[1:]
python
def _remove_soma_initial_point(tree): '''Remove tree's initial point if soma''' if tree.points[0][COLS.TYPE] == POINT_TYPE.SOMA: tree.points = tree.points[1:]
[ "def", "_remove_soma_initial_point", "(", "tree", ")", ":", "if", "tree", ".", "points", "[", "0", "]", "[", "COLS", ".", "TYPE", "]", "==", "POINT_TYPE", ".", "SOMA", ":", "tree", ".", "points", "=", "tree", ".", "points", "[", "1", ":", "]" ]
Remove tree's initial point if soma
[ "Remove", "tree", "s", "initial", "point", "if", "soma" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_core.py#L108-L111
2,667
BlueBrain/NeuroM
neurom/fst/_core.py
_check_soma_topology_swc
def _check_soma_topology_swc(points): '''check if points form valid soma Currently checks if there are bifurcations within a soma with more than three points. ''' if len(points) == 3: return parents = tuple(p[COLS.P] for p in points if p[COLS.P] != ROOT_ID) if len(parents) > len(set(parents)): raise SomaError("Bifurcating soma")
python
def _check_soma_topology_swc(points): '''check if points form valid soma Currently checks if there are bifurcations within a soma with more than three points. ''' if len(points) == 3: return parents = tuple(p[COLS.P] for p in points if p[COLS.P] != ROOT_ID) if len(parents) > len(set(parents)): raise SomaError("Bifurcating soma")
[ "def", "_check_soma_topology_swc", "(", "points", ")", ":", "if", "len", "(", "points", ")", "==", "3", ":", "return", "parents", "=", "tuple", "(", "p", "[", "COLS", ".", "P", "]", "for", "p", "in", "points", "if", "p", "[", "COLS", ".", "P", "]", "!=", "ROOT_ID", ")", "if", "len", "(", "parents", ")", ">", "len", "(", "set", "(", "parents", ")", ")", ":", "raise", "SomaError", "(", "\"Bifurcating soma\"", ")" ]
check if points form valid soma Currently checks if there are bifurcations within a soma with more than three points.
[ "check", "if", "points", "form", "valid", "soma" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_core.py#L114-L125
2,668
BlueBrain/NeuroM
neurom/fst/_core.py
FstNeuron.points
def points(self): '''Return unordered array with all the points in this neuron''' if self._points is None: _points = self.soma.points.tolist() for n in self.neurites: _points.extend(n.points.tolist()) self._points = np.array(_points) return self._points
python
def points(self): '''Return unordered array with all the points in this neuron''' if self._points is None: _points = self.soma.points.tolist() for n in self.neurites: _points.extend(n.points.tolist()) self._points = np.array(_points) return self._points
[ "def", "points", "(", "self", ")", ":", "if", "self", ".", "_points", "is", "None", ":", "_points", "=", "self", ".", "soma", ".", "points", ".", "tolist", "(", ")", "for", "n", "in", "self", ".", "neurites", ":", "_points", ".", "extend", "(", "n", ".", "points", ".", "tolist", "(", ")", ")", "self", ".", "_points", "=", "np", ".", "array", "(", "_points", ")", "return", "self", ".", "_points" ]
Return unordered array with all the points in this neuron
[ "Return", "unordered", "array", "with", "all", "the", "points", "in", "this", "neuron" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_core.py#L52-L60
2,669
BlueBrain/NeuroM
neurom/fst/_core.py
FstNeuron.transform
def transform(self, trans): '''Return a copy of this neuron with a 3D transformation applied''' _data = deepcopy(self._data) _data.data_block[:, 0:3] = trans(_data.data_block[:, 0:3]) return FstNeuron(_data, self.name)
python
def transform(self, trans): '''Return a copy of this neuron with a 3D transformation applied''' _data = deepcopy(self._data) _data.data_block[:, 0:3] = trans(_data.data_block[:, 0:3]) return FstNeuron(_data, self.name)
[ "def", "transform", "(", "self", ",", "trans", ")", ":", "_data", "=", "deepcopy", "(", "self", ".", "_data", ")", "_data", ".", "data_block", "[", ":", ",", "0", ":", "3", "]", "=", "trans", "(", "_data", ".", "data_block", "[", ":", ",", "0", ":", "3", "]", ")", "return", "FstNeuron", "(", "_data", ",", "self", ".", "name", ")" ]
Return a copy of this neuron with a 3D transformation applied
[ "Return", "a", "copy", "of", "this", "neuron", "with", "a", "3D", "transformation", "applied" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_core.py#L62-L66
2,670
BlueBrain/NeuroM
neurom/morphmath.py
vector
def vector(p1, p2): '''compute vector between two 3D points Args: p1, p2: indexable objects with indices 0, 1, 2 corresponding to 3D cartesian coordinates. Returns: 3-vector from p1 - p2 ''' return np.subtract(p1[COLS.XYZ], p2[COLS.XYZ])
python
def vector(p1, p2): '''compute vector between two 3D points Args: p1, p2: indexable objects with indices 0, 1, 2 corresponding to 3D cartesian coordinates. Returns: 3-vector from p1 - p2 ''' return np.subtract(p1[COLS.XYZ], p2[COLS.XYZ])
[ "def", "vector", "(", "p1", ",", "p2", ")", ":", "return", "np", ".", "subtract", "(", "p1", "[", "COLS", ".", "XYZ", "]", ",", "p2", "[", "COLS", ".", "XYZ", "]", ")" ]
compute vector between two 3D points Args: p1, p2: indexable objects with indices 0, 1, 2 corresponding to 3D cartesian coordinates. Returns: 3-vector from p1 - p2
[ "compute", "vector", "between", "two", "3D", "points" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/morphmath.py#L38-L48
2,671
BlueBrain/NeuroM
neurom/morphmath.py
interpolate_radius
def interpolate_radius(r1, r2, fraction): '''Calculate the radius that corresponds to a point P that lies at a fraction of the length of a cut cone P1P2 where P1, P2 are the centers of the circles that bound the shape with radii r1 and r2 respectively. Args: r1: float Radius of the first node of the segment. r2: float Radius of the second node of the segment fraction: float The fraction at which the interpolated radius is calculated. Returns: float The interpolated radius. Note: The fraction is assumed from point P1, not from point P2. ''' def f(a, b, c): ''' Returns the length of the interpolated radius calculated using similar triangles. ''' return a + c * (b - a) return f(r2, r1, 1. - fraction) if r1 > r2 else f(r1, r2, fraction)
python
def interpolate_radius(r1, r2, fraction): '''Calculate the radius that corresponds to a point P that lies at a fraction of the length of a cut cone P1P2 where P1, P2 are the centers of the circles that bound the shape with radii r1 and r2 respectively. Args: r1: float Radius of the first node of the segment. r2: float Radius of the second node of the segment fraction: float The fraction at which the interpolated radius is calculated. Returns: float The interpolated radius. Note: The fraction is assumed from point P1, not from point P2. ''' def f(a, b, c): ''' Returns the length of the interpolated radius calculated using similar triangles. ''' return a + c * (b - a) return f(r2, r1, 1. - fraction) if r1 > r2 else f(r1, r2, fraction)
[ "def", "interpolate_radius", "(", "r1", ",", "r2", ",", "fraction", ")", ":", "def", "f", "(", "a", ",", "b", ",", "c", ")", ":", "''' Returns the length of the interpolated radius calculated\n using similar triangles.\n '''", "return", "a", "+", "c", "*", "(", "b", "-", "a", ")", "return", "f", "(", "r2", ",", "r1", ",", "1.", "-", "fraction", ")", "if", "r1", ">", "r2", "else", "f", "(", "r1", ",", "r2", ",", "fraction", ")" ]
Calculate the radius that corresponds to a point P that lies at a fraction of the length of a cut cone P1P2 where P1, P2 are the centers of the circles that bound the shape with radii r1 and r2 respectively. Args: r1: float Radius of the first node of the segment. r2: float Radius of the second node of the segment fraction: float The fraction at which the interpolated radius is calculated. Returns: float The interpolated radius. Note: The fraction is assumed from point P1, not from point P2.
[ "Calculate", "the", "radius", "that", "corresponds", "to", "a", "point", "P", "that", "lies", "at", "a", "fraction", "of", "the", "length", "of", "a", "cut", "cone", "P1P2", "where", "P1", "P2", "are", "the", "centers", "of", "the", "circles", "that", "bound", "the", "shape", "with", "radii", "r1", "and", "r2", "respectively", "." ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/morphmath.py#L58-L81
2,672
BlueBrain/NeuroM
neurom/morphmath.py
path_fraction_id_offset
def path_fraction_id_offset(points, fraction, relative_offset=False): '''Find the segment which corresponds to the fraction of the path length along the piecewise linear curve which is constructed from the set of points. Args: points: an iterable of indexable objects with indices 0, 1, 2 correspoding to 3D cartesian coordinates fraction: path length fraction (0.0 <= fraction <= 1.0) relative_offset: return absolute or relative segment distance Returns: (segment ID, segment offset) pair. ''' if not (0. <= fraction <= 1.0): raise ValueError("Invalid fraction: %.3f" % fraction) pts = np.array(points)[:, COLS.XYZ] lengths = np.linalg.norm(np.diff(pts, axis=0), axis=1) cum_lengths = np.cumsum(lengths) offset = cum_lengths[-1] * fraction seg_id = np.argmin(cum_lengths < offset) if seg_id > 0: offset -= cum_lengths[seg_id - 1] if relative_offset: offset /= lengths[seg_id] return seg_id, offset
python
def path_fraction_id_offset(points, fraction, relative_offset=False): '''Find the segment which corresponds to the fraction of the path length along the piecewise linear curve which is constructed from the set of points. Args: points: an iterable of indexable objects with indices 0, 1, 2 correspoding to 3D cartesian coordinates fraction: path length fraction (0.0 <= fraction <= 1.0) relative_offset: return absolute or relative segment distance Returns: (segment ID, segment offset) pair. ''' if not (0. <= fraction <= 1.0): raise ValueError("Invalid fraction: %.3f" % fraction) pts = np.array(points)[:, COLS.XYZ] lengths = np.linalg.norm(np.diff(pts, axis=0), axis=1) cum_lengths = np.cumsum(lengths) offset = cum_lengths[-1] * fraction seg_id = np.argmin(cum_lengths < offset) if seg_id > 0: offset -= cum_lengths[seg_id - 1] if relative_offset: offset /= lengths[seg_id] return seg_id, offset
[ "def", "path_fraction_id_offset", "(", "points", ",", "fraction", ",", "relative_offset", "=", "False", ")", ":", "if", "not", "(", "0.", "<=", "fraction", "<=", "1.0", ")", ":", "raise", "ValueError", "(", "\"Invalid fraction: %.3f\"", "%", "fraction", ")", "pts", "=", "np", ".", "array", "(", "points", ")", "[", ":", ",", "COLS", ".", "XYZ", "]", "lengths", "=", "np", ".", "linalg", ".", "norm", "(", "np", ".", "diff", "(", "pts", ",", "axis", "=", "0", ")", ",", "axis", "=", "1", ")", "cum_lengths", "=", "np", ".", "cumsum", "(", "lengths", ")", "offset", "=", "cum_lengths", "[", "-", "1", "]", "*", "fraction", "seg_id", "=", "np", ".", "argmin", "(", "cum_lengths", "<", "offset", ")", "if", "seg_id", ">", "0", ":", "offset", "-=", "cum_lengths", "[", "seg_id", "-", "1", "]", "if", "relative_offset", ":", "offset", "/=", "lengths", "[", "seg_id", "]", "return", "seg_id", ",", "offset" ]
Find the segment which corresponds to the fraction of the path length along the piecewise linear curve which is constructed from the set of points. Args: points: an iterable of indexable objects with indices 0, 1, 2 correspoding to 3D cartesian coordinates fraction: path length fraction (0.0 <= fraction <= 1.0) relative_offset: return absolute or relative segment distance Returns: (segment ID, segment offset) pair.
[ "Find", "the", "segment", "which", "corresponds", "to", "the", "fraction", "of", "the", "path", "length", "along", "the", "piecewise", "linear", "curve", "which", "is", "constructed", "from", "the", "set", "of", "points", "." ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/morphmath.py#L84-L109
2,673
BlueBrain/NeuroM
neurom/morphmath.py
path_fraction_point
def path_fraction_point(points, fraction): '''Computes the point which corresponds to the fraction of the path length along the piecewise linear curve which is constructed from the set of points. Args: points: an iterable of indexable objects with indices 0, 1, 2 correspoding to 3D cartesian coordinates fraction: path length fraction (0 <= fraction <= 1) Returns: The 3D coordinates of the aforementioned point ''' seg_id, offset = path_fraction_id_offset(points, fraction, relative_offset=True) return linear_interpolate(points[seg_id], points[seg_id + 1], offset)
python
def path_fraction_point(points, fraction): '''Computes the point which corresponds to the fraction of the path length along the piecewise linear curve which is constructed from the set of points. Args: points: an iterable of indexable objects with indices 0, 1, 2 correspoding to 3D cartesian coordinates fraction: path length fraction (0 <= fraction <= 1) Returns: The 3D coordinates of the aforementioned point ''' seg_id, offset = path_fraction_id_offset(points, fraction, relative_offset=True) return linear_interpolate(points[seg_id], points[seg_id + 1], offset)
[ "def", "path_fraction_point", "(", "points", ",", "fraction", ")", ":", "seg_id", ",", "offset", "=", "path_fraction_id_offset", "(", "points", ",", "fraction", ",", "relative_offset", "=", "True", ")", "return", "linear_interpolate", "(", "points", "[", "seg_id", "]", ",", "points", "[", "seg_id", "+", "1", "]", ",", "offset", ")" ]
Computes the point which corresponds to the fraction of the path length along the piecewise linear curve which is constructed from the set of points. Args: points: an iterable of indexable objects with indices 0, 1, 2 correspoding to 3D cartesian coordinates fraction: path length fraction (0 <= fraction <= 1) Returns: The 3D coordinates of the aforementioned point
[ "Computes", "the", "point", "which", "corresponds", "to", "the", "fraction", "of", "the", "path", "length", "along", "the", "piecewise", "linear", "curve", "which", "is", "constructed", "from", "the", "set", "of", "points", "." ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/morphmath.py#L112-L126
2,674
BlueBrain/NeuroM
neurom/morphmath.py
scalar_projection
def scalar_projection(v1, v2): '''compute the scalar projection of v1 upon v2 Args: v1, v2: iterable indices 0, 1, 2 corresponding to cartesian coordinates Returns: 3-vector of the projection of point p onto the direction of v ''' return np.dot(v1, v2) / np.linalg.norm(v2)
python
def scalar_projection(v1, v2): '''compute the scalar projection of v1 upon v2 Args: v1, v2: iterable indices 0, 1, 2 corresponding to cartesian coordinates Returns: 3-vector of the projection of point p onto the direction of v ''' return np.dot(v1, v2) / np.linalg.norm(v2)
[ "def", "scalar_projection", "(", "v1", ",", "v2", ")", ":", "return", "np", ".", "dot", "(", "v1", ",", "v2", ")", "/", "np", ".", "linalg", ".", "norm", "(", "v2", ")" ]
compute the scalar projection of v1 upon v2 Args: v1, v2: iterable indices 0, 1, 2 corresponding to cartesian coordinates Returns: 3-vector of the projection of point p onto the direction of v
[ "compute", "the", "scalar", "projection", "of", "v1", "upon", "v2" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/morphmath.py#L129-L139
2,675
BlueBrain/NeuroM
neurom/morphmath.py
vector_projection
def vector_projection(v1, v2): '''compute the vector projection of v1 upon v2 Args: v1, v2: iterable indices 0, 1, 2 corresponding to cartesian coordinates Returns: 3-vector of the projection of point p onto the direction of v ''' return scalar_projection(v1, v2) * v2 / np.linalg.norm(v2)
python
def vector_projection(v1, v2): '''compute the vector projection of v1 upon v2 Args: v1, v2: iterable indices 0, 1, 2 corresponding to cartesian coordinates Returns: 3-vector of the projection of point p onto the direction of v ''' return scalar_projection(v1, v2) * v2 / np.linalg.norm(v2)
[ "def", "vector_projection", "(", "v1", ",", "v2", ")", ":", "return", "scalar_projection", "(", "v1", ",", "v2", ")", "*", "v2", "/", "np", ".", "linalg", ".", "norm", "(", "v2", ")" ]
compute the vector projection of v1 upon v2 Args: v1, v2: iterable indices 0, 1, 2 corresponding to cartesian coordinates Returns: 3-vector of the projection of point p onto the direction of v
[ "compute", "the", "vector", "projection", "of", "v1", "upon", "v2" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/morphmath.py#L142-L152
2,676
BlueBrain/NeuroM
neurom/morphmath.py
dist_point_line
def dist_point_line(p, l1, l2): '''compute the orthogonal distance between from the line that goes through the points l1, l2 and the point p Args: p, l1, l2 : iterable point indices 0, 1, 2 corresponding to cartesian coordinates ''' cross_prod = np.cross(l2 - l1, p - l1) return np.linalg.norm(cross_prod) / np.linalg.norm(l2 - l1)
python
def dist_point_line(p, l1, l2): '''compute the orthogonal distance between from the line that goes through the points l1, l2 and the point p Args: p, l1, l2 : iterable point indices 0, 1, 2 corresponding to cartesian coordinates ''' cross_prod = np.cross(l2 - l1, p - l1) return np.linalg.norm(cross_prod) / np.linalg.norm(l2 - l1)
[ "def", "dist_point_line", "(", "p", ",", "l1", ",", "l2", ")", ":", "cross_prod", "=", "np", ".", "cross", "(", "l2", "-", "l1", ",", "p", "-", "l1", ")", "return", "np", ".", "linalg", ".", "norm", "(", "cross_prod", ")", "/", "np", ".", "linalg", ".", "norm", "(", "l2", "-", "l1", ")" ]
compute the orthogonal distance between from the line that goes through the points l1, l2 and the point p Args: p, l1, l2 : iterable point indices 0, 1, 2 corresponding to cartesian coordinates
[ "compute", "the", "orthogonal", "distance", "between", "from", "the", "line", "that", "goes", "through", "the", "points", "l1", "l2", "and", "the", "point", "p" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/morphmath.py#L155-L165
2,677
BlueBrain/NeuroM
neurom/morphmath.py
point_dist2
def point_dist2(p1, p2): '''compute the square of the euclidian distance between two 3D points Args: p1, p2: indexable objects with indices 0, 1, 2 corresponding to 3D cartesian coordinates. Returns: The square of the euclidian distance between the points. ''' v = vector(p1, p2) return np.dot(v, v)
python
def point_dist2(p1, p2): '''compute the square of the euclidian distance between two 3D points Args: p1, p2: indexable objects with indices 0, 1, 2 corresponding to 3D cartesian coordinates. Returns: The square of the euclidian distance between the points. ''' v = vector(p1, p2) return np.dot(v, v)
[ "def", "point_dist2", "(", "p1", ",", "p2", ")", ":", "v", "=", "vector", "(", "p1", ",", "p2", ")", "return", "np", ".", "dot", "(", "v", ",", "v", ")" ]
compute the square of the euclidian distance between two 3D points Args: p1, p2: indexable objects with indices 0, 1, 2 corresponding to 3D cartesian coordinates. Returns: The square of the euclidian distance between the points.
[ "compute", "the", "square", "of", "the", "euclidian", "distance", "between", "two", "3D", "points" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/morphmath.py#L168-L178
2,678
BlueBrain/NeuroM
neurom/morphmath.py
angle_3points
def angle_3points(p0, p1, p2): ''' compute the angle in radians between three 3D points Calculated as the angle between p1-p0 and p2-p0. Args: p0, p1, p2: indexable objects with indices 0, 1, 2 corresponding to 3D cartesian coordinates. Returns: Angle in radians between (p1-p0) and (p2-p0). 0.0 if p0==p1 or p0==p2. ''' vec1 = vector(p1, p0) vec2 = vector(p2, p0) return math.atan2(np.linalg.norm(np.cross(vec1, vec2)), np.dot(vec1, vec2))
python
def angle_3points(p0, p1, p2): ''' compute the angle in radians between three 3D points Calculated as the angle between p1-p0 and p2-p0. Args: p0, p1, p2: indexable objects with indices 0, 1, 2 corresponding to 3D cartesian coordinates. Returns: Angle in radians between (p1-p0) and (p2-p0). 0.0 if p0==p1 or p0==p2. ''' vec1 = vector(p1, p0) vec2 = vector(p2, p0) return math.atan2(np.linalg.norm(np.cross(vec1, vec2)), np.dot(vec1, vec2))
[ "def", "angle_3points", "(", "p0", ",", "p1", ",", "p2", ")", ":", "vec1", "=", "vector", "(", "p1", ",", "p0", ")", "vec2", "=", "vector", "(", "p2", ",", "p0", ")", "return", "math", ".", "atan2", "(", "np", ".", "linalg", ".", "norm", "(", "np", ".", "cross", "(", "vec1", ",", "vec2", ")", ")", ",", "np", ".", "dot", "(", "vec1", ",", "vec2", ")", ")" ]
compute the angle in radians between three 3D points Calculated as the angle between p1-p0 and p2-p0. Args: p0, p1, p2: indexable objects with indices 0, 1, 2 corresponding to 3D cartesian coordinates. Returns: Angle in radians between (p1-p0) and (p2-p0). 0.0 if p0==p1 or p0==p2.
[ "compute", "the", "angle", "in", "radians", "between", "three", "3D", "points" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/morphmath.py#L193-L209
2,679
BlueBrain/NeuroM
neurom/morphmath.py
angle_between_vectors
def angle_between_vectors(p1, p2): """ Computes the angle in radians between vectors 'p1' and 'p2' Normalizes the input vectors and computes the relative angle between them. >>> angle_between((1, 0), (0, 1)) 1.5707963267948966 >>> angle_between((1, 0), (1, 0)) 0.0 >>> angle_between((1, 0), (-1, 0)) 3.141592653589793 """ v1 = p1 / np.linalg.norm(p1) v2 = p2 / np.linalg.norm(p2) return np.arccos(np.clip(np.dot(v1, v2), -1.0, 1.0))
python
def angle_between_vectors(p1, p2): """ Computes the angle in radians between vectors 'p1' and 'p2' Normalizes the input vectors and computes the relative angle between them. >>> angle_between((1, 0), (0, 1)) 1.5707963267948966 >>> angle_between((1, 0), (1, 0)) 0.0 >>> angle_between((1, 0), (-1, 0)) 3.141592653589793 """ v1 = p1 / np.linalg.norm(p1) v2 = p2 / np.linalg.norm(p2) return np.arccos(np.clip(np.dot(v1, v2), -1.0, 1.0))
[ "def", "angle_between_vectors", "(", "p1", ",", "p2", ")", ":", "v1", "=", "p1", "/", "np", ".", "linalg", ".", "norm", "(", "p1", ")", "v2", "=", "p2", "/", "np", ".", "linalg", ".", "norm", "(", "p2", ")", "return", "np", ".", "arccos", "(", "np", ".", "clip", "(", "np", ".", "dot", "(", "v1", ",", "v2", ")", ",", "-", "1.0", ",", "1.0", ")", ")" ]
Computes the angle in radians between vectors 'p1' and 'p2' Normalizes the input vectors and computes the relative angle between them. >>> angle_between((1, 0), (0, 1)) 1.5707963267948966 >>> angle_between((1, 0), (1, 0)) 0.0 >>> angle_between((1, 0), (-1, 0)) 3.141592653589793
[ "Computes", "the", "angle", "in", "radians", "between", "vectors", "p1", "and", "p2", "Normalizes", "the", "input", "vectors", "and", "computes", "the", "relative", "angle", "between", "them", "." ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/morphmath.py#L212-L226
2,680
BlueBrain/NeuroM
neurom/morphmath.py
polygon_diameter
def polygon_diameter(points): ''' Compute the maximun euclidian distance between any two points in a list of points ''' return max(point_dist(p0, p1) for (p0, p1) in combinations(points, 2))
python
def polygon_diameter(points): ''' Compute the maximun euclidian distance between any two points in a list of points ''' return max(point_dist(p0, p1) for (p0, p1) in combinations(points, 2))
[ "def", "polygon_diameter", "(", "points", ")", ":", "return", "max", "(", "point_dist", "(", "p0", ",", "p1", ")", "for", "(", "p0", ",", "p1", ")", "in", "combinations", "(", "points", ",", "2", ")", ")" ]
Compute the maximun euclidian distance between any two points in a list of points
[ "Compute", "the", "maximun", "euclidian", "distance", "between", "any", "two", "points", "in", "a", "list", "of", "points" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/morphmath.py#L229-L233
2,681
BlueBrain/NeuroM
neurom/morphmath.py
average_points_dist
def average_points_dist(p0, p_list): """ Computes the average distance between a list of points and a given point p0. """ return np.mean(list(point_dist(p0, p1) for p1 in p_list))
python
def average_points_dist(p0, p_list): """ Computes the average distance between a list of points and a given point p0. """ return np.mean(list(point_dist(p0, p1) for p1 in p_list))
[ "def", "average_points_dist", "(", "p0", ",", "p_list", ")", ":", "return", "np", ".", "mean", "(", "list", "(", "point_dist", "(", "p0", ",", "p1", ")", "for", "p1", "in", "p_list", ")", ")" ]
Computes the average distance between a list of points and a given point p0.
[ "Computes", "the", "average", "distance", "between", "a", "list", "of", "points", "and", "a", "given", "point", "p0", "." ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/morphmath.py#L236-L241
2,682
BlueBrain/NeuroM
neurom/morphmath.py
path_distance
def path_distance(points): """ Compute the path distance from given set of points """ vecs = np.diff(points, axis=0)[:, :3] d2 = [np.dot(p, p) for p in vecs] return np.sum(np.sqrt(d2))
python
def path_distance(points): """ Compute the path distance from given set of points """ vecs = np.diff(points, axis=0)[:, :3] d2 = [np.dot(p, p) for p in vecs] return np.sum(np.sqrt(d2))
[ "def", "path_distance", "(", "points", ")", ":", "vecs", "=", "np", ".", "diff", "(", "points", ",", "axis", "=", "0", ")", "[", ":", ",", ":", "3", "]", "d2", "=", "[", "np", ".", "dot", "(", "p", ",", "p", ")", "for", "p", "in", "vecs", "]", "return", "np", ".", "sum", "(", "np", ".", "sqrt", "(", "d2", ")", ")" ]
Compute the path distance from given set of points
[ "Compute", "the", "path", "distance", "from", "given", "set", "of", "points" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/morphmath.py#L244-L250
2,683
BlueBrain/NeuroM
neurom/morphmath.py
segment_radial_dist
def segment_radial_dist(seg, pos): '''Return the radial distance of a tree segment to a given point The radial distance is the euclidian distance between the mid-point of the segment and the point in question. Parameters: seg: tree segment pos: origin to which distances are measured. It must have at lease 3 components. The first 3 components are (x, y, z). ''' return point_dist(pos, np.divide(np.add(seg[0], seg[1]), 2.0))
python
def segment_radial_dist(seg, pos): '''Return the radial distance of a tree segment to a given point The radial distance is the euclidian distance between the mid-point of the segment and the point in question. Parameters: seg: tree segment pos: origin to which distances are measured. It must have at lease 3 components. The first 3 components are (x, y, z). ''' return point_dist(pos, np.divide(np.add(seg[0], seg[1]), 2.0))
[ "def", "segment_radial_dist", "(", "seg", ",", "pos", ")", ":", "return", "point_dist", "(", "pos", ",", "np", ".", "divide", "(", "np", ".", "add", "(", "seg", "[", "0", "]", ",", "seg", "[", "1", "]", ")", ",", "2.0", ")", ")" ]
Return the radial distance of a tree segment to a given point The radial distance is the euclidian distance between the mid-point of the segment and the point in question. Parameters: seg: tree segment pos: origin to which distances are measured. It must have at lease 3 components. The first 3 components are (x, y, z).
[ "Return", "the", "radial", "distance", "of", "a", "tree", "segment", "to", "a", "given", "point" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/morphmath.py#L301-L313
2,684
BlueBrain/NeuroM
neurom/morphmath.py
segment_area
def segment_area(seg): '''Compute the surface area of a segment. Approximated as a conical frustum. Does not include the surface area of the bounding circles. ''' r0 = seg[0][COLS.R] r1 = seg[1][COLS.R] h2 = point_dist2(seg[0], seg[1]) return math.pi * (r0 + r1) * math.sqrt((r0 - r1) ** 2 + h2)
python
def segment_area(seg): '''Compute the surface area of a segment. Approximated as a conical frustum. Does not include the surface area of the bounding circles. ''' r0 = seg[0][COLS.R] r1 = seg[1][COLS.R] h2 = point_dist2(seg[0], seg[1]) return math.pi * (r0 + r1) * math.sqrt((r0 - r1) ** 2 + h2)
[ "def", "segment_area", "(", "seg", ")", ":", "r0", "=", "seg", "[", "0", "]", "[", "COLS", ".", "R", "]", "r1", "=", "seg", "[", "1", "]", "[", "COLS", ".", "R", "]", "h2", "=", "point_dist2", "(", "seg", "[", "0", "]", ",", "seg", "[", "1", "]", ")", "return", "math", ".", "pi", "*", "(", "r0", "+", "r1", ")", "*", "math", ".", "sqrt", "(", "(", "r0", "-", "r1", ")", "**", "2", "+", "h2", ")" ]
Compute the surface area of a segment. Approximated as a conical frustum. Does not include the surface area of the bounding circles.
[ "Compute", "the", "surface", "area", "of", "a", "segment", "." ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/morphmath.py#L316-L325
2,685
BlueBrain/NeuroM
neurom/morphmath.py
segment_volume
def segment_volume(seg): '''Compute the volume of a segment. Approximated as a conical frustum. ''' r0 = seg[0][COLS.R] r1 = seg[1][COLS.R] h = point_dist(seg[0], seg[1]) return math.pi * h * ((r0 * r0) + (r0 * r1) + (r1 * r1)) / 3.0
python
def segment_volume(seg): '''Compute the volume of a segment. Approximated as a conical frustum. ''' r0 = seg[0][COLS.R] r1 = seg[1][COLS.R] h = point_dist(seg[0], seg[1]) return math.pi * h * ((r0 * r0) + (r0 * r1) + (r1 * r1)) / 3.0
[ "def", "segment_volume", "(", "seg", ")", ":", "r0", "=", "seg", "[", "0", "]", "[", "COLS", ".", "R", "]", "r1", "=", "seg", "[", "1", "]", "[", "COLS", ".", "R", "]", "h", "=", "point_dist", "(", "seg", "[", "0", "]", ",", "seg", "[", "1", "]", ")", "return", "math", ".", "pi", "*", "h", "*", "(", "(", "r0", "*", "r0", ")", "+", "(", "r0", "*", "r1", ")", "+", "(", "r1", "*", "r1", ")", ")", "/", "3.0" ]
Compute the volume of a segment. Approximated as a conical frustum.
[ "Compute", "the", "volume", "of", "a", "segment", "." ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/morphmath.py#L328-L336
2,686
BlueBrain/NeuroM
neurom/morphmath.py
taper_rate
def taper_rate(p0, p1): '''Compute the taper rate between points p0 and p1 Args: p0, p1: iterables with first 4 components containing (x, y, z, r) Returns: The taper rate, defined as the absolute value of the difference in the diameters of p0 and p1 divided by the euclidian distance between them. ''' return 2 * abs(p0[COLS.R] - p1[COLS.R]) / point_dist(p0, p1)
python
def taper_rate(p0, p1): '''Compute the taper rate between points p0 and p1 Args: p0, p1: iterables with first 4 components containing (x, y, z, r) Returns: The taper rate, defined as the absolute value of the difference in the diameters of p0 and p1 divided by the euclidian distance between them. ''' return 2 * abs(p0[COLS.R] - p1[COLS.R]) / point_dist(p0, p1)
[ "def", "taper_rate", "(", "p0", ",", "p1", ")", ":", "return", "2", "*", "abs", "(", "p0", "[", "COLS", ".", "R", "]", "-", "p1", "[", "COLS", ".", "R", "]", ")", "/", "point_dist", "(", "p0", ",", "p1", ")" ]
Compute the taper rate between points p0 and p1 Args: p0, p1: iterables with first 4 components containing (x, y, z, r) Returns: The taper rate, defined as the absolute value of the difference in the diameters of p0 and p1 divided by the euclidian distance between them.
[ "Compute", "the", "taper", "rate", "between", "points", "p0", "and", "p1" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/morphmath.py#L339-L350
2,687
BlueBrain/NeuroM
neurom/morphmath.py
principal_direction_extent
def principal_direction_extent(points): '''Calculate the extent of a set of 3D points. The extent is defined as the maximum distance between the projections on the principal directions of the covariance matrix of the points. Parameter: points : a 2D numpy array of points Returns: extents : the extents for each of the eigenvectors of the cov matrix eigs : eigenvalues of the covariance matrix eigv : respective eigenvectors of the covariance matrix ''' # center the points around 0.0 points = np.copy(points) points -= np.mean(points, axis=0) # principal components _, eigv = pca(points) extent = np.zeros(3) for i in range(eigv.shape[1]): # orthogonal projection onto the direction of the v component scalar_projs = np.sort(np.array([np.dot(p, eigv[:, i]) for p in points])) extent[i] = scalar_projs[-1] if scalar_projs[0] < 0.: extent -= scalar_projs[0] return extent
python
def principal_direction_extent(points): '''Calculate the extent of a set of 3D points. The extent is defined as the maximum distance between the projections on the principal directions of the covariance matrix of the points. Parameter: points : a 2D numpy array of points Returns: extents : the extents for each of the eigenvectors of the cov matrix eigs : eigenvalues of the covariance matrix eigv : respective eigenvectors of the covariance matrix ''' # center the points around 0.0 points = np.copy(points) points -= np.mean(points, axis=0) # principal components _, eigv = pca(points) extent = np.zeros(3) for i in range(eigv.shape[1]): # orthogonal projection onto the direction of the v component scalar_projs = np.sort(np.array([np.dot(p, eigv[:, i]) for p in points])) extent[i] = scalar_projs[-1] if scalar_projs[0] < 0.: extent -= scalar_projs[0] return extent
[ "def", "principal_direction_extent", "(", "points", ")", ":", "# center the points around 0.0", "points", "=", "np", ".", "copy", "(", "points", ")", "points", "-=", "np", ".", "mean", "(", "points", ",", "axis", "=", "0", ")", "# principal components", "_", ",", "eigv", "=", "pca", "(", "points", ")", "extent", "=", "np", ".", "zeros", "(", "3", ")", "for", "i", "in", "range", "(", "eigv", ".", "shape", "[", "1", "]", ")", ":", "# orthogonal projection onto the direction of the v component", "scalar_projs", "=", "np", ".", "sort", "(", "np", ".", "array", "(", "[", "np", ".", "dot", "(", "p", ",", "eigv", "[", ":", ",", "i", "]", ")", "for", "p", "in", "points", "]", ")", ")", "extent", "[", "i", "]", "=", "scalar_projs", "[", "-", "1", "]", "if", "scalar_projs", "[", "0", "]", "<", "0.", ":", "extent", "-=", "scalar_projs", "[", "0", "]", "return", "extent" ]
Calculate the extent of a set of 3D points. The extent is defined as the maximum distance between the projections on the principal directions of the covariance matrix of the points. Parameter: points : a 2D numpy array of points Returns: extents : the extents for each of the eigenvectors of the cov matrix eigs : eigenvalues of the covariance matrix eigv : respective eigenvectors of the covariance matrix
[ "Calculate", "the", "extent", "of", "a", "set", "of", "3D", "points", "." ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/morphmath.py#L387-L419
2,688
BlueBrain/NeuroM
examples/features_graph_table.py
stylize
def stylize(ax, name, feature): '''Stylization modifications to the plots ''' ax.set_ylabel(feature) ax.set_title(name, fontsize='small')
python
def stylize(ax, name, feature): '''Stylization modifications to the plots ''' ax.set_ylabel(feature) ax.set_title(name, fontsize='small')
[ "def", "stylize", "(", "ax", ",", "name", ",", "feature", ")", ":", "ax", ".", "set_ylabel", "(", "feature", ")", "ax", ".", "set_title", "(", "name", ",", "fontsize", "=", "'small'", ")" ]
Stylization modifications to the plots
[ "Stylization", "modifications", "to", "the", "plots" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/features_graph_table.py#L60-L64
2,689
BlueBrain/NeuroM
examples/features_graph_table.py
plot_feature
def plot_feature(feature, cell): '''Plot a feature ''' fig = pl.figure() ax = fig.add_subplot(111) if cell is not None: try: histogram(cell, feature, ax) except ValueError: pass stylize(ax, cell.name, feature) return fig
python
def plot_feature(feature, cell): '''Plot a feature ''' fig = pl.figure() ax = fig.add_subplot(111) if cell is not None: try: histogram(cell, feature, ax) except ValueError: pass stylize(ax, cell.name, feature) return fig
[ "def", "plot_feature", "(", "feature", ",", "cell", ")", ":", "fig", "=", "pl", ".", "figure", "(", ")", "ax", "=", "fig", ".", "add_subplot", "(", "111", ")", "if", "cell", "is", "not", "None", ":", "try", ":", "histogram", "(", "cell", ",", "feature", ",", "ax", ")", "except", "ValueError", ":", "pass", "stylize", "(", "ax", ",", "cell", ".", "name", ",", "feature", ")", "return", "fig" ]
Plot a feature
[ "Plot", "a", "feature" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/features_graph_table.py#L94-L106
2,690
BlueBrain/NeuroM
examples/end_to_end_distance.py
path_end_to_end_distance
def path_end_to_end_distance(neurite): '''Calculate and return end-to-end-distance of a given neurite.''' trunk = neurite.root_node.points[0] return max(morphmath.point_dist(l.points[-1], trunk) for l in neurite.root_node.ileaf())
python
def path_end_to_end_distance(neurite): '''Calculate and return end-to-end-distance of a given neurite.''' trunk = neurite.root_node.points[0] return max(morphmath.point_dist(l.points[-1], trunk) for l in neurite.root_node.ileaf())
[ "def", "path_end_to_end_distance", "(", "neurite", ")", ":", "trunk", "=", "neurite", ".", "root_node", ".", "points", "[", "0", "]", "return", "max", "(", "morphmath", ".", "point_dist", "(", "l", ".", "points", "[", "-", "1", "]", ",", "trunk", ")", "for", "l", "in", "neurite", ".", "root_node", ".", "ileaf", "(", ")", ")" ]
Calculate and return end-to-end-distance of a given neurite.
[ "Calculate", "and", "return", "end", "-", "to", "-", "end", "-", "distance", "of", "a", "given", "neurite", "." ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/end_to_end_distance.py#L38-L42
2,691
BlueBrain/NeuroM
examples/end_to_end_distance.py
make_end_to_end_distance_plot
def make_end_to_end_distance_plot(nb_segments, end_to_end_distance, neurite_type): '''Plot end-to-end distance vs number of segments''' plt.figure() plt.plot(nb_segments, end_to_end_distance) plt.title(neurite_type) plt.xlabel('Number of segments') plt.ylabel('End-to-end distance') plt.show()
python
def make_end_to_end_distance_plot(nb_segments, end_to_end_distance, neurite_type): '''Plot end-to-end distance vs number of segments''' plt.figure() plt.plot(nb_segments, end_to_end_distance) plt.title(neurite_type) plt.xlabel('Number of segments') plt.ylabel('End-to-end distance') plt.show()
[ "def", "make_end_to_end_distance_plot", "(", "nb_segments", ",", "end_to_end_distance", ",", "neurite_type", ")", ":", "plt", ".", "figure", "(", ")", "plt", ".", "plot", "(", "nb_segments", ",", "end_to_end_distance", ")", "plt", ".", "title", "(", "neurite_type", ")", "plt", ".", "xlabel", "(", "'Number of segments'", ")", "plt", ".", "ylabel", "(", "'End-to-end distance'", ")", "plt", ".", "show", "(", ")" ]
Plot end-to-end distance vs number of segments
[ "Plot", "end", "-", "to", "-", "end", "distance", "vs", "number", "of", "segments" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/end_to_end_distance.py#L50-L57
2,692
BlueBrain/NeuroM
examples/end_to_end_distance.py
calculate_and_plot_end_to_end_distance
def calculate_and_plot_end_to_end_distance(neurite): '''Calculate and plot the end-to-end distance vs the number of segments for an increasingly larger part of a given neurite. Note that the plots are not very meaningful for bifurcating trees.''' def _dist(seg): '''Distance between segmenr end and trunk''' return morphmath.point_dist(seg[1], neurite.root_node.points[0]) end_to_end_distance = [_dist(s) for s in nm.iter_segments(neurite)] make_end_to_end_distance_plot(np.arange(len(end_to_end_distance)) + 1, end_to_end_distance, neurite.type)
python
def calculate_and_plot_end_to_end_distance(neurite): '''Calculate and plot the end-to-end distance vs the number of segments for an increasingly larger part of a given neurite. Note that the plots are not very meaningful for bifurcating trees.''' def _dist(seg): '''Distance between segmenr end and trunk''' return morphmath.point_dist(seg[1], neurite.root_node.points[0]) end_to_end_distance = [_dist(s) for s in nm.iter_segments(neurite)] make_end_to_end_distance_plot(np.arange(len(end_to_end_distance)) + 1, end_to_end_distance, neurite.type)
[ "def", "calculate_and_plot_end_to_end_distance", "(", "neurite", ")", ":", "def", "_dist", "(", "seg", ")", ":", "'''Distance between segmenr end and trunk'''", "return", "morphmath", ".", "point_dist", "(", "seg", "[", "1", "]", ",", "neurite", ".", "root_node", ".", "points", "[", "0", "]", ")", "end_to_end_distance", "=", "[", "_dist", "(", "s", ")", "for", "s", "in", "nm", ".", "iter_segments", "(", "neurite", ")", "]", "make_end_to_end_distance_plot", "(", "np", ".", "arange", "(", "len", "(", "end_to_end_distance", ")", ")", "+", "1", ",", "end_to_end_distance", ",", "neurite", ".", "type", ")" ]
Calculate and plot the end-to-end distance vs the number of segments for an increasingly larger part of a given neurite. Note that the plots are not very meaningful for bifurcating trees.
[ "Calculate", "and", "plot", "the", "end", "-", "to", "-", "end", "distance", "vs", "the", "number", "of", "segments", "for", "an", "increasingly", "larger", "part", "of", "a", "given", "neurite", "." ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/end_to_end_distance.py#L60-L71
2,693
BlueBrain/NeuroM
neurom/core/types.py
tree_type_checker
def tree_type_checker(*ref): '''Tree type checker functor Returns: Functor that takes a tree, and returns true if that tree matches any of NeuriteTypes in ref Ex: >>> from neurom.core.types import NeuriteType, tree_type_checker >>> tree_filter = tree_type_checker(NeuriteType.axon, NeuriteType.basal_dendrite) >>> nrn.i_neurites(tree.isegment, tree_filter=tree_filter) ''' ref = tuple(ref) if NeuriteType.all in ref: def check_tree_type(_): '''Always returns true''' return True else: def check_tree_type(tree): '''Check whether tree has the same type as ref Returns: True if ref in the same type as tree.type or ref is NeuriteType.all ''' return tree.type in ref return check_tree_type
python
def tree_type_checker(*ref): '''Tree type checker functor Returns: Functor that takes a tree, and returns true if that tree matches any of NeuriteTypes in ref Ex: >>> from neurom.core.types import NeuriteType, tree_type_checker >>> tree_filter = tree_type_checker(NeuriteType.axon, NeuriteType.basal_dendrite) >>> nrn.i_neurites(tree.isegment, tree_filter=tree_filter) ''' ref = tuple(ref) if NeuriteType.all in ref: def check_tree_type(_): '''Always returns true''' return True else: def check_tree_type(tree): '''Check whether tree has the same type as ref Returns: True if ref in the same type as tree.type or ref is NeuriteType.all ''' return tree.type in ref return check_tree_type
[ "def", "tree_type_checker", "(", "*", "ref", ")", ":", "ref", "=", "tuple", "(", "ref", ")", "if", "NeuriteType", ".", "all", "in", "ref", ":", "def", "check_tree_type", "(", "_", ")", ":", "'''Always returns true'''", "return", "True", "else", ":", "def", "check_tree_type", "(", "tree", ")", ":", "'''Check whether tree has the same type as ref\n\n Returns:\n True if ref in the same type as tree.type or ref is NeuriteType.all\n '''", "return", "tree", ".", "type", "in", "ref", "return", "check_tree_type" ]
Tree type checker functor Returns: Functor that takes a tree, and returns true if that tree matches any of NeuriteTypes in ref Ex: >>> from neurom.core.types import NeuriteType, tree_type_checker >>> tree_filter = tree_type_checker(NeuriteType.axon, NeuriteType.basal_dendrite) >>> nrn.i_neurites(tree.isegment, tree_filter=tree_filter)
[ "Tree", "type", "checker", "functor" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/core/types.py#L66-L92
2,694
BlueBrain/NeuroM
neurom/core/types.py
dendrite_filter
def dendrite_filter(n): '''Select only dendrites''' return n.type == NeuriteType.basal_dendrite or n.type == NeuriteType.apical_dendrite
python
def dendrite_filter(n): '''Select only dendrites''' return n.type == NeuriteType.basal_dendrite or n.type == NeuriteType.apical_dendrite
[ "def", "dendrite_filter", "(", "n", ")", ":", "return", "n", ".", "type", "==", "NeuriteType", ".", "basal_dendrite", "or", "n", ".", "type", "==", "NeuriteType", ".", "apical_dendrite" ]
Select only dendrites
[ "Select", "only", "dendrites" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/core/types.py#L95-L97
2,695
BlueBrain/NeuroM
examples/plot_somas.py
plot_somas
def plot_somas(somas): '''Plot set of somas on same figure as spheres, each with different color''' _, ax = common.get_figure(new_fig=True, subplot=111, params={'projection': '3d', 'aspect': 'equal'}) for s in somas: common.plot_sphere(ax, s.center, s.radius, color=random_color(), alpha=1) plt.show()
python
def plot_somas(somas): '''Plot set of somas on same figure as spheres, each with different color''' _, ax = common.get_figure(new_fig=True, subplot=111, params={'projection': '3d', 'aspect': 'equal'}) for s in somas: common.plot_sphere(ax, s.center, s.radius, color=random_color(), alpha=1) plt.show()
[ "def", "plot_somas", "(", "somas", ")", ":", "_", ",", "ax", "=", "common", ".", "get_figure", "(", "new_fig", "=", "True", ",", "subplot", "=", "111", ",", "params", "=", "{", "'projection'", ":", "'3d'", ",", "'aspect'", ":", "'equal'", "}", ")", "for", "s", "in", "somas", ":", "common", ".", "plot_sphere", "(", "ax", ",", "s", ".", "center", ",", "s", ".", "radius", ",", "color", "=", "random_color", "(", ")", ",", "alpha", "=", "1", ")", "plt", ".", "show", "(", ")" ]
Plot set of somas on same figure as spheres, each with different color
[ "Plot", "set", "of", "somas", "on", "same", "figure", "as", "spheres", "each", "with", "different", "color" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/plot_somas.py#L48-L54
2,696
BlueBrain/NeuroM
neurom/view/_dendrogram.py
_max_recursion_depth
def _max_recursion_depth(obj): ''' Estimate recursion depth, which is defined as the number of nodes in a tree ''' neurites = obj.neurites if hasattr(obj, 'neurites') else [obj] return max(sum(1 for _ in neu.iter_sections()) for neu in neurites)
python
def _max_recursion_depth(obj): ''' Estimate recursion depth, which is defined as the number of nodes in a tree ''' neurites = obj.neurites if hasattr(obj, 'neurites') else [obj] return max(sum(1 for _ in neu.iter_sections()) for neu in neurites)
[ "def", "_max_recursion_depth", "(", "obj", ")", ":", "neurites", "=", "obj", ".", "neurites", "if", "hasattr", "(", "obj", ",", "'neurites'", ")", "else", "[", "obj", "]", "return", "max", "(", "sum", "(", "1", "for", "_", "in", "neu", ".", "iter_sections", "(", ")", ")", "for", "neu", "in", "neurites", ")" ]
Estimate recursion depth, which is defined as the number of nodes in a tree
[ "Estimate", "recursion", "depth", "which", "is", "defined", "as", "the", "number", "of", "nodes", "in", "a", "tree" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/view/_dendrogram.py#L44-L49
2,697
BlueBrain/NeuroM
neurom/view/_dendrogram.py
_total_rectangles
def _total_rectangles(tree): ''' Calculate the total number of segments that are required for the dendrogram. There is a vertical line for each segment and two horizontal line at each branching point ''' return sum(len(sec.children) + sec.points.shape[0] - 1 for sec in tree.iter_sections())
python
def _total_rectangles(tree): ''' Calculate the total number of segments that are required for the dendrogram. There is a vertical line for each segment and two horizontal line at each branching point ''' return sum(len(sec.children) + sec.points.shape[0] - 1 for sec in tree.iter_sections())
[ "def", "_total_rectangles", "(", "tree", ")", ":", "return", "sum", "(", "len", "(", "sec", ".", "children", ")", "+", "sec", ".", "points", ".", "shape", "[", "0", "]", "-", "1", "for", "sec", "in", "tree", ".", "iter_sections", "(", ")", ")" ]
Calculate the total number of segments that are required for the dendrogram. There is a vertical line for each segment and two horizontal line at each branching point
[ "Calculate", "the", "total", "number", "of", "segments", "that", "are", "required", "for", "the", "dendrogram", ".", "There", "is", "a", "vertical", "line", "for", "each", "segment", "and", "two", "horizontal", "line", "at", "each", "branching", "point" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/view/_dendrogram.py#L52-L59
2,698
BlueBrain/NeuroM
neurom/view/_dendrogram.py
_n_rectangles
def _n_rectangles(obj): ''' Calculate the total number of rectangles with respect to the type of the object ''' return sum(_total_rectangles(neu) for neu in obj.neurites) \ if hasattr(obj, 'neurites') else _total_rectangles(obj)
python
def _n_rectangles(obj): ''' Calculate the total number of rectangles with respect to the type of the object ''' return sum(_total_rectangles(neu) for neu in obj.neurites) \ if hasattr(obj, 'neurites') else _total_rectangles(obj)
[ "def", "_n_rectangles", "(", "obj", ")", ":", "return", "sum", "(", "_total_rectangles", "(", "neu", ")", "for", "neu", "in", "obj", ".", "neurites", ")", "if", "hasattr", "(", "obj", ",", "'neurites'", ")", "else", "_total_rectangles", "(", "obj", ")" ]
Calculate the total number of rectangles with respect to the type of the object
[ "Calculate", "the", "total", "number", "of", "rectangles", "with", "respect", "to", "the", "type", "of", "the", "object" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/view/_dendrogram.py#L62-L68
2,699
BlueBrain/NeuroM
neurom/view/_dendrogram.py
_square_segment
def _square_segment(radius, origin): '''Vertices for a square ''' return np.array(((origin[0] - radius, origin[1] - radius), (origin[0] - radius, origin[1] + radius), (origin[0] + radius, origin[1] + radius), (origin[0] + radius, origin[1] - radius)))
python
def _square_segment(radius, origin): '''Vertices for a square ''' return np.array(((origin[0] - radius, origin[1] - radius), (origin[0] - radius, origin[1] + radius), (origin[0] + radius, origin[1] + radius), (origin[0] + radius, origin[1] - radius)))
[ "def", "_square_segment", "(", "radius", ",", "origin", ")", ":", "return", "np", ".", "array", "(", "(", "(", "origin", "[", "0", "]", "-", "radius", ",", "origin", "[", "1", "]", "-", "radius", ")", ",", "(", "origin", "[", "0", "]", "-", "radius", ",", "origin", "[", "1", "]", "+", "radius", ")", ",", "(", "origin", "[", "0", "]", "+", "radius", ",", "origin", "[", "1", "]", "+", "radius", ")", ",", "(", "origin", "[", "0", "]", "+", "radius", ",", "origin", "[", "1", "]", "-", "radius", ")", ")", ")" ]
Vertices for a square
[ "Vertices", "for", "a", "square" ]
254bb73535b20053d175bc4725bade662177d12b
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/view/_dendrogram.py#L71-L77