Skip to content
Snippets Groups Projects
Commit b384d014 authored by valentin.emiya's avatar valentin.emiya
Browse files

add notebook create_subregions

parent efea0db2
No related tags found
No related merge requests found
Pipeline #5124 failed
%% Cell type:markdown id: tags:
# Demo for `tffpy.create_subregions.create_subregions`
A simple demonstration for creating sub-regions from a boolean time-frequency mask
%% Cell type:code id: tags:
``` python
%load_ext autoreload
%autoreload 2
%matplotlib inline
```
%% Cell type:code id: tags:
``` python
%%javascript
IPython.OutputArea.prototype._should_scroll = function(lines) {
return false;
}
```
%% Cell type:code id: tags:
``` python
import numpy as np
import matplotlib as mpl
mpl.rcParams['figure.figsize'] = [15.0, 7.0]
import matplotlib.pyplot as plt
from tffpy.datasets import get_mix
from tffpy.create_subregions import create_subregions
```
%% Cell type:code id: tags:
``` python
fig_dir = 'fig_create_subregions'
x_mix, dgt_params, signal_params, mask, x_loc, x_wb = \
get_mix(loc_source='bird',
wideband_src='car',
crop=8192,
win_dur=256/8000,
win_type='gauss',
hop_ratio=1/4,
n_bins_ratio=4,
n_iter_closing=3,
n_iter_opening=3,
closing_first=True,
delta_mix_db=0,
delta_loc_db=20,
wb_to_loc_ratio_db=16,
or_mask=True,
fig_dir=None)
```
%% Cell type:code id: tags:
``` python
tol = 1e-9
mask_with_subregions, norms = create_subregions(mask_bool=mask,
dgt_params=dgt_params, signal_params=signal_params,
tol=tol, fig_dir=fig_dir, return_norms=True)
```
%% Cell type:code id: tags:
``` python
print('Values in mask:', np.unique(mask_with_subregions))
print('Number of sub-regions:', np.max(mask_with_subregions))
plt.semilogy(np.sort(np.unique(norms)))
plt.title('Distances between sub-regions (sorted norm coefficients without duplicates)')
plt.grid()
```
%% Cell type:code id: tags:
``` python
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment