Beispiel #1
0
def process_img(img_path):
    IJ.log('Processing {} ...'.format(img_path))

    # open image
    imp = IJ.openImage(img_path)
    imp.show()
    w_big = imp.getWindow()
    w_big.setLocationAndSize(1050, 400, 500, 500)

    # read relative csv file rows (coordinates of centers)
    img_name, img_extension = os.path.splitext(img_path)
    marker_path = img_name + '.csv'

    if not os.path.exists(marker_path):
        root = os.path.dirname(marker_path)
        IJ.log('Creating corrected CSV files in {}...'.format(root))
        mrk.markers_to_csv(root, y_inv_height=imp.height)

    markers = mrk.read_marker(marker_path, to_int=True)

    for cs in gen_cell_stacks(imp, markers, cube_roi_dim, scaleZ):

        # identify cell in original image
        imp.setSlice(cs.seed[2] + 1)
        point = PointRoi(cs.seed[0], cs.seed[1])
        point.setSize(3)
        point.setColor(Color.RED)
        imp.setRoi(point)

        if discard_margin_cells:
            if not cs.onBorder:
                process_cell(cs)
            else:
                IJ.log('Skipped on border cell in seed ' + str(cs.seed))
        else:
            process_cell(cs)

        c = raw_input(
            "Press enter to show the next cell or 'n' to go to the next image\n"
        )

        cs.close()
        if c == 'n':
            IJ.log("Skipped remaining cells")
            break