def create_data(freq_bands=24, participant_number=19, snr=0.2, normalize=False, azimuth=12, time_window=0.1, max_freq=20000):
    str_r = ((((((((((((('data/processed_' + str(max_freq)) + 'Hz/binaural_right_0_gammatone_') + str(time_window)) + '_window_{0:03d}'.format(participant_number)) + '_cipic_') + str(int((snr * 100)))) + '_srn_') + str(freq_bands)) + '_channels_') + str(((azimuth - 12) * 10))) + '_azi_') + str(normalize)) + '_norm.npy')
    str_l = ((((((((((((('data/processed_' + str(max_freq)) + 'Hz/binaural_left_0_gammatone_') + str(time_window)) + '_window_{0:03d}'.format(participant_number)) + '_cipic_') + str(int((snr * 100)))) + '_srn_') + str(freq_bands)) + '_channels_') + str(((azimuth - 12) * 10))) + '_azi_') + str(normalize)) + '_norm.npy')
    path_data_r = (ROOT / str_r)
    path_data_l = (ROOT / str_l)
    if (path_data_r.is_file() and path_data_l.is_file()):
        print(('Data set found. Loading from file : ' + str_r))
        return (np.load(path_data_r), np.load(path_data_l))
    else:
        print(('Creating data set : ' + str_l))
        hrtf_path = (ROOT / 'data/raw/hrtfs/hrir_{0:03d}.mat'.format(participant_number)).resolve()
        hrir_mat = io.loadmat(hrtf_path.as_posix())
        hrir_l = hrir_mat['hrir_l']
        hrir_r = hrir_mat['hrir_r']
        psd_all_i = np.zeros((len(SOUND_FILES), 50, freq_bands))
        psd_all_c = np.zeros((len(SOUND_FILES), 50, freq_bands))
        for i in range(psd_all_i.shape[0]):
            for i_elevs in range(psd_all_i.shape[1]):
                hrir_elevs = np.squeeze(hrir_l[azimuth, i_elevs, :])
                signal = sf.read(SOUND_FILES[i].as_posix())[0]
                signal_elevs = (((1 - snr) * sp.lfilter(hrir_elevs, 1, signal)) + (snr * (signal + (np.random.random(signal.shape[0]) * snr))))
                hrir_elevs = np.squeeze(hrir_r[azimuth, i_elevs, :])
                signal_elevs_c = (((1 - snr) * sp.lfilter(hrir_elevs, 1, signal)) + (snr * (signal + (np.random.random(signal.shape[0]) * snr))))
                twin = time_window
                thop = (twin / 2)
                fmin = 20
                fs = 44100
                y = gtgram.gtgram(signal_elevs, fs, twin, thop, freq_bands, fmin, max_freq)
                y = (20 * np.log10((y + 1)))
                window_means = np.mean(y, axis=1)
                psd_all_i[i, i_elevs, :] = window_means
                y = gtgram.gtgram(signal_elevs_c, fs, twin, thop, freq_bands, fmin, max_freq)
                y = (20 * np.log10((y + 1)))
                window_means = np.mean(y, axis=1)
                psd_all_c[i, i_elevs, :] = window_means
        np.save(path_data_r.absolute(), psd_all_c)
        np.save(path_data_l.absolute(), psd_all_i)
        return (psd_all_c, psd_all_i)
def create_data(freq_bands=24, participant_number=19, snr=0.2, normalize=False, azimuth=12, time_window=0.1, max_freq=20000):
    str_r = ((((((((((((('data/processed_' + str(max_freq)) + 'Hz/binaural_right_0_gammatone_') + str(time_window)) + '_window_{0:03d}'.format(participant_number)) + '_cipic_') + str(int((snr * 100)))) + '_srn_') + str(freq_bands)) + '_channels_') + str(((azimuth - 12) * 10))) + '_azi_') + str(normalize)) + '_norm.npy')
    str_l = ((((((((((((('data/processed_' + str(max_freq)) + 'Hz/binaural_left_0_gammatone_') + str(time_window)) + '_window_{0:03d}'.format(participant_number)) + '_cipic_') + str(int((snr * 100)))) + '_srn_') + str(freq_bands)) + '_channels_') + str(((azimuth - 12) * 10))) + '_azi_') + str(normalize)) + '_norm.npy')
    path_data_r = (ROOT / str_r)
    path_data_l = (ROOT / str_l)
    if (path_data_r.is_file() and path_data_l.is_file()):
        print(('Data set found. Loading from file : ' + str_r))
        return (np.load(path_data_r), np.load(path_data_l))
    else:
        print(('Creating data set : ' + str_l))
        hrtf_path = (ROOT / 'data/raw/hrtfs/hrir_{0:03d}.mat'.format(participant_number)).resolve()
        hrir_mat = io.loadmat(hrtf_path.as_posix())
        hrir_l = hrir_mat['hrir_l']
        hrir_r = hrir_mat['hrir_r']
        psd_all_i = np.zeros((len(SOUND_FILES), 50, freq_bands))
        psd_all_c = np.zeros((len(SOUND_FILES), 50, freq_bands))
        for i in range(psd_all_i.shape[0]):
            for i_elevs in range(psd_all_i.shape[1]):
                hrir_elevs = np.squeeze(hrir_l[azimuth, i_elevs, :])
                signal = sf.read(SOUND_FILES[i].as_posix())[0]
                signal_elevs = (((1 - snr) * sp.lfilter(hrir_elevs, 1, signal)) + (snr * (signal + (np.random.random(signal.shape[0]) * snr))))
                hrir_elevs = np.squeeze(hrir_r[azimuth, i_elevs, :])
                signal_elevs_c = (((1 - snr) * sp.lfilter(hrir_elevs, 1, signal)) + (snr * (signal + (np.random.random(signal.shape[0]) * snr))))
                twin = time_window
                thop = (twin / 2)
                fmin = 20
                fs = 44100
                y = gtgram.gtgram(signal_elevs, fs, twin, thop, freq_bands, fmin, max_freq)
                y = (20 * np.log10((y + 1)))
                window_means = np.mean(y, axis=1)
                psd_all_i[i, i_elevs, :] = window_means
                y = gtgram.gtgram(signal_elevs_c, fs, twin, thop, freq_bands, fmin, max_freq)
                y = (20 * np.log10((y + 1)))
                window_means = np.mean(y, axis=1)
                psd_all_c[i, i_elevs, :] = window_means
        np.save(path_data_r.absolute(), psd_all_c)
        np.save(path_data_l.absolute(), psd_all_i)
        return (psd_all_c, psd_all_i)