Metadata-Version: 2.4
Name: tnbsclean
Version: 1.20
License: MIT
Classifier: License :: OSI Approved :: MIT License
Description-Content-Type: text/markdown
Requires-Dist: numpy
Requires-Dist: matplotlib
Requires-Dist: mne
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: license
Dynamic: requires-dist

# tnbsclean

## Description
`tnbsclean` is a Python package for preprocessing neurophysiological data.  
It helps clean EEG, MEG, EMG, and ECG signals in [MNE-Python](https://mne.tools) by removing stimulation artifacts, and it supports converting Blackrock `.nsx` recordings into MNE Raw objects for seamless analysis.


## Installation

You can install the package via pip from PyPI:

```bash
pip install tnbsclean
```

## Example use for data cleaning from mne raw object

```bash
import tnbsclean as tnbs

# Example parameters
raw  # Raw time series data in MNE's raw object format
half_win = 3  # Half window size around each stimulus (in samples) that will be chopped away from the artifact peak point
threshold = 2  # Threshold constant above which stimulus is considered significant

# Apply stimulus cleaning 
raw_cleaned, spike_idxs = tnbs.get_stim_markers(raw, half_win, threshold) #cleans based on ECG, returns spike indices
```

## Example use for converting nsx files mne raw object

```bash
# Example parameters for reading Blackrock data
folder        = r'/path/to/data'
aux_chann     = ['L_EMG1', 'R_EMG1', 'ECG']
chan_type_map = {'L_EMG1': 'emg', 'R_EMG1': 'emg', 'ECG': 'ecg'}
file_type     = 'hub'
extension     = 'ns3'

# Load raw data
raw = tnbs.read_blackrock(folder, aux_chann, chan_type_map, file_type, extension)

```
