def build_main_block(input_params): result = f"{INDENTATION}Display outlines on a blank image?:{get_json_value(input_params,'con_blank_img.blank_img')}\n" on_blank = get_json_value(input_params, 'con_blank_img.blank_img') # defaults img_to_display = "None" display_mode = get_json_value(input_params, 'con_blank_img.con_display_mode.display_mode') method_brightness = "Max of image" howto = get_json_value(input_params, 'howto_outline') outline_color = "#FF0000" obj_to_display = "None" name_output_img = get_json_value(input_params, 'name_output_image') if on_blank == "No": img_to_display = get_json_value(input_params, 'con_blank_img.image_to_outline') result += INDENTATION.join( [f"{INDENTATION}Select image on which to display outlines:{img_to_display}\n", f"Name the output image:{name_output_img}\n", f"Outline display mode:{display_mode}\n" ]) if on_blank == "No" and display_mode == "Grayscale": method_brightness = get_json_value(input_params, 'con_blank_img.con_display_mode.method_brightness') result += INDENTATION.join( [f"{INDENTATION}Select method to determine brightness of outlines:{method_brightness}\n", f"How to outline:{howto}\n" ]) obj_outline_str = "" if display_mode == "Color": for obj in input_params['con_blank_img']['con_display_mode']['rpt_obj_to_display']: outline_color = get_json_value(obj, 'outline_color') obj_to_display = get_json_value(obj, 'obj_to_display') obj_outline_str += INDENTATION.join( [f"{INDENTATION}Select outline color:{outline_color}\n", f"Select objects to display:{obj_to_display}\n" ]) else: # grayscale for obj in input_params['con_blank_img']['con_display_mode']['rpt_obj_to_display']: obj_to_display = get_json_value(obj, 'obj_to_display') obj_outline_str += INDENTATION.join( [f"{INDENTATION}Select outline color:{outline_color}\n", f"Select objects to display:{obj_to_display}\n" ]) obj_outline_str = obj_outline_str.rstrip("\n") result += f"{obj_outline_str}" return result
def build_main_block(input_params): result = INDENTATION.join([ f"{INDENTATION}Select an input image:{get_json_value(input_params,'input_image')}\n", f"Name the output image:{get_json_value(input_params,'output_image_name')}\n", f"Tile assembly method:{get_json_value(input_params,'con_assembly_method.assembly_method')}\n" ]) calc_rows = get_json_value( input_params, 'con_assembly_method.con_calc_no_row.calc_no_row') no_of_rows = 8 calc_cols = get_json_value( input_params, 'con_assembly_method.con_calc_no_cols.calc_no_cols') no_of_cols = 12 if calc_rows == "No": no_of_rows = get_json_value( input_params, 'con_assembly_method.con_calc_no_row.no_of_row') if calc_cols == "No": no_of_cols = get_json_value( input_params, 'con_assembly_method.con_calc_no_cols.no_of_cols') corner_to_begin = get_json_value(input_params, 'con_assembly_method.corner_to_begin') direction_tiling = get_json_value(input_params, 'con_assembly_method.direction') meander = get_json_value(input_params, 'con_assembly_method.meander_mode') assembly_method = get_json_value(input_params, 'con_assembly_method.assembly_method') result += INDENTATION.join([ f"{INDENTATION}Final number of rows:{str(no_of_rows)}\n", f"Final number of columns:{str(no_of_cols)}\n", f"Image corner to begin tiling:{corner_to_begin}\n", f"Direction to begin tiling:{direction_tiling}\n", f"Use meander mode?:{meander}\n", f"Automatically calculate number of rows?:{calc_rows}\n", f"Automatically calculate number of columns?:{calc_cols}\n" ]) if assembly_method == "Within cycles": additionals = input_params['con_assembly_method'][ 'rpt_additional_image'] for img in additionals: result += INDENTATION.join([ f"{INDENTATION}Select an additional image to tile:{get_json_value(img, 'additional_img')}\n" ]) result = result.rstrip("\n") return result
def build_main_block(input_params): """Creates the main block of the CP pipeline with the parameters that don't depend on conditional choices""" operation = operator_map[get_json_value(input_params, 'operation.operation')] result = INDENTATION.join([ f"{INDENTATION}Operation:{operation}\n", f"Raise the power of the result by:{get_json_value(input_params,'operation.op_results.raise_the_power_of_the_result_by')}\n", f"Multiply the result by:{get_json_value(input_params,'operation.op_results.multiply_the_result_by')}\n", f"Add to result:{get_json_value(input_params,'operation.op_results.add_to_result')}\n", f"Set values less than 0 equal to 0?:{get_json_value(input_params,'operation.op_results.set_values_less_than_0_equal_to_0')}\n", f"Set values greater than 1 equal to 1?:{get_json_value(input_params,'operation.op_results.set_values_greater_than_1_equal_to_1')}\n", f"Ignore the image masks?:{get_json_value(input_params,'ignore_the_image_masks')}\n", f"Name the output image:{get_json_value(input_params,'name_output_image')}" ]) return result
def build_first_image_block(input_params): """Creates the block of parameters for the first operator in operations""" value_select = get_json_value( input_params, 'image_or_measurement_first.image_or_measurement_first') image_name = get_json_value( input_params, 'image_or_measurement_first.select_the_first_image') value_multiply = get_json_value(input_params, 'multiply_the_first_image_by') category = get_json_value( input_params, 'image_or_measurement_first.category_first.category_first') measurement = get_json_value( input_params, 'image_or_measurement_first.category_first.measurement_first') result = INDENTATION.join([ f"{INDENTATION}Image or measurement?:{value_select}\n", f"Select the first image:{image_name}\n", f"Multiply the first image by:{value_multiply}\n", f"Measurement:{concat_conditional(category, measurement)}" ]) return result
def build_second_image_block(input_params): """Creates the block of parameters for the second operator in binary operations""" value_select = get_json_value( input_params, "image_or_measurement_second.image_or_measurement_second") image_name = get_json_value( input_params, "image_or_measurement_second.select_the_second_image") value_multiply = get_json_value(input_params, "multiply_the_second_image_by") category = get_json_value( input_params, "image_or_measurement_second.category_second.category_second") measurement = get_json_value( input_params, "image_or_measurement_second.category_second.measurement_second") result = INDENTATION.join([ f"{INDENTATION}Image or measurement?:{value_select}\n", f"Select the second image:{image_name}\n", f"Multiply the second image by:{value_multiply}\n", f"Measurement:{concat_conditional(category, measurement)}", ]) return result
def build_main_block(input_params): result = INDENTATION.join([f"{INDENTATION}Choose a tracking method:{get_json_value(input_params,'con_tracking_method.tracking_method')}\n", f"Select the objects to track:{get_json_value(input_params,'object_to_track')}\n" ]) tracking_method = get_json_value(input_params, 'con_tracking_method.tracking_method') obj_measurement = "None" # default value if tracking_method == "Measurements": measurement_category = get_json_value(input_params, 'con_tracking_method.con_measurement_category.measurement_category') measurement = get_json_value(input_params, 'con_tracking_method.con_measurement_category.measurement') if measurement_category == "Intensity" or measurement_category == "Location": img_measure = get_json_value(input_params, 'con_tracking_method.con_measurement_category.img_measure') obj_measurement = f"{measurement_category}_{measurement}_{img_measure}" else: obj_measurement = f"{measurement_category}_{measurement}" result += INDENTATION.join([f"{INDENTATION}Select object measurement to use for tracking:{obj_measurement}\n"]) if tracking_method == "LAP": # no max distance required, set default for pipeline max_distance = 50 else: max_distance = get_json_value(input_params, 'con_tracking_method.max_distance') result += INDENTATION.join([f"{INDENTATION}Maximum pixel distance to consider matches:{max_distance}\n"]) display_option = get_json_value(input_params, 'con_tracking_method.display_option') output_img_name = "TrackedCells" # default value, required by cppipe regardless of its presence in UI save = get_json_value(input_params, 'con_tracking_method.con_save_coded_img.save_coded_img') if save == "Yes": output_img_name = get_json_value(input_params, 'con_tracking_method.con_save_coded_img.name_output_img') result += INDENTATION.join( [f"{INDENTATION}Select display option:{display_option}\n", f"Save color-coded image?:{save}\n", f"Name the output image:{output_img_name}\n" ]) # LAP method default values movement_model = "Both" no_std = 3.0 radius_limit_max = 10.0 radius_limit_min = 2.0 radius = "2.0,10.0" run_second = "Yes" gap_closing = 40 split_alt = 40 merge_alt = 40 max_gap_displacement = 5 max_split = 50 max_merge = 50 max_temporal = 5 max_mitosis_dist = 40 mitosis_alt = 80 # LAP method if tracking_method == "LAP": movement_model = get_json_value(input_params, 'con_tracking_method.movement_method') no_std = get_json_value(input_params, 'con_tracking_method.no_std_radius') radius_limit_max = get_json_value(input_params, 'con_tracking_method.max_radius') radius_limit_min = get_json_value(input_params, 'con_tracking_method.min_radius') radius = f"{radius_limit_min},{radius_limit_max}" run_second = get_json_value(input_params, 'con_tracking_method.con_second_lap.second_lap') if run_second == "Yes": gap_closing = get_json_value(input_params, 'con_tracking_method.con_second_lap.gap_closing') split_alt = get_json_value(input_params, 'con_tracking_method.con_second_lap.split_alt') merge_alt = get_json_value(input_params, 'con_tracking_method.con_second_lap.merge_alt') max_gap_displacement = get_json_value(input_params, 'con_tracking_method.con_second_lap.max_gap_displacement') max_split = get_json_value(input_params, 'con_tracking_method.con_second_lap.max_split') max_merge = get_json_value(input_params, 'con_tracking_method.con_second_lap.max_merge') max_temporal = get_json_value(input_params, 'con_tracking_method.con_second_lap.max_temporal') max_mitosis_dist = get_json_value(input_params, 'con_tracking_method.con_second_lap.max_mitosis_distance') mitosis_alt = get_json_value(input_params, 'con_tracking_method.con_second_lap.mitosis_alt') result += INDENTATION.join( [f"{INDENTATION}Select the movement model:{movement_model}\n", f"Number of standard deviations for search radius:{no_std}\n", f"Search radius limit, in pixel units (Min,Max):{radius}\n", f"Run the second phase of the LAP algorithm?:{run_second}\n", f"Gap closing cost:{gap_closing}\n", f"Split alternative cost:{split_alt}\n", f"Merge alternative cost:{merge_alt}\n", f"Maximum gap displacement, in pixel units:{max_gap_displacement}\n", f"Maximum split score:{max_split}\n", f"Maximum merge score:{max_merge}\n", f"Maximum temporal gap, in frames:{max_temporal}\n" ]) # common section filter_by_lifetime = get_json_value(input_params, 'con_tracking_method.con_filter_by_lifetime.filter_by_lifetime') use_min = "Yes" # default min_life = 1 # default use_max = "No" # default max_life = 100 # default if filter_by_lifetime == "Yes": use_min = get_json_value(input_params, 'con_tracking_method.con_filter_by_lifetime.con_use_min.use_min') if use_min == "Yes": min_life = get_json_value(input_params, 'con_tracking_method.con_filter_by_lifetime.con_use_min.min_lifetime') use_max = get_json_value(input_params, 'con_tracking_method.con_filter_by_lifetime.con_use_max.use_max') if use_max == "Yes": max_life = get_json_value(input_params, 'con_tracking_method.con_filter_by_lifetime.con_use_max.max_lifetime') result += INDENTATION.join( [f"{INDENTATION}Filter objects by lifetime?:{filter_by_lifetime}\n", f"Filter using a minimum lifetime?:{use_min}\n", f"Minimum lifetime:{min_life}\n", f"Filter using a maximum lifetime?:{use_max}\n", f"Maximum lifetime:{max_life}\n" ]) # print 2 leftover from LAP result += INDENTATION.join( [f"{INDENTATION}Mitosis alternative cost:{mitosis_alt}\n", f"Maximum mitosis distance, in pixel units:{max_mitosis_dist}\n" ]) # Follow Neighbors # defaults avg_cell_diameter = 35.0 use_adv = "No" cost_of_cell = 15.0 weight_of_area_diff = 25.0 if tracking_method == "Follow Neighbors": avg_cell_diameter = get_json_value(input_params, 'con_tracking_method.avg_diameter') use_adv = get_json_value(input_params, 'con_tracking_method.con_adv_parameter.adv_parameter') if use_adv == "Yes": cost_of_cell = get_json_value(input_params, 'con_tracking_method.con_adv_parameter.cost') weight_of_area_diff = get_json_value(input_params, 'con_tracking_method.con_adv_parameter.weight') result += INDENTATION.join( [f"{INDENTATION}Average cell diameter in pixels:{avg_cell_diameter}\n", f"Use advanced configuration parameters:{use_adv}\n", f"Cost of cell to empty matching:{cost_of_cell}\n", f"Weight of area difference in function matching cost:{weight_of_area_diff}\n" ]) result = result.rstrip("\n") return result
def build_main_block(input_params): """Creates the main block of the CP pipeline with the parameters that don't depend on conditional choices""" result = INDENTATION.join([ f"{INDENTATION}Select the input image:{get_json_value(input_params,'name_input_image')}\n", f"Conversion method:{get_json_value(input_params,'con_conversion_method.conversion_method')}\n", f"Image type:{get_json_value(input_params,'con_conversion_method.con_image_type.image_type')}\n", ]) conversion_method = get_json_value( input_params, "con_conversion_method.conversion_method") image_type = get_json_value( input_params, "con_conversion_method.con_image_type.image_type") rgb_comb_name_out = "OrigGray" combine_w_red = 1.0 combine_w_green = 1.0 combine_w_blue = 1.0 split_red = "Yes" split_green = "Yes" split_blue = "Yes" red_output_name = "OrigRed" green_output_name = "OrigGreen" blue_output_name = "OrigBlue" split_hue = "Yes" split_saturation = "Yes" split_value = "Yes" hue_output_name = "OrigHue" saturation_output_name = "OrigSaturation" value_output_name = "OrigValue" channel_count = 1 if conversion_method == "Combine": if image_type == "RGB" or image_type == "HSV": rgb_comb_name_out = get_json_value( input_params, "con_conversion_method.name_output_image") combine_w_red = get_json_value( input_params, "con_conversion_method.con_image_type.weight_red_channel") combine_w_green = get_json_value( input_params, "con_conversion_method.con_image_type.weight_green_channel", ) combine_w_blue = get_json_value( input_params, "con_conversion_method.con_image_type.weight_blue_channel") elif conversion_method == "Split": if image_type == "RGB": split_red = get_json_value( input_params, "con_conversion_method.con_image_type.con_convert_red.yes_no", ) red_output_name = get_json_value( input_params, "con_conversion_method.con_image_type.con_convert_red.name_output_image", ) split_green = get_json_value( input_params, "con_conversion_method.con_image_type.con_convert_green.yes_no", ) green_output_name = get_json_value( input_params, "con_conversion_method.con_image_type.con_convert_green.name_output_image", ) split_blue = get_json_value( input_params, "con_conversion_method.con_image_type.con_convert_blue.yes_no", ) blue_output_name = get_json_value( input_params, "con_conversion_method.con_image_type.con_convert_blue.name_output_image", ) elif image_type == "HSV": split_hue = get_json_value( input_params, "con_conversion_method.con_image_type.con_convert_hue.yes_no", ) hue_output_name = get_json_value( input_params, "con_conversion_method.con_image_type.con_convert_hue.name_output_image", ) split_saturation = get_json_value( input_params, "con_conversion_method.con_image_type.con_convert_saturation.yes_no", ) saturation_output_name = get_json_value( input_params, "con_conversion_method.con_image_type.con_convert_saturation.name_output_image", ) split_value = get_json_value( input_params, "con_conversion_method.con_image_type.con_convert_value.yes_no", ) value_output_name = get_json_value( input_params, "con_conversion_method.con_image_type.con_convert_value.name_output_image", ) result += INDENTATION.join([ f"{INDENTATION}Name the output image:{rgb_comb_name_out}\n", f"Relative weight of the red channel:{str(combine_w_red)}\n", f"Relative weight of the green channel:{str(combine_w_green)}\n", f"Relative weight of the blue channel:{str(combine_w_blue)}\n", f"Convert red to gray?:{split_red}\n", f"Name the output image:{red_output_name}\n", f"Convert green to gray?:{split_green}\n", f"Name the output image:{green_output_name}\n", f"Convert blue to gray?:{split_blue}\n", f"Name the output image:{blue_output_name}\n", f"Convert hue to gray?:{split_hue}\n", f"Name the output image:{hue_output_name}\n", f"Convert saturation to gray?:{split_saturation}\n", f"Name the output image:{saturation_output_name}\n", f"Convert value to gray?:{split_value}\n", f"Name the output image:{value_output_name}\n", ]) channel_count = 1 if image_type == "Channels": channels = input_params["con_conversion_method"]["con_image_type"][ "rpt_channel"] channel_count = len(channels) result += INDENTATION.join( [f"{INDENTATION}Channel count:{channel_count}\n"]) for ch in channels: rel_weight_ch = 1.0 image_name = "Channel1" if conversion_method == "Combine": rel_weight_ch = get_json_value(ch, "weight_of_channel") else: image_name = get_json_value(ch, "image_name") result += INDENTATION.join([ f"{INDENTATION}Channel number:{get_json_value(ch,'channel_no')}\n", f"Relative weight of the channel:{str(rel_weight_ch)}\n", f"Image name:{image_name}\n", ]) else: result += INDENTATION.join([ f"{INDENTATION}Channel count:{channel_count}\n", "Channel number:Red\\x3A 1\n", "Relative weight of the channel:1.0\n", "Image name:Channel1\n", ]) result = result.rstrip("\n") return result