Skip to content

Xiangyu-Li97/interactive-cap-analyzer

Repository files navigation

Interactive CAP Analyzer v3

A MATLAB-based interactive tool for analyzing Compound Action Potentials (CAP) from vagus nerve recordings with AUC (Area Under Curve) calculation for fiber recruitment estimation.

中文教程 (Chinese Tutorial)


What's New in v3

  • AUC Calculation: Automatically calculates area under curve for each spike
  • Fiber Recruitment Indicator: AUC_Rectified parameter for assessing nerve fiber activation
  • Enhanced Analysis: More comprehensive statistical outputs
  • Improved Export: CSV files now include all AUC parameters

Features

  • Interactive spike detection with adjustable threshold
  • Manual spike addition/deletion by clicking
  • Real-time visualization with navigation controls
  • AUC (Area Under Curve) calculation for fiber recruitment estimation
  • Export results to CSV, MAT, and summary files

Requirements

MATLAB Version

  • MATLAB R2019b or later (recommended)

Required Toolboxes

  • Signal Processing Toolbox
  • Statistics and Machine Learning Toolbox

How to Check if You Have the Toolboxes

In MATLAB Command Window, type:

ver

Look for "Signal Processing Toolbox" and "Statistics and Machine Learning Toolbox" in the list.

How to Install Toolboxes

Method 1: Through MATLAB Interface

  1. In MATLAB, go to the Home tab
  2. Click Add-OnsGet Add-Ons
  3. Search for "Signal Processing Toolbox"
  4. Click Install
  5. Repeat for "Statistics and Machine Learning Toolbox"

Method 2: Official Download Links

Note: Installing toolboxes requires a valid MATLAB license. If you're using a university or lab computer, these toolboxes are usually already included.


Quick Start

Step 1: Prepare Your Files

Place interactive_cap_analyzer_v3.m and your data file in the same folder.

MyAnalysis/
├── interactive_cap_analyzer_v3.m
└── your_data_file.tme

Step 2: Open MATLAB and Navigate to Your Folder

In MATLAB, navigate to the folder containing your files.

Step 3: Run the Analyzer

interactive_cap_analyzer_v3('your_data_file.tme', 20000, 3)

Parameters:

Parameter Description Example
filepath Path to your data file 'data.tme'
fs Sampling rate in Hz 20000
artifact_time Seconds to skip at beginning 3

User Interface Guide

Main Controls

Control Function
Threshold slider Adjust spike detection threshold
Add Mode Click to add spikes manually (button turns green)
Delete Mode Click on red dots to remove spikes (button turns red)
Auto Detect Re-detect spikes with current threshold
Clear All Remove all detected spikes
Analyze View statistical analysis with AUC
Export Save results to files

Navigation

Button Action
|< Go to start
<< Jump back (1x window)
< Step back (0.5x window)
> Step forward (0.5x window)
>> Jump forward (1x window)
>| Go to end

Window Size Options

  • 0.5s, 1s, 2s, 5s, 10s, 30s

Output Parameters

Spike Parameters (exported to CSV)

Parameter Description
SpikeNumber Sequential spike number
Time_s Spike time in seconds
Amplitude Peak amplitude
HalfWidth_ms Half-width in milliseconds
ISI_ms Inter-spike interval
InstFreq_Hz Instantaneous frequency (1000/ISI)
AUC_Positive Area under positive phase
AUC_Negative Area under negative phase
AUC_Net Net area (positive - negative)
AUC_Rectified Total absolute area (fiber recruitment indicator)

Understanding AUC (Area Under Curve)

The AUC_Rectified parameter is the key indicator for fiber recruitment:

AUC Type Meaning Physiological Significance
AUC_Positive Area above baseline Depolarization charge
AUC_Negative Area below baseline Repolarization charge
AUC_Net Positive - Negative Waveform symmetry
AUC_Rectified Positive + Negative Fiber recruitment indicator

Larger AUC_Rectified values indicate:

  • More nerve fibers firing synchronously
  • Stronger electrical activity
  • Greater compound action potential

File Descriptions

File Description
interactive_cap_analyzer_v3.m Main tool (RECOMMENDED) - Interactive analyzer with AUC
interactive_cap_analyzer_v2.m Previous version without AUC
vagus_nerve_cap_analyzer.m Automated batch analyzer
data_viewer_v2.m Simple data viewer for inspection
README.md English documentation
README.zh-CN.md Chinese documentation (中文文档)
CAP_Analyzer_Tutorial_for_Beginners.md Beginner-friendly tutorial (傻瓜教程)

Recommended Workflow

  1. Start with low threshold - Detect more spikes initially
  2. Click "Auto Detect" - Let the program find spikes
  3. Enter Delete Mode - Remove false positives (noise)
  4. Enter Add Mode - Add any missed spikes
  5. Click "Analyze" - Review statistics and AUC
  6. Click "Export" - Save your results to CSV

Troubleshooting

Q: "Unrecognized function" error?

A: Make sure you're in the correct folder. The .m file must be in MATLAB's current directory. Check the "Current Folder" panel on the left side of MATLAB.

Q: No spikes detected after "Auto Detect"?

A: Lower the threshold using the slider (drag left), then click "Auto Detect" again.

Q: Spike not appearing exactly where I clicked?

A: The program automatically finds the nearest peak within 10ms of your click. This is intentional for accuracy.

Q: How do I know my sampling rate?

A: Check your recording software settings or ask your lab supervisor. Common values are 10000, 20000, or 40000 Hz.

Q: "Toolbox not found" error?

A: Install the required toolboxes using Add-Ons → Get Add-Ons in MATLAB. See the "How to Install Toolboxes" section above.


Analysis Output Figures

When you click "Analyze", the following plots are generated:

  1. Firing Rate - Spikes per second over time
  2. ISI Distribution - Inter-spike interval histogram
  3. Half-Width Distribution - Spike duration histogram
  4. Amplitude Distribution - Peak amplitude histogram
  5. AUC Positive Distribution - Positive phase area
  6. AUC Negative Distribution - Negative phase area
  7. AUC Rectified Distribution - Fiber recruitment indicator
  8. Fiber Recruitment Over Time - AUC changes during recording
  9. Waveform Overlay - All spikes superimposed
  10. Amplitude vs AUC Scatter - Correlation analysis
  11. Half-Width vs AUC Scatter - Correlation analysis
  12. Summary Statistics - Key metrics overview

License

MIT License - See LICENSE file for details.


Citation

If you use this tool in your research, please cite:

Interactive CAP Analyzer v3
https://github.com/your-username/interactive-cap-analyzer

Happy researching! 祝科研顺利!

About

MATLAB tool for interactive analysis of Compound Action Potentials (CAP)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages