Metadata-Version: 2.4
Name: cicada-analysis
Version: 0.5.0
Summary: CICADA analysis framework – headless analysis engine and plugins
Project-URL: Documentation, https://cicada-analysis.readthedocs.io/
Project-URL: Repository, https://gitlab.com/cossartlab/cicada_analysis
Project-URL: Issues, https://gitlab.com/cossartlab/cicada_analysis/-/issues
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: cicada-nwb<0.6,>=0.5
Requires-Dist: numpy<3,>=2.0
Requires-Dist: pandas<4,>=2.2.2
Requires-Dist: scipy<2,>=1.13
Requires-Dist: matplotlib<4,>=3.8.4
Requires-Dist: seaborn<0.14,>=0.13
Requires-Dist: scikit-learn<2,>=1.4.2
Requires-Dist: scikit-image<0.27,>=0.24
Requires-Dist: opencv-python<6,>=4.10.0.84
Requires-Dist: tifffile>=2023.1.23
Requires-Dist: Pillow<14,>=10.0
Requires-Dist: networkx<4,>=3.2
Requires-Dist: shapely<3,>=2.0.4
Requires-Dist: fa2-modified<0.5,>=0.4
Requires-Dist: sortedcontainers<3,>=2.4
Requires-Dist: tqdm<5,>=4.64
Requires-Dist: PyYAML<7,>=6.0
Requires-Dist: openpyxl<4,>=3.1
Requires-Dist: psutil<8,>=5.9
Requires-Dist: packaging>=23.0
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: ruff<0.18,>=0.17; extra == "dev"
Provides-Extra: docs
Requires-Dist: zensical==0.0.74; extra == "docs"
Requires-Dist: mkdocstrings[python]<2,>=1.0; extra == "docs"
Dynamic: license-file

# CICADA Analysis

[![Documentation](https://readthedocs.org/projects/cicada-analysis/badge/?version=latest)](https://cicada-analysis.readthedocs.io/en/latest/analysis/)

<!-- --8<-- [start:intro] -->
`cicada-analysis` runs analyses on NWB files, without the GUI: from a
Python script, the command line or YAML files. It is for users who want to analyze their data in
batches, on a server, and replay a run exactly. It provides the analysis plugins and the
computation library behind them ([`cicada-tools`](https://cicada-analysis.readthedocs.io/en/latest/analysis/cicada_tools_quickstart/)),
and is the engine of the CICADA pipeline ([BiorXiv preprint](https://www.biorxiv.org/content/10.64898/2026.07.03.736318v1)).
<!-- --8<-- [end:intro] -->

CICADA is three installable packages: [`cicada-nwb`](https://gitlab.com/cossartlab/cicada_nwb)
(opens NWB files), `cicada-analysis` (this package) and [`cicada-gui`](https://gitlab.com/cossartlab/cicada_gui)
(desktop application). **Full documentation: [cicada-analysis.readthedocs.io](https://cicada-analysis.readthedocs.io/en/latest/analysis/)**.

## Install

<!-- --8<-- [start:install-user] -->
From PyPI:
```bash
conda create -n cicada_env python=3.11
conda activate cicada_env
pip install cicada-analysis
```

Or from GitLab, a given release (tag):
```bash
conda create -n cicada_env python=3.11
conda activate cicada_env
pip install "git+https://gitlab.com/cossartlab/cicada_analysis.git@0.5.0"
```
<!-- --8<-- [end:install-user] -->

To upgrade:

<!-- --8<-- [start:upgrade-user] -->
From PyPI, the latest release:
```bash
conda activate cicada_env
pip install -U cicada-analysis
```

Or from GitLab, a given release: replace the tag with its version (check available releases on [GitLab](https://gitlab.com/cossartlab/cicada_analysis/-/releases)):
```bash
conda activate cicada_env
pip install "git+https://gitlab.com/cossartlab/cicada_analysis.git@<new_version>"
```
<!-- --8<-- [end:upgrade-user] -->

**Windows: enable long paths.**

<!-- --8<-- [start:windows-long-paths] -->
Windows limits file paths to 259 characters unless long paths are enabled. Some analyses write files in
sub-folders with long names, so with a results folder deep in your tree, saving can fail ("No such file or
directory"). CICADA warns at the start of a run when this may happen. To remove the limit, once, as
administrator:

```bash
reg add HKLM\SYSTEM\CurrentControlSet\Control\FileSystem /v LongPathsEnabled /t REG_DWORD /d 1 /f
```

(or *Local Group Policy Editor* > Computer Configuration > Administrative Templates > System > Filesystem >
*Enable Win32 long paths*), then restart. Otherwise, choose a results folder with a short path (e.g. `C:\results`).
macOS and Linux have no such limit.
<!-- --8<-- [end:windows-long-paths] -->

## Quick start

<!-- --8<-- [start:quickstart] -->
An analysis runs from two YAML files: a sessions file (the NWB files) and a parameters file (the
analysis and its parameter values). Each step is a command or a
[template script](https://gitlab.com/cossartlab/cicada_analysis/-/tree/master/templates).
The example uses Display activity, class `CicadaDisplayRasterAnalysis`.

**Step 0. List the NWB files** in a sessions YAML (a local folder, or a DANDI address such as
`dandi://000219@0.260826.1155/sub-180201-180208`; `-r`: sub-folders too):

```bash
cicada-config sessions /path/to/nwb_folder -o sessions.yaml -r
```

_Template script_: `generate_sessions_config_template.py`.

**Step 1. Generate the parameters file**: every parameter with its default value, and the choices found in the sessions:

```bash
cicada-config params CicadaDisplayRasterAnalysis -s sessions.yaml -o params.yaml --results-path results
```

_Template script_: `generate_config_template.py`.

**Step 2. Edit the parameters** in a text editor. Each parameter is one line: its value, then after
the `#` its type, its choices, `MANDATORY` if it must have a value, and its help. Only the value is read:

```yaml
data_to_display: auto  # choices:['auto', 'imaging', 'spikes', 'LFPs'] | Data to display
time_slice: true  # type:bool | Plot slice of time
time_slice_end: 600  # type:int | range:0-39490 | Slice end time (seconds) | used when time_slice = True
results_path: results  # type:dir | Directory to save the results
```

Set the `MANDATORY` parameters that have no value. `results_path` is an existing
folder (step 1 creates the one it writes) or empty (the results then go to `<Downloads folder>/cicada/results`).

**Step 3. Run**:

```bash
cicada-run -s sessions.yaml -p params.yaml
```

_Template script_: `run_from_config_template.py`.

Each run writes a results folder with a `combined_<ClassName>_<timestamp>.yaml` that records the run;
replay it with `cicada-run --replay combined_<ClassName>_<timestamp>.yaml` (see
[Replaying a previous run](https://cicada-analysis.readthedocs.io/en/latest/analysis/headless_workflow/#replaying-a-previous-run)).
<!-- --8<-- [end:quickstart] -->

No data at hand? Nine small demo NWB files are installed with the package, with the configs that
make the panels of Figure 3 of the CICADA paper: see the
[Demo page](https://cicada-analysis.readthedocs.io/en/latest/overview/demo/).

## Documentation

Headless workflow, plugin catalogue, writing plugins, cicada-tools and the GUI guide:
[cicada-analysis.readthedocs.io](https://cicada-analysis.readthedocs.io/en/latest/analysis/).

<details>
<summary>Contributing: install from a clone, upgrade, source tree</summary>

<!-- --8<-- [start:install-dev] -->
**Contributing to `cicada-analysis` only** (`cicada-nwb` installed from PyPI):

```bash
git clone https://gitlab.com/cossartlab/cicada_analysis.git /path/to/cicada_analysis
conda create -n cicada_env python=3.11
conda activate cicada_env
pip install -e "/path/to/cicada_analysis[dev]"
```

**Contributing to both `cicada-analysis` and `cicada-nwb`** (install `cicada-nwb` first: `cicada-analysis` then uses your local clone, whose version is within its range):

```bash
git clone https://gitlab.com/cossartlab/cicada_nwb.git /path/to/cicada_nwb
git clone https://gitlab.com/cossartlab/cicada_analysis.git /path/to/cicada_analysis
conda create -n cicada_env python=3.11
conda activate cicada_env
pip install -e "/path/to/cicada_nwb[dev]"
pip install -e "/path/to/cicada_analysis[dev]"
```
<!-- --8<-- [end:install-dev] -->

To upgrade a clone:

<!-- --8<-- [start:upgrade-dev] -->
**If you only cloned `cicada_analysis`**: pull it, then update `cicada-nwb` from PyPI.

```bash
cd /path/to/cicada_analysis && git pull
conda activate cicada_env
pip install -U cicada-nwb
```

**If you cloned both repos**: pull each.

```bash
cd /path/to/cicada_nwb && git pull
cd /path/to/cicada_analysis && git pull
```
<!-- --8<-- [end:upgrade-dev] -->

What is inside:

<!-- --8<-- [start:inside] -->
```
cicada_analysis/
├── base/                  # CicadaAnalysis (plugin base class), parameter schema and rules,
│                          # family base classes (events, groups, PSTH)
├── config/                # Headless runner (generate_config, run_from_config) and YAML I/O
├── core_analysis/         # Core plugins (standard NWB data only)
├── cicada_tools/          # Computation and figure library used by the plugins
└── demo/                  # Small demo NWB files (also the plugin test files)
```
<!-- --8<-- [end:inside] -->

</details>
