From 570a2065e99a6729adb9c0474c258ee8f71581ff Mon Sep 17 00:00:00 2001 From: Chris Barnes Date: Fri, 28 Jul 2023 12:49:31 +0100 Subject: [PATCH] Add super-duper explicit methods to NodeConnectorRelation --- navis/core/base.py | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/navis/core/base.py b/navis/core/base.py index 83a0290c..8107d3c1 100644 --- a/navis/core/base.py +++ b/navis/core/base.py @@ -51,7 +51,7 @@ class NodeConnectorRelation(IntEnum): i.e. "the (tree)node is the connector node" - Based on the `CATMAID link types`_. + Inspired by the `CATMAID link types`_. A node PRESYNAPTIC_TO a connector is an output site. A node POSTSYNAPTIC_TO a connector is an input site. @@ -59,12 +59,28 @@ class NodeConnectorRelation(IntEnum): """ PRESYNAPTIC_TO = 0 POSTSYNAPTIC_TO = 1 - ABUTTING = 2 - GAPJUNCTION_WITH = 3 - TIGHTJUNCTION_WITH = 4 - DESMOSOME_WITH = 5 - ATTACHMENT_TO = 6 - CLOSE_TO = 7 + # ABUTTING = 2 + # GAPJUNCTION_WITH = 3 + # TIGHTJUNCTION_WITH = 4 + # DESMOSOME_WITH = 5 + # ATTACHMENT_TO = 6 + # CLOSE_TO = 7 + + def is_output_node(self) -> bool: + """Whether the node is sending output via the connector""" + return self == NodeConnectorRelation.PRESYNAPTIC_TO + + def is_input_node(self) -> bool: + """Whether the node is receiving input via the connector""" + return self == NodeConnectorRelation.POSTSYNAPTIC_TO + + def is_output_connector(self) -> bool: + """Whether the connector is sending output to the node""" + return self.is_input_node() + + def is_input_connector(self) -> bool: + """Whether the connector is receiving input from the node""" + return self.is_output_node() def Neuron(x: Union[nx.DiGraph, str, pd.DataFrame, 'TreeNeuron', 'MeshNeuron'],