Skip to content

Commit

Permalink
snakemake: add descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjnixon committed Jan 22, 2024
1 parent a754dca commit aeed72b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
14 changes: 12 additions & 2 deletions bear/process_irs/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ rule find_global_delays:
shell:
"python -m bear.process_irs.find_global_delays {params.args} --tf-in {input[0]} {params.in_delays} --out {output}"

def get_meta_args(wildcards):
metadata = config["params"][wildcards.params].get("metadata", {}).get(wildcards.sofa, {})
label = metadata.get("label", wildcards.sofa)
description = metadata.get("description")

args = ["--label", label]
if description is not None:
args.extend(["--description", description])
return args

rule finalise:
input:
"irs/{params}/{sofa}.tf",
Expand All @@ -50,10 +60,10 @@ rule finalise:
"finalise_extra/{params}/{sofa}.tf",
params:
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),
meta_args=get_meta_args,
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} --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]}"
"python -m bear.process_irs.finalise {params.args} {params.meta_args: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
13 changes: 9 additions & 4 deletions bear/process_irs/finalise.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def parse_args():
)

parser.add_argument('--label', help="label for metadata", required=True)
parser.add_argument('--description', help="description for metadata")
parser.add_argument('--released', help=argparse.SUPPRESS, action="store_true")

return parser.parse_args()
Expand Down Expand Up @@ -384,12 +385,16 @@ def main(args):
# select front loudspeaker idx
front_loudspeaker = np.argmin(np.linalg.norm(positions - [0, 1, 0], axis=1))

metadata = dict(
label=args.label,
released=args.released,
)
if args.description is not None:
metadata["description"] = args.description

output = dict(
bear_data_version=0,
metadata=dict(
label=args.label,
released=args.released,
),
metadata=metadata,
views=views.astype(np.float32),
# shape (view, loudspeaker, ear, sample)
brirs=irs.astype(np.float32),
Expand Down
4 changes: 3 additions & 1 deletion bear/process_irs/snakemake_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ params:
finalise_args: "--window none"
metadata:
HRIR_FULL2DEG:
label: "FHK KU100 HRIR [Bernschütz 2013] v1.0"
label: "FHK KU100 HRIR v1.0"
description: "derived from the IRs described in \"Bernschütz, B. (2013). A Spherical Far Field HRIR/HRTF Compilation of the Neumann KU 100\""
sadie-d1-hrir:
label: "SADIE D1 KU100 HRIR v1.0"
description: "derived from subject D1 of the SADIE II Database"

0 comments on commit aeed72b

Please sign in to comment.