From f83ad0ee87b8ce1549c4b37bff0c33c6839f0cc4 Mon Sep 17 00:00:00 2001 From: Thomas Nixon Date: Mon, 8 Jan 2024 13:20:33 +0000 Subject: [PATCH] add metadata in finalise --- bear/process_irs/Snakefile | 6 ++++-- bear/process_irs/finalise.py | 7 +++++++ doc/ir_processing.md | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/bear/process_irs/Snakefile b/bear/process_irs/Snakefile index 8a2fb61..1cc3d07 100644 --- a/bear/process_irs/Snakefile +++ b/bear/process_irs/Snakefile @@ -49,9 +49,11 @@ rule finalise: "bear_data/{params}/{sofa}.tf", "finalise_extra/{params}/{sofa}.tf", params: - args=lambda w: config["params"][w.params].get("finalise_args", "") + args=lambda w: config["params"][w.params].get("finalise_args", ""), + label=lambda w: config["params"][w.params].get("metadata", {}).get(w.sofa, {}).get("label", w.sofa), + released_flag=lambda w: "--released" if config["params"][w.params].get("metadata", {}).get(w.sofa, {}).get("released", False) else "", shell: - "python -m bear.process_irs.finalise {params.args} --tf-in {input[0]} --delays {input[1]} --tf-out {output[0]} --hoa-decoder {input[2]} --extra-out {output[1]}" + "python -m bear.process_irs.finalise {params.args} --label {params.label:q} {params.released_flag} --tf-in {input[0]} --delays {input[1]} --tf-out {output[0]} --hoa-decoder {input[2]} --extra-out {output[1]}" rule report: input: diff --git a/bear/process_irs/finalise.py b/bear/process_irs/finalise.py index a0cd241..63b7cee 100644 --- a/bear/process_irs/finalise.py +++ b/bear/process_irs/finalise.py @@ -46,6 +46,9 @@ def parse_args(): help="enable gain normalisation factors", ) + parser.add_argument('--label', help="label for metadata", required=True) + parser.add_argument('--released', help=argparse.SUPPRESS, action="store_true") + return parser.parse_args() @@ -383,6 +386,10 @@ def main(args): output = dict( bear_data_version=0, + metadata=dict( + label=args.label, + released=args.released, + ), views=views.astype(np.float32), # shape (view, loudspeaker, ear, sample) brirs=irs.astype(np.float32), diff --git a/doc/ir_processing.md b/doc/ir_processing.md index c43875a..4c56b5e 100644 --- a/doc/ir_processing.md +++ b/doc/ir_processing.md @@ -113,7 +113,7 @@ final data file. For BRIRs: - python -m bear.process_irs.finalise --tf-in irs.tf --delays global_delays.npy --tf-out bear_data.tf --hoa-decoder bear/process_irs/data/AmbiHOA3_magLS.sofa --extra-out finalise_extra.tf + python -m bear.process_irs.finalise --label "example v1" --tf-in irs.tf --delays global_delays.npy --tf-out bear_data.tf --hoa-decoder bear/process_irs/data/AmbiHOA3_magLS.sofa --extra-out finalise_extra.tf For HRIRs, add "--window none" to disable windowing.