Skip to content
Snippets Groups Projects
Commit 81e9a4c9 authored by Constantin Pape's avatar Constantin Pape
Browse files

Fix some issues in morphology refactor and tests

parent 7fe3e58d
No related branches found
No related tags found
No related merge requests found
......@@ -140,8 +140,8 @@ def morphology(job_id, config_path):
label_starts, label_stops = [], []
for block_id in block_list:
block = blocking.getBlock(block_id)
label_starts.append(block.begin)
label_stops.append(block.end)
label_starts.append(block.begin[0])
label_stops.append(block.end[0])
stats = morphology_impl(segmentation_path, raw_path, table, mapping_path,
min_size, max_size,
......
#! /bin/python
from datetime import datetime
# this is a task called by multiple processes,
# so we need to restrict the number of threads used by numpy
......@@ -13,6 +13,10 @@ from skimage.transform import resize
from skimage.util import pad
def log(msg):
print("%s: %s" % (str(datetime.now()), msg))
# get shape of full data & downsampling factor
def get_scale_factor(path, key_full, key, resolution):
with h5py.File(path, 'r') as f:
......@@ -149,7 +153,7 @@ def compute_morphology_features(table, segmentation_path, raw_path,
stats = []
for label_a, label_b in zip(label_starts, label_stops):
# fu.log("Computing features from label-id %i to %i" % (label_a, label_b))
log("Computing features from label-id %i to %i" % (label_a, label_b))
stats.extend(morphology_features_for_label_range(table, ds, ds_raw,
scale_factor_seg, scale_factor_raw,
label_a, label_b))
......@@ -205,13 +209,13 @@ def morphology_impl(segmentation_path, raw_path, table, mapping_path,
# get scale factor for raw data (if it's given)
if raw_path != '':
# fu.log("Have raw path; compute intensity features")
log("Have raw path; compute intensity features")
# NOTE for now we can hard-code the resolution for the raw data here,
# but we might need to change this if we get additional dataset(s)
raw_resolution = [0.025, 0.01, 0.01]
scale_factor_raw = get_scale_factor(raw_path, raw_key_full, raw_key, raw_resolution)
else:
# fu.log("Don't have raw path; do not compute intensity features")
log("Don't have raw path; do not compute intensity features")
raw_resolution = scale_factor_raw = None
# remove zero label if it exists
......@@ -220,14 +224,14 @@ def morphology_impl(segmentation_path, raw_path, table, mapping_path,
# if we have a mappin, only keep objects in the mapping
# (i.e cells that have assigned nuclei)
if mapping_path != '':
# fu.log("Have mapping path %s" % mapping_path)
log("Have mapping path %s" % mapping_path)
table = filter_table_from_mapping(table, mapping_path)
# fu.log("Number of labels after filter with mapping: %i" % table.shape[0])
log("Number of labels after filter with mapping: %i" % table.shape[0])
# filter by size
table = filter_table(table, min_size, max_size)
# fu.log("Number of labels after size filte: %i" % table.shape[0])
log("Number of labels after size filte: %i" % table.shape[0])
# fu.log("Computing morphology features")
log("Computing morphology features")
stats = compute_morphology_features(table, segmentation_path, raw_path,
seg_key, raw_key, scale_factor_seg, scale_factor_raw,
label_starts, label_stops)
......
......@@ -38,7 +38,7 @@ class TestMorphologyAttributes(unittest.TestCase):
self.write_global_config(MorphologyWorkflow.get_config()['global'])
raw_path = '../../data/0.0.0/images/sbem-6dpf-1-whole-raw.xml'
raw_path = get_h5_path_from_xml(raw_path)
raw_path = get_h5_path_from_xml(raw_path, return_absolute_path=True)
# compute and load the morpho table
seg_path = '../../data/0.0.0/segmentations/sbem-6dpf-1-whole-segmented-nuclei-labels.h5'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment