importMeshFromTXT module
Warning
The following description is partially AI generated, it might be incomplete or incorrect.
- importMeshFromTXT.loadMaterialFromHDF5(mesh, name, customPath=None)[source]
Loads material properties from an HDF5 file and assigns them to a given mesh.
- Args:
mesh (pyvista.UnstructuredGrid): The patient’s mesh to which the material data will be applied. name (str): The name of the patient. customPath (str, optional): Custom path to the patient’s data. Defaults to None.
- Returns:
pyvista.UnstructuredGrid: The mesh with material properties added as point data.
- Raises:
ValueError: If customPath is not provided, it prints a message to specify it.
- Details:
The function reads the HDF5 file containing material data (e.g., c2 values).
The material data is assigned to the mesh’s point_data under the field name ‘mats’.
- importMeshFromTXT.loadMaterialFromTXT(mesh, pt, customPath=None)[source]
Loads material properties from a CSV, Parquet, or HDF5 file and assigns them to a given mesh.
- Args:
mesh (pyvista.UnstructuredGrid): The patient’s mesh to which the material data will be applied. pt (str): The name of the patient or patient-specific identifier. customPath (str, optional): Custom path to the patient’s data. Defaults to None.
- Returns:
pyvista.UnstructuredGrid: The mesh with material properties added as point data.
- Raises:
FileNotFoundError: If no material file is found in supported formats (.csv, .parquet, .hdf5).
- Details:
The function searches for the material file in CSV, Parquet, or HDF5 formats in the given directory.
Once the correct file is found, it reads the material data into a DataFrame.
The material data (e.g., c2 values) is then assigned to the mesh’s point_data under the field name ‘mats’.
- importMeshFromTXT.loadMeshFromHDF5(name, customPath=None)[source]
Loads a 3D mesh from an HDF5 file for the specified patient.
- Args:
name (str): The name of the patient. customPath (str, optional): Custom path to the patient’s data. Defaults to None.
- Returns:
pyvista.UnstructuredGrid: The loaded 3D mesh representing the patient’s anatomy.
- Raises:
ValueError: If customPath is not provided, it prints a message to specify it.
- Details:
The function first builds the file path to the HDF5 file containing the mesh data.
It reads the nodes and elements from the HDF5 file, supporting two mesh types: QuadraticTetra and LinearTetra.
For QuadraticTetra, 10 points per element are processed, while for LinearTetra, 4 points are used.
The elements are adjusted to match PyVista’s expected format (zero-indexed).
Finally, the function creates an unstructured grid using PyVista and returns the mesh.
- importMeshFromTXT.loadMeshFromTXT(name, customPath=None)[source]
Loads a 3D mesh from a TXT file for the specified patient.
- Args:
name (str): The name of the patient. customPath (str, optional): Custom path to the patient’s data. Defaults to None.
- Returns:
pyvista.UnstructuredGrid: The loaded 3D mesh representing the patient’s anatomy.
- Details:
The function first builds the file paths for the nodes and elements from the provided directory.
It reads the nodes from the TXT file and stores them in a NumPy array.
For elements, it supports both QuadraticTetra (10 points per element) and LinearTetra (4 points per element).
The elements are adjusted to match PyVista’s expected format (zero-indexed).
Finally, the function creates an unstructured grid using PyVista and returns the mesh.