Metadata-Version: 2.4
Name: neuropipeline
Version: 0.1.9
Summary: A tool for quick and easy preprocessing and visualization of fNIRS data
Author-email: Adam Emile Aske <adamaske@live.no>
License-Expression: MIT
Project-URL: Homepage, https://github.com/adamaske/neuropipeline
Project-URL: Bug Tracker, https://github.com/adamaske/neuropipeline/issues
Classifier: Programming Language :: Python :: 3.8
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: numpy
Requires-Dist: pandas
Requires-Dist: mne
Requires-Dist: mne-nirs
Requires-Dist: matplotlib
Requires-Dist: snirf
Requires-Dist: nilearn
Requires-Dist: pylsl
Requires-Dist: scipy
Requires-Dist: h5py
Requires-Dist: pywavelets
Requires-Dist: pyedflib
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: flake8; extra == "dev"

# neuropipeline

`neuropipeline` is a tool for quick and easy to use preprocessing and visualization of Functional Near-Infrared Spectroscopy (fNIRS) data.  

## Usage

```python
from neuropipeline.fnirs import fNIRS
import neuropipeline.visualizer as nplv

fnirs = fNIRS("path/to/your_file.snirf")
fnirs.preprocess(optical_density=True,
                 hemoglobin_concentration=True,
                 motion_correction=True,
                 temporal_filtering=True,
                 detrending=True,
                 normalization=False
                 )

nplv.open(fnirs)

snirf.write_snirf("path/to/your_new_file.snirf") # WARNING: Be cautious not to overwrite any data you want to keep. 
```
## Analysis Example: Heel Stimulation

These plots display data from a single subject during a robotic heel-stimulation experiment, showing the Time Series, Spectrogram, and Frequency (PSD/FFT) for two different scenarios. The vertical red dashed lines indicate "markers," which show exactly when a task started or when the robot moved. In this experiment, a robot stimulated the heel 6 times. In the Supination case (left), we see a clear success: oxygenated hemoglobin (HbO) increases right when the stimuli begin. This is supported by the spectrogram, where we see "spikes" of activity at 0.025 Hz (the neurogenic band) that align perfectly with the robot's movements. This confirms the pipeline has successfully captured brain activity in the sensory cortex. In contrast, the Pronation case (right) shows consistently low activity in the spectrogram, and while the time series has some small peaks, they do not show the same clear correlation with the stimulation.

<table>
  <tr>
    <td><img src="https://raw.githubusercontent.com/adamaske/neuropipeline/main/visualization_example.jpg" alt="Supination case"/></td>
    <td><img src="https://raw.githubusercontent.com/adamaske/neuropipeline/main/visualization_example_pronation.jpg" alt="Pronation case"/></td>
  </tr>
  <tr>
    <td align="center"><em>Supination</em></td>
    <td align="center"><em>Pronation</em></td>
  </tr>
</table>

## Installation

```bash
python -m pip install neuropipeline
```

## Advanced Usage

```python
fnirs = fNIRS("path/to/your_file.snirf")

fnirs.preprocess(optical_density=True,
                 hemoglobin_concentration=True,
                 motion_correction=True,
                 temporal_filtering=True,
                 detrending=True,
                 normalization=False
                 )
nplv.set_spectrogram_limits(0.0, 0.12) # Hz

nplv.set_marker_dictionary({
    0: "Rest",
    1: "Stimuli A",
    2: "Stimuli B",
})

nplv.open(fnirs)

fnirs.write_snirf("path/to/your_new_file.snirf") # WARNING : Dont overwrite data you want to keep
```
