Exemple #1
0
def main():
    testSrcsPath = LocMgr().get_test_srcs_path()
    srcSWCFile = Join(testSrcsPath, "swc_srcs/28o_spindle20aFI.CNG.swc")

    srcSWCFile = "/home/michael/Desktop/ply/forPly/aIN 471 nrn + ns 100325.transl.invX.scaled.straightened.swc"

    morphs = NewSWCLoader.load_swc_set(src=open(srcSWCFile))

    m = morphs[0]
    m = m.to_tree()

    mesh = MeshFromGTS.build(m)
Exemple #2
0
    def include_file(self, filename, options):
        src_obj = self.global_scope.getFileObjRead(filename)
        morphs = NewSWCLoader.load_swc_set(src=src_obj)

        # Hack: only first:
        # morphs = [morphs[0]]

        for m in morphs:
            m = m.to_tree()

            # Create the color LUT:
            bi_dict = m.region_number_to_name_bidict

            rgn_colors = {}
            for rgn in m.get_regions():
                rgn_name = rgn.name
                rgn_int = bi_dict.region_name_to_int(rgn_name)
                rgn_color = self.get_region_color(rgn_int)
                print '%s -> %s' % (rgn_name, rgn_int), rgn_color
                rgn_colors[rgn_name] = rgn_color

            # Check for ignored Region:
            if None in rgn_colors.values():
                for v in rgn_colors.values():
                    if v is not None:
                        print 'Partly ignoring Structure:',
                        for (k, v) in rgn_colors.iteritems():
                            print k, v
                        assert False, 'Partly ignored structure!'
                continue

            # Apply the options:
            if 'trim' in options:
                m = AxonTrimmer.trim_axon_from_morphology(
                    m, max_dist_to_parent=options['trim'])
            if 'offset' in options:
                m = MorphologyTranslator.translate(morphology=m,
                                                   offset=options['offset'])
            if self.global_scope.has_option_set(
                    MeshGenerationOptions.minimum_diameter):
                m = MorphologyMinimumDiameter.ensure(
                    m,
                    min_diameter=self.global_scope.get_option(
                        MeshGenerationOptions.minimum_diameter))

            mesh = MeshFromGTS.build(m,
                                     plot=False,
                                     region_color_map=rgn_colors)
            self.meshes.append(mesh)
Exemple #3
0
    def include_file(self, filename, options):
        src_obj = self.global_scope.getFileObjRead(filename)
        morphs = NewSWCLoader.load_swc_set(src=src_obj)

        # Hack: only first:
        # morphs = [morphs[0]]

        for m in morphs:
            m = m.to_tree()

            # Create the color LUT:
            bi_dict = m.region_number_to_name_bidict

            rgn_colors = {}
            for rgn in m.get_regions():
                rgn_name = rgn.name
                rgn_int = bi_dict.region_name_to_int(rgn_name)
                rgn_color = self.get_region_color(rgn_int)
                print '%s -> %s' % (rgn_name, rgn_int), rgn_color
                rgn_colors[rgn_name] = rgn_color

            # Check for ignored Region:
            if None in rgn_colors.values():
                for v in rgn_colors.values():
                    if v is not None:
                        print 'Partly ignoring Structure:',
                        for (k, v) in rgn_colors.iteritems():
                            print k, v
                        assert False, 'Partly ignored structure!'
                continue

            # Apply the options:
            if 'trim' in options:
                m = AxonTrimmer.trim_axon_from_morphology(m,
                        max_dist_to_parent=options['trim'])
            if 'offset' in options:
                m = MorphologyTranslator.translate(morphology=m,
                        offset=options['offset'])
            if self.global_scope.has_option_set(MeshGenerationOptions.minimum_diameter):
                m = MorphologyMinimumDiameter.ensure(m,
                        min_diameter=self.global_scope.get_option(MeshGenerationOptions.minimum_diameter))

            mesh = MeshFromGTS.build(m, plot=False,
                    region_color_map=rgn_colors)
            self.meshes.append(mesh)
Exemple #4
0
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ----------------------------------------------------------------------

from morphforge.core import LocMgr, Join
from morphforge.morphology.ui import MatPlotLibViewer
from morphforge.morphology.core import MorphologyTree
from morphforgecontrib.indev.highqualitymesh.create_mesh import MeshFromGTS
from morphforge.morphology.importer.import_array_swc import NewSWCLoader

testSrcsPath = LocMgr().get_test_srcs_path()
srcSWCFile = Join(testSrcsPath, "swc_srcs/28o_spindle20aFI.CNG.swc")

srcSWCFile = "/home/michael/Desktop/ply/forPly/aIN 471 nrn + ns 100325.transl.invX.scaled.straightened.swc"

morphs = NewSWCLoader.load_swc_set(src=open(srcSWCFile))

m = morphs[0]
m = m.to_tree()

mesh = MeshFromGTS.build(m)

# MatPlotLibViewer(m, use_pca=False)
Exemple #5
0
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ----------------------------------------------------------------------

from morphforge.core import LocMgr, Join
from morphforge.morphology.ui import MatPlotLibViewer
from morphforge.morphology.core import MorphologyTree
from morphforgecontrib.indev.highqualitymesh.create_mesh import MeshFromGTS
from morphforge.morphology.importer.import_array_swc import NewSWCLoader

testSrcsPath = LocMgr().get_test_srcs_path()
srcSWCFile = Join(testSrcsPath, 'swc_srcs/28o_spindle20aFI.CNG.swc')

srcSWCFile = '/home/michael/Desktop/ply/forPly/aIN 471 nrn + ns 100325.transl.invX.scaled.straightened.swc'

morphs = NewSWCLoader.load_swc_set(src=open(srcSWCFile))

m = morphs[0]
m = m.to_tree()

mesh = MeshFromGTS.build(m)

# MatPlotLibViewer(m, use_pca=False)