reprostim.bids.inject_sidecar¶
Core logic for bids-inject-sidecar: extract BIDS media-file metadata from
audio/video files and write or update their .json sidecars.
Functions
|
Main entry point for the bids-inject-sidecar command. |
Classes
|
Context for bids-inject-sidecar processing of scan records. |
|
Policy for bids-inject-sidecar's |
|
Sidecar JSON write mode for bids-inject-sidecar's |
- class reprostim.bids.inject_sidecar.BisContext(*, mode: ~reprostim.bids.inject_sidecar.OverwriteMode = OverwriteMode.UPDATE, conflict_policy: ~reprostim.bids.inject_sidecar.ConflictPolicy = ConflictPolicy.ERROR, videos_tsv: str | None = None, strict: bool = False, dry_run: bool = False, verbose: bool = False, out_func: ~typing.Callable | None = None, ext_props: ~typing.Dict[str, ~typing.Any] = <factory>)[source]¶
Context for bids-inject-sidecar processing of scan records.
- conflict_policy: ConflictPolicy¶
- dry_run: bool¶
- ext_props: Dict[str, Any]¶
- mode: OverwriteMode¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- out_func: Callable | None¶
- strict: bool¶
- verbose: bool¶
- videos_tsv: str | None¶
- class reprostim.bids.inject_sidecar.ConflictPolicy(value)[source]¶
Policy for bids-inject-sidecar’s
--existing-differentoption: how to handle a field that already exists in the sidecar with a different, non-n/avalue.- ERROR = 'error'¶
Abort processing that file and report the conflict.
- OVERWRITE = 'overwrite'¶
Log a warning and proceed with the new value.
- class reprostim.bids.inject_sidecar.OverwriteMode(value)[source]¶
Sidecar JSON write mode for bids-inject-sidecar’s
--modeoption.- REPLACE = 'replace'¶
Overwrite the entire sidecar with only the freshly extracted/added fields.
- UPDATE = 'update'¶
Merge freshly extracted/added fields into the existing sidecar, preserving other existing keys untouched.
- reprostim.bids.inject_sidecar.do_main(files: List[str], videos: str | None, mode: str, add_meta: List[str], existing_different: str, strict: bool, dry_run: bool, verbose: bool, out_func: Callable) int[source]¶
Main entry point for the bids-inject-sidecar command.
For each file in
files, extracts BIDS media-file metadata (see_do_sidecar(): prefers thevideos.tsvcache viabids_properties_from_video_auditwhenvideosis given, falling back toffprobeon lookup failure or whenvideosis not given), merges inaddoverrides, and writes/updates the corresponding.jsonsidecar according tomodeandexisting_different.- Parameters:
files (List[str]) – Audio/video file paths from the CLI
FILESargument.videos (Optional[str]) – Optional path to
videos.tsv(produced byvideo-audit) used to look up cached fields instead of re-runningffprobe.mode (str) – Sidecar write mode,
"replace"or"update".add_meta (List[str]) – Raw values from repeated
--addoptions — each either aMETA=VALUEpair or a bare JSON object string. See_parse_ext_props().existing_different (str) – Conflict policy when a field already exists in the sidecar with a different value,
"error"or"overwrite".strict (bool) – When
True, an invalid BidsMediaInfo (perparse_bids_media_info) is a fatal error for that file. WhenFalse(default), the problem is reported as a warning and processing continues.dry_run (bool) – When
True, compute but do not write any sidecar.verbose (bool) – Enable verbose output.
out_func (Callable) – Callable used to print user-facing output (e.g.
click.echo).
- Returns:
Exit code (0 on success, non-zero on error).
- Return type:
int