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
Kimberly Isobel Meechan
platy-browser-data
Commits
f634feca
Commit
f634feca
authored
5 years ago
by
Constantin Pape
Browse files
Options
Downloads
Patches
Plain Diff
Add export scripts for cilia segmentation
parent
9ca8db04
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
scripts/attributes/__init__.py
+1
-1
1 addition, 1 deletion
scripts/attributes/__init__.py
scripts/attributes/master.py
+18
-0
18 additions, 0 deletions
scripts/attributes/master.py
update_platy_browser.py
+75
-18
75 additions, 18 deletions
update_platy_browser.py
with
94 additions
and
19 deletions
scripts/attributes/__init__.py
+
1
−
1
View file @
f634feca
from
.master
import
make_cell_tables
,
make_nucleus_tables
from
.master
import
make_cell_tables
,
make_nucleus_tables
,
make_cilia_tables
This diff is collapsed.
Click to expand it.
scripts/attributes/master.py
+
18
−
0
View file @
f634feca
...
...
@@ -96,3 +96,21 @@ def make_nucleus_tables(folder, name, tmp_folder, resolution,
# TODO additional tables:
# ???
def
make_cilia_tables
(
folder
,
name
,
tmp_folder
,
resolution
,
target
=
'
slurm
'
,
max_jobs
=
100
):
# make the table folder
table_folder
=
os
.
path
.
join
(
folder
,
'
tables
'
,
name
)
os
.
makedirs
(
table_folder
,
exist_ok
=
True
)
seg_key
=
'
t00000/s00/0/cells
'
seg_path
=
get_seg_path
(
folder
,
name
,
seg_key
)
# make the basic attributes table
base_out
=
os
.
path
.
join
(
table_folder
,
'
default.csv
'
)
base_attributes
(
seg_path
,
seg_key
,
base_out
,
resolution
,
tmp_folder
,
target
=
target
,
max_jobs
=
max_jobs
,
correct_anchors
=
True
)
# TODO additional tables:
# ???
This diff is collapsed.
Click to expand it.
update_platy_browser.py
+
75
−
18
View file @
f634feca
...
...
@@ -5,7 +5,7 @@ import argparse
from
subprocess
import
check_output
,
call
from
shutil
import
rmtree
from
scripts.attributes
import
make_cell_tables
,
make_nucleus_tables
from
scripts.attributes
import
make_cell_tables
,
make_nucleus_tables
,
make_cilia_tables
from
scripts.export
import
export_segmentation
from
scripts.files
import
copy_image_data
,
copy_misc_data
from
scripts.files
import
copy_tables
,
copy_segmentation
,
make_folder_structure
...
...
@@ -17,41 +17,56 @@ from scripts.files import copy_tables, copy_segmentation, make_folder_structure
PAINTERA_ROOT
=
'
/g/kreshuk/data/arendt/platyneris_v1/data.n5
'
PROJECT_CELLS
=
'
volumes/paintera/proofread_cells
'
PROJECT_NUCLEI
=
'
volumes/paintera/nuclei
'
PROJECT_CILIA
=
'
volumes/paintera/cilia
'
# name for cell and nucleus segmentations
NAME_CELLS
=
'
sbem-6dpf-1-whole-segmented-cells-labels
'
NAME_NUCLEI
=
'
sbem-6dpf-1-whole-segmented-nuclei-labels
'
NAME_CILIA
=
'
sbem-6dpf-1-whole-segmented-cilia-labels
'
# resolutions of cell and nucleus segmentation
RES_CELLS
=
[.
025
,
.
02
,
.
02
]
RES_NUCLEI
=
[.
1
,
.
08
,
.
08
]
RES_CILIA
=
[.
025
,
.
01
,
.
01
]
def
check_inputs
(
update_cell_segmentation
,
update_nucleus_segmentation
,
update_cilia_segmentation
,
update_cell_tables
,
update_nucleus_tables
):
update_nucleus_tables
,
update_cilia_tables
):
inputs
=
(
update_cell_segmentation
,
update_nucleus_segmentation
,
update_cell_tables
,
update_nucleus_tables
)
update_cell_tables
,
update_nucleus_tables
,
update_cilia_segmentation
,
update_cilia_tables
)
have_changes
=
any
(
inputs
)
if
update_cell_segmentation
:
update_cell_tables
=
True
if
update_nucleus_segmentation
:
update_nucleus_tables
=
True
return
have_changes
,
update_cell_tables
,
update_nucleus_tables
if
update_cilia_segmentation
:
update_cilia_tables
=
True
return
{
'
have_changes
'
:
have_changes
,
'
update_cell_tables
'
:
update_cell_tables
,
'
update_nucleus_tables
'
:
update_nucleus_tables
,
'
update_cilia_tables
'
:
update_cilia_tables
}
def
get_tags
():
tag
=
check_output
([
'
git
'
,
'
tag
'
]).
decode
(
'
utf-8
'
).
rstrip
(
'
\n
'
)
new_tag
=
tag
.
split
(
'
.
'
)
new_tag
[
-
1
]
=
str
(
int
(
new_tag
[
-
1
])
+
1
)
new_tag
=
'
.
'
.
join
(
new_tag
)
def
get_tags
(
new_tag
):
tag
=
check_output
([
'
git
'
,
'
describe
'
,
'
--abbrev=0
'
]).
decode
(
'
utf-8
'
).
rstrip
(
'
\n
'
)
if
new_tag
==
''
:
new_tag
=
tag
.
split
(
'
.
'
)
new_tag
[
-
1
]
=
str
(
int
(
new_tag
[
-
1
])
+
1
)
new_tag
=
'
.
'
.
join
(
new_tag
)
return
tag
,
new_tag
def
export_segmentations
(
folder
,
new_folder
,
update_cell_segmentation
,
update_nucleus_segmentation
,
update_cilia_segmentation
,
target
,
max_jobs
):
# update or copy cell segmentation
if
update_cell_segmentation
:
...
...
@@ -75,6 +90,17 @@ def export_segmentations(folder, new_folder,
else
:
copy_segmentation
(
folder
,
new_folder
,
NAME_NUCLEI
)
# update or copy cilia segmentation
if
update_cilia_segmentation
:
tmp_cilia_seg
=
'
tmp_export_cilia
'
export_segmentation
(
PAINTERA_ROOT
,
PROJECT_CILIA
,
folder
,
new_folder
,
NAME_CILIA
,
resolution
=
RES_CILIA
,
tmp_folder
=
tmp_cilia_seg
,
target
=
target
,
max_jobs
=
max_jobs
)
else
:
copy_segmentation
(
folder
,
new_folder
,
NAME_CILIA
)
# copy static segmentations
static_seg_names
=
(
'
sbem-6dpf-1-whole-segmented-muscles
'
,
'
sbem-6dpf-1-whole-segmented-tissue-labels
'
)
...
...
@@ -83,7 +109,9 @@ def export_segmentations(folder, new_folder,
def
make_attributes
(
folder
,
new_folder
,
update_cell_tables
,
update_nucleus_tables
,
update_cell_tables
,
update_nucleus_tables
,
update_cilia_tables
,
target
,
max_jobs
):
# update or copy cell tables
if
update_cell_tables
:
...
...
@@ -99,6 +127,12 @@ def make_attributes(folder, new_folder,
else
:
copy_tables
(
folder
,
new_folder
,
NAME_NUCLEI
)
if
update_cilia_tables
:
make_cilia_tables
(
new_folder
,
NAME_CILIA
,
'
tmp_tables_cilia
'
,
RES_CILIA
,
target
=
target
,
max_jobs
=
max_jobs
)
else
:
copy_tables
(
folder
,
new_folder
,
NAME_CILIA
)
# copy tables associated with static segmentations
static_seg_names
=
(
'
sbem-6dpf-1-whole-segmented-tissue-labels
'
,)
for
seg_name
in
static_seg_names
:
...
...
@@ -135,33 +169,45 @@ def clean_up():
# TODO catch all exceptions and handle them properly
def
update_platy_browser
(
update_cell_segmentation
=
False
,
update_nucleus_segmentation
=
False
,
update_cilia_segmentation
=
False
,
update_cell_tables
=
False
,
update_nucleus_tables
=
False
,
description
=
''
):
update_cilia_tables
=
False
,
description
=
''
,
new_tag
=
''
):
"""
Generate new version of platy-browser derived data.
Arguments:
update_cell_segmentation: Update the cell segmentation volume.
update_nucleus_segmentation: Update the nucleus segmentation volume.
update_cilia_segmentation: Update the cilia segmentation volume.
update_cell_tables: Update the cell tables. This needs to be specified if the cell
segmentation is not update, but the tables should be updated.
update_nucleus_tables: Update the nucleus tables. This needs to be specified if the nucleus
segmentation is not updated, but the tables should be updated.
update_cilia_tables: Update the cilia tables. This needs to be specified if the cilia
segmentation is not updated, but the tables should be updated.
description: Optional descrption for release message.
new_tag: Optional tag to override the default new tag.
"""
# check inputs
have_changes
,
update_cell_tables
,
update_nucleus_tables
=
check_inputs
(
update_cell_segmentation
,
update_nucleus_segmentation
,
update_cell_tables
,
update_nucleus_tables
)
if
not
have_changes
:
update_dict
=
check_inputs
(
update_cell_segmentation
,
update_nucleus_segmentation
,
update_cilia_segmentation
,
update_cell_tables
,
update_nucleus_tables
,
update_cilia_tables
)
if
not
update_dict
[
'
have_changes
'
]:
print
(
"
Nothing needs to be update, skipping
"
)
return
update_cell_tables
,
update_nucleus_tables
,
update_cilia_tables
=
\
update_dict
[
'
update_cell_tables
'
],
update_dict
[
'
update_nucleus_tables
'
],
update_dict
[
'
update_cilia_tables
'
]
# we always increase the release tag (in the last digit)
# when making a new version of segmentation or attributes
tag
,
new_tag
=
get_tags
()
tag
,
new_tag
=
get_tags
(
new_tag
)
print
(
"
Updating platy browser from
"
,
tag
,
"
to
"
,
new_tag
)
# make new folder structure
...
...
@@ -184,12 +230,14 @@ def update_platy_browser(update_cell_segmentation=False,
export_segmentations
(
folder
,
new_folder
,
update_cell_segmentation
,
update_nucleus_segmentation
,
update_cilia_segmentation
,
target
=
target
,
max_jobs
=
max_jobs
)
# generate new attribute tables
make_attributes
(
folder
,
new_folder
,
update_cell_tables
,
update_nucleus_tables
,
update_cilia_tables
,
target
=
target
,
max_jobs
=
max_jobs
)
# TODO implement make release properly
...
...
@@ -228,16 +276,25 @@ if __name__ == '__main__':
default
=
False
,
help
=
"
Update the cell segmentation.
"
)
parser
.
add_argument
(
'
--update_nucleus_segmentation
'
,
type
=
str2bool
,
default
=
False
,
help
=
"
Update the nucleus segmentation.
"
)
parser
.
add_argument
(
'
--update_cilia_segmentation
'
,
type
=
str2bool
,
default
=
False
,
help
=
"
Update the cilia segmentation.
"
)
parser
.
add_argument
(
'
--update_cell_tables
'
,
type
=
str2bool
,
default
=
False
,
help
=
table_help_str
(
"
cell
"
))
parser
.
add_argument
(
'
--update_nucleus_tables
'
,
type
=
str2bool
,
default
=
False
,
help
=
table_help_str
(
"
nucleus
"
))
parser
.
add_argument
(
'
--update_cilia_tables
'
,
type
=
str2bool
,
default
=
False
,
help
=
table_help_str
(
"
cilia
"
))
parser
.
add_argument
(
'
--description
'
,
type
=
str
,
default
=
''
,
help
=
"
Optional description for release message
"
)
parser
.
add_argument
(
'
--new_tag
'
,
type
=
str
,
default
=
''
,
help
=
"
Specify a new tag that will override the default new tag
"
)
args
=
parser
.
parse_args
()
update_platy_browser
(
args
.
update_cell_segmentation
,
args
.
update_nucleus_segmentation
,
args
.
update_cilia_segmentation
,
args
.
update_cell_tables
,
args
.
update_nucleus_tables
,
args
.
description
)
args
.
update_cilia_tables
,
args
.
description
,
args
.
new_tag
)
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