예제 #1
0
    def test_annotate_annotate_points(self):
        """Check if individual annotation works."""
        layer_serverdir, layer_host = get_ngserver()

        layer_kws = {}
        layer_kws['ngspace'] = 'FAFB'
        dimensions = _handle_ngdimensions(layer_kws)

        location_data = [{
            'x': 5,
            'y': 10,
            'z': 20
        }, {
            'x': 15,
            'y': 25,
            'z': 30
        }]

        points = pd.DataFrame(location_data)
        points['description'] = 'dummy data'

        ngviewer = openviewer(None)
        layer_scale = (1, 1, 1)
        annot_colors = '#ff0000'

        status = annotate_points(ngviewer, dimensions, annot_colors, points,
                                 'points', layer_scale)

        assert status
예제 #2
0
    def test_put_postsynapsefile(self):
        """Check if the synapse file is stored."""
        layer_serverdir, layer_host = get_ngserver()

        layer_kws = {}
        layer_kws['ngspace'] = 'FAFB'
        dimensions = _handle_ngdimensions(layer_kws)
        synapse_path = create_synapseinfo(dimensions, layer_serverdir)

        location_data = [{
            'x': 5,
            'y': 10,
            'z': 20
        }, {
            'x': 15,
            'y': 25,
            'z': 30
        }]

        presynapses = pd.DataFrame(location_data)

        skeletonid = 456
        type = 'postsynapses'

        put_synapsefile(synapse_path, type, presynapses, skeletonid)

        synapsefilepath = synapse_path + '/precomputed/' + \
            type + '/' + type + '_cell/' + str(skeletonid)

        status = os.path.isfile(synapsefilepath)

        assert status
예제 #3
0
    def test_put_pointfile(self):
        """Check if the point file is stored."""
        layer_serverdir, layer_host = get_ngserver()

        layer_kws = {}
        layer_kws['ngspace'] = 'FAFB'
        dimensions = _handle_ngdimensions(layer_kws)
        layer_name = 'points'
        points_path = create_pointinfo(dimensions, layer_serverdir, layer_name)

        location_data = [{
            'x': 5,
            'y': 10,
            'z': 20
        }, {
            'x': 15,
            'y': 25,
            'z': 30
        }]

        points = pd.DataFrame(location_data)
        points['description'] = 'dummy data'

        upload_points(points, points_path, 'points', [1, 1, 1])

        pointfilepath = points_path + '/precomputed/' + layer_name + '/spatial0/0_0_0'

        status = os.path.isfile(pointfilepath)

        assert status
예제 #4
0
    def test_annotate_synapsescatmaidneuron(self):
        """Check if individual annotation works."""
        # load some example neurons..
        swc_path = os.path.join(BASE_DIR, 'data/swc')
        # print('swc_path: ', swc_path)
        swc_files = glob.glob(os.path.join(swc_path, '*.swc'))
        # print('swc_file: ', swc_files)

        neuronlist = []
        neuronlist += [
            navis.read_swc(f,
                           units='8 nm',
                           connector_labels={
                               'presynapse': 7,
                               'postsynapse': 8
                           },
                           id=int(os.path.splitext(os.path.basename(f))[0]))
            for f in swc_files
        ]

        catmaidneuron = pymaid.core.CatmaidNeuron(neuronlist[0])

        ngviewer = openviewer(None)
        layer_kws = {}
        layer_kws['ngspace'] = 'FAFB'
        dimensions = _handle_ngdimensions(layer_kws)

        status = annotate_synapses(ngviewer, dimensions, catmaidneuron)

        assert status
예제 #5
0
    def test_create_nghandledimensionslayer(self):
        """Check if the dimensions are handled."""
        dimensions = ng.CoordinateSpace(names=['x', 'y', 'z'], units='um', scales=[1, 1, 1])

        dimensions2 = _handle_ngdimensions(layer_kws={'dimensions': dimensions})

        assert dimensions2 == dimensions
예제 #6
0
    def test_create_pointinfo(self):
        """Check if the point info is stored."""
        layer_serverdir, layer_host = get_ngserver()

        layer_kws = {}
        layer_kws['ngspace'] = 'FAFB'
        dimensions = _handle_ngdimensions(layer_kws)
        create_pointinfo(dimensions, layer_serverdir, 'points')

        status = os.path.isfile(
            os.path.join(layer_serverdir, 'precomputed/points', 'info'))

        assert status
예제 #7
0
    def test_annotate_synapsesexception(self):
        """Check if exception occurs."""
        neuronlist = (1, 2, 3)

        layer_serverdir, layer_host = get_ngserver()

        ngviewer = openviewer(None)
        layer_kws = {}
        layer_kws['ngspace'] = 'FAFB'
        dimensions = _handle_ngdimensions(layer_kws)

        with pytest.raises(Exception):
            annotate_synapses(ngviewer, dimensions, neuronlist)
예제 #8
0
    def test_upload_synapsescatmaidneuron(self):
        """Check if synapse upload works in a tree neuronlist."""
        # load some example neurons..
        swc_path = os.path.join(BASE_DIR, 'data/swc')
        # print('swc_path: ', swc_path)
        swc_files = glob.glob(os.path.join(swc_path, '*.swc'))
        # print('swc_file: ', swc_files)

        neuronlist = []
        neuronlist += [
            navis.read_swc(f,
                           units='8 nm',
                           connector_labels={
                               'presynapse': 7,
                               'postsynapse': 8
                           },
                           id=int(os.path.splitext(os.path.basename(f))[0]))
            for f in swc_files
        ]

        catmaidneuron = pymaid.core.CatmaidNeuron(neuronlist[0])

        layer_serverdir, layer_host = get_ngserver()

        layer_kws = {}
        layer_kws['ngspace'] = 'FAFB'
        dimensions = _handle_ngdimensions(layer_kws)
        synapse_path = create_synapseinfo(dimensions, layer_serverdir)

        presynlayer_kws = {
            'type': 'synapses',
            'ngspace': 'FAFB',
            'source': catmaidneuron
        }

        create_nglayer(layer_kws=presynlayer_kws)
        type = 'presynapses'
        synapsefilepath = synapse_path + '/precomputed/' +\
            type + '/' + type + '_cell/' + str(catmaidneuron.id)

        status = os.path.isfile(synapsefilepath)

        assert status