Skip to content

Commit 57537a4

Browse files
authored
Merge pull request #101 from CAVEconnectome/spine-annotation
Add Spine class with volume attribute
2 parents 0400e42 + 1ab904e commit 57537a4

File tree

3 files changed

+59
-9
lines changed

3 files changed

+59
-9
lines changed

emannotationschemas/__init__.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,22 @@
4848
V1DDFunctionalUnitCoregistration,
4949
)
5050
from emannotationschemas.schemas.functional_props import (
51-
FunctionalPropertiesBCM,
5251
DigitalTwinPropertiesBCM,
52+
FunctionalPropertiesBCM,
5353
)
5454
from emannotationschemas.schemas.glia_contact import GliaContact
5555
from emannotationschemas.schemas.groups import SimpleGroup, SimpleGroupIndexed
56+
from emannotationschemas.schemas.matching import (
57+
CellMatch,
58+
CellMatchReference,
59+
CellSimilarity,
60+
)
5661
from emannotationschemas.schemas.neuropil import FlyNeuropil
5762
from emannotationschemas.schemas.nucleus_detection import NucleusDetection
58-
from emannotationschemas.schemas.postsynaptic_compartment import PostsynapticCompartment
63+
from emannotationschemas.schemas.postsynaptic_compartment import (
64+
PostsynapticCompartment,
65+
SpineWithInfo,
66+
)
5967
from emannotationschemas.schemas.presynaptic_bouton_type import PresynapticBoutonType
6068
from emannotationschemas.schemas.proofreading import (
6169
CompartmentProofreadStatus,
@@ -66,11 +74,6 @@
6674
from emannotationschemas.schemas.reference_text_float import (
6775
ReferenceTagFloat,
6876
)
69-
from emannotationschemas.schemas.matching import (
70-
CellMatch,
71-
CellSimilarity,
72-
CellMatchReference,
73-
)
7477
from emannotationschemas.schemas.synapse import (
7578
BuhmannEcksteinSynapseSchema,
7679
BuhmannSynapseSchema,
@@ -92,6 +95,7 @@
9295
"bouton_shape": BoutonShape,
9396
"presynaptic_bouton_type": PresynapticBoutonType,
9497
"postsynaptic_compartment": PostsynapticCompartment,
98+
"spine_with_info": SpineWithInfo,
9599
"microns_func_coreg": FunctionalCoregistration,
96100
"microns_func_unit_coreg": FunctionalUnitCoregistration,
97101
"v1dd_func_unit_coreg": V1DDFunctionalUnitCoregistration,

emannotationschemas/schemas/postsynaptic_compartment.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import marshmallow as mm
2-
from emannotationschemas.schemas.base import ReferenceAnnotation
32
from marshmallow.validate import OneOf
43

4+
from emannotationschemas.schemas.base import BoundSpatialPoint, ReferenceAnnotation
5+
56
allowed_compartments = [
67
"soma",
78
"dendrite",
@@ -12,7 +13,6 @@
1213

1314

1415
class PostsynapticCompartment(ReferenceAnnotation):
15-
1616
compartment = mm.fields.Str(
1717
required=True,
1818
validate=OneOf(allowed_compartments),
@@ -30,3 +30,14 @@ class PostsynapticCompartment(ReferenceAnnotation):
3030
validate=OneOf(allowed_dendrite_classes),
3131
description="Type of dendritic branch, e.g. basal or apical",
3232
)
33+
34+
35+
class SpineWithInfo(BoundSpatialPoint):
36+
volume = mm.fields.Float(
37+
required=False, description="Estimated volume of the spine"
38+
)
39+
40+
n_inputs = mm.fields.Int(
41+
required=False,
42+
description="Number of synaptic inputs (unique root IDs) onto the spine",
43+
)

tests/test_spine.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from emannotationschemas.schemas.postsynaptic_compartment import SpineWithInfo
2+
3+
good_spine_with_info = {
4+
"position": [100, 200, 300],
5+
"supervoxel_id": 50,
6+
"root_id": 10,
7+
"volume": 1.5,
8+
"n_inputs": 3,
9+
}
10+
11+
12+
def test_spine_with_info_schema():
13+
schema = SpineWithInfo()
14+
result = schema.load(good_spine_with_info)
15+
assert result["position"] == [100, 200, 300]
16+
assert result["supervoxel_id"] == 50
17+
assert result["root_id"] == 10
18+
assert result["volume"] == 1.5
19+
assert result["n_inputs"] == 3
20+
21+
22+
def test_spine_with_info_optional():
23+
schema = SpineWithInfo()
24+
result = schema.load(
25+
{
26+
"position": [100, 200, 300],
27+
"supervoxel_id": 50,
28+
"root_id": 10,
29+
}
30+
)
31+
assert result["position"] == [100, 200, 300]
32+
assert result["supervoxel_id"] == 50
33+
assert result["root_id"] == 10
34+
assert "volume" not in result
35+
assert "n_inputs" not in result

0 commit comments

Comments
 (0)