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.4.tar.gz (47.3 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.4-py3-none-any.whl (55.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: neuropipeline-0.2.4.tar.gz
  • Upload date:
  • Size: 47.3 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.4.tar.gz
Algorithm Hash digest
SHA256 69c7abd17de186fa412411f011944084a7527424aa28f090da4c851297cec402
MD5 f44ee0afd36eeab9d853eaae3605afd8
BLAKE2b-256 0dd7d5af899aa651b1cdf61dcf0d31135c73d2da81725ed853ecd6fb1d500ccf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: neuropipeline-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 55.5 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 716766d3eecae0d31ab7a03822ee3d07865fb2172e59d693f1b3614eda44ab1a
MD5 ad939b870db40b5ec2486169783c3be8
BLAKE2b-256 a45e71749e3b6ff2e69e714d04a5dd78096769b7189a1fa4bd101048a3880f7a

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