NeuroMorphoCache#
- class braincell.io.NeuroMorphoCache(root)[source]#
First-class cache over locally-downloaded NeuroMorpho.Org neurons.
Owns a
NeuroMorphoCacheLayoutand provides discovery and loading operations. Replaces the loosefind_standard_swcandload_cached_metadatahelpers from previous versions.- Parameters:
root (
str|Path) – Directory containing one subfolder per cached neuron. The directory is created lazily on first write.- Variables:
root (Path)
layout (NeuroMorphoCacheLayout)
Examples
>>> cache = NeuroMorphoCache("~/data/neuromorpho") >>> for neuron_id in cache.list_neurons(): ... morph = cache.load(neuron_id)
- clear()[source]#
Delete every per-neuron folder under
root.Does not delete files at the root level that are not neuron folders.
- Returns:
Number of folders that were removed.
- Return type:
- load(neuron_id, *, mode='neuromorpho', return_report=False)[source]#
Load a cached neuron as a
Morphology.Parses the cached standardized SWC file with
Morphology.from_swc().- Parameters:
- Return type:
- Raises:
FileNotFoundError – If no standardized SWC file is cached for neuron_id.
- measurement(neuron_id)[source]#
Return the typed measurement for neuron_id, if cached.
- Parameters:
neuron_id (
int)- Returns:
Nonewhen no metadata file is present or it does not contain ameasurementblock.- Return type:
- metadata(neuron_id)[source]#
Return the parsed
metadata.jsonfor neuron_id.- Parameters:
neuron_id (
int)- Return type:
- Raises:
FileNotFoundError – If the metadata file does not exist.
- original_file_path(neuron_id)[source]#
Return the path of the cached original (Source-Version) file.
- standard_swc_path(neuron_id)[source]#
Return the path of the cached standardized SWC file.
Resolves the path by reading
metadata.jsonfor the neuron name when available, otherwise falls back to*.CNG.swcthen*.swcglob inside the per-neuron folder.
- status(neuron_id)[source]#
Return a
NeuroMorphoCacheStatussnapshot for neuron_id.- Parameters:
neuron_id (
int)- Return type: