@@ -29,6 +29,7 @@ class DaskImageDataStack:
29
29
image_list : list [Image_Data ]
30
30
create_delayed_array : bool
31
31
_selected_index : int
32
+ mean : list [float ] = []
32
33
33
34
def __init__ (self , image_list : list [Image_Data ], create_delayed_array : bool = True ):
34
35
self .image_list = image_list
@@ -119,7 +120,7 @@ def create_delayed_stack_from_image_data(self, image_list: list[Image_Data]) ->
119
120
f"{ image_list [0 ].image_path .suffix .lower ()} " )
120
121
return delayed_stack
121
122
122
- def add_images_to_delayed_stack (self , new_image_list : list [Image_Data ]) -> None :
123
+ def add_images_to_delayed_stack (self , new_image_list : list [Image_Data ], param_to_calc : list [ str ] ) -> None :
123
124
if not new_image_list :
124
125
return
125
126
image_paths = [image .image_path for image in self .image_list ]
@@ -131,6 +132,11 @@ def add_images_to_delayed_stack(self, new_image_list: list[Image_Data]) -> None:
131
132
self .delayed_stack = dask .array .concatenate (
132
133
[self .delayed_stack , self .get_delayed_arrays (images_to_add )])
133
134
self .image_list .extend (images_to_add )
135
+ if 'mean' in param_to_calc :
136
+ self .add_last_mean ()
137
+
138
+ def add_last_mean (self ) -> None :
139
+ self .mean .append (dask .array .mean (self .delayed_stack [- 1 ]).compute ())
134
140
135
141
def delete_all_data (self ):
136
142
self .image_list = []
@@ -413,7 +419,7 @@ def _handle_directory_change(self) -> None:
413
419
self .image_stack .delete_all_data ()
414
420
415
421
if self .create_delayed_array :
416
- self .image_stack .add_images_to_delayed_stack (images )
422
+ self .image_stack .add_images_to_delayed_stack (images , [ 'mean' ] )
417
423
418
424
self .update_recent_watcher (images [- 1 :])
419
425
self .image_changed .emit (images , self .image_stack )
0 commit comments