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 proposes some principles and a list of names to agree on before any code 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 |
rdheader |
read_header |
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 |
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: the new name is the function, and the old name is an alias.
- 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
- Should
fsstay, as in SciPy, or becomesampling_frequency? 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.