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
eddbc834
Commit
eddbc834
authored
5 years ago
by
Constantin Pape
Browse files
Options
Downloads
Patches
Plain Diff
Add test for morphology attributes
parent
fe2a9c01
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
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
scripts/attributes/master.py
+1
-1
1 addition, 1 deletion
scripts/attributes/master.py
test/attributes/test_morphology.py
+60
-0
60 additions, 0 deletions
test/attributes/test_morphology.py
with
62 additions
and
1 deletion
.gitignore
+
1
−
0
View file @
eddbc834
*.h5
__pycache__/
tmp*
This diff is collapsed.
Click to expand it.
scripts/attributes/master.py
+
1
−
1
View file @
eddbc834
...
...
@@ -50,7 +50,7 @@ def make_cell_tables(folder, name, tmp_folder, resolution,
if
not
os
.
path
.
exists
(
aux_gene_path
):
raise
RuntimeError
(
"
Can
'
t find auxiliary gene file
"
)
gene_out
=
os
.
path
.
join
(
table_folder
,
'
genes.csv
'
)
#
write_genes_table(seg_path, aux_gene_path, gene_out, label_ids)
write_genes_table
(
seg_path
,
aux_gene_path
,
gene_out
,
label_ids
)
# make table with morphology
morpho_out
=
os
.
path
.
join
(
table_folder
,
'
morphology.csv
'
)
...
...
This diff is collapsed.
Click to expand it.
test/attributes/test_morphology.py
0 → 100644
+
60
−
0
View file @
eddbc834
import
unittest
import
sys
import
os
import
numpy
as
np
sys
.
path
.
append
(
'
../..
'
)
# check new version of gene mapping against original
class
TestMorphologyAttributes
(
unittest
.
TestCase
):
test_file
=
'
test_table.csv
'
def
tearDown
(
self
):
try
:
os
.
remove
(
self
.
test_file
)
except
OSError
:
pass
def
load_table
(
self
,
table_file
):
table
=
np
.
genfromtxt
(
table_file
,
delimiter
=
'
\t
'
,
skip_header
=
1
,
dtype
=
'
float32
'
)
return
table
def
test_nucleus_morphology
(
self
):
from
scripts.attributes.morphology
import
write_morphology_nuclei
# compute and load the morpho table
seg_path
=
'
../../data/0.0.0/segmentations/em-segmented-nuclei-labels.h5
'
table_in_path
=
'
../../data/0.0.0/tables/em-segmented-nuclei-labels/default.csv
'
table_out_path
=
self
.
test_file
print
(
"
Start computation ...
"
)
write_morphology_nuclei
(
seg_path
,
table_in_path
,
table_out_path
)
table
=
self
.
load_table
(
table_out_path
)
# load original table, make sure new and old table agree
original_table_file
=
'
../../data/0.0.0/tables/em-segmented-nuclei-labels/morphology.csv
'
original_table
=
self
.
load_table
(
original_table_file
)
self
.
assertEqual
(
table
.
shape
,
original_table
.
shape
)
self
.
assertTrue
(
np
.
allclose
(
table
,
original_table
))
def
test_cell_morphology
(
self
):
from
scripts.attributes.morphology
import
write_morphology_cells
# compute and load the morpho table
seg_path
=
'
../../data/0.0.0/segmentations/em-segmented-cells-labels.h5
'
mapping_path
=
'
../../data/0.0.0/tables/em-segmented-cells-labels/objects.csv
'
table_in_path
=
'
../../data/0.0.0/tables/em-segmented-cells-labels/default.csv
'
table_out_path
=
self
.
test_file
print
(
"
Start computation ...
"
)
write_morphology_cells
(
seg_path
,
table_in_path
,
mapping_path
,
table_out_path
)
table
=
self
.
load_table
(
table_out_path
)
# load original table, make sure new and old table agree
original_table_file
=
'
../../data/0.0.0/tables/em-segmented-cells-labels/morphology.csv
'
original_table
=
self
.
load_table
(
original_table_file
)
self
.
assertEqual
(
table
.
shape
,
original_table
.
shape
)
self
.
assertTrue
(
np
.
allclose
(
table
,
original_table
))
if
__name__
==
'
__main__
'
:
unittest
.
main
()
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