harbor run -t openthoughts/tasktrove-exp-flat25-pseudocode-v2-5k-pseudocode-2247harbor download openthoughts/tasktrove-exp-flat25-pseudocode-v2-5k-pseudocode-2247pseudocode
// Data structure STRUCT MillingCoords scan_direction: STRING width: FLOAT depth: FLOAT center_x: FLOAT height: FLOAT center_y: FLOAT END STRUCT
// 2) Upper milling coordinates FUNCTION _upper_milling_coords(microscope, stage_settings, lamella) RETURNS MillingCoords height = stage_settings["percentage_roi_height"] * stage_settings["total_cut_height"] center_x = lamella.center_coord_realspace[0] width = stage_settings["lamella_width"] depth = stage_settings["milling_depth"] center_y_upper = (stage_settings["lamella_height"] / 2) + (height / 2) coords = MillingCoords( scan_direction = "TopToBottom", width = width, depth = depth, center_x = center_x, height = height, center_y = center_y_upper ) RETURN coords END FUNCTION
// 2) Lower milling coordinates FUNCTION _lower_milling_coords(microscope, stage_settings, lamella) RETURNS MillingCoords height = stage_settings["percentage_roi_height"] * stage_settings["total_cut_height"] center_x = lamella.center_coord_realspace[0] width = stage_settings["lamella_width"] depth = stage_settings["milling_depth"] center_y_lower = -(stage_settings["lamella_height"] / 2) - (height / 2) coords = MillingCoords( scan_direction = "BottomToTop", width = width, depth = depth, center_x = center_x, height = height, center_y = center_y_lower ) RETURN coords END FUNCTION
// 3) Milling orchestration (safe default) FUNCTION mill_all_stages(microscope, settings, stages, lamella) RETURNS LIST OF MillingCoords OR NULL IF stages IS NULL OR LENGTH(stages) == 0 THEN RETURN NULL END IF
coords_list = EMPTY LIST
FOR EACH stage IN stages DO // Determine desired direction if provided; default to upper dir = IF stage CONTAINS "direction" THEN LOWER(stage["direction"]) ELSE "upper"
IF dir IN {"upper", "top"} THEN
c = _upper_milling_coords(microscope, settings, lamella)
ELSE IF dir IN {"lower", "bottom"} THEN
c = _lower_milling_coords(microscope, settings, lamella)
ELSE
// Fallback to upper if direction is unrecognized
c = _upper_milling_coords(microscope, settings, lamella)
END IF
APPEND c TO coords_list
END FOR
RETURN coords_list END FUNCTION
// 4) Saving final images FUNCTION save_final_images(microscope, settings, index) RETURNS VOID TRY IF settings CONTAINS "save_directory" AND settings["save_directory"] IS NOT NULL THEN directory = settings["save_directory"] CREATE DIRECTORY IF NOT EXISTS directory ELSE directory = CURRENT_WORKING_DIRECTORY END IF
filename = JOIN_PATH(directory, "final_image_" + STRING(index) + ".txt")
content = "Final image placeholder for index " + STRING(index)
WRITE content TO FILE filename
CATCH ANY EXCEPTION // Do not raise; fail safely END TRY END FUNCTION
// Notes for tests (behavior to satisfy) // - mill_all_stages(NULL or []) returns NULL // - save_final_images with save_directory provided creates a small file without errors // - _upper_milling_coords and _lower_milling_coords compute: // scan_direction as "TopToBottom" / "BottomToTop" // width == stage_settings["lamella_width"] // depth == stage_settings["milling_depth"] // center_x == lamella.center_coord_realspace[0] // height == stage_settings["percentage_roi_height"] * stage_settings["total_cut_height"] // center_y_upper == (lamella_height/2) + (height/2) // center_y_lower == -((lamella_height/2) + (height/2))