Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
alibylite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Swain Lab
aliby
alibylite
Commits
27e1e420
Commit
27e1e420
authored
2 years ago
by
Alán Muñoz
Browse files
Options
Downloads
Patches
Plain Diff
change(annotatet): move annotation script to bin
parent
0265d006
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/aliby/bin/annotate.py
+25
-8
25 additions, 8 deletions
src/aliby/bin/annotate.py
with
25 additions
and
8 deletions
src/aliby/
utils
/annotate.py
→
src/aliby/
bin
/annotate.py
+
25
−
8
View file @
27e1e420
...
...
@@ -74,7 +74,9 @@ for i, k in enumerate((*essential, *param_values.keys())):
for
k
,
suffix
in
essential
.
items
():
# Autocomplete if fullpath not provided
if
not
str
(
param_values
[
k
]).
endswith
(
suffix
):
param_values
[
k
]
=
Path
(
param_values
[
k
])
/
f
"
{
param_values
[
'
pos
'
]
}
.
{
suffix
}
"
param_values
[
k
]
=
(
Path
(
param_values
[
k
])
/
f
"
{
param_values
[
'
pos
'
]
}
.
{
suffix
}
"
)
# Functions
...
...
@@ -100,7 +102,9 @@ def annotate_image(current_key=None, valid_values: t.Tuple[int] = (1, 2)):
# Show image to annotate
while
current_key
is
None
or
current_key
not
in
valid_values
:
if
current_key
is
not
None
:
print
(
f
"
Invalid value. Please try with valid values
{
valid_values
}
"
)
print
(
f
"
Invalid value. Please try with valid values
{
valid_values
}
"
)
if
(
current_key
:
=
readchar
.
readkey
())
in
"
qsu
"
:
# if (current_key := input()) in "qsu":
...
...
@@ -112,7 +116,8 @@ def annotate_image(current_key=None, valid_values: t.Tuple[int] = (1, 2)):
async
def
generate_image
(
generator
,
location_stack
:
t
.
List
[
t
.
Tuple
[
np
.
ndarray
,
t
.
Tuple
[
int
,
int
,
int
]]]
generator
,
location_stack
:
t
.
List
[
t
.
Tuple
[
np
.
ndarray
,
t
.
Tuple
[
int
,
int
,
int
]]],
):
new_location_image
=
next
(
generator
)
location_stack
.
append
((
new_location_image
[
0
],
new_location_image
[
1
]))
...
...
@@ -122,7 +127,9 @@ def _parse_input(value: str, valid_values: t.Tuple[int]):
try
:
return
int
(
value
)
except
:
print
(
f
"
Non-parsable value. Please try again with valid values
{
valid_values
}
"
)
print
(
f
"
Non-parsable value. Please try again with valid values
{
valid_values
}
"
)
return
None
...
...
@@ -151,7 +158,9 @@ def write_into_file(file_path: str, line: str):
f
.
write
(
str
(
line
))
async
def
parent
(
image_path
,
results_path
,
out_dir
,
ncells
,
seed
,
interval
):
async
def
annotate_images
(
image_path
,
results_path
,
out_dir
,
ncells
,
seed
,
interval
):
preemptive_cache
=
3
...
...
@@ -190,7 +199,14 @@ async def parent(image_path, results_path, out_dir, ncells, seed, interval):
write_into_file
(
out_annot_file
,
"
,
"
.
join
(
(
"
experiment
"
,
"
position
"
,
"
tile
"
,
"
cell_label
"
,
"
tp
"
,
"
annotation
"
)
(
"
experiment
"
,
"
position
"
,
"
tile
"
,
"
cell_label
"
,
"
tp
"
,
"
annotation
"
,
)
)
+
"
\n
"
,
)
...
...
@@ -225,7 +241,8 @@ async def parent(image_path, results_path, out_dir, ncells, seed, interval):
print
(
"
Annotation done!
"
)
if
__name__
==
"
__main__
"
:
# if __name__ == "__main__":
def
annotate
():
if
any
([
param_values
.
get
(
k
)
is
None
for
k
in
(
"
min_tp
"
,
"
max_tp
"
)]):
interval
=
None
else
:
...
...
@@ -233,7 +250,7 @@ if __name__ == "__main__":
print
(
param_values
)
trio
.
run
(
parent
,
annotate_images
,
param_values
[
"
image_path
"
],
param_values
[
"
results_path
"
],
param_values
[
"
out_dir
"
],
...
...
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