Repository navigation
Description
Many of the package's public names are abbreviations that need the documentation to interpret: rdrecord, rdann, wrsamp, p_signal, e_d_signal, sampfrom, m2s, return_res, label_store. Slightly longer names would make code easier to read and write, and make the package easier to learn, especially for people who don't know the WFDB C tools these names come from.
Renaming affects everyone's code, tutorials and answers online, so this issue tracks principles and names for the remaining API changes.
Principles
- Add, don't break. New names are added alongside the old ones, which keep working. Old names are deprecated only later, and removed (if ever) only in a major release.
- Use the WFDB format's own terms. Header fields such as
adc_gain,adc_res,adc_zero,baseline,skew,byte_offset,checksum,init_valueandblock_sizeare named in the WFDB specification, so they stay as they are. Tools that mirror WFDB programs (sampfreq,signame,wfdbdesc,wfdbtime) keep their names too. - Spell out abbreviations, and follow Python conventions:
read_/write_for I/O,start/stopfor ranges, plural names for lists and arrays, andn_for counts. - Rename once. Changes to how files are located (Use a single
pathargument (and deprecatepn_dirandfile_name) #534) and what signal data is returned (Better API for specifying return data of signals #376) should be settled together with the names, so that nothing is renamed twice.
Proposed names
These are a starting point for discussion. The old names would remain as aliases.
Functions and methods
| Current | Proposed |
|---|---|
rdrecord |
read_record |
rdsamp |
read_signals |
rdann |
read_annotations |
wrsamp |
write_record |
Record.wrsamp |
Record.write |
wrann |
write_annotations |
Annotation.wrann |
Annotation.write |
mrgann |
merge_annotations |
dl_database |
download_database |
dl_files |
download_files |
get_dbs |
list_databases |
get_record_list |
list_records |
show_ann_labels, show_ann_classes |
show_annotation_labels, show_annotation_classes |
processing.Comparitor |
processing.Comparator |
read_header was added in #763 as a separate, immutable description of one
physical header. It is not an alias for rdheader, which continues to return
mutable Record or MultiRecord objects and can read segment headers
recursively. Any replacement name for that legacy behavior needs a separate
decision.
Arguments
| Current | Proposed | Where |
|---|---|---|
sampfrom, sampto |
start, stop |
reading records and annotations |
m2s |
combine_segments |
rdrecord |
return_res |
dtype (or resolution) |
rdrecord, rdsamp |
rd_segments |
read_segments |
rdheader |
extension |
annotator (the WFDB term) |
rdann, wrann |
shift_samps |
relative_samples |
rdann |
return_label_elements |
label_fields |
rdann |
pn_dir |
replaced by physionet:// paths (#534) |
everywhere |
sig |
signal |
processing functions |
qrs_inds |
qrs_indices |
compute_hr and others |
Record and annotation attributes
| Current | Proposed |
|---|---|
p_signal, d_signal |
physical_signals, digital_signals |
e_p_signal, e_d_signal |
expanded_physical_signals, expanded_digital_signals (or folded into #376) |
sig_name |
signal_names |
sig_len |
signal_length |
n_sig |
n_signals |
samps_per_frame |
samples_per_frame |
fmt |
formats |
Annotation.label_store |
Annotation.label_codes |
Annotation.aux_note |
Annotation.notes |
Annotation.chan, Annotation.num |
Annotation.channels, Annotation.numbers |
Annotation.ann_len |
Annotation.n_annotations |
How it could be done
- Functions: for straightforward renames, the new name is the function and
the old name is an alias.read_headeris a distinct API, as noted above. - Arguments: a small decorator maps old keyword names to new ones, and raises an error if both are given.
- Attributes: the new names are the attributes, and the old names are properties that read and write them, so code that sets
record.p_signalkeeps working. Internal names, such as the header field tables, can change separately or stay.
Release plan:
- A minor release adds the new names, and the documentation and examples switch to them. The old names are listed as aliases, with no warnings.
- A later release warns when old names are used. One question below is whether that should be a
DeprecationWarningor aFutureWarning. - A major release decides whether the old names are removed or kept as aliases for good.
Questions
- Resolved in the comments: keep
fs, which is familiar in signal processing
and used directly by libraries such as SciPy. start/stop, orstart/end?stopmatches Python'srangeand slicing, where the stop is excluded, assamptonow is for both signals and annotations.- Should the
processingfunctions be renamed in the same pass, or separately? - Is it worth renaming
rdsampat all, or should it be deprecated in favour ofread_record, which returns the same data and more? - How long should the old names keep working without warnings?
Related: #371 (record metadata), #376 (returned signal data), #500 (reading and writing that match), #534 (a single path argument).
Activity
tompollard commentedon Nov 24, 2026
@briangow please could you add your thoughts on the proposed names above?
tompollard commentedon Nov 24, 2026
Related: #534 now has a proposed plan for phasing out
pn_dirin favour ofphysionet://paths in the first argument. If that argument is renamed here (for example topath), the two changes should go together.Warn when a renamed record would replace another record's signal files (
briangow commentedon Nov 24, 2026
@tompollard , I agree that it would be ideal to have readable names but I also think there is some benefit around keeping the naming consistent with the C package. Consistency in specification and naming between Python and C would be ideal.
I don't see any major issues with your proposed names and I agree that the old variables would need to be supported for some time before being phased out.
For your questions:
fsis so common in signal processing terminology that I'd leave it as-is.start/stop/enddon't make it clear that these are sample numbers (whereassamptoimplies that).rdrecord.tompollard commentedon Nov 25, 2026
Thanks Brian!
👍
start and stop seem cleaner and more memorable to me, but we can discuss. for me,
samptobelongs with some of the other slightly obscure names.I agree, but I'm not sure it's realistic to keep them in sync. I think what we can do is come up with a clear spec for the software at https://github.com/wfdb/wfdb-spec. We can then document level of coverage for different implementations.
Yep, this is easy enough to do.
I agree. We can do this in a small way by having the conversations here - there are a large-ish number of people watching the repo.
I'd like to start regular working group meetings too, but don't want to hold up progress for what (I think) are fairly clear improvements.
tompollard commentedon Nov 25, 2026
@cbrnr @TheNetherWatcher @Ivorforce any thoughts on the proposal above to introduce friendlier names for the public API?
cbrnr commentedon Nov 25, 2026
I like it! I would also leave
fsas it is common enough (FWIW, MNE-Python usessfreq, which I don't really like as it is less common).If the entire package is based on samples, I think
start/stop/endare better than the old names.I cannot say much on keeping names consistent with C other than users will probably not use both versions; it is likely that most users will only ever use one language, and for Python I definitely prefer the new names.
I would continue supporting the old names for several releases, but start warning soon (FutureWarning), and eventually remove the old names. It's just easier to support and maintain, and I guess we want people to switch over.
tompollard commentedon Nov 25, 2026
Thanks @cbrnr!
Your and @briangow’s comments make a good case for keeping
fs. I still lean towardsampling_frequencyfor the new API because it’s immediately clear to new users, and we’re already introducing aliases for other names. Is there a reason beyond familiarity to preferfs?cbrnr commentedon Nov 25, 2026
No, sampling frequency is perfectly fine and the most common term, although sampling rate is equally common and shorter.
TheNetherWatcher commentedon Nov 25, 2026
Thanks for the ping, the proposal reads well to me. A few thoughts:
fs: I'd keep it. It's probably the attribute people use most, and it usually goes straight into SciPy (signal.butter(..., fs=record.fs)), so it's already familiar to anyone doing signal processing. If we do rename it, I agree with @cbrnr thatsampling_rateis better thansampling_frequency. It's shorter, and NeuroKit2 uses it, which a lot of wfdb users already work with.start/stop: +1 forstop. It matchesrangeand slicing, and sincesamptois already exclusive, nothing changes in behaviour.Warnings:
FutureWarning.DeprecationWarningis hidden by default unless it's triggered in__main__, so most users running scripts or notebooks through other modules wouldn't see it until the names are gone.rdsampfields dict: one thing I don't see in the list.rdsampreturns a dict with keys likefs,sig_name,sig_len,n_sigandunits. If the attributes becomesignal_names/n_signalsbutread_signalsstill returns the old keys, the two will disagree. We should either rename the keys too (keeping the old ones for a while) or decide this together with #376, since the return type might change anyway.aux_note→notes: this seems to go against principle 2, since the spec calls it the aux string. Maybeaux_notes, or keepaux_note?return_res: I'd go withdtypeoverresolution. People already think in numpy dtypes, and it says what you get back.Happy to pick up parts of the implementation once the names are settled (the argument-alias decorator, for example).
tompollard commentedon Nov 25, 2026
thanks @TheNetherWatcher!
Sounds like I am in the minority on this one - let's keep
fs.Thanks, I appreciate the offer. It's probably easiest for me to take on the refactor in one go, and then perhaps I'll ping you for a review.
Add immutable read_header API (#763)
Add opt-in explicit signal values reader (#772)
Write selected signal views to a destination path (#776)
Document source location contract for record I/O (#780)
13 remaining items
Add n_frames alias for record frame count (#808)
Add samples_per_frame alias to Record (#809)
tompollard commentedon Nov 30, 2026
Before adding more
Annotationattribute aliases, I suggest one rule: use plural names for fields with one value per annotation. That would give ussample_indices,symbols,subtypes,channels,numbers,notes, andlabel_codesfor the currentsample,symbol,subtype,chan,num,aux_note, andlabel_storefields.I prefer
sample_indicesoversamplesbecause these are positions in a signal, not signal values. Scalar fields such asfsandrecord_namewould stay singular. The existing attribute names would keep working during the transition.The earlier suggestion of
aux_notesis reasonable, since the WFDB format calls this the auxiliary string. I lean towardnotesfor the public attribute, but would like to settle that detail before adding its alias. #810 addschannelsas a small first step; I would leave the remaining aliases for a follow-up once we agree on the convention.Add channels alias to Annotation (#810)
Add remaining readable Annotation field aliases (#811)
Add formats alias to Record (#812)
Add processing.Comparator with Comparitor alias (#813)
Add readable processing argument names (#814)
Add readable aliases for Record signal arrays (#815)
Add list_databases using physionet.list_projects (#816)
tompollard commentedon Dec 1, 2026
Thanks @TheNetherWatcher — I wanted to close the loop on your points now that the first API changes have landed.
fs. The newer readers usestartand exclusivestop.read_signalsreturns aSignalReadobject with values and metadata, rather than the legacy(array, fields)pair.rdsampand its dictionary keys remain as they were, so we do not need to rename those keys in place.Annotation.notesis now an alias foraux_note. I chose the shorter public name while retaining the WFDB field name for compatibility.resolutionrather thandtype: the accepted values select a bit width, not an arbitrary NumPy dtype.I agree that
FutureWarningis the right warning once we deprecate a name. We have not started warning on the older API names generally; I want the remaining behavior and names settled first. Thanks again for the offer to help with the implementation and review.Warn on pn_dir and suggest explicit read paths (#818)
Add a guide for migrating from the legacy API (#829)
Deprecate the legacy function names (#830)
tompollard commentedon Dec 1, 2026
Progress update: #827, #828, #829 and #830 are merged, and #831 has been released as 5.13.0. This release includes
read_channel_header, clearer multi-segment views, a migration guide, and the first warnings for legacy function names. The PyPI upload is still waiting for the repository's required deployment approval.The following names still work but now emit
DeprecationWarningwhen called by user code:rdrecord,rdsamp,rdann,Record.wrsamp,Annotation.wrann,dl_database,get_record_list,get_dbs,show_ann_labels,show_ann_classes, andprocessing.Comparitor. Internal calls do not warn.pn_dirseparately emits theFutureWarningintroduced in 5.12.0.We left
rdheader, module-levelwrsampandwrann,mrgann,dl_files, andMultiRecord.wrsampunwarned because the newer APIs do not yet cover all their uses. The legacy attribute and argument names also remain unwarned. The older APIs have not been removed; deciding whether and when to remove them remains part of the later major-release plan.