Example #1
0
def test_has_sequential_ids_bad_data():

    f = os.path.join(SWC_PATH, 'Neuron_missing_ids.swc')

    ok, ids = check.has_sequential_ids(load_data(f))
    nt.ok_(not ok)
    nt.ok_(ids == [6, 217, 428, 639])
Example #2
0
def test_has_sequential_ids_bad_data():

    f = os.path.join(SWC_PATH, 'Neuron_missing_ids.swc')

    ok, ids = check.has_sequential_ids(load_data(f))
    nt.ok_(not ok)
    nt.ok_(ids == [6, 217, 428, 639])
Example #3
0
def test_has_sequential_ids_good_data():

    files = [
        os.path.join(SWC_PATH, f) for f in [
            'Neuron.swc', 'Single_apical_no_soma.swc', 'Single_apical.swc',
            'Single_basal.swc', 'Single_axon.swc', 'Neuron_zero_radius.swc',
            'sequential_trunk_off_0_16pt.swc',
            'sequential_trunk_off_1_16pt.swc',
            'sequential_trunk_off_42_16pt.swc',
            'Neuron_no_missing_ids_no_zero_segs.swc'
        ]
    ]

    for f in files:
        ok, ids = check.has_sequential_ids(load_data(f))
        nt.ok_(ok)
        nt.ok_(len(ids) == 0)
Example #4
0
def test_has_sequential_ids_good_data():

    files = [os.path.join(SWC_PATH, f)
             for f in ['Neuron.swc',
                       'Single_apical_no_soma.swc',
                       'Single_apical.swc',
                       'Single_basal.swc',
                       'Single_axon.swc',
                       'Neuron_zero_radius.swc',
                       'sequential_trunk_off_0_16pt.swc',
                       'sequential_trunk_off_1_16pt.swc',
                       'sequential_trunk_off_42_16pt.swc',
                       'Neuron_no_missing_ids_no_zero_segs.swc']
             ]

    for f in files:
        ok, ids = check.has_sequential_ids(load_data(f))
        nt.ok_(ok)
        nt.ok_(len(ids) == 0)
Example #5
0
def load_neuron(filename, tree_action=None):
    """
    Loads a neuron keeping a record of the filename.
    Args:
        filename: the path of the file storing morphology data
        tree_action: optional function to run on each of the neuron's
        neurite trees.
    Raises: SomaError if no soma points in data.
    Raises: NonConsecutiveIDsError if filename contains non-consecutive
    point IDs
    """

    data = load_data(filename)
    if not has_sequential_ids(data)[0]:
        raise NonConsecutiveIDsError('Non consecutive IDs found in raw data')

    nrn = make_neuron(data, tree_action)
    nrn.name = os.path.splitext(os.path.basename(filename))[0]

    return nrn
Example #6
0
def load_neuron(filename, tree_action=None):
    """
    Loads a neuron keeping a record of the filename.
    Args:
        filename: the path of the file storing morphology data
        tree_action: optional function to run on each of the neuron's
        neurite trees.
    Raises: SomaError if no soma points in data.
    Raises: NonConsecutiveIDsError if filename contains non-consecutive
    point IDs
    """

    data = load_data(filename)
    if not has_sequential_ids(data)[0]:
        raise NonConsecutiveIDsError('Non consecutive IDs found in raw data')

    nrn = make_neuron(data, tree_action)
    nrn.name = os.path.splitext(os.path.basename(filename))[0]

    return nrn