Skip to content

Lightweight python package for downloading neuron morphologies from the NeuroMorpho archives.

License

Notifications You must be signed in to change notification settings

kpeez/neuromorphopy

Repository files navigation

NeuroMorphopy

codecov Commit activity License

Lightweight python package for downloading neuron morphologies from the NeuroMorpho archives.

Installation

If using poetry, simply clone the repo and install

git clone https://github.com/kpeez/neuromorphopy.git
cd neuromorphopy
make install

Usage

First, import and create a NeuroMorpho object:

import neuromorphopy as nm

neuromorph = nm.NeuroMorpho()

To see a list of valid search fields you can access the valid_field_names attribute:

neuromorph.valid_field_names

Getting neuron metadata from NeuroMorpho

To search the NeuroMorpho archives, construct a search query and run search_archives(query).

The query can be explicitly written, or loaded from a json file using nm.load_json_query(path_to_query_file)

For example, to get all of the mouse interneurons and pyramidal cells from hippocampus and neocortex, you would use the following:

query = {
    "species": ["mouse"],
    "brain_region": ["neocortex", "hippocampus"],
    "cell_type": ["interneuron", "pyramidal"],
    "experiment_condition": ["Control"]
}

# alternatively
query = nm.load_json_query(path_to_query_file)

neuromorph.search_archives(query)

Note: this may take some time if you are request a large set of neurons. For example, the above query takes ~3 mins to get info for ~26,000 neurons.

The results of the search can be viewed by accessing the neuron_metadata attribute:

metadata = neuromorph.neuron_metadata

If you already have a search query, you can pass in the query dictionary at initialization to automatically get the metadata:

neuromorph = nm.NeuroMorpho(query)

Downloading morphology data

Morphology data for a single neuron (in .swc format) can be obtained by passing in the neuron_name:

neuromorph.get_neuron_swc(neuron_name)

In order to get morphological reconstructions for every neuron in the query, use get_neuron_swc:

neuromorph.download_query_swc()

Note: this takes a long time for large groups of neurons. The above query takes ~7 hours to complete.

Once completed you can access a dictionary of {neuron_name: swc_data}:

neuromorph.swc_data

Exporting data

The metadata from your query can be exported to a .csv file by providing an export path and a file name:

neuromorph.export_metadata(export_path, query_filename)

After downloading swc data you can export that as a .pkl file the same way:

neuromorph.export_swc_data(export_path, swc_filename)

About

Lightweight python package for downloading neuron morphologies from the NeuroMorpho archives.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages