JaneliaSciComp / Neuroptikon

Neuroptikon
Other
9 stars 3 forks source link

[Neuroptikon.org] Parent/Child Related Crash #50

Open csweaver opened 9 years ago

csweaver commented 9 years ago

Under unknown certain circumstances, declaring a certain region as a parent region for a subregion results in the attached extended TypeError, preventing the script from completing and correctly rendering.

Neuroptikon.org issue http://www.neuroptikon.org/jira/browse/NEUROPTIKON-187

Reported by cgoertel

Includes the following code:

import math
import osg
from math import pi
flyBrainOnt = library.ontology('Drosophila adult')

regions = {}

#creating main central complex regions and subregions

#creating PB & subregions

protocerebralBridge = network.createRegion(ontologyTerm = flyBrainOnt.findTerm(name = 'Protocerebral bridge'))
display.setVisiblePosition(protocerebralBridge, (0.0,1.5,0.0), True)
display.setVisibleSize(protocerebralBridge, (3.0, 0.2, 0.2))
display.setLabel(protocerebralBridge, protocerebralBridge.name)
display.setLabelPosition(protocerebralBridge, (0.0,0.75,0.0))

leftProtocerebrealBridge = network.createRegion(name = 'Left Protocerebral bridge', parentRegion = protocerebralBridge)
display.setLabel(leftProtocerebrealBridge, '')
for i in range (9,0,-1):
    regions['PB-L' + str(i)] = network.createRegion(name = 'PB-L' + str(i), ontologyTerm = flyBrainOnt.findTerm(abbreviation = 'pcb' + str(i)), abbreviation = str(i), parentRegion = leftProtocerebrealBridge)

rightProtocerebrealBridge = network.createRegion(name = 'Right Protocerebral bridge', parentRegion = protocerebralBridge)
display.setLabel(rightProtocerebrealBridge, '')
for i in range (1,10):
    regions['PB-R' + str(i)] = network.createRegion(name = 'PB-R' + str(i), ontologyTerm = flyBrainOnt.findTerm(abbreviation = 'pcb' + str(i)), abbreviation = str(i), parentRegion = rightProtocerebrealBridge)

display.setArrangedSpacing(protocerebralBridge, 0.005, recurse = True)

#creating FB and subregions

fanShapedBody = network.createRegion(ontologyTerm = flyBrainOnt.findTerm(name = 'Fan-shaped body'))
display.setVisiblePosition(fanShapedBody, (0.0,0.5,0.0),True)
display.setVisibleSize(fanShapedBody, (0.5,0.5,0.3))
display.setVisibleShape(fanShapedBody, None)
display.setLabel(fanShapedBody, fanShapedBody.name)
display.setLabelPosition(fanShapedBody, (0.0,-0.15,0.0))
display.setArrangedAxis(fanShapedBody, None)

#creating layers

for i in range (9,0,-1):
    regions['FBlayer' + str(i)] = network.createRegion(name = 'FB layer ' + str(i), abbreviation = str(i), parentRegion = fanShapedBody)
    layerheight = (i-1)*.15
    display.setVisiblePosition(regions['FBlayer' + str(i)], (0,layerheight,0), True)
    if i == 9:
        layerwidth = 1.25
    elif i == 8:
        layerwidth = 3
    else:
        layerwidth = 0.75*i
    display.setVisibleSize(regions['FBlayer' + str(i)], (layerwidth,0.18,0.3))
    display.setVisibleShape(regions['FBlayer'+ str(i)], shapes['Box'])
    display.setArrangedAxis(regions['FBlayer' + str(i)], 'X')

#creating columns

for i in range(5,0,-1):
    if i == 1:
        j = 10
    else:
        j = 9
    for k in range(1,j):
        regions['FBlayer' + str(i) + 'col' + str(k)] = network.createRegion(name ='FBl' + str(i) + str(k), parentRegion = regions['FBlayer' + str(i)])
        display.setLabel(regions['FBlayer' + str(i) + 'col' + str(k)], '')
    display.setArrangedSpacing(regions['FBlayer' + str(i)], 0.01)

#creating EB and subregions

ellipsoidBody = network.createRegion(ontologyTerm = flyBrainOnt.findTerm(name = 'Ellipsoid Body'))
display.setVisiblePosition(ellipsoidBody, (0.0,-0.5,0.0), True)
display.setVisibleShape(ellipsoidBody, shapes['Ring'](holeSize = 0.0/5.0))
display.setVisibleSize(ellipsoidBody, (1.2, 1.2,0.6))
display.setVisibleOpacity(ellipsoidBody, 0.333)
display.setLabel(ellipsoidBody, ellipsoidBody.name)
display.setLabelPosition(ellipsoidBody, (0.0,-0.6,0.0))
display.setArrangedAxis(ellipsoidBody, None)

#creating tiles
letters = ['C','D','E','F','G','H','A','B']
for i in range(0,8):
    regions['EBtile' + letters[i]] = network.createRegion(name = 'EBtile' + letters[i], abbreviation = letters[i])#,parentRegion = ellipsoidBody)
    xpos = [1.5, 1.0605, 0, -1.0605,-1.5,-1.0605,0,1.0605]
    ypos = [0, 1.0605, 1.5, 1.0605, 0, -1.0605, -1.5, -1.0605]
    display.setVisiblePosition(regions['EBtile' + letters[i]], ((xpos[i]*.25),-0.5+(ypos[i]*.25),-0.15), True)
    display.setVisibleSize(regions['EBtile' + letters[i]], (0.25,0.25,0.25))
    display.setLabel(regions['EBtile' + letters[i]], letters[i])

#creating wedges and demiwedges
names = ['3L','6R','4L','5R','5L','4R','6L','3R','7L','2R','8L','1R','1L','8R','2L','7R']
for i in range(0,16):
    regions['EBwedge' + names[i]] = network.createRegion(name = 'EBwedge' + names[i], abbreviation = names[i])#parentRegion = ellipsoidBody)
    angle = math.radians(11.25 + (22.5*i))
    xpos = 1.5*math.cos(angle)
    ypos = 1.5*math.sin(angle)
    if names[i] in ['3L','7R','3R','7L']:
        xsize = 0.37
        ysize = 0.13
        display.setArrangedAxis(regions['EBwedge' + names[i]], 'Y')
    if names[i] in ['1R','1L','5L','5R']:
        xsize = 0.13
        ysize = 0.37
        display.setArrangedAxis(regions['EBwedge' + names[i]], 'X')
    if names[i] in ['4R','4L','8R','8L']:
        xsize = 0.15
        ysize = 0.26
        if names[i] == '4R':
            xpos -= 0.05
            ypos += 0.25
        elif names[i] == '4L':
            xpos += 0.05
            ypos += 0.25
        elif names[i] == '8R':
            xpos += 0.05
            ypos -= 0.26
        else:
            xpos -= 0.05
            ypos -= 0.25
        display.setArrangedAxis(regions['EBwedge' + names[i]], 'X')
    if names[i] in ['6L','6R','2L','2R']:
        xsize = 0.26
        ysize = 0.15
        xpos += 0.15
        if names[i] == '6R':
            xpos += 0.25
            ypos += 0.05
        elif names[i] == '6L':
            xpos -= 0.25
            ypos += 0.05
        elif names[i] == '2R':
            xpos -= 0.25
            ypos -= 0.05
        else:
            xpos += 0.25
            ypos -= 0.05
        display.setArrangedAxis(regions['EBwedge' + names[i]], 'Y')
    display.setVisiblePosition(regions['EBwedge' + names[i]], (xpos*.235, -0.5+0.235*ypos, 0.2), True)
    display.setVisibleSize(regions['EBwedge' + names[i]], (xsize,ysize,0.3))
    display.setLabel(regions['EBwedge' + names[i]], names[i])
    display.setLabelPosition(regions['EBwedge' + names[i]],(0.0,0., 0.0))
    for k in range(1,3):
        regions['EBwedge' + names[i] + 'demiwedge' + str(k)] = network.createRegion(name = 'EBdemiwedge' + str(k), abbreviation = str(k), parentRegion = regions['EBwedge' + names[i]])
        display.setLabel(regions['EBwedge' + names[i] + 'demiwedge' + str(k)], '')
    display.setArrangedSpacing(regions['EBwedge' + names[i]], 0.05)

#creating nubbin
EBnubbin = network.createRegion(name = 'EB Nubbin', abbreviation = 'Nub', parentRegion = ellipsoidBody)
display.setVisiblePosition(EBnubbin, (0.0,0.09,0.1), True)
display.setVisibleSize(EBnubbin, (0.25,0.075,0.25))
display.setVisibleShape(EBnubbin, shapes['Ball'])
display.setLabel(EBnubbin, '')

#creating lateraltriangles

llateraltriangle = network.createRegion(name = 'Left Lateral Triangle', abbreviation = 'LT')
display.setVisiblePosition(llateraltriangle, (-1.1, -0.5,0.0), True)
display.setVisibleSize(llateraltriangle, (0.2,0.8,0.2))
display.setVisibleShape(llateraltriangle, shapes['Cone'])
display.setVisibleRotation(llateraltriangle, (1,0,0,pi))
display.setLabel(llateraltriangle, 'LT')

rlateraltriangle = network.createRegion(name = 'Right Lateral Triangle', abbreviation = 'LT')
display.setVisiblePosition(rlateraltriangle, (1.1, -0.5,0.0), True)
display.setVisibleSize(rlateraltriangle, (0.2,0.8,0.2))
display.setVisibleShape(rlateraltriangle, shapes['Cone'])
display.setLabel(rlateraltriangle, 'LT')

#creating noduli and subregions

leftnoduli = network.createRegion(name = 'Left Noduli')
display.setVisiblePosition(leftnoduli, (-1.2,-1.5, 0.0), True)
display.setVisibleSize(leftnoduli, (0.5,1.0,0.3))
display.setArrangedAxis(leftnoduli, 'Y')
display.setLabel(leftnoduli, '')

leftnoduli1 = network.createRegion(name = 'Left Noduli 1', abbreviation = 'NO1', parentRegion = leftnoduli)
display.setLabel(leftnoduli1, 'NO1')
display.setLabelPosition(leftnoduli1, (-0.8,0.0,0.0))
display.setArrangedAxis(leftnoduli1, 'X')

LNO1L = network.createRegion(name = 'Left Noduli 1 Lateral', abbreviation = 'LNO1L', parentRegion = leftnoduli1)
display.setLabel(LNO1L, 'L')

LNO1M = network.createRegion(name = 'Left Noduli 1 Medial', abbreviation = 'LNO1M', parentRegion = leftnoduli1)
display.setLabel(LNO1M, 'M')

display.setArrangedSpacing(leftnoduli1, 0.05)

leftnoduli2 = network.createRegion(name = 'Left Noduli 2', abbreviation = 'NO2', parentRegion = leftnoduli)
display.setLabel(leftnoduli2, 'NO2')
display.setLabelPosition(leftnoduli2, (-0.8,0.0,0.0))
display.setArrangedAxis(leftnoduli2, 'Y')

LNO2D = network.createRegion(name = 'Left Noduli 2 Dorsal', abbreviation = 'LNO2D', parentRegion = leftnoduli2)
display.setLabel(LNO2D, 'D')

LNO2V = network.createRegion(name = 'Left Noduli 2 Ventral', abbreviation = 'LNO2V', parentRegion = leftnoduli2)
display.setLabel(LNO2V, 'V')

display.setArrangedSpacing(leftnoduli2, 0.05)

leftnoduli3 = network.createRegion(name = 'Left Noduli 3', abbreviation = 'NO3', parentRegion = leftnoduli)
display.setLabel(leftnoduli3, 'NO3')
display.setLabelPosition(leftnoduli3, (-0.8, 0.0, 0.0))
display.setArrangedAxis(leftnoduli3, 'Z')

LNO3A = network.createRegion(name = 'Left Noduli 3 Anterior', abbreviation = 'LNO3A', parentRegion = leftnoduli3)
display.setLabel(LNO3A, 'A')

LNO3M = network.createRegion(name = 'Left Noduli 3 Medial', abbreviation = 'LNO3A', parentRegion = leftnoduli3)
display.setLabel(LNO3M, 'M')

LNO3P = network.createRegion(name = 'Left Noduli 3 Posterior', abbreviation = 'LNO3P', parentRegion = leftnoduli3)
display.setLabel(LNO3P, 'P')

display.setArrangedSpacing(leftnoduli3, 0.05)

rightnoduli = network.createRegion(name = 'right Noduli')
display.setVisiblePosition(rightnoduli, (1.2,-1.5, 0.0), True)
display.setVisibleSize(rightnoduli, (0.5,1.0,0.3))
display.setArrangedAxis(rightnoduli, 'Y')
display.setLabel(rightnoduli, '')

rightnoduli1 = network.createRegion(name = 'right Noduli 1', abbreviation = 'NO1', parentRegion = rightnoduli)
display.setLabel(rightnoduli1, 'NO1')
display.setLabelPosition(rightnoduli1, (0.8,0.0,0.0))
display.setArrangedAxis(rightnoduli1, 'X')

RNO1L = network.createRegion(name = 'right Noduli 1 Lateral', abbreviation = 'RNO1L', parentRegion = rightnoduli1)
display.setLabel(RNO1L, 'L')

RNO1M = network.createRegion(name = 'right Noduli 1 Medial', abbreviation = 'RNO1M', parentRegion = rightnoduli1)
display.setLabel(RNO1M, 'M')

display.setArrangedSpacing(rightnoduli1, 0.05)

rightnoduli2 = network.createRegion(name = 'right Noduli 2', abbreviation = 'NO2', parentRegion = rightnoduli)
display.setLabel(rightnoduli2, 'NO2')
display.setLabelPosition(rightnoduli2, (0.8,0.0,0.0))
display.setArrangedAxis(rightnoduli2, 'Y')

RNO2D = network.createRegion(name = 'right Noduli 2 Dorsal', abbreviation = 'RNO2D', parentRegion = rightnoduli2)
display.setLabel(RNO2D, 'D')

RNO2V = network.createRegion(name = 'right Noduli 2 Ventral', abbreviation = 'RNO2V', parentRegion = rightnoduli2)
display.setLabel(RNO2V, 'V')

display.setArrangedSpacing(rightnoduli2, 0.05)

rightnoduli3 = network.createRegion(name = 'right Noduli 3', abbreviation = 'NO3', parentRegion = rightnoduli)
display.setLabel(rightnoduli3, 'NO3')
display.setLabelPosition(rightnoduli3, (0.8, 0.0, 0.0))
display.setArrangedAxis(rightnoduli3, 'Z')

RNO3A = network.createRegion(name = 'right Noduli 3 Anterior', abbreviation = 'RNO3A', parentRegion = rightnoduli3)
display.setLabel(RNO3A, 'A')

RNO3M = network.createRegion(name = 'right Noduli 3 Medial', abbreviation = 'RNO3A', parentRegion = rightnoduli3)
display.setLabel(RNO3M, 'M')

RNO3P = network.createRegion(name = 'right Noduli 3 Posterior', abbreviation = 'RNO3P', parentRegion = rightnoduli3)
display.setLabel(RNO3P, 'P')

display.setArrangedSpacing(rightnoduli3, 0.05)

#creating gall and subcompartments

rightgall = network.createRegion(name = 'rightgall', abbreviation = 'G')
display.setVisiblePosition(rightgall, (1.85,-0.5,0.0),True)
display.setVisibleSize(rightgall, (0.25,0.5,0.4))
display.setLabel(rightgall, 'Gall')
display.setLabelPosition(rightgall, (0.0,0.76,0.0))
display.setArrangedAxis(rightgall, 'Y')

rightgallTip = network.createRegion(name = 'rightgall Tip', abbreviation = 'T', parentRegion = rightgall)
rightgallDorsal = network.createRegion(name = 'Dorsal rightgall', abbreviation = 'D', parentRegion = rightgall)
rightgallVentral = network.createRegion(name = 'Ventral rightgall', abbreviation = 'V', parentRegion = rightgall)

display.setArrangedSpacing(rightgall, 0.05)

leftgall = network.createRegion(name = 'leftgall', abbreviation = 'G')
display.setVisiblePosition(leftgall, (-1.85,-0.5,0.0),True)
display.setVisibleSize(leftgall, (0.25,0.5,0.4))
display.setLabel(leftgall, 'Gall')
display.setLabelPosition(leftgall, (0.0,0.76,0.0))
display.setArrangedAxis(leftgall, 'Y')

leftgallTip = network.createRegion(name = 'leftgall Tip', abbreviation = 'T', parentRegion = leftgall)
leftgallDorsal = network.createRegion(name = 'Dorsal leftgall', abbreviation = 'D', parentRegion = leftgall)
leftgallVentral = network.createRegion(name = 'Ventral leftgall', abbreviation = 'V', parentRegion = leftgall)

display.setArrangedSpacing(leftgall, 0.05)

#creating gall-surround

leftgallsurround = network.createRegion(name = 'left gall surround', abbreviation = 'GS')
display.setVisiblePosition(leftgallsurround, (-1.65, -0.5,0.0), True)
display.setVisibleSize(leftgallsurround, (0.1,0.5,0.4))
display.setArrangedAxis(leftgallsurround, 'Y')
display.setLabel(leftgallsurround, '')

leftDgallsurround = network.createRegion(name = 'left dorsal gall surround', abbreviation = 'DGS', parentRegion = leftgallsurround)
leftVgallsurround = network.createRegion(name = 'left ventral gall surround', abbreviation = 'VGS', parentRegion = leftgallsurround)

display.setArrangedSpacing(leftgallsurround, 0.05)

rightgallsurround = network.createRegion(name = 'right gall surround', abbreviation = 'GS')
display.setVisiblePosition(rightgallsurround, (1.65, -0.5,0.0), True)
display.setVisibleSize(rightgallsurround, (0.1,0.5,0.4))
display.setArrangedAxis(rightgallsurround, 'Y')
display.setLabel(rightgallsurround, '')

rightDgallsurround = network.createRegion(name = 'right dorsal gall surround', abbreviation = 'DGS', parentRegion = rightgallsurround)
rightVgallsurround = network.createRegion(name = 'right ventral gall surround', abbreviation = 'VGS', parentRegion = rightgallsurround)

display.setArrangedSpacing(rightgallsurround, 0.05)

#creating minor regions/subregions (note that all are mirrored)

rightLAL = network.createRegion(name = 'rightLAL')
display.setVisiblePosition(rightLAL, (2.3,-0.5,0.0),True)
display.setVisibleSize(rightLAL, (0.75, 0.8, 0.65))
display.setVisibleShape(rightLAL, shapes['Capsule'])
display.setLabel(rightLAL, 'LAL')
display.setLabelPosition(rightLAL, (0.0,-0.55,0.0))

leftLAL = network.createRegion(name = 'leftLAL')
display.setVisiblePosition(leftLAL, (-2.3,-0.5,0.0),True)
display.setVisibleSize(leftLAL, (0.75, 0.8, 0.65))
display.setVisibleShape(leftLAL, shapes['Capsule'])
display.setLabel(leftLAL, 'LAL')
display.setLabelPosition(leftLAL, (0.0,-0.55,0.0))

rightbulb = network.createRegion(name = 'right Bulb')
display.setVisiblePosition(rightbulb, (2.3,-0.25, -0.125), True)
display.setVisibleSize(rightbulb, (0.4,0.6,0.3))
display.setVisibleShape(rightbulb, shapes['Ball'])
display.setLabel(rightbulb, 'BU')
display.setLabelPosition(rightbulb, (0.0,0.55,0.0))

leftbulb = network.createRegion(name = 'left Bulb')
display.setVisiblePosition(leftbulb, (-2.3,-0.25, -0.125), True)
display.setVisibleSize(leftbulb, (0.4,0.6,0.3))
display.setVisibleShape(leftbulb, shapes['Ball'])
display.setLabel(leftbulb, 'BU')
display.setLabelPosition(leftbulb, (0.0,0.55,0.0))

rightcrepine = network.createRegion(name = 'right crepine', abbreviation = 'CRE')
display.setVisiblePosition(rightcrepine, (1.8, 0.65, 0.2), True)
display.setVisibleSize(rightcrepine, (0.85,0.85,0.85))
display.setVisibleShape(rightcrepine, shapes['Ball'])
display.setLabel(rightcrepine, 'CRE')
display.setLabelPosition(rightcrepine, (0.0,0.6,0.0))

rightrubus = network.createRegion(name = 'right rubus')#, parentRegion = rightcrepine)
display.setVisiblePosition(rightrubus, (1.8, 0.65, 0.7), True)
display.setVisibleSize(rightrubus, (0.4,0.4,0.4))
display.setVisibleShape(rightrubus, shapes['Ball'])
display.setLabel(rightrubus, 'RB')

leftcrepine = network.createRegion(name = 'left crepine', abbreviation = 'CRE')
display.setVisiblePosition(leftcrepine, (-1.8, 0.65, 0.2), True)
display.setVisibleSize(leftcrepine, (0.85,0.85,0.85))
display.setVisibleShape(leftcrepine, shapes['Ball'])
display.setLabel(leftcrepine, 'CRE')
display.setLabelPosition(leftcrepine, (0.0,0.6,0.0))

leftrubus = network.createRegion(name = 'left rubus')#, parentRegion = leftcrepine)
display.setVisiblePosition(leftrubus, (-1.8, 0.65, 0.7), True)
display.setVisibleSize(leftrubus, (0.4,0.4,0.4))
display.setVisibleShape(leftrubus, shapes['Ball'])
display.setLabel(leftrubus, 'RB')

inferiorBridge = network.createRegion(name = 'Inferior Bridge', abbreviation = 'IB')
display.setVisiblePosition(inferiorBridge, (0.0,-1.65, -0.5), True)
display.setVisibleSize(inferiorBridge, (1.35, 0.7, 0.6))
display.setVisibleShape(inferiorBridge, shapes['Capsule'])
display.setLabel(inferiorBridge, inferiorBridge.name)

leftposteriorSlope = network.createRegion(name = 'Left Posterior Slope', abbreviation = 'LPS')
display.setVisiblePosition(leftposteriorSlope, (-1.85,-2.6,0.0), True)
display.setVisibleSize(leftposteriorSlope, (1.1,1.1,1.1))
display.setArrangedAxis(leftposteriorSlope, 'Y')
display.setLabel(leftposteriorSlope, '')

leftsuperiorposteriorSlope = network.createRegion(name = 'Left Superior Posterior Slope', abbreviation = 'LSPS', parentRegion = leftposteriorSlope)
display.setLabel(leftsuperiorposteriorSlope, 'SPS')

leftinferiorposteriorSlope = network.createRegion(name = 'Left Inferior Posterior Slope', abbreviation = 'LIPS', parentRegion = leftposteriorSlope)
display.setLabel(leftinferiorposteriorSlope, 'IPS')

display.setArrangedSpacing(leftposteriorSlope, 0.05)

rightposteriorSlope = network.createRegion(name = 'Right Posterior Slope', abbreviation = 'RPS')
display.setVisiblePosition(rightposteriorSlope, (1.85,-2.6,0.0), True)
display.setVisibleSize(rightposteriorSlope, (1.1,1.1,1.1))
display.setArrangedAxis(rightposteriorSlope, 'Y')
display.setLabel(rightposteriorSlope, '')

rightsuperiorposteriorSlope = network.createRegion(name = 'Right Superior Posterior Slope', abbreviation = 'RSPS', parentRegion = rightposteriorSlope)
display.setLabel(rightsuperiorposteriorSlope, 'SPS')

rightinferiorposteriorSlope = network.createRegion(name = 'Right Inferior Posterior Slope', abbreviation = 'RIPS', parentRegion = rightposteriorSlope)
display.setLabel(rightinferiorposteriorSlope, 'IPS')

display.setArrangedSpacing(rightposteriorSlope, 0.05)

display.autoLayout()
display.setLabelsFloatOnTop(True)