def callback(): print("updating") if prev_threshold != threshold.value: new_segmented_image_stack = segmentation.segment_stack( channel_file, "fixed", threshold=threshold.value) new_segmented_image_stack = new_segmented_image_stack.labelled_image > 1 segmented_image_source.data = dict( image=[new_segmented_image_stack[layer.value]]) else: segmented_image_source.data = dict( image=[segmented_image_stack[layer.value]]) nominal_image_source.data = dict(image=[nominal_image_stack[layer.value]])
def callback(): print("updating") print(prev_c, c.value, prev_window_size,layer.value) if prev_c != c.value or prev_window_size != window_size.value: new_segmented_image_stack = segmentation.segment_stack( channel_file, "autolocal", window_size=window_size.value, c_factor=c.value, min_vox_size=min_voxel_size.value, max_vox_size=max_voxel_size.value ) new_segmented_image_stack = new_segmented_image_stack.labelled_image > 1 segmented_image_source.data = dict(image=[new_segmented_image_stack[layer.value]]) else: segmented_image_source.data = dict(image=[segmented_image_stack[layer.value]]) nominal_image_source.data = dict(image=[nominal_image_stack[layer.value]])
def server_run_segment(config: dict): input_dir = config["input_dir"] output_dir = config["output_dir"] file_pattern = config["files"] threshold_method = config["threshold_method"] threshold_params = config["threshold_params"] utils.check_dir_exists(input_dir) utils.check_dir_exists(output_dir) _save_config(config) files_to_segment = glob.glob(f"{input_dir}/{file_pattern}") logger.info(f"{files_to_segment}") for i, file_name in enumerate(files_to_segment): logger.info(f"{i+1}/{len(files_to_segment)}") channel_file = File.from_tiff(file_name) segmented_file = segmentation.segment_stack(channel_file, threshold_method, 3, 90000, **threshold_params) segmented_file.save_to_tiff(output_dir)
from lib import File, segmentation, image_adjustments def reverse_palette(palette): list_palette = [x for x in palette] list_palette.reverse() return list_palette file_name = sys.argv[1] RGreens7 = reverse_palette(Greens7) ROrRd3 = reverse_palette(OrRd3) channel_file = File.from_tiff(file_name) segmented_image_stack = segmentation.segment_stack( channel_file, "fixed", threshold=channel_file.image.mean()) segmented_image_stack = segmented_image_stack.labelled_image > 1 nominal_image_stack = image_adjustments.rescale_intensity(channel_file) main_fig = figure(plot_height=500, plot_width=500, title="Segmentation", sizing_mode="scale_both") print((nominal_image_stack.max())) layer = Slider(start=0, end=len(nominal_image_stack), value=0, step=1, title="z layer") threshold = Slider(start=0,
def reverse_palette(palette): list_palette = [x for x in palette] list_palette.reverse() return list_palette file_name = sys.argv[1] RGreens7 = reverse_palette(Greens7) ROrRd3 = reverse_palette(OrRd3) channel_file = File.from_tiff(file_name) segmented_image_stack = segmentation.segment_stack( channel_file, "autolocal", window_size=1, c_factor=1, min_vox_size=3, max_vox_size=9999 ) segmented_image_stack = segmented_image_stack.labelled_image > 1 nominal_image_stack = image_adjustments.rescale_intensity(channel_file) main_fig = figure( plot_height=500, plot_width=500, title="Segmentation", sizing_mode="scale_both" ) layer = Slider(start=0, end=len(nominal_image_stack), value=0, step=1, title="z layer")