示例#1
0
def repair_all(input_dir,
               output_dir,
               seed=0,
               axons=None,
               cut_points_dir=None,
               plots_dir=None):
    '''Repair all morphologies in input folder'''
    for inputfilename in iter_morphology_files(input_dir):
        outfilename = Path(output_dir, inputfilename.name)
        if cut_points_dir:
            cut_points = pd.read_csv(
                Path(cut_points_dir, inputfilename.name).with_suffix('.csv'))
        else:
            cut_points = None

        if plots_dir is not None:
            name = 'neuron_{}.html'.format(
                Path(inputfilename).stem.replace(' ', '_'))
            plot_file = str(Path(plots_dir, name))
        else:
            plot_file = None

        try:
            repair(inputfilename,
                   outfilename,
                   seed=seed,
                   axons=axons,
                   cut_leaves_coordinates=cut_points,
                   plot_file=plot_file)
        except Exception as e:  # noqa, pylint: disable=broad-except
            L.warning('%s failed', inputfilename)
            L.warning(e, exc_info=True)
示例#2
0
def test_repair_axon():
    filename = DATA_PATH / 'real-with-axon.asc'
    with TemporaryDirectory('test-cli-axon') as tmp_folder:
        outfilename = Path(tmp_folder, 'out.asc')
        test_module.repair(filename, outfilename, axons=[filename])
        neuron_in = load_neuron(filename)
        neuron_out = load_neuron(outfilename)
        axon = neuron_out.section(40)
        ok_(axon.type == NeuriteType.axon)
        assert_array_equal(
            neuron_in.section(40).points[0],
            neuron_out.section(40).points[0])
        ok_(
            len(neuron_out.section(40).points) > len(
                neuron_in.section(40).points))

        # Test disactivating the axon repair
        repair_flags = {RepairType.axon: False}
        test_module.repair(filename,
                           outfilename,
                           axons=[filename],
                           repair_flags=repair_flags)
        neuron_out = load_neuron(outfilename)
        axon = neuron_out.section(40)
        ok_(axon.type == NeuriteType.axon)
        assert_array_equal(
            neuron_in.section(40).points[0],
            neuron_out.section(40).points[0])

        ok_(
            len(neuron_out.section(40).points) == len(
                neuron_in.section(40).points),
            'The section should not have been regrown')
示例#3
0
文件: cli.py 项目: jdcourcol/NeuroR
def file(input_file, output_file, plot_file, axon_donor, cut_file):
    '''Repair dendrites of a cut neuron'''
    from neuror.main import repair  # pylint: disable=redefined-outer-name
    import pandas

    if cut_file:
        cut_points = pandas.read_csv(Path(cut_file).with_suffix('.csv')).values
    else:
        cut_points = None
    repair(input_file,
           output_file,
           axons=axon_donor,
           cut_leaves_coordinates=cut_points,
           plot_file=plot_file)
示例#4
0
def test_repair_no_trunk():
    '''Test repair when the morph has oblique sections but no trunk'''
    filename = DATA_PATH / 'Fluo42_right.h5'
    with TemporaryDirectory('test-no-trunk') as tmp_folder:
        outfilename = Path(tmp_folder, 'out.asc')
        test_module.repair(filename, outfilename, legacy_detection=True)
示例#5
0
def test_repair_no_intact_axon():
    filename = DATA_PATH / 'no-intact-basals.h5'
    with TemporaryDirectory('test-cli-axon') as tmp_folder:
        outfilename = Path(tmp_folder, 'out.asc')
        test_module.repair(filename, outfilename, axons=[filename])