From d5ccff4d2716a250c6b229e9abd6063b99f450e6 Mon Sep 17 00:00:00 2001 From: bjoverst Date: Fri, 1 Aug 2025 20:02:30 +0200 Subject: [PATCH] mask non-healthy tissue frame-by-frame --- .../cpuwave2D/tracker/animation_2d_tracker.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/finitewave/cpuwave2D/tracker/animation_2d_tracker.py b/finitewave/cpuwave2D/tracker/animation_2d_tracker.py index 195664e..ecc411e 100755 --- a/finitewave/cpuwave2D/tracker/animation_2d_tracker.py +++ b/finitewave/cpuwave2D/tracker/animation_2d_tracker.py @@ -67,17 +67,18 @@ def _track(self): The frames are saved in the specified directory as NumPy files. """ - frame = self.model.__dict__[self.variable_name] + frame = self.model.__dict__[self.variable_name].copy() + frame[self.model.cardiac_tissue.mesh != 1] = np.nan dir_path = Path(self.path, self.dir_name) - np.save(dir_path.joinpath(str(self._frame_counter) - ).with_suffix(".npy"), - frame.astype(self.frame_type)) + np.save( + dir_path.joinpath(str(self._frame_counter)).with_suffix(".npy"), + frame.astype(self.frame_type), + ) self._frame_counter += 1 - def write(self, shape_scale=1, fps=12, cmap="coolwarm", clim=[0, 1], - clear=False, prog_bar=True): + def write( self, shape_scale=1, fps=12, cmap="coolwarm", clim=[0, 1], clear=False, prog_bar=True): """ Creates an animation from the saved frames using the Animation2DBuilder class. Fibrosis and boundaries will be shown in black. @@ -101,15 +102,13 @@ def write(self, shape_scale=1, fps=12, cmap="coolwarm", clim=[0, 1], """ animation_builder = Animation2DBuilder() path = Path(self.path, self.dir_name) - mask = self.model.cardiac_tissue.mesh != 1 - animation_builder.write(path, animation_name=self.file_name, - mask=mask, + mask=None, shape_scale=shape_scale, fps=fps, clim=clim, - shape=mask.shape, + shape=self.model.cardiac_tissue.mesh.shape, cmap=cmap, clear=clear, prog_bar=prog_bar)