Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IPI_annot
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maxence Ferrari
IPI_annot
Commits
e5f8157f
Commit
e5f8157f
authored
4 years ago
by
ferrari
Browse files
Options
Downloads
Patches
Plain Diff
Add individual number input and key control
parent
429dbd72
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
IPI_bombyx.py
+1
-1
1 addition, 1 deletion
IPI_bombyx.py
ipi_extract.py
+47
-3
47 additions, 3 deletions
ipi_extract.py
with
48 additions
and
4 deletions
IPI_bombyx.py
+
1
−
1
View file @
e5f8157f
...
@@ -135,7 +135,7 @@ if __name__ == '__main__':
...
@@ -135,7 +135,7 @@ if __name__ == '__main__':
parser
.
add_argument
(
"
--channel
"
,
type
=
int
,
default
=
0
,
help
=
"
Sound channel to be analysed. Indices start from 0.
"
)
parser
.
add_argument
(
"
--channel
"
,
type
=
int
,
default
=
0
,
help
=
"
Sound channel to be analysed. Indices start from 0.
"
)
parser
.
add_argument
(
"
--nb_ind
"
,
type
=
int
,
default
=
1
,
help
=
"
Maximum number of individual for each track. -1 for no limit
"
)
parser
.
add_argument
(
"
--nb_ind
"
,
type
=
int
,
default
=
1
,
help
=
"
Maximum number of individual for each track. -1 for no limit
"
)
parser
.
add_argument
(
"
--erase
"
,
action
=
'
store_true
'
,
help
=
"
If out file exist and this option is not given,
"
parser
.
add_argument
(
"
--erase
"
,
action
=
'
store_true
'
,
help
=
"
If out file exist and this option is not given,
"
"
the
computation will be halt
ed
"
)
"
the
previous output will be read and append
ed
"
)
parser
.
add_argument
(
"
--wd
"
,
type
=
str
,
default
=
'
/nfs/NASDELL/SABIOD/SITE/BOMBYX/
'
,
help
=
'
Path to root dir
'
parser
.
add_argument
(
"
--wd
"
,
type
=
str
,
default
=
'
/nfs/NASDELL/SABIOD/SITE/BOMBYX/
'
,
help
=
'
Path to root dir
'
'
containing Bombyx files
'
)
'
containing Bombyx files
'
)
parser
.
add_argument
(
"
--done_file
"
,
type
=
str
,
parser
.
add_argument
(
"
--done_file
"
,
type
=
str
,
...
...
This diff is collapsed.
Click to expand it.
ipi_extract.py
+
47
−
3
View file @
e5f8157f
...
@@ -259,8 +259,11 @@ class Callback(object):
...
@@ -259,8 +259,11 @@ class Callback(object):
self
.
cursor
=
None
self
.
cursor
=
None
self
.
f_cursor
=
None
self
.
f_cursor
=
None
self
.
reset_b
=
None
self
.
reset_b
=
None
self
.
r_button
=
None
self
.
ind_b
=
None
self
.
spec_b
=
None
self
.
spec_b
=
None
self
.
nfft
=
128
self
.
nfft
=
128
self
.
ind_select
=
False
def
shift_left
(
self
,
event
):
def
shift_left
(
self
,
event
):
self
.
p
=
max
(
0
,
self
.
p
-
FSSR
*
13
)
self
.
p
=
max
(
0
,
self
.
p
-
FSSR
*
13
)
...
@@ -347,6 +350,10 @@ class Callback(object):
...
@@ -347,6 +350,10 @@ class Callback(object):
else
:
else
:
self
.
view_data
[
self
.
curr
][
3
][
1
].
set_xdata
((
row
[
'
ipi_ceps_man
'
],
row
[
'
ipi_ceps_man
'
]))
self
.
view_data
[
self
.
curr
][
3
][
1
].
set_xdata
((
row
[
'
ipi_ceps_man
'
],
row
[
'
ipi_ceps_man
'
]))
self
.
view_data
[
self
.
curr
][
3
][
1
].
set_visible
(
True
)
self
.
view_data
[
self
.
curr
][
3
][
1
].
set_visible
(
True
)
self
.
ind_select
=
False
self
.
ind_b
.
color
=
'
0.85
'
self
.
ind_b
.
howercolor
=
'
0.95
'
self
.
ind_b
.
label
.
set_text
(
f
'
Current individual:
\n
{
self
.
df
[
mpos
/
FSSR
][
"
ind_number
"
]
}
'
)
click
=
self
.
song
[
max
(
int
(
mpos
*
self
.
sr
/
FSSR
-
10e-3
*
self
.
sr
),
0
):
int
(
mpos
*
self
.
sr
/
FSSR
+
10e-3
*
self
.
sr
)]
click
=
self
.
song
[
max
(
int
(
mpos
*
self
.
sr
/
FSSR
-
10e-3
*
self
.
sr
),
0
):
int
(
mpos
*
self
.
sr
/
FSSR
+
10e-3
*
self
.
sr
)]
if
len
(
click
)
!=
2
*
int
(
10e-3
*
self
.
sr
):
if
len
(
click
)
!=
2
*
int
(
10e-3
*
self
.
sr
):
np
.
pad
(
click
,
(
0
,
2
*
int
(
10e-3
*
self
.
sr
)
-
len
(
click
)),
mode
=
'
constant
'
)
np
.
pad
(
click
,
(
0
,
2
*
int
(
10e-3
*
self
.
sr
)
-
len
(
click
)),
mode
=
'
constant
'
)
...
@@ -401,6 +408,30 @@ class Callback(object):
...
@@ -401,6 +408,30 @@ class Callback(object):
self
.
reset_b
.
label
.
set_c
(
'
rgb
'
[
self
.
curr
])
self
.
reset_b
.
label
.
set_c
(
'
rgb
'
[
self
.
curr
])
plt
.
draw
()
plt
.
draw
()
def
toggle_ind
(
self
,
event
):
if
not
len
(
self
.
offset
):
return
self
.
ind_select
=
not
self
.
ind_select
self
.
ind_b
.
color
=
'
limegreen
'
if
self
.
ind_select
else
'
0.85
'
self
.
ind_b
.
hovercolor
=
'
lime
'
if
self
.
ind_select
else
'
0.95
'
if
self
.
ind_select
:
self
.
df
[
self
.
offset
[
self
.
curr_ind
[
self
.
curr
],
0
]][
'
ind_number
'
]
=
''
self
.
ind_b
.
label
.
set_text
(
f
'
Current individual:
\n
'
)
plt
.
draw
()
def
key_pressed
(
self
,
event
):
if
self
.
ind_select
:
row
=
self
.
df
[
self
.
offset
[
self
.
curr_ind
[
self
.
curr
],
0
]]
row
[
'
ind_number
'
]
=
row
[
'
ind_number
'
]
+
event
.
key
self
.
ind_b
.
label
.
set_text
(
f
'
Current individual:
\n
{
row
[
"
ind_number
"
]
}
'
)
plt
.
draw
()
else
:
if
event
.
key
in
'
012
'
:
self
.
change_curr
(
event
.
key
)
self
.
r_button
.
set_active
(
int
(
event
.
key
))
pass
def
play
(
self
,
event
):
def
play
(
self
,
event
):
sound
=
(
norm
(
self
.
song_resample
[
self
.
p
:
self
.
p
+
FSSR
*
20
])
*
(
2
**
15
-
1
)).
astype
(
np
.
int16
)
sound
=
(
norm
(
self
.
song_resample
[
self
.
p
:
self
.
p
+
FSSR
*
20
])
*
(
2
**
15
-
1
)).
astype
(
np
.
int16
)
try
:
try
:
...
@@ -452,7 +483,6 @@ class Callback(object):
...
@@ -452,7 +483,6 @@ class Callback(object):
self
.
spec_b
[
'
minus_res
'
].
label
.
set_text
(
f
'
{
self
.
nfft
//
2
}
\n
bins
'
)
self
.
spec_b
[
'
minus_res
'
].
label
.
set_text
(
f
'
{
self
.
nfft
//
2
}
\n
bins
'
)
plt
.
draw
()
plt
.
draw
()
def
_set_label
(
self
,
ind
=
None
,
dic
=
None
):
def
_set_label
(
self
,
ind
=
None
,
dic
=
None
):
if
ind
is
None
:
if
ind
is
None
:
ind
=
self
.
curr
ind
=
self
.
curr
...
@@ -489,6 +519,7 @@ class Callback(object):
...
@@ -489,6 +519,7 @@ class Callback(object):
self
.
sr
=
sr
self
.
sr
=
sr
sr_update
=
True
sr_update
=
True
self
.
change_curr
(
'
0
'
)
# reset current view to 0
self
.
change_curr
(
'
0
'
)
# reset current view to 0
self
.
r_button
.
set_active
(
0
)
self
.
offset
=
np
.
zeros
((
0
,
2
))
self
.
offset
=
np
.
zeros
((
0
,
2
))
self
.
scat
.
set_offsets
(
self
.
offset
)
self
.
scat
.
set_offsets
(
self
.
offset
)
self
.
scat
.
set_color
([[
0
,
0
,
0
,
1
]])
self
.
scat
.
set_color
([[
0
,
0
,
0
,
1
]])
...
@@ -506,6 +537,10 @@ class Callback(object):
...
@@ -506,6 +537,10 @@ class Callback(object):
for
i
in
range
(
3
):
for
i
in
range
(
3
):
self
.
_set_label
(
i
,
EMLN
)
self
.
_set_label
(
i
,
EMLN
)
self
.
_set_visible
(
i
)
self
.
_set_visible
(
i
)
self
.
ind_select
=
False
self
.
ind_b
.
color
=
'
0.85
'
self
.
ind_b
.
howercolor
=
'
0.95
'
self
.
ind_b
.
label
.
set_text
(
f
'
Current individual:
\n
nan
'
)
plt
.
draw
()
plt
.
draw
()
...
@@ -523,7 +558,7 @@ def init(in_path, channel, low=2e3, high=20e3):
...
@@ -523,7 +558,7 @@ def init(in_path, channel, low=2e3, high=20e3):
full_sig
.
set_ylim
(
-
lim
,
lim
)
full_sig
.
set_ylim
(
-
lim
,
lim
)
full_sig
.
set_yticks
([])
full_sig
.
set_yticks
([])
callback
.
f_cursor
=
Cursor
(
full_sig
,
horizOn
=
False
,
useblit
=
True
,
c
=
'
r
'
)
callback
.
f_cursor
=
Cursor
(
full_sig
,
horizOn
=
False
,
useblit
=
True
,
c
=
'
r
'
)
cid
=
fig
.
canvas
.
mpl_connect
(
'
button_release_event
'
,
callback
.
on_clicked
)
cid
1
=
fig
.
canvas
.
mpl_connect
(
'
button_release_event
'
,
callback
.
on_clicked
)
b_left_ax
=
plt
.
subplot
(
gs
[:
2
,
0
])
b_left_ax
=
plt
.
subplot
(
gs
[:
2
,
0
])
b_right_ax
=
plt
.
subplot
(
gs
[:
2
,
-
1
])
b_right_ax
=
plt
.
subplot
(
gs
[:
2
,
-
1
])
...
@@ -538,6 +573,10 @@ def init(in_path, channel, low=2e3, high=20e3):
...
@@ -538,6 +573,10 @@ def init(in_path, channel, low=2e3, high=20e3):
r_button
.
on_clicked
(
callback
.
change_curr
)
r_button
.
on_clicked
(
callback
.
change_curr
)
for
i
,
c
in
enumerate
(
'
rgb
'
):
for
i
,
c
in
enumerate
(
'
rgb
'
):
r_button
.
labels
[
i
].
set_c
(
c
)
r_button
.
labels
[
i
].
set_c
(
c
)
callback
.
r_button
=
r_button
for
v
in
"
home,back,forward,pan,zoom,save,quit,grid,yscale,xscale,all_axes
"
.
split
(
'
,
'
):
plt
.
rcParams
[
f
'
keymap.
{
v
}
'
]
=
[]
# disable default shortcut but fullsreen
cid2
=
fig
.
canvas
.
mpl_connect
(
'
key_press_event
'
,
callback
.
key_pressed
)
# c_button_ax = plt.subplot(gs[10,3:6])
# c_button_ax = plt.subplot(gs[10,3:6])
# c_button = CheckButtons(c_button_ax, [f'Save {i}' for i in range(3)], [False for i in range(3)])
# c_button = CheckButtons(c_button_ax, [f'Save {i}' for i in range(3)], [False for i in range(3)])
...
@@ -573,6 +612,11 @@ def init(in_path, channel, low=2e3, high=20e3):
...
@@ -573,6 +612,11 @@ def init(in_path, channel, low=2e3, high=20e3):
reset_b
.
on_clicked
(
callback
.
reset_curr
)
reset_b
.
on_clicked
(
callback
.
reset_curr
)
callback
.
reset_b
=
reset_b
callback
.
reset_b
=
reset_b
ind_b_ax
=
plt
.
subplot
(
gs
[
-
1
,
6
:
8
])
ind_b
=
Button
(
ind_b_ax
,
'
Current individual:
\n
nan
'
)
ind_b
.
on_clicked
(
callback
.
toggle_ind
)
callback
.
ind_b
=
ind_b
freq_p_b_ax
=
plt
.
subplot
(
gs
[
2
,
0
])
freq_p_b_ax
=
plt
.
subplot
(
gs
[
2
,
0
])
freq_m_b_ax
=
plt
.
subplot
(
gs
[
3
,
0
])
freq_m_b_ax
=
plt
.
subplot
(
gs
[
3
,
0
])
freq_res_p_b_ax
=
plt
.
subplot
(
gs
[
4
,
0
])
freq_res_p_b_ax
=
plt
.
subplot
(
gs
[
4
,
0
])
...
@@ -641,7 +685,7 @@ def init(in_path, channel, low=2e3, high=20e3):
...
@@ -641,7 +685,7 @@ def init(in_path, channel, low=2e3, high=20e3):
callback
.
view_data
=
data_view
callback
.
view_data
=
data_view
return
{
'
callback
'
:
callback
,
'
fig
'
:
fig
,
'
gridspec
'
:
gs
,
'
buttons
'
:
return
{
'
callback
'
:
callback
,
'
fig
'
:
fig
,
'
gridspec
'
:
gs
,
'
buttons
'
:
{
'
b_left
'
:
b_left
,
'
b_right
'
:
b_right
,
'
play_b
'
:
play_b
,
'
resize_b
'
:
resize_b
,
'
r_button
'
:
r_button
,
{
'
b_left
'
:
b_left
,
'
b_right
'
:
b_right
,
'
play_b
'
:
play_b
,
'
resize_b
'
:
resize_b
,
'
r_button
'
:
r_button
,
'
fs_click
'
:
cid
,
'
reset_b
'
:
reset_b
,
'
ind_b
'
:
ind_b
,
'
fs_click
'
:
cid
1
,
'
key_pressed
'
:
cid2
,
'
reset_b
'
:
reset_b
,
'
spec_button
'
:
spec_button
}}
# Needed to keep the callbacks alive
'
spec_button
'
:
spec_button
}}
# Needed to keep the callbacks alive
...
...
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