Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion tmd/io/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def make_tree(data):


def load_neuron(input_file, line_delimiter='\n', soma_type=None,
tree_types=None, remove_duplicates=True):
tree_types=None, remove_duplicates=True, verbose=True):
'''
Io method to load an swc or h5 file into a Neuron object.
TODO: Check if tree is connected to soma, otherwise do
Expand Down Expand Up @@ -79,6 +79,20 @@ def load_neuron(input_file, line_delimiter='\n', soma_type=None,
except IndexError:
raise LoadNeuronError('Soma points not in the expected format')

# Remove structural annotations other than defined in TYPE_DICT
# Presence of those annotations impede loading of data when generating
# csr_matrix.
in_type_dct = _np.zeros((len(data), len(TYPE_DCT))).astype(bool)
for ind, TYPE in enumerate(TYPE_DCT.values()):
in_type_dct[:, ind] = data[:, 1] == int(TYPE)
in_type_dct = _np.sum(in_type_dct, axis=1).astype(bool)
if verbose and len(data) > _np.sum(in_type_dct):
print('LoadNeuronWarning: Loaded neuron data contains structural '
'annotations that are ignored in current TMD '
' package. Processed data only contains: %s'
% str(TYPE_DCT))
data = data[in_type_dct, :]

# Extract soma information from swc
soma = Soma.Soma(x=_np.transpose(data)[SWC_DCT['x']][soma_ids],
y=_np.transpose(data)[SWC_DCT['y']][soma_ids],
Expand Down