TFADS-Analysis is a Python desktop application for TFADS peak analysis with a best-practice v2 detector and an interactive workflow for timeline inspection and gating.
- Loads multi-channel PMT traces from
csv,tsv,xls/xlsx,fcs,h5/hdf5,tdms, and binary sources. - Detects peaks with prominence + minimum spacing logic (
scipy.signal.find_peaks) and robust boundary extraction. - Computes v2 metrics: height, width, area, prominence, peak/base/boundary indices.
- Supports arbitrary channel counts with independent trace display and shared analysis controls.
- Provides primary and secondary gating views.
- Adds inclusive time-window gating from the timeline.
- Supports timeline time scaling (
time_scale) for datasets with known export timing bugs. - Exports selected peaks to CSV/Excel with v2 reproducibility metadata columns.
- Converts loaded Excel traces to FCS 3.0, with an optional source-folder prompt on ingest and a later raw-data export action.
- Saves/loads sessions (thresholds, gates, time-scale, display settings).
- Interactive timeline with pan/zoom
- Wheel zoom modes:
- wheel = X zoom
- Shift + wheel = Y zoom
- Ctrl + Shift + wheel = X+Y zoom
- Manual and auto Y-axis range controls
- Channel display controls:
- show/hide per channel
- draw order
- color picker
- opacity
- Time-gate regions (inclusive) for downstream gating/export
- Load-time QC summary for finite values, constant channels, duration, and shape
- Sortable Peak Table linked to the focused timeline peak and scatter point
- Cooperative analysis cancellation with per-channel progress reporting
- Detector presets (Sensitive/Balanced/Conservative) with configurable width relative height
- Atomic session saves with a recoverable backup and a last-autosave restore action
python -m venv .venvWindows PowerShell:
.venv\Scripts\Activate.ps1
pip install -e ".[dev]"Windows CMD:
.venv\Scripts\activate.bat
pip install -e ".[dev]"Linux/macOS:
source .venv/bin/activate
pip install -e ".[dev]"setup.battfadsor
python -m tfads.app- Open a data file.
- When opening an
.xlsx/.xls, optionally save an FCS 3.0 copy beside it. - Choose a detector preset and adjust threshold/prominence, minimum spacing, and width relative height.
- Run analysis.
- Review the load-time QC summary, then draw/update gates in scatter plots.
- Select any row in the Peak Table to focus that peak across the timeline and scatter view.
- Add timeline time gates if needed; use Cancel Analysis if a long run needs to stop.
- Export selected peaks or the raw trace as FCS later from the File menu; exports include detector configuration metadata.
from tfads import load_data, detect_peaks, apply_gates, export_results
data = load_data("path/to/file.csv", fs=10_000_000)
peaks = detect_peaks(data["data"], data["fs"])
masks = apply_gates(peaks)
export_results(peaks, masks, fs=data["fs"], output_path="peaks.csv")
# Optional raw-trace FCS export (channels x samples)
from tfads import write_fcs
write_fcs(data["data"], "trace.fcs", fs=data["fs"], source_name="trace.xlsx")export_results(...) now writes a stable v2 table schema including:
- Core metrics:
height_V,width_ms,area_Vms,prominence_V - Indices:
peak_index,start_index,end_index,left_base_index,right_base_index - Selection + reproducibility:
selected,detector_preset,processing_version
Legacy inputs (amplitude, area) are still accepted and mapped into v2 columns.
ruff check tfads tests
black --check tfads tests
pytest -q
python ci/validate_labview_match.pyExample-data parity report:
python ci/validate_example_match.pypowershell -ExecutionPolicy Bypass -File scripts/build_windows_exe.ps1Output:
dist/TFADS-Analysis.exe
- Large example datasets are intentionally not tracked in git (
/Example_datais ignored). - Local build/test artifacts are ignored (
dist/,build/, caches, coverage files). - Machine-local scratch/debug artifacts are ignored.
If this project supports your work, please cite:
- The original TFADS LabVIEW pipeline authors (TFADS Team / original method authors).
- This Python desktop implementation by Matteo Broketa.
Citation metadata is provided in CITATION.cff.
MIT. See LICENSE.