Commit b384d014 authored by valentin.emiya's avatar valentin.emiya

add notebook create_subregions

parent efea0db2
Pipeline #5124 failed with stages
in 5 minutes and 27 seconds
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Demo for `tffpy.create_subregions.create_subregions`\n",
"\n",
"A simple demonstration for creating sub-regions from a boolean time-frequency mask"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2\n",
"\n",
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%javascript\n",
"IPython.OutputArea.prototype._should_scroll = function(lines) {\n",
" return false;\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib as mpl\n",
"mpl.rcParams['figure.figsize'] = [15.0, 7.0]\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from tffpy.datasets import get_mix\n",
"from tffpy.create_subregions import create_subregions"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fig_dir = 'fig_create_subregions'\n",
"x_mix, dgt_params, signal_params, mask, x_loc, x_wb = \\\n",
" get_mix(loc_source='bird',\n",
" wideband_src='car',\n",
" crop=8192,\n",
" win_dur=256/8000,\n",
" win_type='gauss',\n",
" hop_ratio=1/4,\n",
" n_bins_ratio=4,\n",
" n_iter_closing=3,\n",
" n_iter_opening=3,\n",
" closing_first=True,\n",
" delta_mix_db=0,\n",
" delta_loc_db=20,\n",
" wb_to_loc_ratio_db=16,\n",
" or_mask=True,\n",
" fig_dir=None)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"tol = 1e-9\n",
"mask_with_subregions, norms = create_subregions(mask_bool=mask, \n",
" dgt_params=dgt_params, signal_params=signal_params, \n",
" tol=tol, fig_dir=fig_dir, return_norms=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print('Values in mask:', np.unique(mask_with_subregions))\n",
"print('Number of sub-regions:', np.max(mask_with_subregions))\n",
"plt.semilogy(np.sort(np.unique(norms)))\n",
"plt.title('Distances between sub-regions (sorted norm coefficients without duplicates)')\n",
"plt.grid()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment