Exemple #1
0
        def test_from_image(self, image_circle):
            plates = PlateCollection.from_image(
                shape=(1, 1),
                image=image_circle,
                diameter=180,
            )

            assert plates is not None
            assert isinstance(plates, PlateCollection)
Exemple #2
0
        def test_plates_to_csv(self, image_circle, tmp_path):
            import csv

            plates = PlateCollection.from_image(
                shape=(1, 1),
                image=image_circle,
                diameter=180,
            )
            result = plates.plates_to_csv(tmp_path)

            # Check all rows were written correctly
            with open(result, 'r') as csvfile:
                reader = list(csv.reader(csvfile))

                assert len(reader) == plates.count + 1
                assert reader[1] == [
                    "1", "", "(102, 102)", "160", "0", "0", "0", "0.0", "0.0",
                    "0.0", "0.0", "0.0", "0.0", "0.0", "0.0"
                ]
# Output a plate image with plate locations outlined
image_files = [
    ["./images/outlined/3_1_95.tif", (3, 1), 95],
    ["./images/outlined/3_2_35_empty.tif", (3, 2), 35],
    ["./images/outlined/3_2_35.tif", (3, 2), 35],
    ["./images/outlined/3_2_90_empty.tif", (3, 2), 90],
    ["./images/outlined/3_2_90.tif", (3, 2), 90],
    ["./images/outlined/6_4_35_empty.tif", (6, 4), 35],
    ["./images/outlined/6_4_35.tif", (6, 4), 35],
]

for image in image_files:
    image_file, lattice, size = image
    size = int(mm_to_pixels(size, dots_per_inch = 300))

    # Load the image
    img = imread(image_file, as_gray = False, plugin = "pil")

    # Locate plates in the image and store as Plate instances
    plates = PlateCollection.from_image(
        shape = lattice,
        image = rgb2gray(img),
        diameter = size,
        search_radius = size // 20,
        edge_cut = int(round(size * (5 / 100))),
        labels = []
    )

    # Plot the locations on the plate image
    plot_plate_map(img, plates.items, Path(image_file))