diff --git a/plantcv/geospatial/napari_save_points.py b/plantcv/geospatial/napari_save_points.py index cf9efc0..f0990fc 100644 --- a/plantcv/geospatial/napari_save_points.py +++ b/plantcv/geospatial/napari_save_points.py @@ -7,7 +7,7 @@ import os -def napari_save_points(images, num_points, outdir="./", bands="R,G,B", block=True, show=True): +def napari_save_points(images, num_points, outdir="./", bands="R,G,B", show_window=True): """Opens a set of images one at a time in a Napari window, waits for users to click points and then saves those points to a file with the same name as the image. @@ -45,12 +45,13 @@ def napari_save_points(images, num_points, outdir="./", bands="R,G,B", block=Tru # Save image name for output file img_name = (image_path.split("/")[-1]).split(".")[:-1] - viewer = napari.Viewer(show=show) + viewer = napari.Viewer(show=show_window) # Add the image and points layer viewer.add_image(image) viewer.add_points(name="points") - viewer.show(block=block) + if show_window: + viewer.show(block=True) # Save file if correct number of points if len(viewer.layers["points"].data) == num_points: @@ -63,7 +64,7 @@ def napari_save_points(images, num_points, outdir="./", bands="R,G,B", block=Tru warn('Image ' + str(image_path) + ' collected incorrect number of points. ' + 'Added to redo list.') # Close the viewer in case it wasn't shown - if not show: + if not show_window: viewer.close() # Reset debug pcv.params.debug = debug diff --git a/tests/test_geospatial_napari_save_points.py b/tests/test_geospatial_napari_save_points.py index d9a4ace..00b59ed 100644 --- a/tests/test_geospatial_napari_save_points.py +++ b/tests/test_geospatial_napari_save_points.py @@ -9,7 +9,7 @@ def test_geospatial_napari_save_points(test_data, tmpdir): """Test for plantcv-geospatial.""" cache_dir = tmpdir.mkdir("cache") images = [test_data.rgb_tif] - redo_list = napari_save_points(images, num_points=4, outdir=cache_dir, block=False, show=False) + redo_list = napari_save_points(images, num_points=4, outdir=cache_dir, show=False) assert len(redo_list) == 1 @@ -20,5 +20,5 @@ def test_geospatial_napari_save_points_output(test_data, tmpdir): img = read_geotif(filename=test_data.rgb_tif, bands="R,G,B") print_image(img.pseudo_rgb, os.path.join(cache_dir, "rgb.png")) images = [os.path.join(cache_dir, "rgb.png")] - _ = napari_save_points(images, num_points=0, outdir=cache_dir, block=False, show=False) + _ = napari_save_points(images, num_points=0, outdir=cache_dir, show=False) assert os.path.exists(os.path.join(cache_dir, "rgb_warp.txt"))