Esempio n. 1
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
Esempio n. 2
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
Esempio n. 3
0
    def test_create_ngsegmentlayer(self):
        """Check if the segdataset seg_20190805 is created."""
        layer_serverdir, layer_host = get_ngserver()

        ngviewer = openviewer(None)

        ngviewer2 = create_nglayer(ngviewer=ngviewer,
                                   layer_kws={'type': 'segdataset', 'ngspace': 'FAFB', 'name': 'seg_20190805'})

        assert ngviewer2 == ngviewer
Esempio n. 4
0
    def test_create_ngsynapticcleftslayer(self):
        """Check if the synaptic clefts layer is created."""
        layer_serverdir, layer_host = get_ngserver()

        ngviewer = openviewer(None)

        ngviewer2 = create_nglayer(ngviewer=ngviewer,
                                   layer_kws={'type': 'synapticclefts', 'ngspace': 'FAFB',
                                              'name': 'clefts_Heinrich_etal'})

        assert ngviewer2 == ngviewer
Esempio n. 5
0
    def test_create_ngbuhmannsynapselayer(self):
        """Check if the buhmann synapse layer is created."""
        layer_serverdir, layer_host = get_ngserver()

        ngviewer = openviewer(None)

        ngviewer2 = create_nglayer(ngviewer=ngviewer,
                                   layer_kws={'type': 'synapticlayer', 'ngspace': 'FAFB',
                                              'name': 'synapses_buhmann2019'})

        assert ngviewer2 == ngviewer
Esempio n. 6
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)
Esempio n. 7
0
    def test_create_ngvolumelayer(self):
        """Check if the volume layer is created."""
        layer_serverdir, layer_host = get_ngserver()

        ngviewer = openviewer(None)

        segid = 10
        vertices = [(0, 0, 0), (0, 1, 0), (0, 2, 0)]
        faces = [(0, 1, 2)]
        testvolume = navis.Volume(vertices=vertices, faces=faces, name='test', id=segid)

        ngviewer2 = create_nglayer(layer_kws={'type': 'volumes', 'source': testvolume, 'ngspace': 'FAFB',
                                              'color': 'white', 'alpha': 0.3})

        assert ngviewer2 == ngviewer
Esempio n. 8
0
    def test_create_ngpointslayer(self):
        """Check if the points layer is created."""
        layer_serverdir, layer_host = get_ngserver()

        ngviewer = openviewer(None)

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

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

        ngviewer2 = create_nglayer(layer_kws={'type': 'points', 'name': 'points1', 'ngspace': 'FAFB',
                                              'source': points, 'scale': [8, 8, 8], 'color': 'yellow'})

        assert ngviewer2 == ngviewer
Esempio n. 9
0
    def test_create_ngtreeneuronlist(self):
        """Check if create layer 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]

        neuronlist = navis.core.NeuronList(neuronlist)

        ngviewer = openviewer(None)

        ngviewer2 = create_nglayer(layer_kws={'type': 'skeletons', 'source': neuronlist, 'ngspace': 'FAFB',
                                              'color': ['white', 'green', 'grey', 'yellow', 'magenta'],
                                              'alpha': 0.9})

        assert ngviewer2 == ngviewer
Esempio n. 10
0
import sys
import unittest

from pyroglancer.layers import get_ngserver
from pyroglancer.localserver import closedataserver
from pyroglancer.localserver import startdataserver
from pyroglancer.ngspaces import create_ngspace
from pyroglancer.ngviewer import closeviewer
from pyroglancer.ngviewer import openviewer

# Add a common viewer, dataserver(specific port for travis) for each test module..
closeviewer()
closedataserver()
startdataserver(port=8005)  # start dataserver..
openviewer(headless=True)  # open ngviewer

# def setup_module(module):
#     """Start all servers."""
#     # Add a common viewer, dataserver for the whole serie of test..
#     startdataserver()  # start dataserver..
#     openviewer(headless=True)  # open ngviewer
#
#
# def teardown_module(module):
#     """Stop all servers."""
#     # Stop all viewers..
#     closedataserver()
#     closeviewer()

Esempio n. 11
0
    def test_reuseoldviewer(self):
        """Check if old viewer is reused incase of new opening request."""
        viewer1 = openviewer(None)
        viewer2 = openviewer(viewer1)

        assert viewer1 == viewer2
Esempio n. 12
0
    def test_newviewer(self):
        """Check if the viewer opens when no object is passed."""
        viewer = openviewer(None)

        assert isinstance(viewer, ng.viewer.Viewer)