Skip to content

Commit

Permalink
add metadata in finalise
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjnixon committed Jan 8, 2024
1 parent f444aec commit f83ad0e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 4 additions & 2 deletions bear/process_irs/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions bear/process_irs/finalise.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion doc/ir_processing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit f83ad0e

Please sign in to comment.