pymaid.CatmaidNeuronList.has_annotation¶
- CatmaidNeuronList.has_annotation(x, intersect=False, partial=False, raise_not_found=True)[source]¶
Filter neurons by their annotations.
- Parameters:
x (str | list of str) – Annotation(s) to filter for. Use tilde (~) as prefix to look for neurons WITHOUT given annotation(s).
intersect (bool, optional) – If True, neuron must have ALL positive annotations to be included and ALL negative (~) annotations to be excluded. If False, must have at least one positive to be included and one of the negative annotations to be excluded.
partial (bool, optional) – If True, allow partial match of annotation.
raise_not_found (bool, optional) – If True, will raise exception if no match is found. If False, will simply return empty list.
- Returns:
Neurons that have given annotation(s).
- Return type:
Examples
>>> # Get neurons that have "test1" annotation >>> nl.has_annotation('test1') >>> # Get neurons that have either "test1" or "test2" >>> nl.has_annotation(['test1', 'test2']) >>> # Get neurons that have BOTH "test1" and "test2" >>> nl.has_annotation(['test1', 'test2'], intersect=True) >>> # Get neurons that have "test1" but NOT "test2" >>> nl.has_annotation(['test1', '~test2'])