Data processing and analysis library for TDT, Oxysoft NIRS, and Terranova EFNMR lab data
Project description
PhysicsLibrary
Data processing and analysis library backing PhysicsAnalysis — file parsing, signal processing, and curve-fitting logic, with no GUI code of its own. Any interface (tkinter, PyQt6, a script, a notebook) can sit on top of it.
What it does
- Loads lab data from three instrument formats plus generic tabular files:
- TDT (Tucker-Davis Technologies) fibre photometry tanks
- Oxysoft / Artinis (Oxymon, OctaMon, PortaMon …) NIRS
.txtexports - Terranova Prospa
.pt2EFNMR/MRI 2D images - Generic Excel / CSV / TSV / plain text, with automatic sub-table detection for side-by-side data layouts on one sheet
- Processes signals — bleach correction, denoising, Z-score PETH slicing, FFT with peak annotation, slope/segment analysis
- Fits curves — linear, single/double exponential, exponential rise, Gaussian, sinusoidal, and a photon-entanglement visibility model, all via
scipy.optimize.curve_fit
Structure
PhysicsLibrary/
__init__.py Public API — see below
dataset.py Dataset struct, DataFormat enum, format detection, folder picker
file_parser.py Top-level dispatcher: load_dataset(), load_dataset_file()
file_parser_generic.py Generic Excel/CSV/TSV/text parser with sub-table detection
processing_TDT.py TDT tank reading, bleach correction, denoising, event markers
analysis.py PETH/Z-score, FFT, slope segments, curve-fit runner
models.py Parametric model functions for curve fitting
loaders/
tdt_loader.py Wraps processing_TDT into a Dataset
oxysoft_loader.py Oxysoft .txt parsing (folder + single-file) into a Dataset
pt2_loader.py .pt2 EFNMR/MRI image parser
Each loader/parser is single-purpose and has no knowledge of the others — file_parser.py is the only place that ties format detection to the right loader.
Installation
pip install git+https://github.com/zakgm2/PhysicsLibrary.git
Or as a dependency in another project's requirements.txt:
git+https://github.com/zakgm2/PhysicsLibrary.git
Requirements
- Python 3.10+
numpy,scipy,tdt(installed automatically)openpyxl— only needed for.xlsx/.xlsfiles; imported lazily with a clear error if missing when you actually try to load Excel
Usage
import PhysicsLibrary as pl
# Detect + load a TDT tank or Oxysoft export folder
fmt = pl.detect_format(folder_path)
dataset = pl.load_dataset(folder_path, fmt)
# Or load a single Oxysoft .txt file directly
dataset = pl.load_dataset_file(file_path)
# Every loader returns the same universal Dataset struct
dataset.source_format # "TDT" | "Oxysoft"
dataset.sample_rate # Hz
dataset.signals # (num_channels, num_samples)
dataset.channel_names # list[str]
dataset.events # [{'label': str, 'sample': int}, ...]
# Generic tabular data (Excel/CSV/TSV/text) — returns one GenericTable per
# detected sub-table, since a single sheet can contain several side-by-side
tables = pl.load_any_file(path)
table = tables[0]
table.headers # list[str]
table.data # (n_rows, n_cols) float64, NaN for missing
# Terranova .pt2 EFNMR/MRI image — returns a raw 2D array, not a Dataset
img = pl.load_pt2(path) # (n, n) float32
# Analysis
x_seg, z = pl.get_zscore_slice(time_array, signal, center_t, window=30)
freqs, power, seg_x, seg_y = pl.compute_fft_slice(time_array, signal, center_t, fs)
pl.annotate_fft_peaks(ax, freqs, power, color='blue') # matplotlib peak labels
# Curve fitting
result = pl.fit_model_to_segment(x_seg, y_seg, pl.single_exponential_model, p0_fn)
result["popt"], result["r2"], result["y_fit"]
See CHANGELOG.md for the version history.
Public API
Everything importable from PhysicsLibrary directly:
| Category | Names |
|---|---|
| Format detection | choose_file, detect_format, detect_format_file, DataFormat, Dataset |
| Loading | load_dataset, load_dataset_file, load_any_file, load_pt2 |
| TDT processing | process_tdt_folder, validate_tdt_folder, get_tdt_struct, get_plot_data, correct_bleaching, denoise_signal, get_event_markers |
| Analysis | get_zscore_slice, smooth_signal, bin_for_heatmap, compute_fft_slice, annotate_fft_peaks, compute_slope_segment, fit_model_to_segment |
| Curve fit models | linear_model, single_exponential_model, exponential_rise_model, double_exponential_model, gaussian_model, sinusoidal_model, visibility_model |
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 zaksphysicslibrary-1.3.0.tar.gz.
File metadata
- Download URL: zaksphysicslibrary-1.3.0.tar.gz
- Upload date:
- Size: 21.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40b9f1495b4239998333c68b35506d5cbc002477f2b325875356b16079625ddd
|
|
| MD5 |
f927d08135daafc17787648cd08b128e
|
|
| BLAKE2b-256 |
4530d940ab7e04c088df09610ad2efecb3a1d313d3ced41fbd20a336631da11b
|
Provenance
The following attestation bundles were made for zaksphysicslibrary-1.3.0.tar.gz:
Publisher:
publish.yml on zakgm2/PhysicsLibrary
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zaksphysicslibrary-1.3.0.tar.gz -
Subject digest:
40b9f1495b4239998333c68b35506d5cbc002477f2b325875356b16079625ddd - Sigstore transparency entry: 2054403467
- Sigstore integration time:
-
Permalink:
zakgm2/PhysicsLibrary@08f8e40701854f12036fd36da9adc9bea308643f -
Branch / Tag:
refs/tags/v1.3.0 - Owner: https://github.com/zakgm2
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@08f8e40701854f12036fd36da9adc9bea308643f -
Trigger Event:
push
-
Statement type:
File details
Details for the file zaksphysicslibrary-1.3.0-py3-none-any.whl.
File metadata
- Download URL: zaksphysicslibrary-1.3.0-py3-none-any.whl
- Upload date:
- Size: 23.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
002fe452b4c144b916edf993ded978a30901656e64840dcdca8fa70ae697cbc2
|
|
| MD5 |
0cc9d5f2705a672febe33845f0fc7d3c
|
|
| BLAKE2b-256 |
0e590d5bcc6964a84d0bf4951a7ba6198a42ebea48171f2c1cbffb6eab04219a
|
Provenance
The following attestation bundles were made for zaksphysicslibrary-1.3.0-py3-none-any.whl:
Publisher:
publish.yml on zakgm2/PhysicsLibrary
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zaksphysicslibrary-1.3.0-py3-none-any.whl -
Subject digest:
002fe452b4c144b916edf993ded978a30901656e64840dcdca8fa70ae697cbc2 - Sigstore transparency entry: 2054403661
- Sigstore integration time:
-
Permalink:
zakgm2/PhysicsLibrary@08f8e40701854f12036fd36da9adc9bea308643f -
Branch / Tag:
refs/tags/v1.3.0 - Owner: https://github.com/zakgm2
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@08f8e40701854f12036fd36da9adc9bea308643f -
Trigger Event:
push
-
Statement type: