Usage

Examples of batch usage

You can find simple working examples under the /examples folder. Parameters used are defined in params.txt for each example.

Example 1:

python main.py -b --path "./examples/ex1_letters/input"
    --format "image" --n_interp 60  --z_size 90.0
    --target_faces 50000 --sampling_factor 0.1
    --min_mesh_size 5.0 --max_mesh_size 5.0
    --output_dir "./examples/ex1_letters/output" --export_vtk

formatreader Module

Code containing all functions related to format reading and mask obtention

Functions

analyze_slice_opencv(mask, z_pos[, show_plots])

OpenCV implementation to obtain the contours present in the slice.

contour_from_3dmask(mask, slices[, n_interp])

From a 3D array containing the semgentation and the list of slices, it creates a set of interpolated slices between each pair of adjacent real slices using the sliceinterpolator module.

dilate_countour(img[, n_iter, circle_size])

Dilates the image to capture the external contour afterwards.

get_largest_CC(mask)

Retrieves the largest connected component in a 3D volume (biggest separated object).

get_mask(selected_path, file_format[, ...])

Calls the corresponding function depending on the file format selected and retrieves its outputs.

get_mask_dcmseg(filename[, mask_id, ...])

Retrieves the surface points of the 3D volume defined by the masks of a DICOM seg file.

get_mask_dicom(directory[, n_interp, ...])

Retrieves the surface points of the 3D volume defined by a DICOM file.

get_mask_from_images(dirname, ext[, z_size, ...])

Retrieves the surface points of the 3D volume defined in multiple individual images.

get_mask_nifti(filename[, mask_id, ...])

Retrieves the surface points of the 3D volume defined by a NIfTI file.

get_numbers_from_filename(filename)

Read numbers in a filename.

label(label_image[, background, return_num, ...])

Label connected regions of an integer array.

smooth_mask(img[, n_iter, circle_size])

Smooths the input image via erosion/dilation operations.

voxel2space(transformation_matrix, ...)

Transforms the coordinates in voxel CSYS to real world, using the transformation matrix generated using the get_val_pos() function.

formatwriter Module

Code containing all functions related to format writing (stl, gsmh mesh, ansys)

Functions

mesh3d_from_stl(output_dir, output_prefix[, ...])

Generates a 3D FE mesh using linear tetrahedrons from a 3D .stl file using the GMSH library.

stl_from_3dply(total_points_3d, output_dir, ...)

Creates a 3D STL object from a given 3D point cloud using the pymeshlab library.

write_abaqus_inp(nodes, elements, ...)

Exports the given mesh data (nodes and connectivity) as a compatible ANSYS input file.

write_ansys_inp(nodes, elements, output_dir, ...)

Exports the given mesh data (nodes and connectivity) as a compatible ANSYS input file.

sliceinterpolator Module

Code with utilities to interpolate coordinates between two countours

Functions

bwdist(im)

Find euclidean distance map of image

bwperim(bw[, n])

Find the perimeter of objects in binary images.

distance_transform_edt(input[, sampling, ...])

Exact Euclidean distance transform.

interpn(points, values, xi[, method, ...])

Multidimensional interpolation on regular or rectilinear grids.

interpshape(top, bottom, position)

Find interpolated shape at specific position between top and bottom

ndgrid(*args, **kwargs)

Same as calling numpy meshgrid with indexing = 'ij' (see meshgrid for documentation).

signedbwdist(im)

Find perim and return masked image (signed/reversed)

visualization Module

Code with utilities to visualize (e.g. point clouds)

Functions

progressbar(iteration, total[, prefix, ...])

Call in a loop to create terminal progress bar

show_point_cloud(coords)

Shows point cloud in 3D