Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add spectrum plotting of data in the Live Viewer via Dask #2336

Open
wants to merge 46 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
a410321
Create DaskImageDataStack to hold delayed array of all images in LV path
MikeSullivan7 Aug 7, 2024
37088ad
add dask and dask-image to dependancies
MikeSullivan7 Aug 7, 2024
fd92b8d
live viewer model unit test fixes
MikeSullivan7 Aug 8, 2024
0890fee
yapf ruff fixes
MikeSullivan7 Aug 8, 2024
85a4695
cleanup
MikeSullivan7 Aug 8, 2024
85f699a
impliment toggle to create delayed dask array
MikeSullivan7 Aug 8, 2024
a09127b
added ability to read fits files via delayed dask functions
MikeSullivan7 Aug 8, 2024
71bb53f
remove astropy import and yapf fix
MikeSullivan7 Aug 8, 2024
09927e5
live viewer eyes tests fixes
MikeSullivan7 Aug 9, 2024
c7079b1
move all delayed array creation into DaskImageDataStack
MikeSullivan7 Aug 12, 2024
9be8efe
eyes test fixes
MikeSullivan7 Aug 13, 2024
93a146d
DaskImageDataStackTest created
MikeSullivan7 Aug 13, 2024
ed192d1
test_WHEN_create_delayed_array_THEN_delayed_array_created
MikeSullivan7 Aug 13, 2024
22a3534
create _get_fake_data() to test tif and fits files
MikeSullivan7 Aug 14, 2024
96ed759
test tif files handled correctly
MikeSullivan7 Aug 14, 2024
ff47f2d
testing unsupported files
MikeSullivan7 Aug 14, 2024
aeafeb9
testing supported files
MikeSullivan7 Aug 14, 2024
ccbe595
minor refactoring and using NotImplimentedError to check supported files
MikeSullivan7 Aug 14, 2024
ab1aa55
yapf and ruff fixes
MikeSullivan7 Aug 14, 2024
47acbf3
release note
MikeSullivan7 Aug 15, 2024
161dd1a
setting create_delayed_array to false falls back to loading into memory
MikeSullivan7 Aug 16, 2024
5099710
ruff fix
MikeSullivan7 Aug 16, 2024
b80b905
mypy fixes
MikeSullivan7 Aug 16, 2024
b0876c9
eyes_tests_fix
MikeSullivan7 Aug 16, 2024
b013797
Dask array now handles current image being deleted
MikeSullivan7 Aug 19, 2024
4c01e01
yapf fix
MikeSullivan7 Aug 19, 2024
7593ea5
Dask Stack now copes with file deletion
MikeSullivan7 Aug 20, 2024
64f3883
DaskImageDataStack allows images to be added and removed dynamically
MikeSullivan7 Aug 21, 2024
3c18f43
fixes to LV Model test
MikeSullivan7 Aug 22, 2024
23ce67c
fix get_computed_image
MikeSullivan7 Aug 22, 2024
3d4b575
mean is calculated as each image is added to DaskImageStack
MikeSullivan7 Aug 23, 2024
1785d74
mypy fix
MikeSullivan7 Aug 23, 2024
7eaf611
added split spectrum plot to LV window
MikeSullivan7 Sep 9, 2024
c08fb5a
live viewer spectrum plot toggles via right click menu
MikeSullivan7 Sep 10, 2024
54c185b
Spectrum calculation now toggled on and off by right click menu
MikeSullivan7 Sep 12, 2024
427ff4b
Live Viewer behaves correctly when spectrum is turned on with no data
MikeSullivan7 Sep 13, 2024
26737ed
dask slicing is optimised
MikeSullivan7 Sep 17, 2024
056f304
Using z slider is more fluid with Dask
MikeSullivan7 Sep 17, 2024
beacb41
dask mean calculation optimised
MikeSullivan7 Sep 18, 2024
7ec86f0
refactor and optimise how DaskImageDataStack updates its image lis
MikeSullivan7 Sep 19, 2024
7b9c47d
change how image_list updates and some benchmarking
MikeSullivan7 Sep 23, 2024
708344b
small optimization of mean calc and mypy fix
MikeSullivan7 Sep 27, 2024
94888a2
release note
MikeSullivan7 Sep 27, 2024
a14efd5
100 most recent images are stored in LRU cache
MikeSullivan7 Nov 22, 2024
c85406a
Images stored in LRUCache and new means append correctly (with debug …
MikeSullivan7 Nov 26, 2024
67a58c0
Mean buffer loading and prints removed
MikeSullivan7 Nov 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
eyes test fixes
  • Loading branch information
MikeSullivan7 committed Nov 20, 2024
commit 9be8efe58d911392ce17087e32b79aa52acda391
11 changes: 6 additions & 5 deletions mantidimaging/gui/windows/live_viewer/model.py
Original file line number Diff line number Diff line change
@@ -24,8 +24,9 @@ class DaskImageDataStack:
"""
A Dask Image Data Stack Class to hold a delayed array of all the images in the Live Viewer Path
"""
delayed_stack: dask.array.Array
delayed_stack: dask.array.Array | None = None
image_list: list[Image_Data]
create_delayed_array: bool

def __init__(self, image_list: list[Image_Data], create_delayed_array: bool = True):
self.image_list = image_list
@@ -53,11 +54,11 @@ def get_delayed_arrays(self) -> list[dask.array.Array] | None:
else:
return None

def get_delayed_image(self, index) -> dask.array.Array:
return self.delayed_stack[index]
def get_delayed_image(self, index: int) -> dask.array.Array | None:
return self.delayed_stack[index] if self.delayed_stack else None

def get_image_data(self, index) -> Image_Data:
return self.image_list[index]
def get_image_data(self, index: int) -> Image_Data | None:
return self.image_list[index] if self.image_list else None


class Image_Data:
11 changes: 7 additions & 4 deletions mantidimaging/gui/windows/live_viewer/presenter.py
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ def __init__(self, view: LiveViewerWindowView, main_window: MainWindowView):
self.main_window = main_window
self.model = LiveViewerWindowModel(self)
self.selected_image: Image_Data | None = None
self.selected_delayed_image: dask.array.Array
self.selected_delayed_image: dask.array.Array | None

self.filters = {f.filter_name: f for f in load_filter_packages()}

@@ -86,7 +86,7 @@ def select_image(self, index: int) -> None:

self.display_image(self.selected_image, self.selected_delayed_image)

def display_image(self, image_data_obj: Image_Data, delayed_image: dask.array.Array) -> None:
def display_image(self, image_data_obj: Image_Data, delayed_image: dask.array.Array | None) -> None:
"""
Display image in the view after validating contents
"""
@@ -109,12 +109,15 @@ def display_image(self, image_data_obj: Image_Data, delayed_image: dask.array.Ar
self.view.live_viewer.show_error(None)

@staticmethod
def load_image(delayed_image: dask.array.Array) -> np.ndarray:
def load_image(delayed_image: dask.array.Array | None) -> np.ndarray:
"""
Load a .Tif, .Tiff or .Fits file only if it exists
and returns as an ndarray
"""
image_data = delayed_image.compute()
if delayed_image:
image_data = delayed_image.compute()
else:
raise ValueError
return image_data

def update_image_modified(self, image_path: Path) -> None: