-
Notifications
You must be signed in to change notification settings - Fork 11
/
synapse.py
94 lines (77 loc) · 3.07 KB
/
synapse.py
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import marshmallow as mm
from emannotationschemas.schemas.base import (
AnnotationSchema,
BoundSpatialPoint,
SpatialPoint,
ReferenceAnnotation,
)
class BaseSynapseSchema(AnnotationSchema):
pre_pt = mm.fields.Nested(
BoundSpatialPoint,
required=True,
description="a nearby point located in the presynaptic compartment of the synapse",
order=0,
)
post_pt = mm.fields.Nested(
BoundSpatialPoint,
required=True,
description="a nearby point located in the postsynaptic compartment of the synapse",
order=2,
)
@mm.post_load
def check_root_id(self, data, **kwargs):
pre_id = data["pre_pt"].get("root_id", None)
post_id = data["post_pt"].get("root_id", None)
# when the root_id is present
# we should set the valid flag depending up on this rule
# when the root_id is not present
# (i.e. when posting new annotations with no root_id's in mind)
# then the valid flag should be not present
if pre_id is not None:
data["valid"] = False if pre_id == post_id else True
else:
data.pop("valid", None)
return data
class NoCleftSynapse(BaseSynapseSchema):
score = mm.fields.Float(
description="synapse score (see table metadata for description of score)"
)
class SynapseSchema(BaseSynapseSchema):
ctr_pt = mm.fields.Nested(
SpatialPoint, required=True, description="central point", order=1
)
size = mm.fields.Float(description="size of synapse")
class NoCenterSynapse(BaseSynapseSchema):
size = mm.fields.Float(description="size of synapse")
class BuhmannSynapseSchema(BaseSynapseSchema):
connection_score = mm.fields.Float(
description="score assigned by Buhmann et al. 2019"
)
cleft_score = mm.fields.Float(
description="score derived by Buhmann et al. 2019 "
"by combining their synapses with the synapse "
"segmentation from Heinrich et al. 2018"
)
class BuhmannEcksteinSynapseSchema(BuhmannSynapseSchema):
gaba = mm.fields.Float(description="Gaba probability by Eckstein et al. 2020")
ach = mm.fields.Float(
description="Acetylcholine probability by Eckstein et al. 2020"
)
glut = mm.fields.Float(description="Glutamate probability by Eckstein et al. 2020")
oct = mm.fields.Float(description="Octopamine probability by Eckstein et al. 2020")
ser = mm.fields.Float(description="Serotonin probability by Eckstein et al. 2020")
da = mm.fields.Float(description="Dopamine probability by Eckstein et al. 2020")
valid_nt = mm.fields.Bool(
description="False = no neurotransmitter prediction available."
)
class PlasticSynapse(SynapseSchema):
plasticity = mm.fields.Int(
required=True,
validate=mm.validate.OneOf([0, 1, 2, 3, 4]),
description="plasticity state 0:not synapse 1:normal 2:mild 3:strong 4:not rated",
)
class ValidSynapse(ReferenceAnnotation):
is_valid = mm.fields.Bool(
required=True,
description="Valid annotation for synapses",
)