Metadata-Version: 2.4
Name: neuromorphopy
Version: 0.3.3
Summary: Lightweight standalone python CLI tool for downloading neuron morphologies from the NeuroMorpho archives.
Project-URL: repository, https://github.com/kpeez/neuromorphopy
Project-URL: documentation, https://neuromorphopy.readthedocs.io/en/latest/
Author-email: Kyle Puhger <krpuhger@gmail.com>
License: MIT License
        
        Copyright (c) 2022, Kyle Puhger
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: morphology,neuromorpho,neurons,neuroscience
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.11
Requires-Dist: httpx>=0.28.1
Requires-Dist: pandas>=2.2.3
Requires-Dist: pydantic>=2.11.3
Requires-Dist: pyyaml>=6.0.2
Requires-Dist: tqdm>=4.67.1
Requires-Dist: typer>=0.15.2
Description-Content-Type: text/markdown

# neuromorphopy

[![License](https://img.shields.io/github/license/kpeez/neuromorphopy)](https://img.shields.io/github/license/kpeez/neuromorphopy)
[![Documentation](https://img.shields.io/badge/docs-latest-blue.svg)](https://neuromorphopy.readthedocs.io/)
[![PyPI](https://badge.fury.io/py/neuromorphopy.svg)](https://badge.fury.io/py/neuromorphopy)

<p align="left">
  <img src="https://raw.githubusercontent.com/kpeez/neuromorphopy/main/docs/assets/logo.png" width="350" alt="Neuromorphopy logo">
</p>

**neuromorphopy** is a lightweight, standalone Python CLI tool and library for efficiently searching and downloading neuron morphologies from the [NeuroMorpho.org](https://neuromorpho.org/) archives.

## Features

- **Efficient Downloads:** Uses asynchronous I/O (`httpx` + `asyncio`) for fast, concurrent downloads.
- **Flexible Querying:** Search using simple YAML or JSON configuration files.
- **Metadata Management:** Automatically cleans and saves neuron metadata to CSV.
- **Smart Validation:** Validates search queries against the API schema before execution.
- **Robust:** Handles legacy SSL requirements of the NeuroMorpho API automatically.

## Installation

`neuromorphopy` requires Python 3.11 or later.

### CLI Installation (Recommended)

The best way to install the tool for command-line use is with [`uv`](https://github.com/astral-sh/uv):

```bash
# Install the latest release
uv tool install neuromorphopy

# Or install the latest development version from GitHub
uv tool install git+https://github.com/kpeez/neuromorphopy.git
```

### Development Installation

To work on the codebase or run from source:

1. Clone the repository:

   ```bash
   git clone https://github.com/kpeez/neuromorphopy.git
   cd neuromorphopy
   ```

2. Sync dependencies:

   ```bash
   uv sync
   # OR using just
   just install
   ```

## Usage

### 1. Create a Query File

Define your search criteria in a `query.yaml` (or `.json`) file:

```yaml
filters:
  species: ["mouse", "rat"]
  brain_region: ["neocortex"]
  cell_type: ["pyramidal"]
sort:
  field: "brain_region"
  order: "ascending"
```

### 2. Run Commands

Use the `neuromorpho` command to explore, preview, and download.

**Explore Fields:**
See what fields and values are available for filtering.

```bash
# List all filterable fields
neuromorpho fields

# List valid values for a specific field
neuromorpho fields species
```

**Preview Download:**
Check how many neurons match your query without downloading files.

```bash
neuromorpho preview query.yaml
```

**Download Data:**
Download the SWC morphology files and metadata.

```bash
# Download to default ./neurons directory
neuromorpho download query.yaml

# Download to a specific directory with higher concurrency
neuromorpho download query.yaml --output-dir ./data --concurrent 50

# Group downloaded files by species and brain region
neuromorpho download query.yaml --group-by species,brain_region
```

## Documentation

For more detailed usage, see our [documentation](https://neuromorphopy.readthedocs.io/en/latest/getting_started/).
