From de1d18c80da949aac4cc07d3290073afad53f68f Mon Sep 17 00:00:00 2001 From: Hastings Greer Date: Mon, 4 Feb 2019 14:04:41 -0500 Subject: [PATCH] cleanup debug statements --- server/protocol.py | 62 ++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 33 deletions(-) diff --git a/server/protocol.py b/server/protocol.py index 7de103b..7d3a1b3 100644 --- a/server/protocol.py +++ b/server/protocol.py @@ -7,7 +7,6 @@ class Protocol(helper.ObjectProtocol): @rpc('median_filter') @helper.objdir_wrap def median_filter(self, image, radius): - print (itk.__path__) itk_image = helper.vtkjs_to_itk_image(image) median_filter = itk.MedianImageFilter[type(itk_image), type(itk_image)].New() @@ -23,46 +22,43 @@ def median_filter(self, image, radius): @rpc('otsu_segment_filter') @helper.objdir_wrap def otsu_segment_filter(self, image): - try: - print ("otsu_segment") - - itk_image = helper.vtkjs_to_itk_image(image) - - otsu_filter = itk.TubeTK.SegmentUsingOtsuThreshold[helper.itk_pixel_type(itk_image), - helper.itk_image_dimension(itk_image), - helper.itk_pixel_type(itk_image)].New() - otsu_filter.SetInput(itk_image) - otsu_filter.Update() + print ("otsu_segment") + + itk_image = helper.vtkjs_to_itk_image(image) + + otsu_filter = itk.TubeTK.SegmentUsingOtsuThreshold[helper.itk_pixel_type(itk_image), + helper.itk_image_dimension(itk_image), + helper.itk_pixel_type(itk_image)].New() + otsu_filter.SetInput(itk_image) + otsu_filter.Update() + + result = otsu_filter.GetOutput() - result = otsu_filter.GetOutput() + # TODO auto-serialize in objdir_wrap? + return helper.itk_to_vtkjs_image(result) - # TODO auto-serialize in objdir_wrap? - return helper.itk_to_vtkjs_image(result) - except Exception as e: - print(e) @rpc('segment') @helper.objdir_wrap def segment(self, image, point): - try: - itk_image = helper.vtkjs_to_itk_image(image) + + itk_image = helper.vtkjs_to_itk_image(image) - itk_image = itk.CastImageFilter[type(itk_image), itk.Image[itk.F, 3]].New()(itk_image) + itk_image = itk.CastImageFilter[type(itk_image), itk.Image[itk.F, 3]].New()(itk_image) - print('segment at:', point) + print('segment at:', point) - tuber = itk.TubeTK.SegmentTubes[type(itk_image)].New() + tuber = itk.TubeTK.SegmentTubes[type(itk_image)].New() - tuber.SetInputImage(itk_image) - atube = tuber.ExtractTube(point, 0, True) - - tube_py = [] - for j in range(atube.GetNumberOfPoints()): - pt = atube.GetPoint(j) - pos = helper.itk_pos_to_array(pt.GetPosition()) - radius = helper.spatial_object_pt_to_radius(pt) - tube_py.append({'point': pos, 'radius': radius},) + tuber.SetInputImage(itk_image) + atube = tuber.ExtractTube(point, 0, True) + + tube_py = [] + for j in range(atube.GetNumberOfPoints()): + pt = atube.GetPoint(j) + pos = helper.itk_pos_to_array(pt.GetPosition()) + radius = helper.spatial_object_pt_to_radius(pt) + tube_py.append({'point': pos, 'radius': radius},) - return tube_py - except Exception as e: - print(e) + return tube_py +