# Path: msaf/exceptions.py
# class NoReferencesError(MSAFError):
#     '''Exception class for trying evaluations without references'''
#     pass
# 
# Path: msaf/utils.py
# def lognormalize(F, floor=0.1, min_db=-80):
# def min_max_normalize(F, floor=0.001):
# def normalize(X, norm_type, floor=0.0, min_db=-80):
# def ensure_dir(directory):
# def times_to_intervals(times):
# def intervals_to_times(inters):
# def get_num_frames(dur, anal):
# def get_time_frames(dur, anal):
# def remove_empty_segments(times, labels):
# def sonify_clicks(audio, clicks, out_file, fs, offset=0):
# def synchronize_labels(new_bound_idxs, old_bound_idxs, old_labels, N):
# def process_segmentation_level(est_idxs, est_labels, N, frame_times, dur):
# def align_end_hierarchies(hier1, hier2, thres=0.5):
#     F = min_max_normalize(F, floor=floor)
#     F = np.abs(min_db) * np.log10(F)  # Normalize from min_db to 0
#     F = F / F.max(axis=0)


import jams
import logging
import mir_eval
import numpy as np
import os
import pandas as pd
import six
import msaf
import msaf.input_output as io
from joblib import Parallel, delayed
from msaf.exceptions import NoReferencesError
from msaf import utils
        jam = jams.load(ref_file, validate=False)
        ann = jam.search(namespace='segment_.*')[annotator_id]
        ref_inter, ref_labels = ann.to_interval_values()

    # Read estimations with correct configuration
    est_inter, est_labels = io.read_estimations(est_file, boundaries_id,
                                                labels_id, **config)

    # Compute the results and return
    logging.info("Evaluating %s" % os.path.basename(est_file))
    if config["hier"]:
        # Hierarchical
        assert len(est_inter) == len(est_labels), "Same number of levels " \
            "are required in the boundaries and labels for the hierarchical " \
            "evaluation."
        est_times = []
        est_labels = []

        # Sort based on how many segments per level
        est_inter = sorted(est_inter, key=lambda level: len(level))

        for inter in est_inter:
            est_times.append(msaf.utils.intervals_to_times(inter))
            # Add fake labels (hierarchical eval does not use labels --yet--)
            est_labels.append(np.ones(len(est_times[-1]) - 1) * -1)

        # Align the times
        utils.align_end_hierarchies(est_times, ref_times, thres=1)

        # To intervals

# Path: msaf/exceptions.py
# class NoReferencesError(MSAFError):
#     '''Exception class for trying evaluations without references'''
#     pass
# 
# Path: msaf/utils.py
# def lognormalize(F, floor=0.1, min_db=-80):
# def min_max_normalize(F, floor=0.001):
# def normalize(X, norm_type, floor=0.0, min_db=-80):
# def ensure_dir(directory):
# def times_to_intervals(times):
# def intervals_to_times(inters):
# def get_num_frames(dur, anal):
# def get_time_frames(dur, anal):
# def remove_empty_segments(times, labels):
# def sonify_clicks(audio, clicks, out_file, fs, offset=0):
# def synchronize_labels(new_bound_idxs, old_bound_idxs, old_labels, N):
# def process_segmentation_level(est_idxs, est_labels, N, frame_times, dur):
# def align_end_hierarchies(hier1, hier2, thres=0.5):
#     F = min_max_normalize(F, floor=floor)
#     F = np.abs(min_db) * np.log10(F)  # Normalize from min_db to 0
#     F = F / F.max(axis=0)


# Path: msaf/eval.py
import jams
import logging
import mir_eval
import numpy as np
import os
import pandas as pd
import six
import msaf
import msaf.input_output as io
from joblib import Parallel, delayed
from msaf.exceptions import NoReferencesError
from msaf import utils

        jam = jams.load(ref_file, validate=False)
        ann = jam.search(namespace='segment_.*')[annotator_id]
        ref_inter, ref_labels = ann.to_interval_values()

    # Read estimations with correct configuration
    est_inter, est_labels = io.read_estimations(est_file, boundaries_id,
                                                labels_id, **config)

    # Compute the results and return
    logging.info("Evaluating %s" % os.path.basename(est_file))
    if config["hier"]:
        # Hierarchical
        assert len(est_inter) == len(est_labels), "Same number of levels " \
            "are required in the boundaries and labels for the hierarchical " \
            "evaluation."
        est_times = []
        est_labels = []

        # Sort based on how many segments per level
        est_inter = sorted(est_inter, key=lambda level: len(level))

        for inter in est_inter:
            est_times.append(msaf.utils.intervals_to_times(inter))
            # Add fake labels (hierarchical eval does not use labels --yet--)
            est_labels.append(np.ones(len(est_times[-1]) - 1) * -1)

        # Align the times
        utils.align_end_hierarchies(est_times, ref_times, thres=1)

        # To intervals

        est_hier = [utils.times_to_intervals(times) for times in est_times]