Skip to main content

A tool for quick and easy preprocessing and visualization of fNIRS data

Project description

neuropipeline

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

Usage

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

fnirs = fNIRS("path/to/your_data.snirf")
fnirs.preprocess(optical_density=True,
                 hemoglobin_concentration=True,
                 motion_correction=True,
                 temporal_filtering=True,
                 detrending=True,
                 normalization=False # Only use normalization if necessary
                 )

# WARNING: Be cautious not to overwrite any data you want to keep.
fnirs.write_snirf("path/to/your/new_processed_data.snirf") 

nplv.open(fnirs)

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.

Supination case Pronation case
Supination Pronation

Installation

python -m pip install neuropipeline

Advanced Usage

from neuropipeline import fNIRS, fNIRSPreprocessor
from neuropipeline.fnirs import visualizer as nplv

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

# Advanced Preprocessing Configuration
pp = fNIRSPreprocessor(fnirs) # Create preprocesssor
pp.set_optical_density(True) # Configure
pp.set_hemoglobin_concentration(True)
pp.set_motion_correction(True)
pp.set_temporal_filtering(True, lowcut=0.01, highcut=0.2, order=15)
pp.set_detrending(True)
pp.set_normalization(False)

pp.print() # Inspect the settings

fnirs.preprocess(pp) # Pass the preprocesser only

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

nplv.set_spectrogram_limits(0.0, 0.2) # The spectrogram will show frequencies from  0 to 0.2 Hz 

nplv.set_marker_dictionary({2:"Rest",      # Display as text rather than indices
                             3:"Stimuli A", 
                             4:"Stimuli B"})

nplv.set_spectrum_mode("FFT") # What type of spectrum to show: "FFT" or "PSD"

# NOTE : The wavelet method is computationally intensive
# Try "STFT" first, then "Wavelet" if needed
nplv.set_spectrogram_method("Wavelet") 

nplv.open(fnirs)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

neuropipeline-0.2.3.tar.gz (46.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

neuropipeline-0.2.3-py3-none-any.whl (54.7 kB view details)

Uploaded Python 3

File details

Details for the file neuropipeline-0.2.3.tar.gz.

File metadata

  • Download URL: neuropipeline-0.2.3.tar.gz
  • Upload date:
  • Size: 46.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for neuropipeline-0.2.3.tar.gz
Algorithm Hash digest
SHA256 ff45c89184aa342f368373f9a71385365de09f2c899691a2e6ac2110a1ff3f32
MD5 b57ae96dd0cc2af98309c5ab43fdb486
BLAKE2b-256 b37332db3ad52e0e69d6ed540ac410e2fb24a4fe539e6ddce0a59885a962fc4f

See more details on using hashes here.

File details

Details for the file neuropipeline-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: neuropipeline-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 54.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for neuropipeline-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bb6d2d03a8af1b769b41ed2cbd081024c1b0d640da39c61269d51927dae8b520
MD5 89286ced6d4c5a4a9989a979ac647e4e
BLAKE2b-256 7046f2fef467114680d7a2d9a0b100d47189f71a69d5f2eafced371af951a53f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page