Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions emannotationschemas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,22 @@
V1DDFunctionalUnitCoregistration,
)
from emannotationschemas.schemas.functional_props import (
FunctionalPropertiesBCM,
DigitalTwinPropertiesBCM,
FunctionalPropertiesBCM,
)
from emannotationschemas.schemas.glia_contact import GliaContact
from emannotationschemas.schemas.groups import SimpleGroup, SimpleGroupIndexed
from emannotationschemas.schemas.matching import (
CellMatch,
CellMatchReference,
CellSimilarity,
)
from emannotationschemas.schemas.neuropil import FlyNeuropil
from emannotationschemas.schemas.nucleus_detection import NucleusDetection
from emannotationschemas.schemas.postsynaptic_compartment import PostsynapticCompartment
from emannotationschemas.schemas.postsynaptic_compartment import (
PostsynapticCompartment,
SpineWithInfo,
)
from emannotationschemas.schemas.presynaptic_bouton_type import PresynapticBoutonType
from emannotationschemas.schemas.proofreading import (
CompartmentProofreadStatus,
Expand All @@ -66,11 +74,6 @@
from emannotationschemas.schemas.reference_text_float import (
ReferenceTagFloat,
)
from emannotationschemas.schemas.matching import (
CellMatch,
CellSimilarity,
CellMatchReference,
)
from emannotationschemas.schemas.synapse import (
BuhmannEcksteinSynapseSchema,
BuhmannSynapseSchema,
Expand All @@ -92,6 +95,7 @@
"bouton_shape": BoutonShape,
"presynaptic_bouton_type": PresynapticBoutonType,
"postsynaptic_compartment": PostsynapticCompartment,
"spine_with_info": SpineWithInfo,
"microns_func_coreg": FunctionalCoregistration,
"microns_func_unit_coreg": FunctionalUnitCoregistration,
"v1dd_func_unit_coreg": V1DDFunctionalUnitCoregistration,
Expand Down
15 changes: 13 additions & 2 deletions emannotationschemas/schemas/postsynaptic_compartment.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import marshmallow as mm
from emannotationschemas.schemas.base import ReferenceAnnotation
from marshmallow.validate import OneOf

from emannotationschemas.schemas.base import BoundSpatialPoint, ReferenceAnnotation

allowed_compartments = [
"soma",
"dendrite",
Expand All @@ -12,7 +13,6 @@


class PostsynapticCompartment(ReferenceAnnotation):

compartment = mm.fields.Str(
required=True,
validate=OneOf(allowed_compartments),
Expand All @@ -30,3 +30,14 @@ class PostsynapticCompartment(ReferenceAnnotation):
validate=OneOf(allowed_dendrite_classes),
description="Type of dendritic branch, e.g. basal or apical",
)


class SpineWithInfo(BoundSpatialPoint):
volume = mm.fields.Float(
required=False, description="Estimated volume of the spine"
)

n_inputs = mm.fields.Int(
required=False,
description="Number of synaptic inputs (unique root IDs) onto the spine",
)
35 changes: 35 additions & 0 deletions tests/test_spine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from emannotationschemas.schemas.postsynaptic_compartment import SpineWithInfo

good_spine_with_info = {
"position": [100, 200, 300],
"supervoxel_id": 50,
"root_id": 10,
"volume": 1.5,
"n_inputs": 3,
}


def test_spine_with_info_schema():
schema = SpineWithInfo()
result = schema.load(good_spine_with_info)
assert result["position"] == [100, 200, 300]
assert result["supervoxel_id"] == 50
assert result["root_id"] == 10
assert result["volume"] == 1.5
assert result["n_inputs"] == 3


def test_spine_with_info_optional():
schema = SpineWithInfo()
result = schema.load(
{
"position": [100, 200, 300],
"supervoxel_id": 50,
"root_id": 10,
}
)
assert result["position"] == [100, 200, 300]
assert result["supervoxel_id"] == 50
assert result["root_id"] == 10
assert "volume" not in result
assert "n_inputs" not in result