RefillingFlowDataset#

class RefillingFlowDataset(mesh, slice_position, slice_normal, slice_thickness, lookup_map_spacing, seeding_vol_spacing, field_list, particle_creation_callables=None, slice_bounding_box=None)[source]#

Wraps a vtk-mesh of containing a velocity field. Functionality tackles the problem of in-/ out-flow of particles for a given imaging slice.

Methods:

__call__(particle_density[, ...])

Checks given particle positions and drops all that are out of bounds and sufficiently far away from the reseeding box.

get_lookup_table()

Returns a C-ordered gridded 3D velocity-field and the corresponding physical extends of the grid.

initial_filling(particle_density[, ...])

Randomly uniform seeds particle into the rasterized version of the input mesh with the specified particle density.

project_density_to_mesh(particles)

Evaluates the density of given particle positions and projects it onto the geometry of the original mesh

update_mesh(mesh, lookup_map_spacing)

Processes the mesh handed in as argument, and saves the nessecary information into class attributes.

update_seeding_volume([seeding_vol_spacing, ...])

Creates a uniform grid which represents the surrounding cuboid of the selected slice from self.gridded_mesh.

Attributes:

gridded_mesh

Reference to the uniformly gridded input mesh

gridded_seeding_volume

Reference to the seeding volume represented as an uniform grid

lookup_map_spacing

Spacing of the uniform grid used for defining the lookup-maps taken from original mesh

mean_density

Property storing the mean particle density in the specified seeding volume

n_drop

n_new

original_mesh

Reference to the original mesh, given as input

seeding_slice_normal

Normal vector of the re-seeding volume (formulated as plane +/ slice thickness/2)

seeding_slice_position

Positional offset of the re-seeding volume in meter

seeding_slice_thickness

Slice thickness the re-seeding volume in meter

seeding_vol_spacing

Spacing of the uniform grid used for defining the seeding volume

slice_bounding_box

Maximal extend of the cartesian bounding box for the re-seeding slice.

Parameters:
  • mesh (pyvista.UnstructuredGrid) –

  • slice_position (ndarray) –

  • slice_normal (ndarray) –

  • slice_thickness (float) –

  • lookup_map_spacing (ndarray) –

  • seeding_vol_spacing (ndarray) –

  • field_list (List[Tuple[str, int]]) –

  • particle_creation_callables (Dict[str, callable]) –

  • slice_bounding_box (ndarray) –

__call__(particle_density, residual_particle_pos=None, particle_properties=None, distance_tolerance=0.005, reseed_threshold=1)[source]#

Checks given particle positions and drops all that are out of bounds and sufficiently far away from the reseeding box.

Parameters:
  • particle_density – target values for particle per 1/mm^3 cell of the grid

  • residual_particle_pos – np.ndarray - Shape (-1, 3)

  • particle_properties – dictionary of arrays (magnetization, T1, T2)

  • distance_tolerance (float) – float maximal distance to slice of particles that are reused

  • reseed_threshold (float) – [0,1], threshold as a fraction of particle density below which reseeding will occur. Positions with higher density than reseed_threshold*particle_density will not reseed

Returns:

If no residual particles are handed in the returned tuple of properties is set to default values only. otherwise it contains the properties of the particles selected to keep Tuple[np.ndarray, (np.ndarray)] - Shape[(-1, 3), (-1, 3)] (particle_positions, (particle_properties), in_tolerance)

get_lookup_table()[source]#

Returns a C-ordered gridded 3D velocity-field and the corresponding physical extends of the grid. Assumes that the internally stored mesh/ImageData is stored in Fortran order.

Returns:

Array of shape [X, Y, Z, 3+N] containing the lookup-tables for velocity and N additional entries

initial_filling(particle_density, slice_dictionary=None)[source]#

Randomly uniform seeds particle into the rasterized version of the input mesh with the specified particle density. The density of particles per mm^3 will be an integer multiple of rasterized cells within a cubic mm (defined by lookup_map_spacing on object initialization). Along with the positions, particle properties are returned (defined by the factory functions passed on object initialization)

Parameters:
  • particle_density (float) – approximate density; will be rounded according to n_particles_per_cell = max([int(particle_density * sampling_volume_mm3), 1])

  • slice_dictionary (dict) – keys: (slice_normal, slice_position, slice_thickness, slice_bounding_box)

Returns:

(-1, 3) particle positions, dict(“T1”: (-1), …) particle properties

project_density_to_mesh(particles)[source]#

Evaluates the density of given particle positions and projects it onto the geometry of the original mesh

Parameters:

particles (ndarray) – (-1, 3)

Return type:

UnstructuredGrid

update_mesh(mesh, lookup_map_spacing)[source]#

Processes the mesh handed in as argument, and saves the nessecary information into class attributes.

Sets the module attributes:
  • self.original_mesh

  • self.lookup_map_spacing

  • self.gridded_mesh

Parameters:
  • mesh (UnstructuredGrid) – ‘pyvista.UnstructuredGrid’ 3D mesh of flow-field

  • lookup_map_spacing (ndarray) – (3, ) in meter - determines the pixel size of the uniformly gridded mesh

Returns:

None

update_seeding_volume(seeding_vol_spacing=None, slice_position=None, slice_normal=None, slice_thickness=None, slice_bounding_box=None)[source]#

Creates a uniform grid which represents the surrounding cuboid of the selected slice from self.gridded_mesh. The pv.ImageData contains the arrays ‘in_slice’ and ‘in_mesh’. Using logical_and on those, yields the condition for positions being inside the sliced flow field.

Sets the module attributes:
  • self.gridded_seeding_volume

  • self.seeding_slice_position

  • self.seeding_slice_normal

  • self.seeding_slice_thickness

  • self.slice_bounding_box

Parameters:
  • seeding_vol_spacing (ndarray) – (3, ) in meter - determines the pixel size of the seeding volume, should be at least 4 times smaller that Voxel-size of the simulated image

  • slice_position (ndarray) – (3, ) in meter

  • slice_normal (ndarray) – (3, )

  • slice_thickness (float) – float in meter

  • slice_bounding_box (array) – (3, ) in meter - user defined bounding box for slicing mesh.

gridded_mesh: ImageData#

Reference to the uniformly gridded input mesh

gridded_seeding_volume: ImageData#

Reference to the seeding volume represented as an uniform grid

lookup_map_spacing: ndarray#

Spacing of the uniform grid used for defining the lookup-maps taken from original mesh

mean_density: float#

Property storing the mean particle density in the specified seeding volume

n_drop: int#
n_new: int#
original_mesh: UnstructuredGrid#

Reference to the original mesh, given as input

seeding_slice_normal: ndarray#

Normal vector of the re-seeding volume (formulated as plane +/ slice thickness/2)

seeding_slice_position: ndarray#

Positional offset of the re-seeding volume in meter

seeding_slice_thickness: float#

Slice thickness the re-seeding volume in meter

seeding_vol_spacing: ndarray#

Spacing of the uniform grid used for defining the seeding volume

slice_bounding_box: ndarray#

Maximal extend of the cartesian bounding box for the re-seeding slice. If not specified, the seeding volume includes the union of an infinite slice & the original mesh