{"id":39675667,"url":"https://github.com/ucsd-e4e/pyha","last_synced_at":"2026-01-18T09:45:47.848Z","repository":{"id":38091109,"uuid":"334537681","full_name":"UCSD-E4E/PyHa","owner":"UCSD-E4E","description":"A repo designed to convert audio-based \"weak\" labels to \"strong\" intraclip labels. Provides a pipeline to compare automated moment-to-moment labels to human labels. Methods range from DSP based foreground-background separation, cross-correlation based template matching, as well as bird presence sound event detection deep learning models!","archived":false,"fork":false,"pushed_at":"2025-01-11T03:19:20.000Z","size":390757,"stargazers_count":17,"open_issues_count":46,"forks_count":11,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-01-11T03:26:55.665Z","etag":null,"topics":["audio","automation","bioacoustics","bird-audio-clips","bird-species-classification","birdsong","deep-learning","foreground-detection","human-labels","machine-learning","moment-labels","natural-language-processing","neural-network","object-detection","python","python3","sed","sound-processing","template-matching","training"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/UCSD-E4E.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-31T00:01:15.000Z","updated_at":"2025-01-11T03:19:17.000Z","dependencies_parsed_at":"2025-01-11T03:36:03.113Z","dependency_job_id":null,"html_url":"https://github.com/UCSD-E4E/PyHa","commit_stats":{"total_commits":188,"total_committers":20,"mean_commits":9.4,"dds":0.574468085106383,"last_synced_commit":"c991cda085f8018b0c371babe6a8e4a3b7bf3b2f"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/UCSD-E4E/PyHa","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UCSD-E4E%2FPyHa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UCSD-E4E%2FPyHa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UCSD-E4E%2FPyHa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UCSD-E4E%2FPyHa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UCSD-E4E","download_url":"https://codeload.github.com/UCSD-E4E/PyHa/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UCSD-E4E%2FPyHa/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28534175,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T00:39:45.795Z","status":"online","status_checked_at":"2026-01-18T02:00:07.578Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio","automation","bioacoustics","bird-audio-clips","bird-species-classification","birdsong","deep-learning","foreground-detection","human-labels","machine-learning","moment-labels","natural-language-processing","neural-network","object-detection","python","python3","sed","sound-processing","template-matching","training"],"created_at":"2026-01-18T09:45:47.011Z","updated_at":"2026-01-18T09:45:47.737Z","avatar_url":"https://github.com/UCSD-E4E.png","language":"Jupyter Notebook","readme":" \u003cimg src=\"https://github.com/UCSD-E4E/PyHa/blob/main/Logos/PyHa.svg\" alt=\"PyHa logo\" title=\"PyHa\" align=\"right\" height=\"300\" /\u003e\n\n# PyHa\n\n\u003c!-- ## Automated Audio Labeling System --\u003e\n\nA tool designed to convert audio-based \"weak\" labels to \"strong\" moment-to-moment labels. Provides a pipeline to compare automated moment-to-moment labels to human labels. Current proof of concept work being fulfilled on Bird Audio clips using Microfaune predictions.\n\nThis package is being developed and maintained by the [Engineers for Exploration Acoustic Species Identification Team](http://e4e.ucsd.edu/acoustic-species-identification) in collaboration with the [San Diego Zoo Wildlife Alliance](https://sandiegozoowildlifealliance.org/).\n\nPyHa = Python + Piha (referring to a bird species of our interest known as the screaming-piha)\n\n## Contents\n\n- [Installation and Setup](#installation-and-setup)\n- [Functions](#functions)\n- [Examples](#examples)\n\n## Installation and Setup\n\n1. Navigate to a desired folder and clone the repository onto your local machine. `git clone https://github.com/UCSD-E4E/PyHa.git`\n\n- If you wish to reduce the size of the repository on your local machine you can alternatively use `git clone https://github.com/UCSD-E4E/PyHa.git --depth 1` which will only install the most up-to-date version of the repo without its history.\n\n2. Install Python 3.8, Python 3.9, or Python 3.10\n3. Create a `venv` by running `python3.x -m venv .venv` where `python3.x` is the appropriate python.\n4. Activate the `venv` with the following commands:\n\n- Windows: `.venv\\Scripts\\activate`\n- macOS/Linux: `source .venv/bin/activate`\n\n5. Install the build tools: `python -m pip install --upgrade pip poetry`\n6. Install the environment: `poetry install`\n7. Here you can download the Xeno-canto Screaming Piha test set used in our demos: https://drive.google.com/drive/u/0/folders/1lIweB8rF9JZhu6imkuTg_No0i04ClDh1\n8. Run `jupyter notebook` while in the proper folder to activate the PyHa_Tutorial.ipynb notebook and make sure PyHa is running properly. Make sure the paths are properly aligned to the TEST folder in the notebook as well as in the ScreamingPiha_Manual_Labels.csv file\n\n## Functions\n\n![design](https://user-images.githubusercontent.com/44332326/126560960-e9816f7e-c31b-40ee-804d-6947053323c2.png)\n\n_This image shows the design of the automated audio labeling system._\n\n### `isolation_parameters`\n\nMany of the functions take in the `isolation_parameters` argument, and as such it will be defined globally here.\n\nThe `isolation_parameters` dictionary definition depends on the model used. The currently supported models are BirdNET-Lite, Microfaune, and TweetyNET.\n\nThe BirdNET-Lite `isolation_parameters` dictionary is as follows:\n\n```python\nisolation_parameters = {\n    \"model\" : \"birdnet\",\n    \"output_path\" : \"\",\n    \"lat\" : 0.0,\n    \"lon\" : 0.0,\n    \"week\" : 0,\n    \"overlap\" : 0.0,\n    \"sensitivity\" : 0.0,\n    \"min_conf\" : 0.0,\n    \"custom_list\" : \"\",\n    \"filetype\" : \"\",\n    \"num_predictions\" : 0,\n    \"write_to_csv\" : False,\n    \"verbose\" : True\n}\n```\n\n\u003cbr\u003e\n\nThe Microfaune `isolation_parameters` dictionary is as follows:\n\n```python\nisolation_parameters = {\n    \"model\" : \"microfaune\",\n    \"technique\" : \"\",\n    \"threshold_type\" : \"\",\n    \"threshold_const\" : 0.0,\n    \"threshold_min\" : 0.0,\n    \"window_size\" : 0.0,\n    \"chunk_size\" : 0.0,\n    \"verbose\" : True\n}\n```\n\nThe `technique` parameter can be: Simple, Stack, Steinberg, and Chunk. This input must be a string in all lowercase.  \nThe `threshold_type` parameter can be: median, mean, average, standard deviation, or pure. This input must be a string in all lowercase.\n\nThe remaining parameters are floats representing their respective values.\n\n\u003cbr\u003e\n\nThe TweetyNET `isolation_parameters` dictionary is as follows:\n\n```python\nisolation_parameters = {\n    \"model\" : \"tweetynet\",\n    \"tweety_output\": False,\n    \"technique\" : \"\",\n    \"threshold_type\" : \"\",\n    \"threshold_const\" : 0.0,\n    \"threshold_min\" : 0.0,\n    \"window_size\" : 0.0,\n    \"chunk_size\" : 0.0,\n    \"verbose\" : True\n}\n```\n\nThe `tweety_output` parameter sets whether to use TweetyNET's original output or isolation techniques. If set to `False`, TweetyNET will use the specified `technique` parameter.\n\n\u003cbr\u003e\n\nThe Foreground-Background Separation technique `isolation_parameters` is as follows:\n\n```python\nisolation_parameters = {\n   \"model\" : \"fg_bg_dsp_sep\",\n   \"technique\" : \"\",\n   \"threshold_type\" : \"\",\n   \"threshold_const\" : 0.0,\n   \"kernel_size\" : 4,\n   \"power_threshold\" : 0.0,\n   \"threshold_min\" : 0.0,\n   \"verbose\" : True\n}\n```\n\nThe `kernel_size` parameter is an integer _n_ that specifies the size of the kernel used in the morphological opening process. For the opening of the binary mask, this will be an _n_ by _n_ kernel. For the processing of the indicator vector, this will be a 1 by _n_ kernel. \u003cbr\u003e\nThe `power_threshold` parameter is a float that determines by how many times the power of a pixel must be larger than its row and column medians. For example, if this value is set to 3.0, each pixel will have to have a power of at least 3 times its row and column medians to be included in the binary mask.\n\n\u003cbr\u003e\n\nThe Template Matching `isolation_parameters` is as follows:\n\n```python\nisolation_parameters = {\n   \"model\" : \"template_matching\",\n   \"template_path\" : \"\",\n   \"technique\" : \"\",\n   \"window_size\" : 0.0,\n   \"threshold_type\" : \"\",\n   \"threshold_const\" : 0.0,\n   \"cutoff_freq_low\" : 0,\n   \"cutoff_freq_high\" : 0,\n   \"verbose\" : True,\n   \"write_confidence\" : True\n}\n```\n\nThe `template_path` parameter should be set to the path to the template to use, stored as a .wav file. \u003cbr\u003e\nThe `window_size` parameter should be a float corresponding to the length (in seconds) of the template. This is so the Steinberg isolation can correctly convert the local score array into labels. \u003cbr\u003e\n`cutoff_freq_low` and `cutoff_freq_high` should be integer values. If both are defined, both signal and template will be put through a butterworth bandpass filter set to those cutoff frequencies. This is recommended to ensure that the signal and template are the same shape on the frequency axis. \u003cbr\u003e\n`write_confidence` determines whether or not the confidence of each label is written to the array, determined by the max score in the local score array for each label.\n\n\u003cbr\u003e\n\n\u003c!-- annotation_post_processing.py file --\u003e\n\n\u003cdetails\u003e\n \u003csummary\u003eannotation_post_processing.py file\u003c/summary\u003e\n\n### [`annotation_chunker`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/annotation_post_processing.py)\n\n_Found in [`annotation_post_processing.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/annotation_post_processing.py)_\n\nThis function converts a Kaleidoscope-formatted Dataframe containing annotations to uniform chunks of `chunk_length`. Drops any annotation that less than chunk_length.\n\n| Parameter         | Type      | Description                                                   |\n| ----------------- | --------- | ------------------------------------------------------------- |\n| `kaleidoscope_df` | Dataframe | Dataframe of automated or human labels in Kaleidoscope format |\n| `chunk_length`    | int       | Duration in seconds of each annotation chunk                  |\n\nThis function returns a dataframe with annotations converted to uniform second chunks.\n\nUsage: `annotation_chunker(kaleidoscope_df, chunk_length)`\n\n\u003c/details\u003e\n\n\u003c!-- IsoAutio.py file --\u003e\n\n\u003cdetails\u003e\n \u003csummary\u003eIsoAutio.py file\u003c/summary\u003e\n\n### [`write_confidence`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)\n\n_Found in [`IsoAutio.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)_\n\nThis function adds a new column to a clip dataframe that has had automated labels generated, going through all of the annotations and adding to said row a confidence metric based on the maximum value of said annotation.\n\n| Parameter             | Type             | Description                                                                            |\n| --------------------- | ---------------- | -------------------------------------------------------------------------------------- |\n| `local_score_arr`     | list of floats   | Array of small predictions of bird presence.                                           |\n| `automated_labels_df` | Pandas Dataframe | Dataframe of labels derived from the local score array using the `isolate()` function. |\n\nThis function returns a Pandas Dataframe with an additional column of confidence scores from the local score array.\n\nUsage: `write_confidence(local_score_arr, automated_labels_df)`\n\n### [`isolate`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)\n\n_Found in [`IsoAutio.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)_\n\nThis function is the wrapper function for audio isolation techniques, and will call the respective function based on `isolation_parameters` \"technique\" key.\n\n| Parameter              | Type           | Description                                                                          |\n| ---------------------- | -------------- | ------------------------------------------------------------------------------------ |\n| `local_scores`         | list of floats | Local scores of the audio clip as determined by Microfaune Recurrent Neural Network. |\n| `SIGNAL`               | list of ints   | Samples that make up the audio signal.                                               |\n| `SAMPLE_RATE`          | int            | Sampling rate of the audio clip, usually 44100.                                      |\n| `audio_dir`            | string         | Directory of the audio clip.                                                         |\n| `filename`             | string         | Name of the audio clip file.                                                         |\n| `isolation_parameters` | dict           | Python Dictionary that controls the various label creation techniques.               |\n\nThis function returns a dataframe of automated labels for the audio clip based on the passed in isolation technique.\n\nUsage:\n`isolate(local_scores, SIGNAL, SAMPLE_RATE, audio_dir, filename, isolation_parameters)`\n\n### [`threshold`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)\n\n_Found in [`IsoAutio.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)_\n\nThis function takes in the local score array output from a neural network and determines the threshold at which we determine a local score to be a positive ID of a class of interest. Most proof of concept work is dedicated to bird presence. Threshold is determined by \"threshold_type\" and \"threshold_const\" from the isolation_parameters dictionary.\n\n| Parameter              | Type           | Description                                                                          |\n| ---------------------- | -------------- | ------------------------------------------------------------------------------------ |\n| `local_scores`         | list of floats | Local scores of the audio clip as determined by Microfaune Recurrent Neural Network. |\n| `isolation parameters` | dict           | Python Dictionary that controls the various label creation techniques.               |\n\nThis function returns a float representing the threshold at which the local scores in the local score array of an audio clip will be viewed as a positive ID.\n\nUsage: `threshold(local_scores, isolation_parameters)`\n\n### [`steinberg_isolate`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)\n\n_Found in [`IsoAutio.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)_\n\nThis function uses the technique developed by Gabriel Steinberg that attempts to take the local score array output of a neural network and lump local scores together in a way to produce automated labels based on a class across an audio clip. It is called by the `isolate` function when `isolation_parameters['technique'] == steinberg`.\n\n| Parameter              | Type           | Description                                                                          |\n| ---------------------- | -------------- | ------------------------------------------------------------------------------------ |\n| `local_scores`         | list of floats | Local scores of the audio clip as determined by Microfaune Recurrent Neural Network. |\n| `SIGNAL`               | list of ints   | Samples that make up the audio signal.                                               |\n| `SAMPLE_RATE`          | int            | Sampling rate of the audio clip, usually 44100.                                      |\n| `audio_dir`            | string         | Directory of the audio clip.                                                         |\n| `filename`             | string         | Name of the audio clip file.                                                         |\n| `isolation_parameters` | dict           | Python Dictionary that controls the various label creation techniques.               |\n| `manual_id`            | string         | controls the name of the class written to the pandas dataframe                       |\n\nThis function returns a dataframe of automated labels for the audio clip.\n\nUsage: `steinberg_isolate(local_scores, SIGNAL, SAMPLE_RATE, audio_dir, filename,isolation_parameters, manual_id)`\n\n### [`simple_isolate`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)\n\n_Found in [`IsoAutio.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)_\n\nThis function uses the technique suggested by Irina Tolkova and implemented by Jacob Ayers. Attempts to produce automated annotations of an audio clip based on local score array outputs from a neural network. It is called by the `isolate` function when `isolation_parameters['technique'] == simple`.\n\n| Parameter              | Type           | Description                                                                          |\n| ---------------------- | -------------- | ------------------------------------------------------------------------------------ |\n| `local_scores`         | list of floats | Local scores of the audio clip as determined by Microfaune Recurrent Neural Network. |\n| `SIGNAL`               | list of ints   | Samples that make up the audio signal.                                               |\n| `SAMPLE_RATE`          | int            | Sampling rate of the audio clip, usually 44100.                                      |\n| `audio_dir`            | string         | Directory of the audio clip.                                                         |\n| `filename`             | string         | Name of the audio clip file.                                                         |\n| `isolation_parameters` | dict           | Python Dictionary that controls the various label creation techniques.               |\n| `manual_id`            | string         | controls the name of the class written to the pandas dataframe                       |\n\nThis function returns a dataframe of automated labels for the audio clip.\n\nUsage: `simple_isolate(local_scores, SIGNAL, SAMPLE_RATE, audio_dir, filename,isolation_parameters, manual_id)`\n\n### [`stack_isolate`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)\n\n_Found in [`IsoAutio.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)_\n\nThis function uses a technique created by Jacob Ayers. Attempts to produce automated annotations of an audio clip based on local score array outputs from a neural network. It is called by the `isolate` function when `isolation_parameters['technique'] == stack`.\n\n| Parameter              | Type           | Description                                                                          |\n| ---------------------- | -------------- | ------------------------------------------------------------------------------------ |\n| `local_scores`         | list of floats | Local scores of the audio clip as determined by Microfaune Recurrent Neural Network. |\n| `SIGNAL`               | list of ints   | Samples that make up the audio signal.                                               |\n| `SAMPLE_RATE`          | int            | Sampling rate of the audio clip, usually 44100.                                      |\n| `audio_dir`            | string         | Directory of the audio clip.                                                         |\n| `filename`             | string         | Name of the audio clip file.                                                         |\n| `isolation_parameters` | dict           | Python Dictionary that controls the various label creation techniques.               |\n| `manual_id`            | string         | controls the name of the class written to the pandas dataframe                       |\n\nThis function returns a dataframe of automated labels for the audio clip.\n\nUsage: `stack_isolate(local_scores, SIGNAL, SAMPLE_RATE, audio_dir, filename,isolation_parameters, manual_id)`\n\n### [`chunk_isolate`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)\n\n_Found in [`IsoAutio.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)_\n\nThis function uses a technique created by Jacob Ayers. Attempts to produce automated annotations of an audio clip based on local score array outputs from a neural network. It is called by the `isolate` function when `isolation_parameters['technique'] == chunk`.\n\n| Parameter              | Type           | Description                                                                          |\n| ---------------------- | -------------- | ------------------------------------------------------------------------------------ |\n| `local_scores`         | list of floats | Local scores of the audio clip as determined by Microfaune Recurrent Neural Network. |\n| `SIGNAL`               | list of ints   | Samples that make up the audio signal.                                               |\n| `SAMPLE_RATE`          | int            | Sampling rate of the audio clip, usually 44100.                                      |\n| `audio_dir`            | string         | Directory of the audio clip.                                                         |\n| `filename`             | string         | Name of the audio clip file.                                                         |\n| `isolation_parameters` | dict           | Python Dictionary that controls the various label creation techniques.               |\n| `manual_id`            | string         | controls the name of the class written to the pandas dataframe                       |\n\nThis function returns a dataframe of automated labels for the audio clip.\n\nUsage: `chunk_isolate(local_scores, SIGNAL, SAMPLE_RATE, audio_dir, filename,isolation_parameters, manual_id)`\n\n### [`generate_automated_labels`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)\n\n_Found in [`IsoAutio.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)_\n\nThis function generates labels across a folder of audio clips determined by the model and other parameters specified in the `isolation_parameters` dictionary.\n\n| Parameter                | Type    | Description                                                                                 |\n| ------------------------ | ------- | ------------------------------------------------------------------------------------------- |\n| `audio_dir`              | string  | Directory with wav audio files                                                              |\n| `isolation_parameters`   | dict    | Python Dictionary that controls the various label creation techniques.                      |\n| `manual_id`              | string  | controls the name of the class written to the pandas dataframe                              |\n| `weight_path`            | string  | File path of weights to be used by the RNNDetector for determining presence of bird sounds. |\n| `normalized_sample_rate` | int     | Sampling rate that the audio files should all be normalized to.                             |\n| `normalize_local_scores` | boolean | Set whether or not to normalize the local scores.                                           |\n\nThis function returns a dataframe of automated labels for the audio clips in audio_dir.\n\nUsage: `generate_automated_labels(audio_dir, isolation_parameters, manual_id, weight_path, normalized_sample_rate, normalize_local_scores)`\n\n### [`generate_automated_labels_birdnet`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)\n\n_Found in [`IsoAutio.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)_\n\nThis function is called by `generate_automated_labels` if `isolation_parameters[\"model\"]` is set to `birdnet`. It generates bird labels across a folder of audio clips using BirdNET-Lite given the isolation parameters.\n\n| Parameter              | Type   | Description                                                            |\n| ---------------------- | ------ | ---------------------------------------------------------------------- |\n| `audio_dir`            | string | Directory with wav audio files                                         |\n| `isolation_parameters` | dict   | Python Dictionary that controls the various label creation techniques. |\n\nThis function returns a dataframe of automated labels for the audio clips in audio_dir.\n\nUsage: `generate_automated_labels_birdnet(audio_dir, isolation_parameters)`\n\n### [`generate_automated_labels_microfaune`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)\n\n_Found in [`IsoAutio.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)_\n\nThis function is called by `generate_automated_labels` if `isolation_parameters[\"model\"]` is set to `microfaune`. It applies the isolation technique determined by the `isolation_parameters` dictionary across a whole folder of audio clips.\n\n| Parameter                | Type    | Description                                                                                 |\n| ------------------------ | ------- | ------------------------------------------------------------------------------------------- |\n| `audio_dir`              | string  | Directory with wav audio files                                                              |\n| `isolation_parameters`   | dict    | Python Dictionary that controls the various label creation techniques.                      |\n| `manual_id`              | string  | controls the name of the class written to the pandas dataframe                              |\n| `weight_path`            | string  | File path of weights to be used by the RNNDetector for determining presence of bird sounds. |\n| `normalized_sample_rate` | int     | Sampling rate that the audio files should all be normalized to.                             |\n| `normalize_local_scores` | boolean | Set whether or not to normalize the local scores.                                           |\n\nThis function returns a dataframe of automated labels for the audio clips in audio_dir.\n\nUsage: `generate_automated_labels_microfaune(audio_dir, isolation_parameters, manual_id, weight_path, normalized_sample_rate, normalize_local_scores)`\n\n### [`generate_automated_labels_tweetynet`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)\n\n_Found in [`IsoAutio.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)_\n\nThis function is called by `generate_automated_labels` if `isolation_parameters[\"model\"]` is set to `tweetynet`. It applies the isolation technique determined by the `isolation_parameters` dictionary across a whole folder of audio clips.\n\n| Parameter                | Type    | Description                                                                                 |\n| ------------------------ | ------- | ------------------------------------------------------------------------------------------- |\n| `audio_dir`              | string  | Directory with wav audio files                                                              |\n| `isolation_parameters`   | dict    | Python Dictionary that controls the various label creation techniques.                      |\n| `manual_id`              | string  | controls the name of the class written to the pandas dataframe                              |\n| `weight_path`            | string  | File path of weights to be used by the RNNDetector for determining presence of bird sounds. |\n| `normalized_sample_rate` | int     | Sampling rate that the audio files should all be normalized to.                             |\n| `normalize_local_scores` | boolean | Set whether or not to normalize the local scores.                                           |\n\nThis function returns a dataframe of automated labels for the audio clips in audio_dir.\n\nUsage: `generate_automated_labels_tweetynet(audio_dir, isolation_parameters, manual_id, weight_path, normalized_sample_rate, normalize_local_scores)`\n\n### [`generate_automated_labels_FG_BG_separation`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)\n\n_Found in [`IsoAutio.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)_\n\nThis function is called by `generate_automated_labels` if `isolation_parameters[\"model\"]` is set to `fg_bg_dsp_sep`. It applies the isolation technique determined by the `isolation_parameters` dictionary across a whole folder of audio clips.\n\n| Parameter                | Type   | Description                                                            |\n| ------------------------ | ------ | ---------------------------------------------------------------------- |\n| `audio_dir`              | string | Directory with wav audio files                                         |\n| `isolation_parameters`   | dict   | Python Dictionary that controls the various label creation techniques. |\n| `manual_id`              | string | controls the name of the class written to the pandas dataframe         |\n| `normalized_sample_rate` | int    | Sampling rate that the audio files should all be normalized to.        |\n\nThis function returns a dataframe of automated labels for the audio clips in audio_dir.\n\nUsage: `generate_automated_labels_FG_BG_separation(audio_dir, isolation_parameters, manual_id, weight_path, normalized_sample_rate, normalize_local_scores)`\n\n### [`generate_automated_labels_template_matching`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)\n\n_Found in [`IsoAutio.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)_\n\nThis function is called by `generate_automated_labels` if `isolation_parameters[\"model\"]` is set to `template_matching`. It applies the isolation technique determined by the `isolation_parameters` dictionary across a whole folder of audio clips.\n\n| Parameter                | Type   | Description                                                            |\n| ------------------------ | ------ | ---------------------------------------------------------------------- |\n| `audio_dir`              | string | Directory with wav audio files                                         |\n| `isolation_parameters`   | dict   | Python Dictionary that controls the various label creation techniques. |\n| `manual_id`              | string | controls the name of the class written to the pandas dataframe         |\n| `normalized_sample_rate` | int    | Sampling rate that the audio files should all be normalized to.        |\n\nThis function returns a dataframe of automated labels for the audio clips in audio_dir.\n\nUsage: `generate_automated_labels_template_matching(audio_dir, isolation_parameters, manual_id, weight_path, normalized_sample_rate, normalize_local_scores)`\n\n### [`kaleidoscope_conversion`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)\n\n_Found in [`IsoAutio.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/IsoAutio.py)_\n\nThis function strips away Pandas Dataframe columns necessary for the PyHa package that aren't compatible with the Kaleidoscope software.\n\n| Parameter | Type             | Description                                                                            |\n| --------- | ---------------- | -------------------------------------------------------------------------------------- |\n| `df`      | Pandas Dataframe | Dataframe compatible with PyHa package whether it be human labels or automated labels. |\n\nThis function returns a Pandas Dataframe compatible with Kaleidoscope.\n\nUsage: `kaleidoscope_conversion(df)`\n\n\u003c/details\u003e\n\n\u003c!-- FG_BG_sep/utils.py file --\u003e\n\u003cdetails\u003e\n\u003csummary\u003eFG_BG_sep/utils.py file\u003c/summary\u003e\n\n### [`perform_stft`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/FG_BG_sep/utils.py)\n\n_Found in ['FG_BG_sep/utils.py'](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/FG_BG_sep/utils.py)_\n\nThis function reverse-engineers the birdnet FG-BG separation technique. It generates a spectrogram, normalized between 0 and 1, from a given signal.\n\n| Parameter     | Type          | Description                                                    |\n| ------------- | ------------- | -------------------------------------------------------------- |\n| `SIGNAL`      | list, ndarray | Audio signal that the stft is being performed on.              |\n| `SAMPLE_RATE` | int           | Nyquist sample rate to load the clip in as. Defaults to 44100. |\n\nThis function returns two things, stored in a tuple:\n\n- a floating point value representing the ratio between the length of the signal and the length of the x-axis of the spectrogram\n- a 2D Numpy array representing the normalized magnitude stft of the signal\n\nUsage: `perform_stft(SIGNAL)` or `perform_stft(SIGNAL, SAMPLE_RATE = SAMPLE_RATE)`\n\n### [`calculate_medians`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/FG_BG_sep/utils.py)\n\n_Found in ['FG_BG_sep/utils.py'](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/FG_BG_sep/utils.py)_\n\nThis function calculates the temporal (column) and frequency (row) medians of a 2D stft spectrogram. These values are used for binary thresholding in FG-BG separation.\n\n| Parameter | Type    | Description                                                |\n| --------- | ------- | ---------------------------------------------------------- |\n| `stft`    | ndarray | 2D numpy array containing the spectrogram to be processed. |\n\nThis function returns two vectors, one containing the time medians and the other containing the frequency medians.\n\nUsage: `calculate_medians(stft)`\n\n### [`binary_thresholding`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/FG_BG_sep/utils.py)\n\n_Found in ['FG_BG_sep/utils.py'](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/FG_BG_sep/utils.py)_\n\nThis function performs the primary foreground-background separation step used in BirdNET.\n\n| Parameter              | Type    | Description                                                                                                              |\n| ---------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------ |\n| `stft`                 | ndarray | 2D numpy array containing the spectrogram to be processed.                                                               |\n| `time_medians`         | ndarray | Vector of the median powers with respect to time (column medians) in the spectrogram.                                    |\n| `freq_medians`         | ndarray | Vector of the median powers with respect to frequency (row medians) in the spectrogram.                                  |\n| `multiplier_threshold` | float   | Constant that the time and frequency medians are multiplied by in order to determine the power threshold. Defaults to 3. |\n\nThis function returns a binary 2D numpy array that is the same shape as `stft`. It contains 1's for the foreground, and 2's for the background.\n\nUsage: `binary_thresholding(stft, time_medians, freq_medians)` or `binary_thresholding(stft, time_medians, freq_medians, multiplier_threshold = multiplier_threshold)`\n\n### [`binary_morph_opening`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/FG_BG_sep/utils.py)\n\n_Found in ['FG_BG_sep/utils.py'](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/FG_BG_sep/utils.py)_\n\nThis function performs a binary morphological opening operation on the given signal spectrogram, consisting of morphological \"and\" (erosion) and \"or\" (dilation) operations in succession.\n\n| Parameter      | Type    | Description                                                                                                                      |\n| -------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------- |\n| `binary_stft`  | ndarray | 2D numpy array containing the binary spectrogram of the foreground (represented as 1's) and the background (represented as 0's). |\n| `kernel_shape` | int     | Dimension of the square binary morph kernel. Defaults to 4. (kernel_size, kernel_size)                                           |\n\nThis function returns the result of the opening process.\n\nUsage: `binary_morph_opening(binary_stft)` or `binary_morph_opening(binary_stft, kernel_size=kernel_size)`\n\n### [`temporal_thresholding`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/FG_BG_sep/utils.py)\n\n_Found in ['FG_BG_sep/utils.py'](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/FG_BG_sep/utils.py)_\n\nThis function converts a 2D binary stft into a temporal indicator vector, for the purpose of generating a local score array.\nThis array has the same number of values as the number of columns in the time axis of the spectrogram.\nEach value represents whether (1) or not (0) the corresponding column has at least one foreground pixel.\n\n| Parameter            | Type    | Description                                                    |\n| -------------------- | ------- | -------------------------------------------------------------- |\n| `opened_binary_stft` | ndarray | 2D numpy array containing a binary foreground-background stft. |\n\nThis function returns a binary temporal indicator vector that signifies temporal components with high power.\n\nUsage: `temporal_thresholding(opened_binary_stft)`\n\n### [`indicator_vector_processing`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/FG_BG_sep/utils.py)\n\n_Found in ['FG_BG_sep/utils.py'](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/FG_BG_sep/utils.py)_\n\nThis function performs an additional morphological \"or\" (dilation) on a temporal indicator vector for the purpose of expanding on smaller high-power sections.\n\n| Parameter          | Type    | Description                                                                                 |\n| ------------------ | ------- | ------------------------------------------------------------------------------------------- |\n| `indicator_vector` | ndarray | Binary temporal indicator vector to be dilated.                                             |\n| `kernel_size`      | int     | Determines the length of the kernel that performs dilation. Defaults to 4. (1, kernel_size) |\n\nThis function returns the indicator vector after having undergone dilation.\n\nUsage: `indicator_vector_processing(indicator_vector)` or `indicator_vector_processing(indicator_vector, kernel_size=kernel_size)`\n\n### [`FG_BG_local_score_arr`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/FG_BG_sep/utils.py)\n\n_Found in ['FG_BG_sep/utils.py'](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/FG_BG_sep/utils.py)_\n\nThis function builds a local score array for an audio clip by reverse-engineering BirdNET's signal-to-noise-ratio technique.\n\n| Parameter     | Type          | Description                                           |\n| ------------- | ------------- | ----------------------------------------------------- |\n| `SIGNAL`      | list, ndarray | Signal to be processed.                               |\n| `SAMPLE_RATE` | int           | Nyquist sampling rate at which to process the signal. |\n\nThis function returns:\n\n- The ratio between the length of the audio clip and the stft time axis\n- The local score array derived from median thresholding, stored in a numpy array\n\nUsage: `FG_BG_local_score_arr(SIGNAL, isolation_parameters, normalized_sample_rate)`\n\n\u003c/details\u003e\n\n\u003c!-- template_matching/utils.py file --\u003e\n\u003cdetails\u003e\n \u003csummary\u003etemplate_matching/utils.py file\u003c/summary\u003e\n\n### [`generate_specgram`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/template_matching/utils.py)\n\n_Found in ['template_matching/utils.py'](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/template_matching/utils.py)_\n\nThis function generates a stft spectrogram, normalized between 0 and 1, for use in template matching.\n\n| Parameter     | Type    | Description                                                                 |\n| ------------- | ------- | --------------------------------------------------------------------------- |\n| `SIGNAL`      | ndarray | Audio signal of which the stft is performed and the spectrogram is created. |\n| `SAMPLE_RATE` | int     | Rate at which the audio signal was sampled.                                 |\n\nThis function returns a 2D numpy array representing the stft of the given signal. It uses a window length of 1024 and a 50% overlap.\n\nUsage: `generate_specgram(SIGNAL, SAMPLE_RATE)`\n\n### [`butter_bandpass`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/template_matching/utils.py)\n\n_Found in ['template_matching/utils.py'](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/template_matching/utils.py)_\n\nThis function designs a Butterworth filter for a signal based on cutoffs and sample rate..\n\n| Parameter | Type  | Description                         |\n| --------- | ----- | ----------------------------------- |\n| `lowcut`  | int   | The lower frequency cutoff.         |\n| `highcut` | int   | The higher frequency cutoff.        |\n| `fs`      | float | Sample rate of the signal.          |\n| `order`   | int   | Order of the filter. Defaults to 5. |\n\nThis function returns two numpy arrays that represent the numerator and denominator polynomials for the IIR filter.\n\nUsage: `butter_bandpass(lowcut, highcut, fs)` or `butter_bandpass(lowcut, highcut, fs, order=order)`\n\n### [`filter`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/template_matching/utils.py)\n\n_Found in ['template_matching/utils.py'](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/template_matching/utils.py)_\n\nThis is a wrapper function for the `scipy.stats.lfilter()` function. It applies a digital filter to a given signal using given coefficient vectors.\n\n| Parameter | Type    | Description                            |\n| --------- | ------- | -------------------------------------- |\n| `data`    | ndarray | Signal to which the filter is applied. |\n| `b`       | ndarray | the numerator coefficient vector.      |\n| `a`       | ndarray | The denominator coefficient vector.    |\n\nThis function returns the output of the digital filter.\n\nUsage: `filter(data, b, a)`\n\n### [`butter_bandpass_filter`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/template_matching/utils.py)\n\n_Found in ['template_matching/utils.py'](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/template_matching/utils.py)_\n\nThis function designs then applies a Butterworth filter to a given signal.\n\n| Parameter | Type    | Description                                       |\n| --------- | ------- | ------------------------------------------------- |\n| `data`    | ndarray | Signal to which the filter is applied.            |\n| `lowcut`  | int     | The lower frequency cutoff.                       |\n| `highcut` | int     | The higher frequency cutoff.                      |\n| `fs`      | int     | Sample rate for the signal.                       |\n| `order`   | int     | Order of the filter to be applied. Defaults to 5. |\n\nThis function returns the output of putting the given signal through the filter.\n\nUsage: `butter_bandpass_filter(data, lowcut, highcut, fs)` or `butter_bandpass_filter(data, lowcut, highcut, fs, order=order)`\n\n### [`template_matching_local_score_arr`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/template_matching/utils.py)\n\n_Found in ['template_matching/utils.py'](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/template_matching/utils.py)_\n\nThis function uses template matching to generate a local score array for a given signal. This array is used in the isolation techniques to generate labels.\n\n| Parameter          | Type    | Description                                                  |\n| ------------------ | ------- | ------------------------------------------------------------ |\n| `SIGNAL`           | ndarray | 1D numpy array representing the signal.                      |\n| `SAMPLE_RATE`      | int     | Sample rate of the signal in Hz.                             |\n| `template_spec`    | ndarray | 2D numpy array representing the spectrogram of the template. |\n| `n`                | int     | Size of the template spectrogram.                            |\n| `template_std_dev` | float   | Standard deviation of all pixels in the template.            |\n\nThis function returns a local score array of cross-correlation scores generated from template matching.\n\nUsage: `template_matching_local_score_arr(SIGNAL, SAMPLE_RATE, template_spec, n, template_std_dev)`\n\n\u003c/details\u003e\n\n\u003c!-- statistics.py file --\u003e\n\u003cdetails\u003e\n \u003csummary\u003estatistics.py file\u003c/summary\u003e\n\n### [`annotation_duration_statistics`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/statistics.py)\n\n_Found in [`statistics.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/statistics.py)_\n\nThis function calculates basic statistics related to the duration of annotations of a Pandas Dataframe compatible with PyHa.\n\n| Parameter | Type             | Description                                     |\n| --------- | ---------------- | ----------------------------------------------- |\n| `df`      | Pandas Dataframe | Dataframe of automated labels or manual labels. |\n\nThis function returns a Pandas Dataframe containing count, mean, mode, standard deviation, and IQR values based on annotation duration.\n\nUsage: `annotation_duration_statistics(df)`\n\n### [`clip_general`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/statistics.py)\n\n_Found in [`statistics.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/statistics.py)_\n\nThis function generates a dataframe with statistics relating to the efficiency of the automated label compared to the human label. These statistics include true positive, false positive, false negative, true negative, union, precision, recall, F1, and Global IoU for general clip overlap.\n\n| Parameter      | Type      | Description                                |\n| -------------- | --------- | ------------------------------------------ |\n| `automated_df` | Dataframe | Dataframe of automated labels for one clip |\n| `human_df`     | Dataframe | Dataframe of human labels for one clip.    |\n\nThis function returns a dataframe with general clip overlap statistics comparing the automated and human labeling.\n\nUsage: `clip_general(automated_df, human_df)`\n\n### [`automated_labeling_statistics`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/statistics.py)\n\n_Found in [`statistics.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/statistics.py)_\n\nThis function allows users to easily pass in two dataframes of manual labels and automated labels, and returns a dataframe with statistics examining the efficiency of the automated labelling system compared to the human labels for multiple clips.\n\n| Parameter      | Type      | Description                                                     |\n| -------------- | --------- | --------------------------------------------------------------- |\n| `automated_df` | Dataframe | Dataframe of automated labels of multiple clips.                |\n| `manual_df`    | Dataframe | Dataframe of human labels of multiple clips.                    |\n| `stats_type`   | String    | String that determines which type of statistics are of interest |\n| `threshold`    | float     | Defines a threshold for certain types of statistics             |\n\nThis function returns a dataframe of statistics comparing automated labels and human labels for multiple clips.\n\nThe `stats_type` parameter can be set as follows:\n| Name | Description |\n| --- | --- |\n|`\"IoU\"`| Default. Compares the intersection over union of automated annotations with respect to manual annotations for individual clips. |\n|`\"general\"` | Consolidates all automated annotations and compares them to all of the manual annotations that have been consolidated across a clip. |\n\nUsage: `automated_labeling_statistics(automated_df, manual_df, stats_type, threshold)`\n\n### [`global_dataset_statistics`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/statistics.py)\n\n_Found in [`statistics.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/statistics.py)_\n\nThis function takes in a dataframe of efficiency statistics for multiple clips and outputs their global values.\n\n| Parameter       | Type      | Description                                                                                                        |\n| --------------- | --------- | ------------------------------------------------------------------------------------------------------------------ |\n| `statistics_df` | Dataframe | Dataframe of statistics value for multiple audio clips as returned by the function automated_labelling_statistics. |\n\nThis function returns a dataframe of global statistics for the multiple audio clips' labelling.\n\nUsage: `global_dataset_statistics(statistics_df)`\n\n### [`clip_IoU`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/statistics.py)\n\n_Found in [`statistics.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/statistics.py)_\n\nThis function takes in the manual and automated labels for a clip and outputs IoU metrics of each human label with respect to each automated label.\n\n| Parameter      | Type      | Description                                |\n| -------------- | --------- | ------------------------------------------ |\n| `automated_df` | Dataframe | Dataframe of automated labels for one clip |\n| `human_df`     | Dataframe | Dataframe of human labels for one clip.    |\n\nThis function returns an `IoU_Matrix` (arr) - (human label count) x (automated label count) matrix where each row contains the IoU of each automated annotation with respect to a human label.\n\nUsage: `clip_IoU(automated_df, manual_df)`\n\n### [`matrix_IoU_Scores`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/statistics.py)\n\n_Found in [`statistics.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/statistics.py)_\n\nThis function takes in the manual and automated labels for a clip and outputs IoU metrics of each human label with respect to each automated label.\n\n| Parameter    | Type      | Description                                                                                                                                      |\n| ------------ | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |\n| `IoU_Matrix` | arr       | (human label count) x (automated label count) matrix where each row contains the IoU of each automated annotation with respect to a human label. |\n| `manual_df ` | Dataframe | Dataframe of human labels for an audio clip.                                                                                                     |\n| `threshold`  | float     | IoU threshold for determining true positives, false positives, and false negatives.                                                              |\n\nThis function returns a dataframe of clip statistics such as True Positive, False Negative, False Positive, Precision, Recall, and F1 values for an audio clip.\n\nUsage: `matrix_IoU_Scores(IoU_Matrix, manual_df, threshold)`\n\n### [`clip_catch`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/statistics.py)\n\n_Found in [`statistics.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/statistics.py)_\n\nThis function determines whether or not a human label has been found across all of the automated labels.\n\n| Parameter      | Type      | Description                                |\n| -------------- | --------- | ------------------------------------------ |\n| `automated_df` | Dataframe | Dataframe of automated labels for one clip |\n| `human_df`     | Dataframe | Dataframe of human labels for one clip.    |\n\nThis function returns a Numpy Array of statistics regarding the amount of overlap between the manual and automated labels relative to the number of samples.\n\nUsage: `clip_catch(automated_df,manual_df)`\n\n### [`global_statistics`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/statistics.py)\n\n_Found in [`statistics.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/statistics.py)_\n\nThis function takes the output of dataset_IoU Statistics and outputs a global count of true positives and false positives, as well as computes the precision, recall, and f1 metrics across the dataset.\n\n| Parameter       | Type      | Description                                        |\n| --------------- | --------- | -------------------------------------------------- |\n| `statistics_df` | Dataframe | Dataframe of matrix IoU scores for multiple clips. |\n\nThis function returns a dataframe of global IoU statistics which include the number of true positives, false positives, and false negatives. Contains Precision, Recall, and F1 metrics as well\n\nUsage: `global_statistics(statistics_df)`\n\n### [`dataset_Catch`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/statistics.py)\n\n_Found in [`statistics.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/statistics.py)_\n\nThis function determines the overlap of each human label with respect to all of the human labels in a clip across a large number of clips.\n\n| Parameter      | Type      | Description                                |\n| -------------- | --------- | ------------------------------------------ |\n| `automated_df` | Dataframe | Dataframe of automated labels for one clip |\n| `human_df`     | Dataframe | Dataframe of human labels for one clip.    |\n\nThis function returns a dataframe of human labels with a column for the catch values of each label.\n\nUsage: `dataset_Catch(automated_df, manual_df)`\n\n### [`clip_statistics`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/statistics.py)\n\n_Found in [`statistics.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/statistics.py)_\n\n| Parameter      | Type      | Description                                              |\n| -------------- | --------- | -------------------------------------------------------- |\n| `automated_df` | Dataframe | Dataframe of automated labels for multiple classes.      |\n| `human_df`     | Dataframe | Dataframe of human labels for multiple classes.          |\n| `stats_type`   | String    | String that determines which statistics are of interest. |\n| `threshold`    | float     | Defines a threshold for certain types of statistics.     |\n\nThis function returns a dataframe with clip overlap statistics comparing automated and human labeling for multiple classes\n\nThe `stats_type` parameter can be set as follows:\n| Name | Description |\n| --- | --- |\n|`\"IoU\"`| Default. Compares the intersection over union of automated annotations with respect to manual annotations for individual clips. |\n|`\"general\"` | Consolidates all automated annotations and compares them to all of the manual annotations that have been consolidated across a clip. |\n\nUsage: `clip_statistics(automated_df, manual_df, stats_type, threshold)`\n\n### [`class_statistics`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/statistics.py)\n\n_Found in [`statistics.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/statistics.py)_\n\n| Parameter         | Type      | Description                                                                                             |\n| ----------------- | --------- | ------------------------------------------------------------------------------------------------------- |\n| `clip_statistics` | Dataframe | Dataframe of multi-class statistics values for audio clips as returned by the function clip_statistics. |\n\nThis function returns a dataframe of global efficacy values for multiple classes.\n\nUsage: `class_statistics(clip_statistics)`\n\n\u003c/details\u003e\n\n\u003c!-- visualizations.py file --\u003e\n\u003cdetails\u003e\n \u003csummary\u003evisualizations.py file\u003c/summary\u003e\n\n### [`spectrogram_graph`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/visualizations.py)\n\n_Found in [`visualizations.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/visualizations.py)_\n\nThis function produces graphs with the spectrogram of an audio clip. It is now integrated with Pandas so you can visualize human and automated annotations.\n\n| Parameter                   | Type         | Description                                                                 |\n| --------------------------- | ------------ | --------------------------------------------------------------------------- |\n| `clip_name`                 | string       | Directory of the clip.                                                      |\n| `sample_rate`               | int          | Sample rate of the audio clip, usually 44100.                               |\n| `samples`                   | list of ints | Each of the samples from the audio clip.                                    |\n| `automated_df`              | Dataframe    | Dataframe of automated labelling of the clip.                               |\n| `premade_annotations_df`    | Dataframe    | Dataframe labels that have been made outside of the scope of this function. |\n| `premade_annotations_label` | string       | Descriptor of premade_annotations_df                                        |\n| `save_fig`                  | boolean      | Whether the clip should be saved in a directory as a png file.              |\n\nThis function does not return anything.\n\nUsage: `spectrogram_graph(clip_name, sample_rate, samples, automated_df, premade_annotations_df, premade_annotations_label, save_fig, normalize_local_scores)`\n\n### [`local_line_graph`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/visualizations.py)\n\n_Found in [`visualizations.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/visualizations.py)_\n\nThis function produces graphs with the local score plot and spectrogram of an audio clip. It is now integrated with Pandas so you can visualize human and automated annotations.\n\n| Parameter                   | Type           | Description                                                                     |\n| --------------------------- | -------------- | ------------------------------------------------------------------------------- |\n| `local_scores`              | list of floats | Local scores for the clip determined by the RNN.                                |\n| `clip_name`                 | string         | Directory of the clip.                                                          |\n| `sample_rate`               | int            | Sample rate of the audio clip, usually 44100.                                   |\n| `samples`                   | list of ints   | Each of the samples from the audio clip.                                        |\n| `automated_df`              | Dataframe      | Dataframe of automated labelling of the clip.                                   |\n| `premade_annotations_df`    | Dataframe      | Dataframe labels that have been made outside of the scope of this function.     |\n| `premade_annotations_label` | string         | Descriptor of premade_annotations_df                                            |\n| `log_scale`                 | boolean        | Whether the axis for local scores should be logarithmically scaled on the plot. |\n| `save_fig`                  | boolean        | Whether the clip should be saved in a directory as a png file.                  |\n\nThis function does not return anything.\n\nUsage: `local_line_graph(local_scores, clip_name, sample_rate, samples, automated_df, premade_annotations_df, premade_annotations_label, log_scale, save_fig, normalize_local_scores)`\n\n### [`spectrogram_visualization`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/visualizations.py)\n\n_Found in [`visualizations.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/visualizations.py)_\n\nThis is the wrapper function for the local_line_graph and spectrogram_graph functions for ease of use. Processes clip for local scores to be used for the local_line_graph function.\n\n| Parameter                   | Type      | Description                                                                                 |\n| --------------------------- | --------- | ------------------------------------------------------------------------------------------- |\n| `clip_path`                 | string    | Path to an audio clip.                                                                      |\n| `weight_path`               | string    | Weights to be used for RNNDetector.                                                         |\n| `premade_annotations_df`    | Dataframe | Dataframe of annotations to be displayed that have been created outside of the function.    |\n| `premade_annotations_label` | string    | String that serves as the descriptor for the premade_annotations dataframe.                 |\n| `automated_df`              | Dataframe | Whether the audio clip should be labelled by the isolate function and subsequently plotted. |\n| `log_scale`                 | boolean   | Whether the axis for local scores should be logarithmically scaled on the plot.             |\n| `save_fig`                  | boolean   | Whether the plots should be saved in a directory as a png file.                             |\n\nThis function does not return anything.\n\nUsage: `spectrogram_visualization(clip_path, weight_path, premade_annotations_df, premade_annotations_label,automated_df = False, isolation_parameters, log_scale, save_fig, normalize_local_scores)`\n\n### [`binary_visualization`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/visualizations.py)\n\n_Found in [`visualizations.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/visualizations.py)_\n\nThis function visualizes automated and human annotation scores across an audio clip.\n\n| Parameter      | Type      | Description                                                   |\n| -------------- | --------- | ------------------------------------------------------------- |\n| `automated_df` | Dataframe | Dataframe of automated labels for one clip.                   |\n| `human_df`     | Dataframe | Dataframe of human labels for one clip.                       |\n| `plot_fig`     | boolean   | Whether or not the efficiency statistics should be displayed. |\n| `save_fig`     | boolean   | Whether or not the plot should be saved within a file.        |\n\nThis function returns a dataframe with statistics comparing the automated and human labeling.\n\nUsage: `binary_visualization(automated_df,human_df,save_fig)`\n\n### [`annotation_duration_histogram`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/visualizations.py)\n\n_Found in [`visualizations.py`](https://github.com/UCSD-E4E/PyHa/blob/main/PyHa/visualizations.py)_\n\nThis function builds a histogram to visualize the length of annotations.\n\n| Parameter       | Type      | Description                                            |\n| --------------- | --------- | ------------------------------------------------------ |\n| `annotation_df` | Dataframe | Dataframe of automated or human labels.                |\n| `n_bins`        | int       | Number of histogram bins in the final histogram.       |\n| `min_length`    | int       | Minimum length of the audio clip.                      |\n| `max_length`    | int       | Maximum length of the audio clip.                      |\n| `save_fig`      | boolean   | Whether or not the plot should be saved within a file. |\n| `filename`      | String    | Name of the file to save the histogram to.             |\n\nThis function returns a histogram with the length of the annotations.\n\nUsage: `binary_visualization(annotation_df, n_bins, min_length, max_length, save_fig, filename)`\n\n\u003c/details\u003e\n\nAll files in the `birdnet_lite` directory are from a [modified version](https://github.com/UCSD-E4E/BirdNET-Lite) of the [BirdNET Lite repository](https://github.com/kahst/BirdNET-Lite), and their associated documentation can be found there.\n\nAll files in the `microfaune_package` directory are from the [microfaune repository](https://github.com/microfaune/microfaune), and their associated documentation can be found there.\n\nAll files in the `tweetynet` directory are from the [tweetynet repository](https://github.com/yardencsGitHub/tweetynet), and their associated documentation can be found there.\n\nAll files in the `tweetynet` directory are from the [tweetynet repository](https://github.com/yardencsGitHub/tweetynet), and their associated documentation can be found there.\n\n## Examples\n\n_These examples were created on an Ubuntu 16.04 machine. Results may vary between different Operating Systems and Tensorflow versions._\n\nExamples using Microfaune were created using the following dictionary for `isolation_parameters`:\n\n```json\nisolation_parameters = {\n     \"model\" : \"microfaune\",\n     \"technique\" : \"steinberg\",\n     \"threshold_type\" : \"median\",\n     \"threshold_const\" : 2.0,\n     \"threshold_min\" : 0.0,\n     \"window_size\" : 2.0,\n     \"chunk_size\" : 5.0\n }\n```\n\n### To generate automated labels and get manual labels:\n\n```python\nautomated_df = generate_automated_labels(path,isolation_parameters,normalize_local_scores=True)\nmanual_df = pd.read_csv(\"ScreamingPiha_Manual_Labels.csv\")\n```\n\n### Function that gathers statistics about the duration of labels\n\n```python\nannotation_duration_statistics(automated_df)\n```\n\n![image](https://user-images.githubusercontent.com/44332326/127575042-96d46c11-cc3e-470e-a10d-31f1d7ef052a.png)\n\n```python\nannotation_duration_statistics(manual_df)\n```\n\n![image](https://user-images.githubusercontent.com/44332326/127575181-9ce49439-5396-425d-a1d5-148ef47db373.png)\n\n### Function that converts annotations into 3 second chunks\n\n```python\nannotation_chunker(automated_df, 3)\n```\n\n![annotation chunker](https://user-images.githubusercontent.com/33042752/176480538-671b731d-89ad-402c-a603-8a0ee35124f6.png)\n\n### Helper function to convert to kaleidoscope-compatible format\n\n```python\nkaleidoscope_conversion(manual_df)\n```\n\n![image](https://user-images.githubusercontent.com/44332326/127575089-023bc41a-5aaf-43fc-8ea6-3a8b9dd69b66.png)\n\n### Baseline Graph without any annotations\n\n```python\nclip_path = \"./TEST/ScreamingPiha2.wav\"\nspectrogram_visualization(clip_path)\n```\n\n![image](https://user-images.githubusercontent.com/44332326/126691710-01c4e88c-0c54-4539-a24d-c682cd93aebf.png)\n\n### Baseline Graph with log scale\n\n```python\nspectrogram_visualization(clip_path,log_scale = True)\n```\n\n![image](https://user-images.githubusercontent.com/44332326/126691745-b1cb8be6-c52f-45cc-b7e6-9973070aacc9.png)\n\n### Baseline graph with normalized local score values between [0,1]\n\n```python\nspectrogram_visualization(clip_path, normalize_local_scores = True)\n```\n\n![image](https://user-images.githubusercontent.com/44332326/126691803-b01c96e8-31bc-45dd-b936-58f0d9a153b4.png)\n\n### Graph with Automated Labeling\n\n```python\nspectrogram_visualization(clip_path,automated_df = True, isolation_parameters = isolation_parameters)\n```\n\n![image](https://user-images.githubusercontent.com/44332326/127575291-8e83e9ed-0ca3-4caf-a3fb-a83785123f33.png)\n\n### Graph with Human Labelling\n\n```python\nspectrogram_visualization(clip_path, premade_annotations_df = manual_df[manual_df[\"IN FILE\"] == \"ScreamingPiha2.wav\"],premade_annotations_label = \"Piha Human Labels\")\n```\n\n![image](https://user-images.githubusercontent.com/44332326/127575314-712aeaf8-f88c-44ef-8afa-3c3da86000cb.png)\n\n### Graph with Both Automated and Human Labels\n\n_Legend:_\n\n    - Orange ==\u003e True Positive\n    - Red ==\u003e False Negative\n    - Yellow ==\u003e False Positive\n    - White ==\u003e True Negative\n\n```python\nspectrogram_visualization(clip_path,automated_df = True,isolation_parameters=isolation_parameters,premade_annotations_df = manual_df[manual_df[\"IN FILE\"] == \"ScreamingPiha2.wav\"])\n```\n\n![image](https://user-images.githubusercontent.com/44332326/127575359-9dbfd330-f9e1-423c-a063-62b2a9af78dc.png)\n\n### Another Visualization of True Positives, False Positives, False Negatives, and True Negatives\n\n```python\nautomated_piha_df = automated_df[automated_df[\"IN FILE\"] == \"ScreamingPiha2.wav\"]\nmanual_piha_df = manual_df[manual_df[\"IN FILE\"] == \"ScreamingPiha2.wav\"]\npiha_stats = binary_visualization(automated_piha_df,manual_piha_df)\n```\n\n![image](https://user-images.githubusercontent.com/44332326/127575392-2c5df40c-27e7-490f-ace5-7d9d253487f7.png)\n\n### Function that generates statistics to gauge efficacy of automated labeling compared to human labels\n\n```python\nstatistics_df = automated_labeling_statistics(automated_df,manual_df,stats_type = \"general\")\n```\n\n![image](https://user-images.githubusercontent.com/44332326/127575467-cb9a8637-531e-4ed7-a15e-5b5b611ba92c.png)\n\n### Function that takes the statistical output of all of the clips and gets the equivalent global scores\n\n```python\nglobal_dataset_statistics(statistics_df)\n```\n\n![image](https://user-images.githubusercontent.com/44332326/127575622-5be17af4-f3a0-40ee-8a54-365825eea03e.png)\n\n### Function that takes in the manual and automated labels for a clip and outputs human label-by-label IoU Scores. Used to derive statistics that measure how well a system is isolating desired segments of audio clips\n\n```python\nIntersection_over_Union_Matrix = clip_IoU(automated_piha_df,manual_piha_df)\n```\n\n![image](https://user-images.githubusercontent.com/44332326/127575675-71f91fc8-3143-49e6-a10b-0c1781fb498e.png)\n\n### Function that turns the IoU Matrix of a clip into true positive and false positives values, as well as computing the precision, recall, and F1 statistics\n\n```python\nmatrix_IoU_Scores(Intersection_over_Union_Matrix,manual_piha_df,0.5)\n```\n\n![image](https://user-images.githubusercontent.com/44332326/127575732-6c805bcc-a863-4c32-aba6-712ce2bac7bb.png)\n\n### Wrapper function that takes matrix_IoU_Scores across multiple clips. Allows user to modify the threshold that determines whether or not a label is a true positive.\n\n```python\nstats_df = automated_labeling_statistics(automated_df,manual_df,stats_type = \"IoU\",threshold = 0.5)\n```\n\n![image](https://user-images.githubusercontent.com/44332326/127575771-9866f288-61cf-47c5-b9de-041b49e583d1.png)\n\n### Function that takes the output of dataset_IoU Statistics and outputs a global count of true positives and false positives, as well as computing common metrics across the dataset\n\n```python\nglobal_stats_df = global_statistics(stats_df)\n```\n\n![image](https://user-images.githubusercontent.com/44332326/127575798-f84540ea-5121-4e7a-83c4-4ca5ad02e9d0.png)\n\nAll relevant audio from the PyHa tutorial can be found within the [\"TEST\" folder]([https://drive.google.com/drive/u/0/folders/1lIweB8rF9JZhu6imkuTg_No0i04ClDh1](https://drive.google.com/drive/folders/1lIweB8rF9JZhu6imkuTg_No0i04ClDh1?usp=sharing)).\nIn order to replicate the results displayed in the GitHub repository, make sure\nthe audio clips are located in a folder called \"TEST\" in the same directory\npath as we had in the Jupyter Notebook tutorial.\n\nAll audio clips can be found on [xeno-canto.org](xeno-canto.org) under the Creative Commons\nAttribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)\n[https://creativecommons.org/licenses/by-nc-sa/4.0/ license](https://creativecommons.org/licenses/by-nc-sa/4.0/ license).\n\nThe manual labels provided for this dataset are automatically downloaded as a .csv when\nthe repository is cloned.\n\n## Testing\nTests require E4E NAS credentials.  These must be provided as a JSON file, or as an environment variable.\n\nIf provided as a JSON file, this file must be placed at `${workspaceFolder}/credentials.json`, and have the following structure:\n```\n{\n    \"username\": \"e4e_nas_user\",\n    \"password\": \"e4e_nas_password\"\n}\n```\n\nIf provided as an environment variable, the variable must be named `NAS_CREDS` and must have the following structure:\n```\n{\"username\":\"e4e_nas_user\",\"password\":\"e4e_nas_password\"}\n```\n\nAny account used must have read access to the following share:\n- //e4e-nas.ucsd.edu/temp\n\nExecute `pytest` as follows:\n```\npython -m pytest pyha_tests\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fucsd-e4e%2Fpyha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fucsd-e4e%2Fpyha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fucsd-e4e%2Fpyha/lists"}