Source code for allensdk.internal.morphology.compartment
# Copyright 2016 Allen Institute for Brain Science
# This file is part of Allen SDK.
#
# Allen SDK is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# Allen SDK is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Allen SDK. If not, see <http://www.gnu.org/licenses/>.
import allensdk.internal.morphology.node as node
[docs]class Compartment(object):
def __init__(self, node1, node2):
if not isinstance(node1, node.Node) or not isinstance(node2, node.Node):
raise TypeError("Must supply Node objects to Compartment constructor")
self.length = node.euclidean_distance(node1, node2)
self.center = node.midpoint(node1, node2)
self.node1 = node1
self.node2 = node2
def __str__(self):
s = "%s %f" % (str(self.center), self.length)
s += "\n\t" + self.node1.short_string() + "\n\t" + self.node2.short_string()
return s