Beispiel #1
0
    def __init__(self,
                 cell,
                 morphlocation=None,
                 section=None,
                 sectionpos=None):
        self._cell = cell

        if morphlocation:
            assert not section and not sectionpos
            self.morphlocation = morphlocation
        else:
            assert not morphlocation
            self.morphlocation = MorphLocation(section=section,
                                               sectionpos=sectionpos)

        assert not self.morphlocation.section.is_dummy_section()
Beispiel #2
0
    def get_locations_at_distance_away_from_dummy(cls, morphology,
            distance, section_predicate=None):

        dist_to_section_distal = SectionVistorFactory.dict_section_distal_dist_from_soma(morph=morphology)()


        # Section predicates: allows us to generate only on a path, region, etc
        section_predicate = section_predicate if section_predicate else lambda s:True

        locations = []

        for section in morphology:
            if not section_predicate(section):
                continue

            if section.is_a_root_section():

                if distance < dist_to_section_distal[section]:
                    #assert False, 'Not implemented'
                    locations.append(MorphLocation(section=section, sectionpos=distance/dist_to_section_distal[section]) )

                else:

                    pass
            else:
                proximal_dist = dist_to_section_distal[section.parent]
                distal_dist = dist_to_section_distal[section]

                # Does a distance fall on this section:
                if proximal_dist < distance < distal_dist:
                    prop = (distance - proximal_dist) / (distal_dist - proximal_dist)
                    assert 0.0 <= prop <= 1.0
                    locations.append(MorphLocation(section=section, sectionpos=prop))
                else:
                    pass


        dummy = MorphLocation(morphology.get_dummy_section().children[0], 0.0)
        # Some sanity checking:
        for loc in locations:
            p = MorphPath(loc, dummy)
            assert np.fabs(p.get_length() - distance) < 0.01

        return locations
Beispiel #3
0
    def __init__(self, cell, morphlocation=None, section=None, sectionpos=None):
        self._cell = cell

        if morphlocation:
            assert not section and not sectionpos
            self.morphlocation = morphlocation
        else:
            assert not morphlocation
            self.morphlocation = MorphLocation(section=section, sectionpos=sectionpos)

        assert not self.morphlocation.section.is_dummy_section()
Beispiel #4
0
class CellLocation(object):
    def __init__(self,
                 cell,
                 morphlocation=None,
                 section=None,
                 sectionpos=None):
        self._cell = cell

        if morphlocation:
            assert not section and not sectionpos
            self.morphlocation = morphlocation
        else:
            assert not morphlocation
            self.morphlocation = MorphLocation(section=section,
                                               sectionpos=sectionpos)

        assert not self.morphlocation.section.is_dummy_section()

    def get_cell(self):
        return self._cell

    cell = property(get_cell, None, None)

    # We want to be able to treat CellLocations as locations,
    # so that we can measure between them for example:

    @property
    def section(self):
        return self.morphlocation.section

    @property
    def sectionpos(self):
        return self.morphlocation.sectionpos

    def get_3d_position(self):
        return self.morphlocation.get_3d_position()

    def get_location_description_str(self):
        desc = self.cell.name
        t = ''
        if self.morphlocation.section.idtag:
            t = self.morphlocation.section.idtag
        return desc + t
class CellLocation(object):

    def __init__(self, cell, morphlocation=None, section=None, sectionpos=None):
        self._cell = cell

        if morphlocation:
            assert not section and not sectionpos
            self.morphlocation = morphlocation
        else:
            assert not morphlocation
            self.morphlocation = MorphLocation(section=section,
                                               sectionpos=sectionpos)

        assert not self.morphlocation.section.is_dummy_section()

    def get_cell(self):
        return self._cell

    cell = property(get_cell, None, None)

    # We want to be able to treat CellLocations as locations,
    # so that we can measure between them for example:

    @property
    def section(self):
        return self.morphlocation.section

    @property
    def sectionpos(self):
        return self.morphlocation.sectionpos

    def get_3d_position(self):
        return self.morphlocation.get_3d_position()

    def get_location_description_str(self):
        desc = self.cell.name
        t = ''
        if self.morphlocation.section.idtag:
            t = '@' + self.morphlocation.section.idtag
        return desc + t