In [6]:
from os import listdir
from os.path import join, isfile, basename

from neurom import load_neuron
from neurom.apps.cut_plane_detection import find_cut_plane

import matplotlib.pyplot as plt
%matplotlib inline

In [2]:
def benchmark():
    '''This benchmark provide a weak proof that the algorithm works'''
    path = '/gpfs/bbp.cscs.ch/project/proj55/data/morphologies'

    files = [join(path, f) for f in listdir(path) if isfile(join(path, f))]

    def is_ok(r):
        '''Estimator of whether or not the cut plane was found'''
        return r['cut_plane'][0] == 'Z' and 15 < r['cut_plane'][1] < 60 and r['status'] == 'ok'

    results = [find_cut_plane(load_neuron(f)) for f in files]
    n_success = sum(is_ok(r) for r in results)
    n_total = float(len(results))
    print('Success rate: {0}%'.format(n_success / n_total * 100.))

benchmark()


Success rate: 100.0%

In [11]:
def display():
    path = '/gpfs/bbp.cscs.ch/project/proj55/data/morphologies'

    files = [join(path, f) for f in listdir(path) if isfile(join(path, f))]

    for f in files[:10]:
        find_cut_plane(load_neuron(f), display=True)
    
display()


/home/bcoste/env/neurom/lib/python3.5/site-packages/matplotlib/pyplot.py:524: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).
  max_open_warning, RuntimeWarning)