Summary
bidser::read_events dispatches via UseMethod(), so the public signature surfaced by autocomplete, ?read_events, and tooling like rpeek sig is just function(x, ...). The actual filtering arguments — subid, task, run, session — only appear on the read_events.bids_project method body, and users typically don't read method source.
The visible effect: callers write defensive post-filtering instead of passing the args that are already there. For example, I wrote this in a script today:
tabs <- bidser::read_events(proj, subid = subject_id, task = TASK)
if (".session" %in% names(tabs))
tabs <- tabs[as.character(tabs$.session) == SESSION, ]
…when the right call is simply:
tabs <- bidser::read_events(proj, subid = subject_id, task = TASK, session = SESSION)
The same point applies to read_confounds, read_func_scans, read_preproc_scans — all generics with function(x, ...) signatures whose useful filtering args live on the method.
Suggestion
The minimal, non-breaking fix is to document the dispatched args on the generic's roxygen. Concretely:
- Add
@param subid, @param task, @param run, @param session (and @param ...) to the generic's roxygen block, so the help page and IDE autocomplete surface them.
- Optionally, lift the args onto the generic itself:
read_events <- function(x, subid = ".*", task = ".*", run = ".*",
session = ".*", ...) UseMethod("read_events")
This is purely additive — existing methods continue to receive them via ....
A nice-to-have, but breaking: renaming the metadata columns .session / .run / .subid / .task / .file to plain session / run / etc. The . prefix forces backtick-quoted column references in dplyr and trips up names()-based membership checks. If a 1.0 release is on the horizon, worth bundling there.
Repro
?bidser::read_events # only `x` and `...` documented
formals(bidser::read_events) # function (x, ...)
vs. the actual method:
formals(bidser:::read_events.bids_project)
# $x ; $subid = ".*" ; $task = ".*" ; $run = ".*" ; $session = ".*" ; $...
Happy to send a PR for the documentation-only fix if useful.
Summary
bidser::read_eventsdispatches viaUseMethod(), so the public signature surfaced by autocomplete,?read_events, and tooling likerpeek sigis justfunction(x, ...). The actual filtering arguments —subid,task,run,session— only appear on theread_events.bids_projectmethod body, and users typically don't read method source.The visible effect: callers write defensive post-filtering instead of passing the args that are already there. For example, I wrote this in a script today:
…when the right call is simply:
The same point applies to
read_confounds,read_func_scans,read_preproc_scans— all generics withfunction(x, ...)signatures whose useful filtering args live on the method.Suggestion
The minimal, non-breaking fix is to document the dispatched args on the generic's roxygen. Concretely:
@param subid,@param task,@param run,@param session(and@param ...) to the generic's roxygen block, so the help page and IDE autocomplete surface them.....A nice-to-have, but breaking: renaming the metadata columns
.session/.run/.subid/.task/.fileto plainsession/run/ etc. The.prefix forces backtick-quoted column references in dplyr and trips upnames()-based membership checks. If a 1.0 release is on the horizon, worth bundling there.Repro
vs. the actual method:
Happy to send a PR for the documentation-only fix if useful.