Ejemplo n.º 1
0
  def test_seed (self):
    """Upload a seed and test it's fields"""

    # Make a seed
    makeAnno (p, 3)

    # Test the parent
    parent = random.randint (0,100)
    f = setField(p, 'parent', parent)
    f = getField(p, 'parent')
    assert parent == int(f.content)

    # Test the source
    source = random.randint (0,100)
    f = setField(p, 'source', source)
    f = getField(p, 'source')
    assert source == int(f.content)

    # Test the cubelocation
    cubelocation = random.randint (0,100)
    f = setField(p, 'cubelocation', cubelocation)
    f = getField(p, 'cubelocation')
    assert cubelocation == int(f.content)

    # Test the position
    position = [random.randint (0,100), random.randint(0,100), random.randint(0,100)]
    f = setField(p, 'position', ','.join([str(i) for i in position]))
    f = getField(p, 'position')
    assert ','.join([str(i) for i in position]) == f.content
Ejemplo n.º 2
0
    def test_query_kvpairs(self):
        """validate that one can query arbitray kvpairs for equality only"""

        # do a general kv test for each annotation type
        for i in range(1, 10):

            key = ''.join(
                random.choice(string.ascii_letters + string.digits)
                for _ in range(random.randint(1, 128)))
            value = ''.join(
                random.choice(string.ascii_letters + string.digits)
                for _ in range(random.randint(1, 1024)))

            annids = []

            makeAnno(p, i)
            setField(p, key, value)
            annids.append(p.annoid)

            makeAnno(p, i)
            setField(p, key, value)
            annids.append(p.annoid)
            h5 = queryField(p, key, value)

            assert (h5['ANNOIDS'].shape[0] == 2)
Ejemplo n.º 3
0
    def test_roi(self):
        """Upload an roi and test it's fields"""

        # Make a skeleton
        makeAnno(p, 9)

        # test the parent
        parent = random.randint(0, 65535)
        f = setField(p, 'parent', parent)
        f = getField(p, 'parent')
        assert parent == int(f.content)

        # make a bunch of children ROIs
        q = Params()
        q.token = 'unittest'
        q.resolution = 0
        q.channels = ['unit_anno']

        childids = []
        for i in range(0, 4):
            makeAnno(q, 9)
            f = setField(q, 'parent', p.annoid)
            childids.append(q.annoid)

        # Test children
        f = getField(p, 'children')
        rchildids = f.content.split(',')
        for cid in rchildids:
            assert int(cid) in childids
        assert len(rchildids) == 4
Ejemplo n.º 4
0
  def test_wrong ( self ):

    # Make an annotation
    makeAnno (p, 2)

    # Test the synapse type
    synapse_type = random.randint (0,100)
    f = setField(p, 'synapse_type', synapse_type)
    f = getField(p, 'synapse_type')
    assert synapse_type == int(f.content)

    # Test the weight
    weight = random.random ()
    f = setField(p, 'weight', weight)
    f = getField(p, 'weight')
    assert abs(weight - float(f.content)) < 0.001

    # Test inheritance
    status = random.randint (0,100)
    f = setField(p, 'status', status)
    f = getField(p, 'status')
    assert status == int(f.content)

    #  bad format to a number
    url =  "https://{}/sd/{}/{}/{}/setField/status/aa/".format(SITE_HOST, 'unittest', 'unit_anno', p.annoid)
    req = getURL( url )
    assert(req.status_code >= 400)

    #  request a missing field
    url =  "https://{}/sd/{}/{}/{}/getField/othernonesuch/".format(SITE_HOST, 'unittest', 'unit_anno', p.annoid)
    req = getURL( url )
    assert(req.status_code >= 400)
Ejemplo n.º 5
0
  def test_organelle (self):
    """Upload an organelle and test it's fields"""

    # Make an organelle
    makeAnno ( p, 6 )

    # Test the parentseed
    parentseed = random.randint (0,100)
    f = setField(p, 'parentseed', parentseed)
    f = getField(p, 'parentseed')
    assert parentseed == int(f.content)

    # Test the organelleclass
    organelleclass = random.randint (0,100)
    f = setField(p, 'organelleclass', organelleclass)
    f = getField(p, 'organelleclass')
    assert organelleclass == int(f.content)

    # Test the segment
    segment = random.randint (0,65535)
    f = setField(p, 'segment', segment)
    f = getField(p, 'segment')
    assert segment == int(f.content)

    # Test status
    status = random.randint (0,100)
    f = setField(p, 'status', status)
    f = getField(p, 'status')
    assert status == int(f.content)

    # Test the seeds
    seeds = [random.randint(0,100), random.randint(0,100), random.randint(0,100)]
    f = setField(p, 'seeds', ','.join([str(i) for i in seeds]))
    f = getField(p, 'seeds')
    assert ','.join([str(i) for i in seeds]) == f.content
Ejemplo n.º 6
0
    def test_wrong(self):

        # Make an annotation
        makeAnno(p, 2)

        # Test the synapse type
        synapse_type = random.randint(0, 100)
        f = setField(p, 'synapse_type', synapse_type)
        f = getField(p, 'synapse_type')
        assert synapse_type == int(f.content)

        # Test the weight
        weight = random.random()
        f = setField(p, 'weight', weight)
        f = getField(p, 'weight')
        assert abs(weight - float(f.content)) < 0.001

        # Test inheritance
        status = random.randint(0, 100)
        f = setField(p, 'status', status)
        f = getField(p, 'status')
        assert status == int(f.content)

        #  bad format to a number
        url = "https://{}/sd/{}/{}/{}/setField/status/aa/".format(
            SITE_HOST, 'unittest', 'unit_anno', p.annoid)
        req = getURL(url)
        assert (req.status_code >= 400)

        #  request a missing field
        url = "https://{}/sd/{}/{}/{}/getField/othernonesuch/".format(
            SITE_HOST, 'unittest', 'unit_anno', p.annoid)
        req = getURL(url)
        assert (req.status_code >= 400)
Ejemplo n.º 7
0
  def test_roi (self):
    """Upload an roi and test it's fields"""

    # Make a skeleton
    makeAnno (p, 9)

    # test the parent
    parent = random.randint (0,65535)
    f = setField(p, 'parent', parent)
    f = getField(p, 'parent')
    assert parent == int(f.content)

    # make a bunch of children ROIs
    q = Params()
    q.token = 'unittest'
    q.resolution = 0
    q.channels = ['unit_anno']

    childids = []
    for i in range(0,4):
      makeAnno ( q, 9)
      f = setField(q, 'parent', p.annoid)
      childids.append(q.annoid)

    # Test children
    f = getField(p, 'children')
    rchildids = f.content.split(',')
    for cid in rchildids:
      assert int(cid) in childids
    assert len(rchildids) == 4
Ejemplo n.º 8
0
    def test_seed(self):
        """Upload a seed and test it's fields"""

        # Make a seed
        makeAnno(p, 3)

        # Test the parent
        parent = random.randint(0, 100)
        f = setField(p, 'parent', parent)
        f = getField(p, 'parent')
        assert parent == int(f.content)

        # Test the source
        source = random.randint(0, 100)
        f = setField(p, 'source', source)
        f = getField(p, 'source')
        assert source == int(f.content)

        # Test the cubelocation
        cubelocation = random.randint(0, 100)
        f = setField(p, 'cubelocation', cubelocation)
        f = getField(p, 'cubelocation')
        assert cubelocation == int(f.content)

        # Test the position
        position = [
            random.randint(0, 100),
            random.randint(0, 100),
            random.randint(0, 100)
        ]
        f = setField(p, 'position', ','.join([str(i) for i in position]))
        f = getField(p, 'position')
        assert ','.join([str(i) for i in position]) == f.content
Ejemplo n.º 9
0
  def test_kvpairs(self):

    # do a general kv test for each annotation type
    for i in range(1,10):

      makeAnno (p, i)

      key = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(random.randint(1,128)))
      value = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(random.randint(1,1024)))

      setField( p, key, value )
      f = getField ( p, key )
      assert ( f.content == value )
Ejemplo n.º 10
0
  def test_neuron (self):
    """Make a multiple segments that overlap and then query them as a neuron"""

    # create neuron
    makeAnno(p,5)
    neuronid = p.annoid

    # create annotations
    for i in range(0,3):

      # create annotations
      makeAnno(p,4)
      f = setField(p,'neuron',neuronid)

      # add data
      p.args = (3000,3100,4000,4100,100+2*i,100+2*i+3)
      image_data = np.ones( [1,3,100,100], dtype=np.uint32 ) * p.annoid
      response = postNPZ(p, image_data)

    # get the neuron annotation
    p.annoid = neuronid
    p.field = 'tight_cutout'
    h5ret = getAnnotation(p)
    idgrp = h5ret.get(str(p.annoid))

    # count the voxels to make sure they remapped correctly
    assert ( np.unique(np.array(idgrp['CUTOUT'][:,:,:])) == [0,neuronid] ).all()
    assert ( len(np.nonzero(np.array(idgrp['CUTOUT'][:,:,:]))[0]) == 70000 )
Ejemplo n.º 11
0
    def test_neuron(self):
        """Make a multiple segments that overlap and then query them as a neuron"""

        # create neuron
        makeAnno(p, 5)
        neuronid = p.annoid

        # create annotations
        for i in range(0, 3):

            # create annotations
            makeAnno(p, 4)
            f = setField(p, 'neuron', neuronid)

            # add data
            p.args = (3000, 3100, 4000, 4100, 100 + 2 * i, 100 + 2 * i + 3)
            image_data = np.ones([1, 3, 100, 100], dtype=np.uint32) * p.annoid
            response = postNPZ(p, image_data)

        # get the neuron annotation
        p.annoid = neuronid
        p.field = 'tight_cutout'
        h5ret = getAnnotation(p)
        idgrp = h5ret.get(str(p.annoid))

        # count the voxels to make sure they remapped correctly
        assert (np.unique(np.array(idgrp['CUTOUT'][:, :, :])) == [0, neuronid
                                                                  ]).all()
        assert (len(np.nonzero(np.array(
            idgrp['CUTOUT'][:, :, :]))[0]) == 70000)
Ejemplo n.º 12
0
    def test_kvpairs(self):

        # do a general kv test for each annotation type
        for i in range(1, 10):

            makeAnno(p, i)

            key = ''.join(
                random.choice(string.ascii_letters + string.digits)
                for _ in range(random.randint(1, 128)))
            value = ''.join(
                random.choice(string.ascii_letters + string.digits)
                for _ in range(random.randint(1, 1024)))

            setField(p, key, value)
            f = getField(p, key)
            assert (f.content == value)
Ejemplo n.º 13
0
  def test_annotation (self):
    """Upload an annotation and test it's fields"""

    # Make an annotation
    makeAnno (p, 1)

    # Test Status
    status = random.randint (0,100)
    f = setField(p, 'status', status)
    f = getField(p, 'status')
    assert status == int(f.content)

    # Test confidence
    confidence = random.random ()
    f = setField(p, 'confidence', confidence)
    f = getField(p, 'confidence')
    assert abs(confidence - float(f.content)) < 0.001
Ejemplo n.º 14
0
    def test_annotation(self):
        """Upload an annotation and test it's fields"""

        # Make an annotation
        makeAnno(p, 1)

        # Test Status
        status = random.randint(0, 100)
        f = setField(p, 'status', status)
        f = getField(p, 'status')
        assert status == int(f.content)

        # Test confidence
        confidence = random.random()
        f = setField(p, 'confidence', confidence)
        f = getField(p, 'confidence')
        assert abs(confidence - float(f.content)) < 0.001
Ejemplo n.º 15
0
    def test_node(self):
        """Upload a skeleton node and test it's fields"""

        # Make a node
        makeAnno(p, 7)

        # test the nodetype
        nodetype = random.randint(0, 100)
        f = setField(p, 'nodetype', nodetype)
        f = getField(p, 'nodetype')
        assert nodetype == int(f.content)

        # test the skeletonid
        skeletonid = random.randint(0, 65535)
        f = setField(p, 'skeletonid', skeletonid)
        f = getField(p, 'skeletonid')
        assert skeletonid == int(f.content)

        # test the pointid
        pointid = random.randint(0, 65535)
        f = setField(p, 'pointid', pointid)
        f = getField(p, 'pointid')
        assert pointid == int(f.content)

        # test the parentid
        parentid = random.randint(0, 65535)
        f = setField(p, 'parentid', parentid)
        f = getField(p, 'parentid')
        assert parentid == int(f.content)

        # test the radius
        radius = random.random()
        f = setField(p, 'radius', radius)
        f = getField(p, 'radius')
        assert abs(radius - float(f.content)) < 0.001

        # test the location
        location = [random.random(), random.random(), random.random()]
        f = setField(p, 'location', ','.join([str(i) for i in location]))
        f = getField(p, 'location')
        assert ','.join([str(i) for i in location]) == f.content

        # make a bunch of children
        q = Params()
        q.token = 'unittest'
        q.resolution = 0
        q.channels = ['unit_anno']

        childids = []
        for i in range(0, 4):
            makeAnno(q, 9)
            f = setField(q, 'parent', p.annoid)
            childids.append(q.annoid)

        # Test children
        f = getField(p, 'children')
        rchildids = f.content.split(',')
        for cid in rchildids:
            assert int(cid) in childids
        assert len(rchildids) == 4
Ejemplo n.º 16
0
  def test_node (self):
    """Upload a skeleton node and test it's fields"""

    # Make a node
    makeAnno (p, 7)

    # test the nodetype
    nodetype = random.randint (0,100)
    f = setField(p, 'nodetype', nodetype)
    f = getField(p, 'nodetype')
    assert nodetype == int(f.content)

    # test the skeletonid
    skeletonid = random.randint (0,65535)
    f = setField(p, 'skeletonid', skeletonid)
    f = getField(p, 'skeletonid')
    assert skeletonid == int(f.content)

    # test the pointid
    pointid = random.randint (0,65535)
    f = setField(p, 'pointid', pointid)
    f = getField(p, 'pointid')
    assert pointid == int(f.content)

    # test the parentid
    parentid = random.randint (0,65535)
    f = setField(p, 'parentid', parentid)
    f = getField(p, 'parentid')
    assert parentid == int(f.content)

    # test the radius
    radius = random.random()
    f = setField(p, 'radius', radius)
    f = getField(p, 'radius')
    assert abs(radius - float(f.content)) < 0.001

    # test the location
    location = [random.random(), random.random(), random.random()]
    f = setField(p, 'location', ','.join([str(i) for i in location]))
    f = getField(p, 'location')
    assert ','.join([str(i) for i in location]) == f.content

    # make a bunch of children
    q = Params()
    q.token = 'unittest'
    q.resolution = 0
    q.channels = ['unit_anno']

    childids = []
    for i in range(0,4):
      makeAnno ( q, 9)
      f = setField(q, 'parent', p.annoid)
      childids.append(q.annoid)

    # Test children
    f = getField(p, 'children')
    rchildids = f.content.split(',')
    for cid in rchildids:
      assert int(cid) in childids
    assert len(rchildids) == 4
Ejemplo n.º 17
0
  def test_synapse (self):
    """Upload a synapse and test it's fields"""

    # Make a synapse
    makeAnno (p, 2)

    # Test synapse type
    synapse_type = random.randint (0,100)
    f = setField(p, 'synapse_type', synapse_type)
    f = getField(p, 'synapse_type')
    assert synapse_type == int(f.content)

    # Test the weight
    weight = random.random ()
    f = setField(p, 'weight', weight)
    f = getField(p, 'weight')
    assert abs(weight - float(f.content)) < 0.001

    # Test the inheritance
    status = random.randint (0,100)
    f = setField(p, 'status', status)
    f = getField(p, 'status')
    assert status == int(f.content)

    # Test the seeds
    seeds = [random.randint(0,100), random.randint(0,100), random.randint(0,100)]
    f = setField(p, 'seeds', ','.join([str(i) for i in seeds]))
    f = getField(p, 'seeds')
    assert ','.join([str(i) for i in seeds]) == f.content

    # test the centroid
    centroid = [random.randint(0,65535), random.randint(0,65535), random.randint(0,65535)]
    f = setField(p, 'centroid', ','.join([str(i) for i in centroid]))
    f = getField(p, 'centroid')
    assert ','.join([str(i) for i in centroid]) == f.content

    # Test the segments
    segments = [random.randint(0,100), random.randint(0,100), random.randint(0,100)]
    f = setField(p, 'segments', ','.join([str(i) for i in segments]))
    f = getField(p, 'segments')
    assert ','.join([str(i) for i in segments]) == f.content

    # Test the presegments
    presegments = [random.randint(0,100), random.randint(0,100), random.randint(0,100)]
    f = setField(p, 'presegments', ','.join([str(i) for i in presegments]))
    f = getField(p, 'presegments')
    assert ','.join([str(i) for i in presegments]) == f.content

    # Test the postsegments
    postsegments = [random.randint(0,100), random.randint(0,100), random.randint(0,100)]
    f = setField(p, 'postsegments', ','.join([str(i) for i in postsegments]))
    f = getField(p, 'postsegments')
    assert ','.join([str(i) for i in postsegments]) == f.content
Ejemplo n.º 18
0
  def test_query_kvpairs ( self ):
    """validate that one can query arbitray kvpairs for equality only"""

    # do a general kv test for each annotation type
    for i in range(1,10):

      key = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(random.randint(1,128)))
      value = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(random.randint(1,1024)))

      annids = []

      makeAnno (p, i)
      setField( p, key, value )
      annids.append(p.annoid)

      makeAnno (p, i)
      setField( p, key, value )
      annids.append(p.annoid)
      h5 = queryField ( p, key, value )

      assert ( h5['ANNOIDS'].shape[0] == 2 )
Ejemplo n.º 19
0
    def test_organelle(self):
        """Upload an organelle and test it's fields"""

        # Make an organelle
        makeAnno(p, 6)

        # Test the parentseed
        parentseed = random.randint(0, 100)
        f = setField(p, 'parentseed', parentseed)
        f = getField(p, 'parentseed')
        assert parentseed == int(f.content)

        # Test the organelleclass
        organelleclass = random.randint(0, 100)
        f = setField(p, 'organelleclass', organelleclass)
        f = getField(p, 'organelleclass')
        assert organelleclass == int(f.content)

        # Test the segment
        segment = random.randint(0, 65535)
        f = setField(p, 'segment', segment)
        f = getField(p, 'segment')
        assert segment == int(f.content)

        # Test status
        status = random.randint(0, 100)
        f = setField(p, 'status', status)
        f = getField(p, 'status')
        assert status == int(f.content)

        # Test the seeds
        seeds = [
            random.randint(0, 100),
            random.randint(0, 100),
            random.randint(0, 100)
        ]
        f = setField(p, 'seeds', ','.join([str(i) for i in seeds]))
        f = getField(p, 'seeds')
        assert ','.join([str(i) for i in seeds]) == f.content
Ejemplo n.º 20
0
  def test_query_objects (self):
    """Test the function that lists objects of different types."""

    # synapse annotations
    p.anntype = 2
    status = random.randint(0,100)
    confidence = random.random()*0.3+0.1   # number between 0.1 and 0.4
    synapse_type = random.randint(0,100)
    synapse_weight = random.random()*0.9+0.1   # number between 0.1 and 0.9

    for i in range (10):

      # Make an annotation
      makeAnno( p, p.anntype)

      # set some fields in the even annotations
      if i % 2 == 0:
        setField(p, 'status', status)

        # set the confidence
        setField(p, 'confidence', confidence)

        # set the type
        setField(p, 'synapse_type', synapse_type)

      # set some fields in the odd annotations
      if i % 2 == 1:
        # set the confidence
        setField(p, 'confidence', 1.0 - confidence)


    # check the status
    h5 = queryField(p, 'status', status)
    assert ( h5['ANNOIDS'].shape[0] == 5 )

    # check all the confidence variants
    field_value = '/'.join( ['lt',str(1.0-confidence-0.0001), ''] )
    h5 = queryField(p, 'confidence', field_value)
    assert ( h5['ANNOIDS'].shape[0] == 5 )

    field_value = '/'.join( ['gt',str(confidence+0.0001), ''] )
    h5 = queryField(p, 'confidence', field_value)
    assert ( h5['ANNOIDS'].shape[0] == 5 )
Ejemplo n.º 21
0
    def test_query_objects(self):
        """Test the function that lists objects of different types."""

        # synapse annotations
        p.anntype = 2
        status = random.randint(0, 100)
        confidence = random.random() * 0.3 + 0.1  # number between 0.1 and 0.4
        synapse_type = random.randint(0, 100)
        synapse_weight = random.random(
        ) * 0.9 + 0.1  # number between 0.1 and 0.9

        for i in range(10):

            # Make an annotation
            makeAnno(p, p.anntype)

            # set some fields in the even annotations
            if i % 2 == 0:
                setField(p, 'status', status)

                # set the confidence
                setField(p, 'confidence', confidence)

                # set the type
                setField(p, 'synapse_type', synapse_type)

            # set some fields in the odd annotations
            if i % 2 == 1:
                # set the confidence
                setField(p, 'confidence', 1.0 - confidence)

        # check the status
        h5 = queryField(p, 'status', status)
        assert (h5['ANNOIDS'].shape[0] == 5)

        # check all the confidence variants
        field_value = '/'.join(['lt', str(1.0 - confidence - 0.0001), ''])
        h5 = queryField(p, 'confidence', field_value)
        assert (h5['ANNOIDS'].shape[0] == 5)

        field_value = '/'.join(['gt', str(confidence + 0.0001), ''])
        h5 = queryField(p, 'confidence', field_value)
        assert (h5['ANNOIDS'].shape[0] == 5)
Ejemplo n.º 22
0
    def test_neuron(self):
        """Upload a neuron and test it's fields"""

        # Make a neuron
        makeAnno(p, 5)

        # make a bunch of segments and add to the neuron
        q = Params()
        q.token = 'unittest'
        q.resolution = 0
        q.channels = ['unit_anno']

        segids = []
        for i in range(0, 5):
            makeAnno(q, 4)
            f = setField(q, 'neuron', p.annoid)
            segids.append(q.annoid)

        # Test segments
        f = getField(p, 'segments')
        rsegids = f.content.split(',')
        for sid in rsegids:
            assert int(sid) in segids
        assert len(rsegids) == 5
Ejemplo n.º 23
0
  def test_neuron (self):
    """Upload a neuron and test it's fields"""

    # Make a neuron
    makeAnno (p, 5)

    # make a bunch of segments and add to the neuron
    q = Params()
    q.token = 'unittest'
    q.resolution = 0
    q.channels = ['unit_anno']

    segids = []
    for i in range(0,5):
      makeAnno ( q, 4)
      f = setField(q, 'neuron', p.annoid)
      segids.append(q.annoid)

    # Test segments
    f = getField(p, 'segments')
    rsegids = f.content.split(',')
    for sid in rsegids:
      assert int(sid) in segids
    assert len(rsegids) == 5
Ejemplo n.º 24
0
    def test_test_segment(self):
        """Upload a segment and test it's fields"""

        for i in range(1, 10):
            makeAnno(p, 1)

        # Make a segment
        makeAnno(p, 4)

        # make a bunch of synapses
        q = Params()
        q.token = 'unittest'
        q.resolution = 0
        q.channels = ['unit_anno']

        synids = []
        presynids = []
        postsynids = []
        for i in range(0, 8):
            makeAnno(q, 2)
            f = setField(
                q, 'segments',
                ','.join([str(p.annoid),
                          str(random.randint(500, 1000))]))
            #      f = setField(q, 'presegments', ','.join([str(p.annoid),str(random.randint(500,1000))]))
            f = setField(q, 'presegments', ','.join([str(p.annoid)]))
            f = setField(q, 'postsegments', ','.join([str(p.annoid)]))
            synids.append(q.annoid)
            presynids.append(q.annoid)
            postsynids.append(q.annoid)

        # make one more segment
        makeAnno(q, 2)
        f = setField(q, 'segments', p.annoid)
        synids.append(q.annoid)

        # Test synapses
        f = getField(p, 'synapses')
        rsynids = f.content.split(',')
        for sid in rsynids:
            assert int(sid) in synids
        assert len(rsynids) == 9

        # Test presynapses
        f = getField(p, 'presynapses')
        rsynids = f.content.split(',')
        for sid in rsynids:
            assert int(sid) in presynids
        assert len(rsynids) == 8

        # Test postsynapses
        f = getField(p, 'postsynapses')
        rsynids = f.content.split(',')
        for sid in rsynids:
            assert int(sid) in postsynids
        assert len(rsynids) == 8

        # make a bunch of organelles
        q = Params()
        q.token = 'unittest'
        q.resolution = 0
        q.channels = ['unit_anno']

        orgids = []
        for i in range(0, 8):
            makeAnno(q, 6)
            f = setField(q, 'segment', p.annoid)
            orgids.append(q.annoid)

        # Test synapses
        f = getField(p, 'organelles')
        rorgids = f.content.split(',')
        for cid in rorgids:
            assert int(cid) in orgids
        assert len(rorgids) == 8
Ejemplo n.º 25
0
  def test_skeleton (self):
    """Upload a skeleton and test it's fields"""

    # Make a node
    makeAnno (p, 8)

    # test the nodetype
    skeletontype = random.randint (0,100)
    f = setField(p, 'skeletontype', skeletontype)
    f = getField(p, 'skeletontype')
    assert skeletontype == int(f.content)

    # test the rootnode
    rootnode = random.randint (0,65535)
    f = setField(p, 'rootnode', rootnode)
    f = getField(p, 'rootnode')
    assert rootnode == int(f.content)

    # add some nodes to the skeleton and query them
    # make a bunch of children cnodes
    q = Params()
    q.token = 'unittest'
    q.resolution = 0
    q.channels = ['unit_anno']

    r = Params()
    r.token = 'unittest'
    r.resolution = 0
    r.channels = ['unit_anno']
    # make a root node

    s = Params()
    s.token = 'unittest'
    s.resolution = 0
    s.channels = ['unit_anno']
    # make a root node

    skelids = []

    # make a root node
    makeAnno ( q, 7)
    setField(p, 'rootnode', q.annoid)
    setField(q, 'skeleton', p.annoid)
    skelids.append(q.annoid)

    # Make 2 children and four grandchildren
    for i in range(0,2):
      makeAnno ( r, 7)
      f = setField(r, 'parent', q.annoid)
      f = setField(r, 'skeleton', p.annoid)
      skelids.append(r.annoid)
      for i in range(0,2):
        makeAnno ( s, 7)
        f = setField(s, 'parent', r.annoid)
        f = setField(s, 'skeleton', p.annoid)
        skelids.append(s.annoid)

    # Test skeleton
    f = getField(p, 'nodes')
    rskelids = f.content.split(',')
    for sid in rskelids:
      assert int(sid) in skelids
    assert len(rskelids) == 7
Ejemplo n.º 26
0
  def test_test_segment (self):
    """Upload a segment and test it's fields"""

    for i in range(1,10):
      makeAnno (p, 1)

    # Make a segment
    makeAnno (p, 4)

    # make a bunch of synapses
    q = Params()
    q.token = 'unittest'
    q.resolution = 0
    q.channels = ['unit_anno']

    synids = []
    presynids = []
    postsynids = []
    for i in range(0,8):
      makeAnno ( q, 2)
      f = setField(q, 'segments', ','.join([str(p.annoid),str(random.randint(500,1000))]))
#      f = setField(q, 'presegments', ','.join([str(p.annoid),str(random.randint(500,1000))]))
      f = setField(q, 'presegments', ','.join([str(p.annoid)]))
      f = setField(q, 'postsegments', ','.join([str(p.annoid)]))
      synids.append(q.annoid)
      presynids.append(q.annoid)
      postsynids.append(q.annoid)

    # make one more segment
    makeAnno ( q, 2)
    f = setField(q, 'segments', p.annoid)
    synids.append(q.annoid)

    # Test synapses
    f = getField(p, 'synapses')
    rsynids = f.content.split(',')
    for sid in rsynids:
      assert int(sid) in synids
    assert len(rsynids) == 9

    # Test presynapses
    f = getField(p, 'presynapses')
    rsynids = f.content.split(',')
    for sid in rsynids:
      assert int(sid) in presynids
    assert len(rsynids) == 8

    # Test postsynapses
    f = getField(p, 'postsynapses')
    rsynids = f.content.split(',')
    for sid in rsynids:
      assert int(sid) in postsynids
    assert len(rsynids) == 8

    # make a bunch of organelles
    q = Params()
    q.token = 'unittest'
    q.resolution = 0
    q.channels = ['unit_anno']

    orgids = []
    for i in range(0,8):
      makeAnno ( q, 6 )
      f = setField(q, 'segment', p.annoid)
      orgids.append(q.annoid)

    # Test synapses
    f = getField(p, 'organelles')
    rorgids = f.content.split(',')
    for cid in rorgids:
      assert int(cid) in orgids
    assert len(rorgids) == 8
Ejemplo n.º 27
0
    def test_skeleton(self):
        """Upload a skeleton and test it's fields"""

        # Make a node
        makeAnno(p, 8)

        # test the nodetype
        skeletontype = random.randint(0, 100)
        f = setField(p, 'skeletontype', skeletontype)
        f = getField(p, 'skeletontype')
        assert skeletontype == int(f.content)

        # test the rootnode
        rootnode = random.randint(0, 65535)
        f = setField(p, 'rootnode', rootnode)
        f = getField(p, 'rootnode')
        assert rootnode == int(f.content)

        # add some nodes to the skeleton and query them
        # make a bunch of children cnodes
        q = Params()
        q.token = 'unittest'
        q.resolution = 0
        q.channels = ['unit_anno']

        r = Params()
        r.token = 'unittest'
        r.resolution = 0
        r.channels = ['unit_anno']
        # make a root node

        s = Params()
        s.token = 'unittest'
        s.resolution = 0
        s.channels = ['unit_anno']
        # make a root node

        skelids = []

        # make a root node
        makeAnno(q, 7)
        setField(p, 'rootnode', q.annoid)
        setField(q, 'skeleton', p.annoid)
        skelids.append(q.annoid)

        # Make 2 children and four grandchildren
        for i in range(0, 2):
            makeAnno(r, 7)
            f = setField(r, 'parent', q.annoid)
            f = setField(r, 'skeleton', p.annoid)
            skelids.append(r.annoid)
            for i in range(0, 2):
                makeAnno(s, 7)
                f = setField(s, 'parent', r.annoid)
                f = setField(s, 'skeleton', p.annoid)
                skelids.append(s.annoid)

        # Test skeleton
        f = getField(p, 'nodes')
        rskelids = f.content.split(',')
        for sid in rskelids:
            assert int(sid) in skelids
        assert len(rskelids) == 7
Ejemplo n.º 28
0
    def test_synapse(self):
        """Upload a synapse and test it's fields"""

        # Make a synapse
        makeAnno(p, 2)

        # Test synapse type
        synapse_type = random.randint(0, 100)
        f = setField(p, 'synapse_type', synapse_type)
        f = getField(p, 'synapse_type')
        assert synapse_type == int(f.content)

        # Test the weight
        weight = random.random()
        f = setField(p, 'weight', weight)
        f = getField(p, 'weight')
        assert abs(weight - float(f.content)) < 0.001

        # Test the inheritance
        status = random.randint(0, 100)
        f = setField(p, 'status', status)
        f = getField(p, 'status')
        assert status == int(f.content)

        # Test the seeds
        seeds = [
            random.randint(0, 100),
            random.randint(0, 100),
            random.randint(0, 100)
        ]
        f = setField(p, 'seeds', ','.join([str(i) for i in seeds]))
        f = getField(p, 'seeds')
        assert ','.join([str(i) for i in seeds]) == f.content

        # test the centroid
        centroid = [
            random.randint(0, 65535),
            random.randint(0, 65535),
            random.randint(0, 65535)
        ]
        f = setField(p, 'centroid', ','.join([str(i) for i in centroid]))
        f = getField(p, 'centroid')
        assert ','.join([str(i) for i in centroid]) == f.content

        # Test the segments
        segments = [
            random.randint(0, 100),
            random.randint(0, 100),
            random.randint(0, 100)
        ]
        f = setField(p, 'segments', ','.join([str(i) for i in segments]))
        f = getField(p, 'segments')
        assert ','.join([str(i) for i in segments]) == f.content

        # Test the presegments
        presegments = [
            random.randint(0, 100),
            random.randint(0, 100),
            random.randint(0, 100)
        ]
        f = setField(p, 'presegments', ','.join([str(i) for i in presegments]))
        f = getField(p, 'presegments')
        assert ','.join([str(i) for i in presegments]) == f.content

        # Test the postsegments
        postsegments = [
            random.randint(0, 100),
            random.randint(0, 100),
            random.randint(0, 100)
        ]
        f = setField(p, 'postsegments',
                     ','.join([str(i) for i in postsegments]))
        f = getField(p, 'postsegments')
        assert ','.join([str(i) for i in postsegments]) == f.content