Convert NEURON simulator .HOC files to .SWC morphology format
Project description
hoc2swc: A Python package to convert NEURON cell HOC files to SWC morphology files
hoc2swc is a Python library that converts the morphology of neuron models defined using NEURON simulator HOC files to the popular SWC morphology format. The library can also be used to convert cell morphologies instantiated in NEURON simulator (e.g. models that were build using NEURON+Python).
Once converted to SWC, tools that can consume SWC files can be used to compute SWC morphology metrics, create professional 3D neuron morphology visualizations, etc...
Requirements
hoc2swc requires a working version of NEURON either installed from a package/installer (easier) or compiled (more challenging). Linux, Mac, and Windows versions are supported.
You must be able to run at least one of these commands in a terminal window without errors:
nrniv -python
- Or
python -c 'from neuron import h'
If you cannot run any of these commands, it indicates that there is something amiss with your NEURON installation. Search the error messages on the NEURON forum for help.
Installation and Usage
Installation and usage depends on how you installed NEURON simulator (installed vs. compiled). More customizable functionality is available for those who compiled.
If you installed a downloaded NEURON package
Download and extract this hoc2swc ZIP file to a known folder. This folder will have a script named hoc2swc.py
. Note its location.
Then, to convert a HOC file, run the following command in terminal (note the '-'s before the hoc and swc paths):
nrniv -python path/to/hoc2swc.py -path/to/cell.hoc -path/to/converted.swc
If you compiled NEURON+Python
To install the library, simply type in pip install hoc2swc
in your terminal.
Then in a Python session, run the following to convert a HOC file to SWC.
from hoc2swc import hoc2swc
hoc2swc("path/to/cell.hoc", "out.swc")
Exporting non-HOC cells
If a cell is not defined in a HOC file (e.g. defined using a custom script or using Python), you can instantiate the cell in NEURON and when it is ready for export to SWC, use the following Python script lines:
# Load your cell
from neuron import h
run_scripts_build_cell_etc()
# Export loaded cell to SWC
from hoc2swc import neuron2swc
neuron2swc("out.swc")
Note to packaged NEURON users, if you start nrniv -python
from the directory where the hoc2swc.py file is located OR append the location to the PYTHONPATH environment variable, the above lines will work for you as well.
Issues
If you encounter an issues, first make sure it's not due to NEURON itself -- this library simply interacts with the NEURON executables. If it is, please contact the NEURON team. If the issue is with this library, please create an issue on Github.
Contributing
To contribute, please open an issue first and discuss your plan for contributing. Then fork this repository and commit a pull-request with your changes.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file hoc2swc-0.1.1.tar.gz
.
File metadata
- Download URL: hoc2swc-0.1.1.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.18.4 setuptools/38.5.1 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 097a3524913c1344841afe731cd5d6084e6da83414f069c816b4451d282cc52f |
|
MD5 | e45184f4d0a5b70029e6f032faee7fa9 |
|
BLAKE2b-256 | 80e9879dc5f4458555752a037fdd0424091f0d4fea99b0dfa7933e441ec80c4b |
File details
Details for the file hoc2swc-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: hoc2swc-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.18.4 setuptools/38.5.1 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31e48e20f605d9317da4ffc00fdcf003a53094dcd1c80ceffe42b8642fc4c288 |
|
MD5 | e15939aaa53277debfd059e98d3a03b9 |
|
BLAKE2b-256 | c25669d046c2f1dcea40284e8bf8a818c4a7778b57327b147dc7b9a23e7718c3 |
File details
Details for the file hoc2swc-0.1.1-py2-none-any.whl
.
File metadata
- Download URL: hoc2swc-0.1.1-py2-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.18.4 setuptools/38.5.1 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08304c92824fa44147dceddba3dd0cf9e0ae116c917d1fd2e2faf4e7bb7493be |
|
MD5 | 691e5d2ce18085820ac91126de03199a |
|
BLAKE2b-256 | 54a346b3c8ffd8943ffded2016c9c7cf4af48b574d97377a464c3aab82ab12b2 |