fasttomo#

This module contains the Data class, which is designed for processing and analyzing volumetric image data. The Data class is used to create a Data object, which is then used to perform various operations, including segmentation, visualization, movie creation, 3D model generation, and data analysis.

Module Contents#

Classes#

Data

The Data class is designed for processing and analyzing volumetric image data.

class fasttomo.Data(exp, parent_folder='/Volumes/T7/Thesis')#

The Data class is designed for processing and analyzing volumetric image data. It provides various functionalities including segmentation, visualization, movie creation, 3D model generation, and data analysis. A Data object for a specific experiment is initialized with the experiment name and the parent folder containing the experiments folders.

Parameters:
  • exp (str) – Experiment name.

  • parent_folder (str, optional) – Path of the parent folder containing the experiments folders. By default “/Volumes/T7/Thesis”. Experiments folders must contain 4D tomography data in \((t,z,y,x)\) format in a ct.npy file.

segment(threshold_target=6800, filtering3D=True, filtering4D=True, pre_TR_filtering=True, smallest_3Dvolume=50, smallest_4Dvolume=250)#

Segments the volumetric data ct.npy creating a 4D mask mask.npy. First, the threshold value is found by iteratively adjusting it to obtain a target area of the external shell of the battery. Then, the 3D mask is obtained by thresholding each volume and removing small agglomerates. Agglomerate labels are propagated from one volume to the next to ensure label consistency through time. Finally, 4D filtering is applied to remove small agglomerates, agglomerates appearing before the start of thermal runaway, and agglomerates appearing in only one time instant.

Parameters:
  • threshold_target (int, optional) – Target area (in pixels) of the external shell of the battery. Default is 6800.

  • filtering3D (bool, optional) – Set to True to remove agglomerates with a volume smaller than smallest_3Dvolume in each reconstructed volume. Default is True.

  • filtering4D (bool, optional) – Set to True to remove agglomerates whose cumulative volume (sum of agglomerate volume for each time instant) is smaller than smallest_4Dvolume. Default is True.

  • pre_TR_filtering (bool, optional) – Set to True to remove agglomerates appearing before the start of thermal runaway. Thermal runaway start time instant has to be specified in TR_map list in _find_pre_TR_agglomerates function. Default is True.

  • smallest_3Dvolume (int, optional) – Minimum volume (in voxels) of an agglomerate in a single reconstructed volume. Default is 50.

  • smallest_4Dvolume (int, optional) – Minimum cumulative volume (in voxels) of an agglomerate in all reconstructed volumes. Default is 250.

segment_jellyroll(threshold=1, smallest_3Dvolume=50)#

Segments the volumetric data ct.npy creating a 4D binary mask jellyroll_mask.npy. The binary mask is obtained by thresholding each volume and applying a binary morphological operation to remove small isolated regions and reconstruction artifacts. jellyroll_mask.npy is used for rendering the sidewall rupture of the battery.

Parameters:
  • threshold (float, optional) – Threshold value for binary masking. Default is 1.

  • smallest_3Dvolume (: int, optional) – Minimum volume (in voxels) of an agglomerate in a single reconstructed volume. Default is 50.

view(mask=False, jellyroll_mask=False, contrast_limits=[0.1, 3.5])#

Display tomography data within napari interactive viewer, optionally overlaying agglomerate segmentation mask mask.npy or jellyroll_mask.npy.

Parameters:
  • mask (bool, optional) – Display mask overlay if True. Default is False.

  • binary_mask (bool, optional) – Display jellyroll mask overlay if True. Default is False.

save_slice(time, z, contrast_limits=[0.1, 3.5], crop=0)#

Save a slice of the 4D CT-scan to a .png file in the experiment folder.

Parameters:
  • time (int) – Time index of the slice to be saved.

  • z (int) – Z-level index of the slice to be saved.

  • contrast_limits (list, optional) – Minimum and maximum intensity values for image scaling. Default is [0.1, 3.5].

create_slice_movie(z, contrast_limits=[0.1, 3.5], fps=7, invert=False)#

Create a movie by slicing through the data at the specified z-level and adding a time label to each frame.

Parameters:
  • z (int) – The z-level at which to slice through the data.

  • img_min (int, optional) – Minimum intensity value for image scaling. Default is 0.

  • img_max (int, optional) – Maximum intensity value for image scaling. Default is 5.

  • fps (int, optional) – Frames per second for the movie. Default is 7.

create_stls(rupture=False, times=None)#

Create .stl files for each agglomerate at each time instant. The files are saved in the stls folder in the experiment folder. If rupture is set to True, the function creates .stl files for the binary mask used to render the sidewall rupture of the battery. The files are saved in the sidewall_stls folder in the experiment folder.

Parameters:
  • rupture (bool, optional) – Set to True to create .stl files for the binary mask. Default is False.

  • times (list, optional) – List of time instants for which to create .stl files. Default is None (stl files for all time instants are created).

create_dataframe()#

Create a dataframe containing agglomerate properties such as centroid coordinates, velocity, volume, volume derivative, radial section location and vertical section location. The dataframe is saved as dataframe.csv in the experiment folder.

plots(save=True)#

Create and display plots of agglomerate properties over time. These include total volume, average volume, volume expansion rate, speed, and density. The plots are saved as plots.png in the experiment folder.

Parameters:

save (bool, optional) – Set to True to save the plots as plots.png in the experiment folder. Default is True.

render(rupture=False, blender_executable_path='/Applications/Blender.app/Contents/MacOS/Blender', parent_path='/Users/matteoventurelli/Documents/VS Code/MasterThesis/src/fasttomo/blender/')#

Render the agglomerates in the 4D mask using Blender. Run Data.segment() (or Data.segment_jellyroll()) and Data.create_stls() before running this method. This method calls the render.py() script to render the agglomerates.

Parameters:
  • rupture (bool, optional) – Set to True to render the sidewall rupture. Default is False.

  • blender_executable_path (str, optional) – Path to the Blender executable. Default is "/Applications/Blender.app/Contents/MacOS/Blender".

  • parent_path (str, optional) – Path to the folder containing the render.blend and render.py files. Default is "/Users/matteoventurelli/Documents/VS Code/MasterThesis/src/fasttomo/blender/".

create_render_movie(fps=5, rupture=False)#

Create a movie by sequencing rendered frames written with Data.render().

Parameters:
  • fps (int, optional) – Frames per second for the movie. Default is 5.

  • rupture (bool, optional) – Set to True to create a movie for the sidewall rupture. Default is False.