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()
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()