Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
overview-DF
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DOLPHINFREE experiments
overview-DF
Commits
13c76a7d
Commit
13c76a7d
authored
2 years ago
by
Loic-Lenof
Browse files
Options
Downloads
Patches
Plain Diff
Spell check
parent
d19a6ecb
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
BBPs/2-manual_verification.py
+4
-4
4 additions, 4 deletions
BBPs/2-manual_verification.py
Whistles/1-Identification_of_whistles.py
+5
-5
5 additions, 5 deletions
Whistles/1-Identification_of_whistles.py
Whistles/WhistleUtils.py
+16
-16
16 additions, 16 deletions
Whistles/WhistleUtils.py
with
25 additions
and
25 deletions
BBPs/2-manual_verification.py
+
4
−
4
View file @
13c76a7d
...
...
@@ -109,8 +109,8 @@ for file in range(len(audio_paths)):
width
=
[
0
,
max_length
])[
0
]
Magnitude_audio
=
stft
(
signal_high
,
n_fft
=
nfft
,
hop_length
=
hop_length
)
#spectr
e
= amplitude_to_db(np.abs(Magnitude_audio))
spectr
e
=
pcen
(
np
.
abs
(
Magnitude_audio
)
*
(
2
**
31
))
#spectr
um
= amplitude_to_db(np.abs(Magnitude_audio))
spectr
um
=
pcen
(
np
.
abs
(
Magnitude_audio
)
*
(
2
**
31
))
# show ICI of each BBP
n_BBP
=
np
.
unique
(
BBP_all
[
use
,
-
1
])
...
...
@@ -143,7 +143,7 @@ for file in range(len(audio_paths)):
axs
[
0
].
axis
(
xmin
=
lower
,
xmax
=
upper
)
axs
[
0
].
tick_params
(
'
x
'
,
labelbottom
=
False
,
bottom
=
False
)
axs
[
1
].
imshow
(
spectr
e
[::
-
1
][:,
int
(
lower
/
hop_length
):
int
(
upper
/
hop_length
)],
axs
[
1
].
imshow
(
spectr
um
[::
-
1
][:,
int
(
lower
/
hop_length
):
int
(
upper
/
hop_length
)],
aspect
=
'
auto
'
,
interpolation
=
'
none
'
,
cmap
=
'
jet
'
,
extent
=
(
0
,(
upper
-
lower
)
/
sr
,
0
,
int
(
sr
/
2
)))
axs
[
1
].
set_title
(
"
Spectrogram (dB scale)
"
)
...
...
@@ -195,7 +195,7 @@ for file in range(len(audio_paths)):
plt
.
close
(
'
all
'
)
del
signal
,
signal_high
,
signal_peaks
,
tk_signal
,
\
Magnitude_audio
,
spectr
e
Magnitude_audio
,
spectr
um
dict_annot
[
audio_paths
[
file
]]
=
BBP_manual
# Temp save (in case of a crash)
...
...
This diff is collapsed.
Click to expand it.
Whistles/1-Identification_of_whistles.py
+
5
−
5
View file @
13c76a7d
...
...
@@ -71,14 +71,14 @@ for file in range(len(audio_paths)):
# resample
signal_dec
=
resample
(
signal
,
int
(((
stop
-
start
)
*
new_sr
)))
# extract spectr
al
informations
# extract spectr
um
informations
Magnitude_audio
=
stft
(
signal_dec
,
n_fft
=
nfft
,
hop_length
=
hop_length
)
spectr
e
=
np
.
copy
(
np
.
abs
(
Magnitude_audio
[
f_min
:,:]))
# PCEN could replace spectr
ogra
m in very noisy recordings
#spectr
e
_pcen = pcen(np.abs(Magnitude_audio) * (2**31), bias=10)[f_min:,:]
spectr
um
=
np
.
copy
(
np
.
abs
(
Magnitude_audio
[
f_min
:,:]))
# PCEN could replace spectr
u
m in very noisy recordings
#spectr
um
_pcen = pcen(np.abs(Magnitude_audio) * (2**31), bias=10)[f_min:,:]
# Selection algorithm
max_loc_per_bin_check1
=
get_local_maxima
(
spectr
e
,
spectr
e
,
nrg_rap
)[
1
]
max_loc_per_bin_check1
=
get_local_maxima
(
spectr
um
,
spectr
um
,
nrg_rap
)[
1
]
trajectories
=
get_trajectories
(
max_loc_per_bin_check1
,
dist_f
=
dist_f
,
dist_t
=
dist_t
)
final_traj
=
select_trajectories
(
trajectories
,
taille_traj_min
,
min_acce
,
max_acce
,
verbose
=
0
)
corrected_traj
=
sparsity_ridoff
(
final_traj
,
error_thresh
=
sparsity
)
...
...
This diff is collapsed.
Click to expand it.
Whistles/WhistleUtils.py
+
16
−
16
View file @
13c76a7d
...
...
@@ -112,11 +112,11 @@ def get_csv(csv_folder, slash="\\"):
return
data_frame
,
sorted_names
#%% Trajectories algorithms
def
get_local_maxima
(
spectr
ogra
m
,
spectr
ogra
m2
,
hardness
,
threshold
=
10e-5
):
def
get_local_maxima
(
spectr
u
m
,
spectr
u
m2
,
hardness
,
threshold
=
10e-5
):
"""
Parameters
----------
spectr
ogra
m : NUMPY ARRAY
spectr
u
m : NUMPY ARRAY
Spectrogram (float values) of an audio signal.
hardness : INT or FLOAT
Number of times a value has to be above the geometric mean in order to be kept.
...
...
@@ -128,21 +128,21 @@ def get_local_maxima(spectrogram, spectrogram2, hardness, threshold=10e-5):
local_max2 : NUMPY ARRAY
Spectrogram with 1 & 0 indicating local maxima above hardness*geom_mean
"""
local_max1
=
np
.
zeros
(
spectr
ogra
m
.
shape
,
dtype
=
int
)
local_max2
=
np
.
zeros
(
spectr
ogra
m
.
shape
,
dtype
=
int
)
geom_mean
=
gmean
(
gmean
(
spectr
ogra
m
,
axis
=
1
))
geom_mean0
=
gmean
(
spectr
ogra
m
,
axis
=
0
)
geom_mean1
=
gmean
(
spectr
ogra
m
,
axis
=
1
)
# geom_mean0, geom_mean1 = gmean(spectr
ogra
m), gmean(spectr
ogra
m)
for
each_bin
in
range
(
spectr
ogra
m
.
shape
[
1
]):
for
freq
in
range
(
1
,
spectr
ogra
m
.
shape
[
0
]
-
1
):
if
(
spectr
ogram2
[
freq
,
each_bin
]
>
spectr
ogra
m2
[
freq
-
1
,
each_bin
])
and
\
(
spectr
ogra
m2
[
freq
,
each_bin
]
>
spectr
ogra
m2
[
freq
+
1
,
each_bin
]):
local_max1
=
np
.
zeros
(
spectr
u
m
.
shape
,
dtype
=
int
)
local_max2
=
np
.
zeros
(
spectr
u
m
.
shape
,
dtype
=
int
)
geom_mean
=
gmean
(
gmean
(
spectr
u
m
,
axis
=
1
))
geom_mean0
=
gmean
(
spectr
u
m
,
axis
=
0
)
geom_mean1
=
gmean
(
spectr
u
m
,
axis
=
1
)
# geom_mean0, geom_mean1 = gmean(spectr
u
m), gmean(spectr
u
m)
for
each_bin
in
range
(
spectr
u
m
.
shape
[
1
]):
for
freq
in
range
(
1
,
spectr
u
m
.
shape
[
0
]
-
1
):
if
(
spectr
um1
[
freq
,
each_bin
]
>
spectr
u
m2
[
freq
-
1
,
each_bin
])
and
\
(
spectr
u
m2
[
freq
,
each_bin
]
>
spectr
u
m2
[
freq
+
1
,
each_bin
]):
local_max1
[
freq
,
each_bin
]
=
1
if
(
spectr
ogra
m
[
freq
,
each_bin
]
>
(
threshold
)):
if
(
spectr
ogra
m
[
freq
,
each_bin
]
>
(
geom_mean0
[
each_bin
]
*
hardness
)):
if
(
spectr
ogra
m
[
freq
,
each_bin
]
>
(
geom_mean1
[
freq
]
*
hardness
)):
if
(
spectr
u
m
[
freq
,
each_bin
]
>
(
threshold
)):
if
(
spectr
u
m
[
freq
,
each_bin
]
>
(
geom_mean0
[
each_bin
]
*
hardness
)):
if
(
spectr
u
m
[
freq
,
each_bin
]
>
(
geom_mean1
[
freq
]
*
hardness
)):
local_max2
[
freq
,
each_bin
]
=
1
return
local_max1
,
local_max2
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment