Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
platy-browser-data
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Christian Tischer
platy-browser-data
Commits
03d2ac6a
Commit
03d2ac6a
authored
5 years ago
by
Constantin Pape
Browse files
Options
Downloads
Patches
Plain Diff
Extend bookmark functionality
parent
cfd5da4e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mmpb/bookmarks.py
+42
-11
42 additions, 11 deletions
mmpb/bookmarks.py
with
42 additions
and
11 deletions
mmpb/bookmarks.py
+
42
−
11
View file @
03d2ac6a
import
os
import
json
import
pandas
as
pd
# TODO change to the proper root folder
ROOT_FOLDER
=
'
/g/arendt/EM_6dpf_segmentation/platy-browser-data/data/test_n5
'
# TODO allowed values ?
LAYER_KEYS
=
{
'
Color
'
,
'
MinValue
'
,
'
MaxValue
'
,
'
SelectedIds
'
}
ROOT_FOLDER
=
'
/g/arendt/EM_6dpf_segmentation/platy-browser-data/data
'
LAYER_KEYS
=
{
'
Color
'
,
'
MinValue
'
,
'
MaxValue
'
,
'
SelectedIds
'
,
'
Tables
'
}
# TODO add all color maps supported by platybrowser
COLORMAPS
=
{
'
Glasbey
'
,
'
Viridis
'
}
def
validate_tables
(
table_dict
,
table_folder
):
n_color_by
=
0
for
table_name
,
table_values
in
table_dict
.
items
():
table_file
=
os
.
path
.
join
(
table_folder
,
table_name
)
if
not
os
.
path
.
exists
(
table_file
):
return
False
if
table_values
:
if
not
len
(
table_values
)
==
2
:
return
False
table
=
pd
.
from_csv
(
table_file
,
sep
=
'
\t
'
)
col
,
cmap
=
table_values
if
col
not
in
table
.
comlumns
:
return
False
if
cmap
not
in
COLORMAPS
:
return
False
n_color_by
+=
1
# can color by maximally 1 column
if
n_color_by
>
1
:
return
False
return
True
def
validate_layer
(
version
,
name
,
layer
):
# check that the corresponding file exists
if
'
segmented
'
in
name
:
data_folder
=
os
.
path
.
join
(
ROOT_FOLDER
,
version
,
'
segmentations
'
,
'
s3-n5
'
)
else
:
data_folder
=
os
.
path
.
join
(
ROOT_FOLDER
,
version
,
'
images
'
,
'
s3-n5
'
)
# check that the corresponding name exists
image_dict
=
os
.
path
.
join
(
ROOT_FOLDER
,
version
,
'
images
'
,
'
images.json
'
)
with
open
(
image_dict
)
as
f
:
image_dict
=
json
.
load
(
f
)
file_name
=
os
.
path
.
join
(
data_folder
,
name
+
'
.xml
'
)
if
not
os
.
path
.
exists
(
file_name
):
if
name
not
in
image_dict
:
return
False
if
not
isinstance
(
layer
,
dict
):
...
...
@@ -25,6 +52,10 @@ def validate_layer(version, name, layer):
if
len
(
keys
-
LAYER_KEYS
)
>
0
:
return
False
if
'
Tables
'
in
keys
:
table_folder
=
os
.
path
.
join
(
ROOT_FOLDER
,
version
,
image_dict
[
name
][
'
TableFolder
'
])
return
validate_tables
(
layer
[
'
Tables
'
],
table_folder
)
return
True
...
...
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