projectTree.remove(False, sibl, None)
    colorPt = neurite.getParent().createChild("neurite")
    colorPt.setTitle("color_" + neurite.getTitle())
    nn = projectTree.findNode(neurite, projectTree)
    cn = DefaultMutableTreeNode(colorPt)
    projectTree.getModel().insertNodeInto(cn, nn.getParent(), nn.getParent().getChildCount())

    areatreePts = neurite.findChildrenOfTypeR("areatree")
    for areatreePt in areatreePts:

        # display connectors first
        oiPt = getOutAndInPt(areatreePt, ct)
        oiPt = [x for y in oiPt for x in y]
        if oiPt is None: continue
        for c in oiPt:
            Display3D.show(c, False, 5)

        areatree = areatreePt.getObject()
        las = areatree.getLayerSet()

        # add a clone of areatree to 'color_***' neurite
        colortree = areatree.clone(project, False)
        colortreePt = ProjectThing(areatreePt.getTemplate(), project, colortree)
        las.add(colortree)
        colorPt.addChild(colortreePt)
        catn = DefaultMutableTreeNode(colortreePt)
        projectTree.getModel().insertNodeInto(catn, cn, 0)
        print colorPt, colortreePt

        # prepare cut and bead nodes 
        root = colortree.getRoot()
Exemple #2
0
nOuts = 0
nIns = 0
neurites = projectRoot.findChildrenOfTypeR("neurite")
for neurite in neurites:
    if re.match(r"^(apla_|in_|out_)", neurite.getTitle()):
        areatrees = neurite.findChildrenOfTypeR("areatree")
        for areatree in areatrees:
            nNeurites += 1
            oiPt = getOutAndInPt(areatree, ct)
            nOuts += len(oiPt[0])
            nIns += len(oiPt[1])
            oiPt = [x for y in oiPt for x in y]
            # print oiPt
            if oiPt is None:
                continue
            for c in oiPt:
                Display3D.show(c, False, 4)
            Display3D.show(areatree, False, 4)
            # for iPt in oiPt[0]:
            #     Display3D.show(iPt, 1, 8)
    # if 'in_' in neurite.getTitle():
    #     connectors = neurite.findChildrenOfTypeR("connector")
    #     for connector in connectors:
    #         Display3D.show(connector, 1, 8)

print 'done.'
print nNeurites, 'neurites,', nOuts, 'outputs,', nIns, 'inputs'
# ps = Display.getFront().getLayerSet().getLayer(800).getAll(Patch)
# for p in ps:
# print type(p), p
#    Display3D.show(p)
def exportWavefront(zds, filepath):
    """
  Takes a sequence of ZDisplayable instances and saves all as meshes to disk in wavefront format.
  A materials .mtl file is saved along with it.
  See: https://github.com/fiji/3D_Viewer/blob/master/src/main/java/customnode/WavefrontExporter.java
  """
    meshes = {
        zd.getTitle(): d3d.createMesh(zd.project.findProjectThing(zd), zd,
                                      resampling_factor).call()
        for zd in zds
    }
    WavefrontExporter.save(meshes, filepath)


project = Project.getProjects()[0]
d3d = Display3D.getDisplay(project.getRootLayerSet())


def exportSelectedAsWavefront(project, filepath):
    """ Select a node in the Project Tree, then run this function
      to export the meshes of all ZDisplayable under the node
      in Wavefront format. """
    exportWavefront(list(loadFromSelectedTreeNode(project)), filepath)


# Strategy 1: provide a list of IDs
# The IDs of the AreaList (zDisplayables: arealists, balls etc.) instances
"""
to_add = [67163, 66596]

for zd_id in to_add:
nOuts = 0
nIns = 0
neurites = projectRoot.findChildrenOfTypeR("neurite")
for neurite in neurites:
    if re.match(r"^(apla_|in_|out_)", neurite.getTitle()):
        areatrees = neurite.findChildrenOfTypeR("areatree")
        for areatree in areatrees:
            nNeurites += 1
            oiPt = getOutAndInPt(areatree, ct)
            nOuts += len(oiPt[0])
            nIns += len(oiPt[1])
            oiPt = [x for y in oiPt for x in y]
            # print oiPt
            if oiPt is None:
                continue
            for c in oiPt:
                Display3D.show(c, False, 4)
            Display3D.show(areatree, False, 4)
            # for iPt in oiPt[0]:
            #     Display3D.show(iPt, 1, 8)
    # if 'in_' in neurite.getTitle():
    #     connectors = neurite.findChildrenOfTypeR("connector")
    #     for connector in connectors:
    #         Display3D.show(connector, 1, 8)

print 'done.'
print nNeurites, 'neurites,', nOuts, 'outputs,', nIns, 'inputs'
# ps = Display.getFront().getLayerSet().getLayer(800).getAll(Patch)
# for p in ps:
    # print type(p), p
#    Display3D.show(p)