Metadata-Version: 2.1
Name: viewephys
Version: 1.3.1
Summary: Neuropixel raw data viewer
Author: Olivier Winter
License: MIT
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Project-URL: Homepage, https://github.com/int-brain-lab/viewephys
Project-URL: Bug Tracker, https://github.com/int-brain-lab/viewephys/issues
Requires-Python: >=3.10
Requires-Dist: ibl-neuropixel>=1.0.1
Requires-Dist: ibllib
Requires-Dist: iblutil>=1.6.0
Requires-Dist: numpy
Requires-Dist: pandas
Requires-Dist: probeinterface
Requires-Dist: pyqtgraph>=0.13.1
Requires-Dist: qtpy
Requires-Dist: scipy
Requires-Dist: spikeinterface
Provides-Extra: lfpack
Requires-Dist: lfpack; extra == "lfpack"
Requires-Dist: iblatlas; extra == "lfpack"
Provides-Extra: nwb
Requires-Dist: h5py; extra == "nwb"
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-qt; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: coverage; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: codespell; extra == "dev"
Provides-Extra: pyqt5
Requires-Dist: PyQt5>=5.15.0; extra == "pyqt5"
Provides-Extra: pyqt6
Requires-Dist: PyQt6>=6.2.0; extra == "pyqt6"
Provides-Extra: pyside2
Requires-Dist: PySide2>=5.15.0; extra == "pyside2"
Provides-Extra: pyside6
Requires-Dist: PySide6>=6.2.0; extra == "pyside6"
Provides-Extra: qt
Requires-Dist: PyQt5>=5.15.0; extra == "qt"
Description-Content-Type: text/markdown

# viewephys
Neuropixel raw data viewer

## Installation
`pip install viewephys`

Alternatively, in development mode:
```shell
git clone https://github.com/int-brain-lab/viewephys.git
cd viewephys
pip install -e .
```

### Supported environments
This is compatible with the [IBL environment](https://github.com/int-brain-lab/iblenv)

Otherwise, you can create a new environment as such:
```shell
conda create -n viewephys python=3.12
conda activate viewephys
```
And then follow the install instructions above.

## Controls
- `ctrl + z`: -3dB gain
- `ctrl + a`: +3dB gain
- `ctrl + p`: in multi-windows mode, link the displays (pan, zoom and gain)

### Pick spikes
When the picking mode is enabled (menu pick)
- left button click sets a point
- shift + left button removes a point
- control + left does not wrap on maximum around pick
- space increments the spike group number


## Examples

### Visualize raw data through the GUI
Activate your environment and type `viewephys`. Use `File > open > SpikeGLX` to load a neuropixel binary file, or `File > open > Open Ephys` to select an Open Ephys folder (containing `structure.oebin`). The GUI will prompt you to select a specific recording and data stream if multiple exist. `File > open > NWB` loads an NWB file containing an electrical series. If the file holds several electrical series you are prompted to select one.

For recordings without probe information, `Probe > Load from probeinterface library` allows for attaching probe geometries of different manufacturers and models from the probeinterface library (fetched online) to recordings. Channels are then shown at their positions on the probe, and can be spatially sorted.

![alt text](./docs/raw_bin_viewer_destripe.png "Ephys viewer ")

### Visualize raw binary file through the command line
Alternatively you can point the viewer to a specific file using the command line:
```shell
viewphys -f /path/to/raw.bin
```

### Load in a numpy array or slice

`viewephys` can be used through the Python console or iPython, allowing you to create
multiple instances of the viewer at once.


```python
# if running ipython, you may have to use the `%gui qt` magic command
import numpy as np
from viewephys.gui import viewephys
nc, ns, fs = (384, 50000, 30000)  # this mimics one second of neuropixel data
data = np.random.randn(nc, ns) / 1e6  # volts by default
ve = viewephys(data, fs=fs)

# We can open multiple windows at once, but they must have different titles
data2 = data * 50
ve2 = viewephys(data, fs=fs, title="plot 2")

```
![alt text](./docs/view_rand_array.png "Ephys viewer")


Note if you are running through a script, you need to instantiate
the Qt application yourself:

#### Opening a binary file through a script

```python
from viewephys.gui import EphysBinViewer, create_app

app = create_app()

viewer = EphysBinViewer(r"C:\Users\Joe\Desktop\1119617_LSE1_shank12_g0_imec0\1119617_LSE1_shank12_g0_t0.imec0.ap.bin")

app.exec()
```

#### Load in a numpy array or slice through a script

```python

import numpy as np
from viewephys.gui import viewephys, create_app

app = create_app()

nc, ns, fs = (384, 50000, 30000)  # this mimics one second of neuropixel data
data = np.random.randn(nc, ns) / 1e6  # volts by default

ve = viewephys(data, fs=fs)
ve2 = viewephys(data * 50, fs=fs, title="plot 2")

app.exec()

```

## Contribution
Fork and PR.

Pypi Release checklist:
```shell
ruff check
rm -fR dist
rm -fR .pdm-build
pdm publish
#twine upload --repository-url https://test.pypi.org/legacy/ dist/*
```
