From 4ad65e0bce85e1c4350c4303e57cb79b1fa6a864 Mon Sep 17 00:00:00 2001 From: felixdietz Date: Tue, 16 Dec 2025 17:08:39 +0100 Subject: [PATCH 1/3] Provide tissue mask to SimData Object when building a VoxelGridPhantom --- python/MRzeroCore/phantom/voxel_grid_phantom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/MRzeroCore/phantom/voxel_grid_phantom.py b/python/MRzeroCore/phantom/voxel_grid_phantom.py index ccd3382..c773fa9 100644 --- a/python/MRzeroCore/phantom/voxel_grid_phantom.py +++ b/python/MRzeroCore/phantom/voxel_grid_phantom.py @@ -181,7 +181,7 @@ def dephasing_func(t, _): return identity(t) recover_func=lambda data: recover(mask, data), phantom_motion=self.phantom_motion, voxel_motion=self.voxel_motion, - tissue_masks=self.tissue_masks + tissue_masks=mask ) @classmethod From b09300d91bc102b68bf264d5fbbc044efb4707d2 Mon Sep 17 00:00:00 2001 From: felixdietz Date: Wed, 17 Dec 2025 10:56:16 +0100 Subject: [PATCH 2/3] Refinement: use provided tissue masks, if no masks are provided consider whole phantom as a single tissue and provide PD mask --- python/MRzeroCore/phantom/voxel_grid_phantom.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/python/MRzeroCore/phantom/voxel_grid_phantom.py b/python/MRzeroCore/phantom/voxel_grid_phantom.py index c773fa9..603a857 100644 --- a/python/MRzeroCore/phantom/voxel_grid_phantom.py +++ b/python/MRzeroCore/phantom/voxel_grid_phantom.py @@ -164,6 +164,13 @@ def dephasing_func(t, n): return sigmoid(t, n) def dephasing_func(t, _): return identity(t) else: raise ValueError(f"Unsupported voxel shape '{voxel_shape}'") + + if not self.tissue_masks: + # tissue masks is empty -> interpret as one tissue + tissue_masks = mask + else: + # use provided tissue masks + tissue_masks = self.tissue_masks return SimData( self.PD[mask], @@ -180,8 +187,8 @@ def dephasing_func(t, _): return identity(t) dephasing_func, recover_func=lambda data: recover(mask, data), phantom_motion=self.phantom_motion, - voxel_motion=self.voxel_motion, - tissue_masks=mask + voxel_motion=self.voxel_motion, + tissue_masks = tissue_masks ) @classmethod From 09060d549f0c1b78882f51f6698db20cf74bbee2 Mon Sep 17 00:00:00 2001 From: felixdietz Date: Wed, 17 Dec 2025 17:01:19 +0100 Subject: [PATCH 3/3] bugfix: fix type error with combined tissue mask --- python/MRzeroCore/phantom/voxel_grid_phantom.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/python/MRzeroCore/phantom/voxel_grid_phantom.py b/python/MRzeroCore/phantom/voxel_grid_phantom.py index 603a857..f5ebebb 100644 --- a/python/MRzeroCore/phantom/voxel_grid_phantom.py +++ b/python/MRzeroCore/phantom/voxel_grid_phantom.py @@ -166,11 +166,7 @@ def dephasing_func(t, _): return identity(t) raise ValueError(f"Unsupported voxel shape '{voxel_shape}'") if not self.tissue_masks: - # tissue masks is empty -> interpret as one tissue - tissue_masks = mask - else: - # use provided tissue masks - tissue_masks = self.tissue_masks + self.tissue_masks = {"combined": mask} return SimData( self.PD[mask], @@ -188,7 +184,7 @@ def dephasing_func(t, _): return identity(t) recover_func=lambda data: recover(mask, data), phantom_motion=self.phantom_motion, voxel_motion=self.voxel_motion, - tissue_masks = tissue_masks + tissue_masks = self.tissue_masks ) @classmethod