Skip to content

Commit

Permalink
attempt 7
Browse files Browse the repository at this point in the history
  • Loading branch information
bgraedel committed Dec 12, 2023
1 parent 5a670dc commit 89ad0c6
Showing 1 changed file with 4 additions and 30 deletions.
34 changes: 4 additions & 30 deletions src/arcospx/_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
Replace code below according to your needs.
"""
from typing import TYPE_CHECKING, Literal
from time import sleep
from typing import Literal

from arcos4py.tools import track_events_image
from magicgui import magic_factory
Expand All @@ -15,14 +16,7 @@
from napari.types import LayerDataTuple
from napari.utils import progress

if TYPE_CHECKING:
pass

# A global flag for aborting the process
abort_flag = False


# Optional: Define a custom exception for aborting the process
class AbortException(Exception):
pass

Expand All @@ -41,35 +35,15 @@ def remove_background(

@thread_worker(connect={"returned": pbar.close})
def remove_image_background_2() -> LayerDataTuple:
global abort_flag

# Reset the abort flag at the start of each execution
abort_flag = False

selected_image = image.data

Check warning on line 38 in src/arcospx/_widget.py

View check run for this annotation

Codecov / codecov/patch

src/arcospx/_widget.py#L38

Added line #L38 was not covered by tests
# removed_background = remove_image_background(
# image=selected_image, filter_type=filter_type, size=size, dims=dims, crop_time_axis=crop_time_axis
# )

removed_background = selected_image

Check warning on line 43 in src/arcospx/_widget.py

View check run for this annotation

Codecov / codecov/patch

src/arcospx/_widget.py#L43

Added line #L43 was not covered by tests

if abort_flag:
pbar.close()
raise AbortException("Operation aborted by user.")

layer_properties = {
"name": f"{image.name} background removed",
"metadata": {
"filter_type": filter_type,
"size_0": size_0,
"size_1": size_1,
"size_2": size_2,
"dims": dims,
"crop_time_axis": crop_time_axis,
"filename": image.name,
},
}

layer_properties = {"name": f"{image.name} background removed"}
sleep(0.5)

Check warning on line 46 in src/arcospx/_widget.py

View check run for this annotation

Codecov / codecov/patch

src/arcospx/_widget.py#L45-L46

Added lines #L45 - L46 were not covered by tests
return (removed_background, layer_properties, "image")

return remove_image_background_2()
Expand Down

0 comments on commit 89ad0c6

Please sign in to comment.