Batch analysis tool for patch-clamp electrophysiology data
Project description
PatchBatch - Electrophysiology Data Analysis Tool
Installation
Option 1: Download Executable
-
Go to Releases
Windows:
-
Download
PatchBatch-Windows.zip -
Extract and run
PatchBatch.exe
Mac:
-
Download
PatchBatch-macOS.dmg -
Double-click to mount
-
First run: Right-click > Open (to bypass Gatekeeper)
-
Option 2: Install from PyPI (Recommended if you have any installation issues with the executables)
To update:
To update your version if you installed from PyPI, open a terminal and enter pip install --upgrade patchbatch
Alternatively, you may need to enter python3 -m pip install --upgrade patchbatch
Prerequisites: Installing Python
If you don't have Python installed:
- Download Python: Visit python.org and download Python 3.9 or newer
- Install Python: Run the installer and check "Add Python to PATH" during installation (Windows) or use the default settings (Mac/Linux)
- Verify Installation: Open a terminal/command prompt and type
python --versionorpython3 --versionto confirm installation
Opening a Terminal/Command Prompt
Windows:
- Press
Win + R, typecmd, press Enter - OR: Right-click in any folder while holding Shift, select "Open PowerShell window here"
Mac:
- Press
Cmd + Space, typeTerminal, press Enter - OR: Finder → Applications → Utilities → Terminal
Linux:
- Press
Ctrl + Alt + T - OR: Right-click desktop, select "Open Terminal"
In your terminal, run these commands:
pip install patchbatch
patchbatch
If pip isn't recognized, instead try
python -m pip install patchbatch
If python is not a recognized command, try replacing python with python3 in all instances.
If you install from PyPI, you will always start the program by opening a terminal in the same directory where you installed it and simply enter patchbatch.
Option 3: Install from Source (For Development)
git clone https://github.com/ck852/patchbatch.git
cd patchbatch
pip install -r requirements.txt
python src/data_analysis_gui/main.py
Contributing
Found a bug or want to contribute? Please open an issue at: https://github.com/ck852/patchbatch/issues
Introduction
Welcome to PatchBatch! The purpose of this program is to streamline electrophysiology data analysis workflows by enabling batch-analysis of data files that share the same analysis parameters. I developed this after growing impatient with the long, tedious workflows that require defining the same parameters repeatedly for every file, followed by further rote transformations that could be defined algorithmically. This is typically a repetitive process that, while not technically complicated, requires extended periods of focus to do reproducibly without errors. I developed this program because I wanted to conserve this cognitive effort for data interpretation and further experiments.
How to Use
Start by clicking "Open" in the top left corner. Select a single file to analyze. The sweeps should appear in the plot. The right and left arrows next to the "Open" button adjust which sweep is displayed. You can drag the green cursors to desired positions to define your analysis time range, very similar to WinWCP. You can also define them in the "Range 1 Start (ms)" and similar fields under "Analysis Settings". Note that you can check "Use Dual Analysis" to extract data from two regions in one output. Below, adjust "Plot Settings" for your desired analysis. This program includes the same four peak analysis modes (absolute, positive, negative, and peak-peak) available in WinWCP. The peak mode can be adjusted in the corresponding drop-down menu in the main window.
If you'd like to preview the output plot, click "Generate Analysis Plot". From there, you can export a CSV file with the analyzed data. If you only want the data without seeing the plot first, just click "Export Analysis Data" at the bottom of the window.
This program makes it possible to analyze several electrophysiology files with the same analysis parameters. To use this feature, start by setting all of the desired parameters as you would do for a single file. The "Batch Analyze" button is under the "Analysis" menu at the top. A new window will appear which will prompt you to select files for analysis. Click "Start Analysis", then "View Results". A new window will appear that plots the analysis results. From this window, you can export individual CSV files for each analyzed file. These can be directly imported into Graphpad Prism.
IV Analysis
If you are doing I-V analyses, the program allows you to create summary IV curves from batch analyses. When Current and Voltage are chosen as the Plot Settings, the Batch Analysis window will have an option to "Export IV Summary". This will output a single CSV that contains the voltage set from your first analyzed file, rounded to the nearest integer, in the first column. All subsequent columns will contain the analyzed current data from all sweeps from all input files.
IMPORTANT FOR SUMMARY IV: the user is responsible for their own data inputs; input files that use different voltage sets will yield erroneous results. Also note that voltages are rounded to the nearest integer. If the voltage sweeps are leaky, unstable, or otherwise inconsistent, the Summary CSV will likely be missing data points.
You also have the option to generate a current density IV curve. Click the "Current Density IV" button in the Batch Analysis window. You will be prompted to enter Cslow values for all files. Then, a new window will appear that plots the current densities against voltages.
Similarly to the initial batch analysis, you have the option to export individual CSV files for every analyzed file, as well as a single Summary IV that follows the same format described above. The only difference is that these outputs contain current densities, rather than raw currents. All output CSVs are designed to be easily imported into Graphpad Prism.
Time-course Analysis
The workflow for other analyses, such as Time vs Current, proceeds in a very similar manner. For such time-course analyses, it is sometimes desirable to extract data from more than one analysis range per sweep. To this end, the "Use Dual Analysis" box enables the user to define a second analysis range.
This enables the user to quickly plot both analysis ranges against the sweep times. The user can also output a CSV containing this data, ready for import into downstream analysis procedures.
Background Subtraction
You can define a region from any current trace as the background region. The average current in this region will be calculated and subtracted from all current measurements in the sweep. This process repeats for all sweeps in the file. Batch execution is available for this as well. The same background region will be used for all files in a batch (new background value calculated for each sweep in each file).
Ramp IV
If your data uses ramp voltage protocols to measure IV relationships, you can use the "Ramp IV" option in the "Analysis" menu. First, set the cursors around the ramp.
Then you can define the voltage range you are analyzing. The script will find the closest measured voltages within your analysis range and extract the current measurements at those time points. It will do this for all sweeps or a selection of sweeps.
Conductance
You can also plot conductance values in the Y Axis. Conductance calculations follow the formula G = I / (V-Vrev). Calculations are skipped if (V-Vrev) < 0.1 mV. Vrev is input by the user in mV.
Sweep Extraction
Access from the Analysis menu. Load a file in the main window first. Users can also extract the currently displayed sweep from main window. Batch extraction is available as well to extract one or multiple of the same sweeps from several files at the same time. This makes it much easier to quantify differences between sweep phenotypes in different conditions.
Leak Subtraction
Performs P/N leak subtraction on WCP files recorded with WinWCP's leak subtraction protocol. This operation follows the same processes performed by WinWCP's native leak subtraction analysis tool. The user specifies the VHold and VTest positions, in which VHold is the set to the holding potential and VTest is positioned in the test range of the sweep. The algorithm removes passive membrane currents using voltage-scaled subtraction:
-
Baseline Correction: All voltage and current traces are zeroed by subtracting the value at the holding potential (VHold cursor position averaged over the following 20 time indices).
-
Sweep Averaging: If multiple LEAK or TEST sweeps exist per group, they are averaged after baseline correction to improve signal-to-noise ratio. A pair consisting of one TEST sweep and one LEAK sweep is the typical output from WinWCP leak-subtraction voltage protocols (one pair per leak-subtracted data point).
-
Voltage-Based Scaling: The LEAK current is scaled by the ratio of voltage steps:
- Measure voltage step in TEST sweep: ΔV_test = V(VTest) - V(VHold)
- Measure voltage step in LEAK sweep: ΔV_leak = V(VTest) - V(VHold)
- Calculate scaling factor: scale = ΔV_test / ΔV_leak
-
Subtraction: The final leak-subtracted current is calculated as: I_subtracted = I_test - (scale × I_leak) Sweep groups for which TEST voltage is equal to LEAK voltage (LEAK voltage step < 0.001 mV) will be excluded from the leak-subtracted output.
Requirements:
- WCP file with sweeps classified as LEAK/TEST in WinWCP
- At least one LEAK and one TEST sweep per group
It has been noted that some leak-subtracted outputs by WinWCP do not match the outputs of this program. This is likely due to WinWCP version differences in which a wcp file was recorded in an earlier version but analyzed in a later version. Outputs from this program match manually-performed leak subtractions in Excel using complete raw TEST and LEAK traces following the algorithm described above.
Validation
To validate the data processing modules of this program, analyses were performed on sets of real electrophysiology data files. The outputs by this program were compared with outputs by WinWCP, both analyses using identical parameters.
IV Analysis
This program's data processing methods have been validated by comparing PatchBatch outputs to those of WinWCP. Both analyses used the same dataset of 12 patch-clamp recordings. Each analysis used an analysis range of 150.1 ms - 649.2 ms, with the X-axis plotting Average Voltage and the Y-axis plotting Average Current. The comparison found excellent agreement between both analysis methods. Each recording contained 11 sweeps, thus 132 data points were compared. The maximum discrepancy in the analyzed current values was 0.049694 pA. Similarly, the distinction in the measured voltage was 0.011475 mV. The distinction is due to differences in floating point arithmetic in data averaging operations in WinWCP (written in Pascal) versus Python. WinWCP uses 32-bit floating-point precision (~7 significant digits), while PatchBatch uses Python formulas with 64-bit precision (~15-16 significant digits). Because the raw data is stored as integers before being scaled to practical units, the only real difference is that 64-bit precision actually produces more accurate calculations at the expense of increased computation time, which is negligible for the intended applications of this program. These results are summarized as follows:
To assess the ABF functionality, the same WCP files were converted to ABF. File format conversions were performed in WinWCP. The ABF dataset was analyzed with the same parameters as the WCP dataset. The results were functionally identical to those of the WCP dataset.
For files analyzed in WinWCP, current densities were calculated in Graphpad Prism. A direct comparison of a Current Density vs. Voltage relationship plot produced by WinWCP vs. by PatchBatch shows that the WinWCP results are accurately reproduced by PatchBatch. In this example, the ABF dataset was used:
For current density analysis, the following Cslow values were used:
| File ID | Cslow |
|---|---|
| 250514_001 | 34.4 |
| 250514_002 | 14.5 |
| 250514_003 | 20.5 |
| 250514_004 | 16.3 |
| 250514_005 | 18.4 |
| 250514_006 | 17.3 |
| 250514_007 | 14.4 |
| 250514_008 | 14.1 |
| 250514_009 | 18.4 |
| 250514_010 | 21.0 |
| 250514_011 | 22.2 |
| 250514_012 | 23.2 |
Time Course and Dual Range
To validate the functionality of time course analyses, three WCP files were analyzed in WinWCP and PatchBatch. For these files, there were two analysis ranges of interest. Thus, the dual analysis range functionality was also validated. The first analysis range was 50.45 - 249.8 ms and the second range was 250.45 - 449.5 ms. The files were batch-analyzed in PatchBatch using Time (Voltage) on the X-Axis and Average (Current) on the Y-Axis. There was excellent agreement between the analysis of both programs, with a maximum discrepancy of 0.005005 pA found across all data points (n = 1278). Similarly, the Time values extracted from the WCP files in PatchBatch showed very good agreement with WinWCP, with a maximum discrepancy of 0.005 s in this data set (n = 639).
Users performing time course analyses of ABF files are encouraged to ensure that accurate sweep times are returned. Some discrepancies in the sweep time array were observed during testing in .abf files that were converted from .wcp via WinWCP; this is believed to be related to the file conversion and not an inherent issue with this program's data processing or pyABF, based on similar observations of the same files loaded in pClamp. Users with .wcp files are discouraged from converting them to .abf for use in this program.
Peak Analysis
The four peak analysis modes (absolute, positive, negative, and peak-peak) were validated using one of the same WCP files from the time course validation. The analysis range was 50.2 - 164.9 ms. The analysis plotted Peak Voltage versus Peak Current. A similar maximum discrepancy of 0.00497 pA and 0.000485 mV was found across all four peak modes (n = 1278). The discrepancies of the peak current values for all four peak modes are summarized in the following figure.
License
PatchBatch License
PatchBatch is released under the MIT License. See LICENSE.md for details.
Third-Party Components
PatchBatch uses PySide6 (Qt for Python), which is licensed under LGPLv3. This means:
- PatchBatch itself remains MIT-licensed
- PySide6 components remain LGPLv3-licensed
- You can modify and redistribute both, subject to their respective licenses
See LICENSES/THIRD-PARTY-NOTICES.txt for complete attribution and LICENSES/LICENSE-LGPLv3.txt for the full LGPLv3 terms.
Rebuilding with Modified PySide6
Advanced users can replace or modify the PySide6 library. See BUILD-INSTRUCTIONS.md for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file patchbatch-1.0.3.tar.gz.
File metadata
- Download URL: patchbatch-1.0.3.tar.gz
- Upload date:
- Size: 215.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e7a0a1fd7e9bcea8a86f016ed6940a2cd98e0255b88e5489eeb23bc8b7749b6
|
|
| MD5 |
e253529af635e0f939d2d3a557a79517
|
|
| BLAKE2b-256 |
32ac2fc292581760431dc8475541f3aa9f2e40afe26288dcc5fc744307293b03
|
File details
Details for the file patchbatch-1.0.3-py3-none-any.whl.
File metadata
- Download URL: patchbatch-1.0.3-py3-none-any.whl
- Upload date:
- Size: 235.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a330b3c6930e2cfb0da0a27756137093cf1b2c2fe6bfd81be6810a0b75e38f58
|
|
| MD5 |
6d5daa9ca398b04da5c0947a954f4b92
|
|
| BLAKE2b-256 |
1d64ce756678feef99daf92e5b6c898a16d4882bdee3e1ca903ee968d3d06f12
|