File Input/Output (IO)

ITK IO

LoadITKFile(filename, device='cpu', dtype=torch.float32)[source]

Load an ITK compatible file using the SimpleITK package into a StructuredGrid object.

Parameters
  • filename (str) – File path

  • device (str, optional) – Memory location - one of ‘cpu’, ‘cuda’, or ‘cuda:X’ where X specifies the device identifier. Default: ‘cpu’

  • dtype (str, optional) – Data type, specified from torch memory types. Default: ‘torch.float32’

Returns

StructuredGrid

SaveITKFile(grid, f_name)[source]

Save a StructuredGrid object to an ITK compatible file using the SimpleITK package.

Parameters
  • gridStructuredGrid to be saved.

  • f_name (str) – File path

Returns

None

Object IO

ReadOBJ(file, device='cpu')[source]

Read a triangle mesh OBJ file into vertex and index tensors.

Parameters
  • file (str) – File path

  • device (str, optional) – Memory location - one of ‘cpu’, ‘cuda’, or ‘cuda:X’ where X specifies the device identifier. Default: ‘cpu’

Returns

[Vertices, Faces]

WriteOBJ(vert, faces, file)[source]

Write a triangle mesh object defined by verts and faces to an OBJ file.

Parameters
  • vert (tensor) – Output vertices (must be on the CPU).

  • faces (tensor) – Output indices (must be on the CPU).

  • file (str) – OBJ file to be written.

Returns

None