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
ff35f303
Commit
ff35f303
authored
5 years ago
by
Constantin Pape
Browse files
Options
Downloads
Patches
Plain Diff
Add cell criterion column functionality
parent
f860222d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mmpb/attributes/base_attributes.py
+26
-1
26 additions, 1 deletion
mmpb/attributes/base_attributes.py
mmpb/attributes/master.py
+5
-1
5 additions, 1 deletion
mmpb/attributes/master.py
with
31 additions
and
2 deletions
mmpb/attributes/base_attributes.py
+
26
−
1
View file @
ff35f303
...
...
@@ -215,7 +215,7 @@ def propagate_attributes(id_mapping_path, table_path, output_path,
id_col
[
np
.
isnan
(
id_col
)]
=
0
id_col
=
id_col
.
astype
(
'
uint32
'
)
keys
=
list
(
id_mapping
.
keys
())
#
keys = list(id_mapping.keys())
id_col
=
nt
.
takeDict
(
id_mapping
,
id_col
)
# TODO need to implement merge rules
...
...
@@ -226,3 +226,28 @@ def propagate_attributes(id_mapping_path, table_path, output_path,
table
[
column_name
]
=
id_col
table
.
to_csv
(
output_path
,
index
=
False
,
sep
=
'
\t
'
)
# Do we need to extend the cell criterion? Possibilties:
# - size threshold
def
add_cell_criterion_column
(
base_table_path
,
nucleus_mapping_path
,
out_table_path
=
None
):
"""
Add a column to the cell defaults table that indicates whether the id
is considered as a cell or not.
Currently the criterion is based on having a unique nucleus id mapped to the cell.
"""
base_table
=
pd
.
read_csv
(
base_table_path
,
sep
=
'
\t
'
)
nucleus_mapping
=
pd
.
read_csv
(
nucleus_mapping_path
,
sep
=
'
\t
'
)
assert
len
(
base_table
)
==
len
(
nucleus_mapping
)
mapped_nucleus_ids
=
nucleus_mapping
[
'
nucleus_id
'
].
values
mapped
,
mapped_counts
=
np
.
unique
(
mapped_nucleus_ids
,
return_counts
=
True
)
unique_mapped_nuclei
=
mapped
[
mapped_counts
==
1
]
cell_criterion
=
np
.
isin
(
mapped_nucleus_ids
,
unique_mapped_nuclei
)
assert
len
(
cell_criterion
)
==
len
(
base_table
)
base_table
[
'
cells
'
]
=
cell_criterion
.
astype
(
'
uint8
'
)
out_path
=
base_table_path
if
out_table_path
is
None
else
out_table_path
base_table
.
to_csv
(
out_path
,
index
=
False
,
sep
=
'
\t
'
)
This diff is collapsed.
Click to expand it.
mmpb/attributes/master.py
+
5
−
1
View file @
ff35f303
...
...
@@ -2,7 +2,8 @@ import os
import
h5py
from
pybdv.metadata
import
get_data_path
from
.base_attributes
import
base_attributes
,
propagate_attributes
,
write_additional_table_file
from
.base_attributes
import
(
add_cell_criterion_column
,
base_attributes
,
propagate_attributes
,
write_additional_table_file
)
from
.cell_nucleus_mapping
import
map_cells_to_nuclei
from
.genes
import
gene_assignment_table
,
vc_assignment_table
from
.morphology
import
write_morphology_cells
,
write_morphology_nuclei
...
...
@@ -41,6 +42,9 @@ def make_cell_tables(old_folder, folder, name, tmp_folder, resolution,
map_cells_to_nuclei
(
label_ids
,
seg_path
,
nuc_path
,
nuc_mapping_table
,
tmp_folder
,
target
,
max_jobs
)
# add a column with (somewhat stringent) cell criterion to the default table
add_cell_criterion_column
(
base_out
,
nuc_mapping_table
)
# make table with gene mapping
aux_gene_xml
=
os
.
path
.
join
(
folder
,
'
misc
'
,
'
prospr-6dpf-1-whole_meds_all_genes.xml
'
)
aux_gene_path
=
get_data_path
(
aux_gene_xml
,
return_absolute_path
=
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