Commit fb9da90f authored by Jan Kiene's avatar Jan Kiene
Browse files

fix concat order and add check for concat order files being there

parent cfa0d681
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -115,17 +115,17 @@ def create_experiment_setup(experiment, lab) -> list[Path]:
        cfg.prerun_seed = seed
        cfg.input_path = str(input_path)
        cfg.output_path = str(output_path)

        cat_num = int(cat[-1])
        if (
            bg_noise_pre_proc_2 := cfg.preprocessing_2.get("background_noise", None)
        ) is not None:
            bg_noise_pre_proc_2["background_noise_path"] = str(bg_noise_path)

            # bg noise SNR only differs from default config for some experiments
            cat_num = int(cat[-1])
            if experiment in ["P800-5", "P800-9"] and cat_num >= 3:
                bg_noise_pre_proc_2["snr"] = 15
        if cfg.preprocessing_2.get("concatenate_input", None) is not None:
            cat_num = int[cat[-1]]
            cfg.preprocessing_2["concatenation_order"] = concatenation_order(lab, experiment, cat_num)

        # for MASA, the input format can differ between categories
@@ -165,7 +165,7 @@ def exp_lab_pair(arg):

def concatenation_order(lab_id, experiment, category):
    exp_id = f"p0{experiment[-1]}"
    return [f"{lab_id}{exp_id}a{category}s0{i}.wav" for i in range(1, 7)]
    return [f"{lab_id}{exp_id}a{category}s0{i}.wav" for i in range(1, 8)]


if __name__ == "__main__":
+4 −0
Original line number Diff line number Diff line
@@ -80,6 +80,10 @@ def reorder_items_list(items_list: list, concatenation_order: list) -> list:
        Re-ordered list of input items
    """
    name_to_full = {Path(full_file).name: full_file for full_file in items_list}

    if set(name_to_full.keys()) != set(concatenation_order):
        raise ValueError("Items given in concatenation_order are not identical to what was found inthe input folder")

    ordered_full_files = [
        name_to_full[name] for name in concatenation_order if name in name_to_full
    ]