Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from __future__ import annotations
from type import array_t, site_path_h
import numpy as np_
class glial_cmp_t:
#
__slots__ = ("uid", "sites", "connection_path", "extensions", "img_shape")
def __init__(self):
#
self.uid = None
self.sites = None
self.connection_path = None
self.extensions = None
self.img_shape = None
def InitializeFromMaps(self, lmp: array_t, uid: int) -> None:
#
self.uid = uid
# sites: might contain voxels that could be removed w/o breaking connectivity
self.sites = (lmp == uid).nonzero()
self.connection_path = {}
self.extensions = []
self.img_shape = lmp.shape
def ExtendWith(
self, extension: glial_cmp_t, through: site_path_h, costs: array_t
) -> None:
#
connection_path = tuple(zip(*through[1:-1]))
if connection_path.__len__() == 0:
connection_path = None
extension_path = extension.sites
self.connection_path[extension.uid] = connection_path
self.extensions.append(extension)
extension.BackReferenceSoma(self)
# TODO: Ideally, these paths should be dilated
# but in ext-ext connections, there must not be dilation around the current ext
# (current ext plays the role of a soma in soma-ext step)
if connection_path is not None:
costs[connection_path] = np_.inf
costs[extension_path] = np_.inf
def BackReferenceSoma(self, glial_cmp: glial_cmp_t):
#
raise NotImplementedError