Metadata-Version: 2.4
Name: phasor-handler
Version: 3.1.3
Summary: A PyQt6 GUI toolbox for processing two-photon phasor imaging data
Author-email: Josia Shemuel <joshemuel@users.noreply.github.com>
License: MIT License
        
        Copyright (c) 2025 Josia Shemuel
        
        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.
Project-URL: Homepage, https://github.com/joshemuel/Phasor-Handler
Project-URL: Repository, https://github.com/joshemuel/Phasor-Handler
Project-URL: Issues, https://github.com/joshemuel/Phasor-Handler/issues
Keywords: two-photon,phasor,imaging,calcium,neuroscience,suite2p
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Classifier: Topic :: Scientific/Engineering :: Image Processing
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Operating System :: Microsoft :: Windows
Classifier: Environment :: X11 Applications :: Qt
Requires-Python: <3.10,>=3.9.23
Description-Content-Type: text/markdown
License-File: LICENSE.md
Requires-Dist: PyQt6>=6.4.0
Requires-Dist: numpy<2.0.0,>=1.21.0
Requires-Dist: matplotlib>=3.5.0
Requires-Dist: tifffile>=2021.11.2
Requires-Dist: pyyaml>=6.0
Requires-Dist: suite2p<1.0.0,>=0.14.0
Requires-Dist: pyqtdarktheme>=1.0.0
Requires-Dist: Pillow>=9.0.0
Requires-Dist: scikit-image>=0.19.0
Requires-Dist: scipy>=1.7.0
Requires-Dist: npTDMS>=1.2.0
Requires-Dist: pandas>=1.3.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: black>=22.0.0; extra == "dev"
Requires-Dist: flake8>=4.0.0; extra == "dev"
Dynamic: license-file

# Phasor-Handler (Windows)

Phasor Handler is a toolbox for processing raw two-photon phasor imaging data:  **convert → register → explore → extract calcium traces**.  
It provides a PyQt6 GUI for viewing registered or raw stacks (Ch1/Ch2), z-projections (std/max/mean), drawing/storing ROIs, overlaying stimulated ROIs from metadata, and exporting ROI traces.

> ⚠️ **Platform:** Windows 10/11 only  
> 🚀 **Version 3.0** — Latest stable release

---

## Features

- Load **registered TIFF** (`Ch1-reg.tif`, `Ch2-reg.tif`) or **raw NPY** fallbacks (`ImageData_Ch0_TP0000000.npy`, `ImageData_Ch1_TP0000000.npy`)
- Linear and non-linear motion-correct **TIFF images** using Suite2p
- Automated cell detection using Suite2p
- Channel switching (Ch1/Ch2) and **Composite (G/R)**
- **Z-projections**: standard deviation, max, mean
- **Brightness & Contrast (BnC)**: adjust image display settings
- **ROI tools**: draw elliptical ROIs, **freehand drawing tool**, translate or rotate ROIs, **move multiple ROIs**, save/load as JSON, quick-select saved ROIs
- **Metadata viewer**: inspect experiment metadata directly in the application
- **Second-level analysis viewer**: explore and visualize second-level analysis results
- **Stimulus overlay**: show stimulated ROI locations from experiment metadata and add to the saved ROIs
- **Trace plotting**: configurable formula, custom y-limits, frame/time (s) x-axis
- **Export**: write per-ROI traces for all frames to `.txt` (tab-separated)
- Keyboard: `R` save/add ROI, `Delete` remove selected ROI, `Esc` clear selection, `Alt+S` load stimulated ROIs, `Right Click + drag` translate selected ROI, `Y` toggle right click to rotation mode

---

## Input data layout

For each dataset directory, Phasor Handler looks for any of: 

- Ch1-reg.tif
- Ch2-reg. tif                 # optional
- ImageData_Ch0_TP0000000.npy # raw fallback for Ch1
- ImageData_Ch1_TP0000000.npy # optional raw fallback for Ch2
- experiment_summary.pkl      # optional metadata (or .json)

Registered TIFFs are preferred when available; raw NPYs are used as fallback.

---

## Installation

Phasor Handler is now available on **PyPI** and can be installed via pip or from source using Conda/Mamba. 

### Option 1: Install via pip (Recommended)

The easiest way to install Phasor Handler is through pip:

```powershell
pip install phasor-handler
```

After installation, you can run the application: 

```powershell
phasor-handler
```

**PyPI Package:** [https://pypi.org/project/phasor-handler/](https://pypi.org/project/phasor-handler/)

### Option 2: Install from source (Windows, Conda)

This project provides an `environment.yml` for Windows. The environment is large (GUI, image I/O, napari/suite2p), so **mamba** is recommended, but `conda` works too.

#### 1) Install Conda/Mamba (if needed)
- Install **Miniconda** or **Mambaforge** on Windows.
- (Optional) Add mamba for faster solves:
  ```powershell
  conda install -n base -c conda-forge mamba
  ```

#### 2) Get the code
- Clone the repo and change into it:
  ```powershell
  git clone https://github.com/joshemuel/Phasor-Handler.git
  cd Phasor-Handler
  ```
- Alternatively, you can download the entire project as a zip file, unzip it, then open that directory in **Miniconda**

#### 3) Create the environment
- Using mamba:
  ```powershell
  mamba env create -f environment.yml
  ```
- Using conda:
  ```powershell
  conda env create -f environment.yml
  ```

#### 4) Activate and run
- Before running the toolbox, activate the environment:
  ```powershell
  conda activate suite2p
  python app.py
  ```

---

## Update (Windows, Conda)

### If installed via pip: 
```powershell
pip install --upgrade phasor-handler
```

### If installed from source: 

#### 1) Go to your local repo and pull the latest code from the branch you use
```powershell
cd Phasor-Handler
git pull --ff-only
```

---
