# 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/exceptions.py
# class NoEstimationsError(MSAFError):
#     '''Exception class for missing estimations'''
#     pass


import datetime
import glob
import json
import logging
import os
import re
import jams
import numpy as np
import six
import msaf
from collections import defaultdict
from msaf import utils
from msaf.exceptions import NoEstimationsError
def save_estimations(file_struct, times, labels, boundaries_id, labels_id,
                     **params):
    """Saves the segment estimations in a JAMS file.

    Parameters
    ----------
    file_struct : FileStruct
        Object with the different file paths of the current file.
    times : np.array or list
        Estimated boundary times.
        If `list`, estimated hierarchical boundaries.
    labels : np.array(N, 2)
        Estimated labels (None in case we are only storing boundary
        evaluations).
    boundaries_id : str
        Boundary algorithm identifier.
    labels_id : str
        Labels algorithm identifier.
    params : dict
        Dictionary with additional parameters for both algorithms.
    """
    # Remove features if they exist
    params.pop("features", None)

    # Get duration
    dur = get_duration(file_struct.features_file)

    # Convert to intervals and sanity check
    if 'numpy' in str(type(times)):
        # Flat check

# 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/exceptions.py
# class NoEstimationsError(MSAFError):
#     '''Exception class for missing estimations'''
#     pass


# Path: msaf/input_output.py
import datetime
import glob
import json
import logging
import os
import re
import jams
import numpy as np
import six
import msaf
from collections import defaultdict
from msaf import utils
from msaf.exceptions import NoEstimationsError

def save_estimations(file_struct, times, labels, boundaries_id, labels_id,
                     **params):
    """Saves the segment estimations in a JAMS file.

    Parameters
    ----------
    file_struct : FileStruct
        Object with the different file paths of the current file.
    times : np.array or list
        Estimated boundary times.
        If `list`, estimated hierarchical boundaries.
    labels : np.array(N, 2)
        Estimated labels (None in case we are only storing boundary
        evaluations).
    boundaries_id : str
        Boundary algorithm identifier.
    labels_id : str
        Labels algorithm identifier.
    params : dict
        Dictionary with additional parameters for both algorithms.
    """
    # Remove features if they exist
    params.pop("features", None)

    # Get duration
    dur = get_duration(file_struct.features_file)

    # Convert to intervals and sanity check
    if 'numpy' in str(type(times)):
        # Flat check

        inters = utils.times_to_intervals(times)