imutils module¶
- imutils.AIMreader(fileINname, spacing)[source]
Reads an AIM file and provides the corresponding VTK image along with spacing, calibration data, and header information.
- Parameters:
fileINname (str) – The filename of the AIM file to be read.
spacing (numpy.ndarray) – Initial spacing values for the image.
- Returns:
- A tuple containing the following elements:
imvtk (vtk.vtkImageData): The VTK image data.
spacing (numpy.ndarray): The spacing between image slices.
scaling (float or None): The scaling factor for the image, if available.
slope (float or None): The slope used in the image, if available.
intercept (float or None): The intercept used in the image, if available.
header (list): The header information from the AIM file.
- Return type:
tuple
- Raises:
SystemExit – If the AIM file format is not supported.
This function performs the following operations: 1. Reads the header of the AIM file to determine the format and version. 2. Extracts necessary parameters such as spacing, scaling, slope, and intercept from the header. 3. Calculates the spacing based on the original dimensions and scaling factor. 4. Reads the AIM file using VTK and sets the appropriate data type and spacing. 5. Returns the VTK image data along with the extracted parameters and header information.
- class imutils.CropType[source]
Bases:
object
- __dict__ = mappingproxy({'__module__': 'imutils', 'expand': 0, 'crop': 1, 'variable': 2, '__dict__': <attribute '__dict__' of 'CropType' objects>, '__weakref__': <attribute '__weakref__' of 'CropType' objects>, '__doc__': None, '__annotations__': {}})
- __module__ = 'imutils'
- __weakref__
list of weak references to the object (if defined)
- crop = 1
- expand = 0
- variable = 2
- imutils.__adjust__img_size__(image, coarsefactor, crop_z=1)[source]
Images are adjusted according to CropType: 0 = CropType.expand (Expand image by copying layers) 1 = CropType.crop (Crop image) 2 = CropType.variable (Either crop or expand, depending on what includes less layers)
- imutils.__save_image_with_colorbar__(data, output_path)[source]
- imutils.adjust_image_size(name, bone, cfg, croptype=1)[source]
Adjusts the image size to match the current finite element (FE) element size.
- Parameters:
name (str) – Specifier for the type of image (e.g., “BMD”, “SEG”).
bone (dict) – Dictionary containing the image data and related parameters.
cfg (dict) – Configuration object containing meshing settings.
croptype (CropType, optional) – Type of cropping to apply. Defaults to CropType.crop.
- Returns:
Updated bone dictionary with adjusted image size and related parameters.
- Return type:
dict
This function performs the following operations: 1. Retrieves the image array and spacing from the bone dictionary. 2. Calculates the coarsening factor based on the FE element size and CT voxel size. 3. Adjusts the image size for BMD image and Mask. 4. Handles specific adjustments for XCTI image resolution (82µm). 5. Updates the bone dictionary with the original and adjusted image arrays, FE element size, and coarsening factor.
- imutils.compute_bvtv_d_seg(bone: dict, sample: str) dict [source]
Compute BVTV from segmented images and from corrected BVTVd values for comparison :param bone: :param sample:
- Returns:
bone
- Return type:
dict
- imutils.fab2vtk_fromdict(filename, abq_dict)[source]
- imutils.general_image_reader(filename)[source]
- imutils.get_AIM_ints(f)[source]
Function by Glen L. Niebur, University of Notre Dame (2010) reads the integer data of an AIM file to find its header length
- imutils.mha_header_reader(filename)[source]
- imutils.numpy2vtk(imnp, spacing)[source]
turns a numpy array into a vtk image data
- imutils.pad_image(image, iso_pad_size: int)[source]
Pads the input image with a constant value (background value) to increase its size. Padding is used to prevent having contours on the edges of the image, which would cause the spline fitting to fail. Padding is performed on the transverse plane only (image orientation is assumed to be z, y, x)
- Parameters:
image (SimpleITK.Image) – The input image to be padded.
iso_pad_size (int) – The size of the padding to be added to each dimension.
- Returns:
The padded image.
- Return type:
SimpleITK.Image
- imutils.plot_MSL_fabric_spline(cfg, abq_dict: dict, sample)[source]
- imutils.quiver_3d_MSL(eval, evect, cogs, path)[source]
- imutils.read_image(name, filenames, bone, lock)[source]
Reads an AIM image and stores it in the bone dictionary.
- Parameters:
name (str) – Specifier for the type of image (e.g., “BMD”, “SEG”).
filenames (dict) – Dictionary containing the filenames, including the key “<name>name” for the AIM image.
bone (dict) – Dictionary to store the image data and related parameters.
lock (threading.Lock) – Lock to ensure thread-safe operations on the bone dictionary.
- Returns:
Updated bone dictionary containing the numpy array of the AIM image.
- Return type:
dict
This function performs the following operations: 1. Reads the AIM image using the AIMreader function. 2. Converts the AIM image to a numpy array. 3. Pads the image to avoid non-zero values at the boundary. 4. Updates the bone dictionary with the processed image array.
- imutils.read_img_param(filenames: FileConfig)[source]
Reads image parameters from the AIM image header.
- Parameters:
filenames (dict) – Dictionary containing the filenames, including the key “RAWname” for the raw AIM image.
- Returns:
The spacing between image slices. scaling (float): The scaling factor for the image. slope (float): The slope used in the image. intercept (float): The intercept used in the image.
- Return type:
spacing (np.ndarray(float))
- Raises:
Exception – If an error occurs while reading the AIM image.
- imutils.save_images_with_colorbar(cfg, sample, bone)[source]
Saves images of arrays with or without colorbar.
- Parameters:
config (dict) – Configuration dictionary containing paths and other parameters.
sample (str) – The sample identifier.
bone (dict) – Dictionary containing arrays to be saved as images.
The function loops over the arrays in the bone dictionary and saves images. If the array is “BMD_array” or “SEG_array”, it uses the provided function to save the image with a colorbar. For other arrays, it saves the image without a colorbar.
- imutils.vtk2numpy(imvtk)[source]
turns a vtk image data into a numpy array