morph_tool.morphdb

Provides two classes to work with neurondb files.

The main use is to provide a neuronDB loader and a method to retrieve information as a dataframe.

Example: old_release = MorphDB.from_neurondb(Path(“/release/one/neuronDB.xml”), label=’old-release’) new_release = MorphDB.from_neurondb(Path(“/release/two/neuronDB.xml”), label=’new-release’) total = old_release + new_release

# neurondb information print(total.df)

# combined information (neurondb + morph_stats) print(total.features({‘neurite’: {‘section_lengths’: [‘max’]}}))

Classes

MorphDB([morph_info_seq])

A MorphInfo container.

MorphInfo(name, mtype[, layer])

A class the contains information about a morphology.

class morph_tool.morphdb.MorphDB(morph_info_seq: Iterable[MorphInfo] | None = None)

A MorphInfo container.

It takes care of maintaining uniqueness of the MorphInfo element and methods to write neurondb to various format (xml, dat, csv)

check_files_exist()

Raises if self.df.path has None values or non existing paths.

features(config: Dict, n_workers=1)

Returns a dataframe containing morphometrics and neurondb information.

Parameters:
Returns:

A jointure dataframe between neurom.stats.extract_dataframe and self.df

Raises:

ValueError – if self.df has undefined (ie. None) paths

classmethod from_folder(morphology_folder: Path | str, mtypes: Iterable[Tuple[str, str]], label: str = 'default', extension: str | None = None)

Factory method to create a MorphDB object from a folder containing morphologies.

Parameters:
  • morphology_folder – a folder containing morphologies

  • mtypes – a sequence of 2-tuples (morphology name, mtype)

  • label – (optional) a group label to be used to identify the morphlogies from this folder

  • extension – Specify the morphology format to consider, if the folder contains multiple formats

Raises: ValueError if the folder contains multiple files with the same name but different extensions and the extension argument has not been provided :returns: an instance of MorphDB. :rtype: MorphDB

classmethod from_neurondb(neurondb: Path | str, label: str = 'default', morphology_folder: Path | str | None = None)

Builds a MorphologyDB from a neurondb.(xml|dat) file.

Parameters:
  • neurondb – path to a neurondb.(xml|dat) file

  • label – a unique label to mark all morphologies coming from this neurondb

  • morphology_folder – the location of the morphology files, if None it will default to the neurondb folder

Raises: ValueError if the neurondb does not abide by the specification https://bbpteam.epfl.ch/documentation/projects/morphology-repair-workflow/latest/input_files.html#specification

..note:: missing keys are filled with True values

write(output_path: Path | str)

Write the neurondb file to XML or DAT format.

Parameters:

output_path – the output path

class morph_tool.morphdb.MorphInfo(name: str, mtype: str, layer: str | int | None = None, **kwargs)

A class the contains information about a morphology.

Its role is to abstract away the raw data.

property row: List

Flattened data structude ready to be used by a dataframe.