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#
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
Dataobject 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.npyfile.
- segment(threshold_target=6800, filtering3D=True, filtering4D=True, pre_TR_filtering=True, smallest_3Dvolume=50, smallest_4Dvolume=250)#
Segments the volumetric data
ct.npycreating a 4D maskmask.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
Trueto remove agglomerates with a volume smaller thansmallest_3Dvolumein each reconstructed volume. Default isTrue.filtering4D (bool, optional) – Set to
Trueto remove agglomerates whose cumulative volume (sum of agglomerate volume for each time instant) is smaller thansmallest_4Dvolume. Default isTrue.pre_TR_filtering (bool, optional) – Set to
Trueto remove agglomerates appearing before the start of thermal runaway. Thermal runaway start time instant has to be specified inTR_maplist in_find_pre_TR_agglomeratesfunction. Default isTrue.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.npycreating a 4D binary maskjellyroll_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.npyis 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
napariinteractive viewer, optionally overlaying agglomerate segmentation mask mask.npy orjellyroll_mask.npy.- Parameters:
mask (bool, optional) – Display mask overlay if
True. Default isFalse.binary_mask (bool, optional) – Display jellyroll mask overlay if
True. Default isFalse.
- save_slice(time, z, contrast_limits=[0.1, 3.5], crop=0)#
Save a slice of the 4D CT-scan to a
.pngfile 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
.stlfiles for each agglomerate at each time instant. The files are saved in thestlsfolder in the experiment folder. Ifruptureis set toTrue, the function creates.stlfiles for the binary mask used to render the sidewall rupture of the battery. The files are saved in thesidewall_stlsfolder in the experiment folder.- Parameters:
rupture (bool, optional) – Set to
Trueto create.stlfiles for the binary mask. Default isFalse.times (list, optional) – List of time instants for which to create
.stlfiles. Default isNone(stlfiles 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.csvin 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.pngin the experiment folder.- Parameters:
save (bool, optional) – Set to
Trueto save the plots asplots.pngin the experiment folder. Default isTrue.
- 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. RunData.segment()(orData.segment_jellyroll()) andData.create_stls()before running this method. This method calls therender.py()script to render the agglomerates.- Parameters:
rupture (bool, optional) – Set to
Trueto render the sidewall rupture. Default isFalse.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.blendandrender.pyfiles. 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.