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.
- 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
- 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
- MATLAB R2019b or later (recommended)
- Signal Processing Toolbox
- Statistics and Machine Learning Toolbox
In MATLAB Command Window, type:
verLook for "Signal Processing Toolbox" and "Statistics and Machine Learning Toolbox" in the list.
Method 1: Through MATLAB Interface
- In MATLAB, go to the Home tab
- Click Add-Ons → Get Add-Ons
- Search for "Signal Processing Toolbox"
- Click Install
- 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.
Place interactive_cap_analyzer_v3.m and your data file in the same folder.
MyAnalysis/
├── interactive_cap_analyzer_v3.m
└── your_data_file.tme
In MATLAB, navigate to the folder containing your files.
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 |
| 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 |
| 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 |
- 0.5s, 1s, 2s, 5s, 10s, 30s
| 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) |
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 | 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 (傻瓜教程) |
- Start with low threshold - Detect more spikes initially
- Click "Auto Detect" - Let the program find spikes
- Enter Delete Mode - Remove false positives (noise)
- Enter Add Mode - Add any missed spikes
- Click "Analyze" - Review statistics and AUC
- Click "Export" - Save your results to CSV
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.
When you click "Analyze", the following plots are generated:
- Firing Rate - Spikes per second over time
- ISI Distribution - Inter-spike interval histogram
- Half-Width Distribution - Spike duration histogram
- Amplitude Distribution - Peak amplitude histogram
- AUC Positive Distribution - Positive phase area
- AUC Negative Distribution - Negative phase area
- AUC Rectified Distribution - Fiber recruitment indicator
- Fiber Recruitment Over Time - AUC changes during recording
- Waveform Overlay - All spikes superimposed
- Amplitude vs AUC Scatter - Correlation analysis
- Half-Width vs AUC Scatter - Correlation analysis
- Summary Statistics - Key metrics overview
MIT License - See LICENSE file for details.
If you use this tool in your research, please cite:
Interactive CAP Analyzer v3
https://github.com/your-username/interactive-cap-analyzer
Happy researching! 祝科研顺利!