pumapy.io

pumapy.io.export_texgen_weave

pumapy.io.export_texgen_weave.export_weave_vtu(filename, weave, domain, max_dim_nvox, round_vox_up=True, export_orientation=True)[source]

Exporting weave to vtu, to be read by pumapy

Parameters
  • filename (string) – filepath and name

  • weave (CTextile or child class of CTextile) – weave object, as defined in TexGen

  • domain (CDomainPlanes) – domain size object, as defined in TexGen

  • max_dim_nvox (int) – number of voxels to add in the largest domain dimension

  • round_vox_up (bool) – for the shorter dimensions, round number of voxels up (for +/-1 vox)

  • export_orientation (bool) – specify whether to export orientation

Returns

filename of weave exported (input filename + dimensions)

Return type

string

pumapy.io.input

pumapy.io.input.import_3Dtiff(filename, voxel_length=1e-06, import_ws=True)[source]

Function to io 3D tiff

Parameters
  • filename (string) – filepath and name

  • voxel_length (float, optional) – size of a voxel side

  • import_ws (bool, optional) – if True returns a puma.Workspace, otherwise a ndarray

Returns

domain

Return type

Workspace or ndarray

Example

>>> import pumapy as puma
>>> ws_tiff = puma.import_3Dtiff(puma.path_to_example_file("50_artfibers.tif"), 1.3e-6, import_ws=True)
>>> ws_tiff.get_shape()
pumapy.io.input.import_bin(filename)[source]

Import a puma.Workspace to binary (.pumapy extension)

Parameters

filename (string) – filepath and name

Returns

True if successful, False otherwise.

Return type

bool

Example

>>> import pumapy as puma
>>> ws_binary = puma.import_bin(puma.path_to_example_file("fibers_with_orientation.pumapy"))
pumapy.io.input.import_vti(filename, voxel_length=None, import_ws=True)[source]

Function to import either legacy VTK file (.vtk) or vtkImageData (.vti)

Parameters
  • filename (string) – filepath and name

  • voxel_length (float, optional) – voxel_length. If None, voxel_length from the vtk file is used

  • import_ws (bool, optional) – True returns a puma.Workspace, otherwise a list of ndarrays

Returns

if import_ws is True, then it returns a Workspace. if import_ws is False, it returns a dictionary of ndarrays as {“name1”: data1, “name2”: data2 …}

Return type

Workspace or dict(string: ndarray)

Example

>>> import pumapy as puma
>>> ws_vtk = puma.import_vti(puma.path_to_example_file("fibers_with_orientation.vti"))
pumapy.io.input.import_weave_vtu(filename)[source]

Import TexGen vtu weave in a Workspace

Parameters

filename (string) – file path and name

Returns

voxelized weave from TexGen

Return type

Workspace

pumapy.io.output

pumapy.io.output.export_3Dtiff(filename, ws_or_nparray, to8bit=False)[source]

Export either a puma.Workspace or numpy array to 3Dtiff

Parameters
  • filename (string) – filepath and name

  • ws_or_nparray (Workspace or ndarray) – to be exported

  • to8bit (bool, optional) – if True, it converts the image to 8bit, otherwise 16bit is exported

Returns

True if successful, False otherwise.

Return type

bool

Example

>>> import pumapy as puma
>>> ws_tiff = puma.import_3Dtiff(puma.path_to_example_file("50_artfibers.tif"), 1.3e-6, import_ws=True)
>>> puma.export_3Dtiff("50_artfibers.tif", ws_tiff)
pumapy.io.output.export_bin(filename, ws)[source]

Export a puma.Workspace to binary (.pumapy extension)

Parameters
  • filename (string) – filepath and name

  • ws – to be exported

Type

Workspace

Returns

True if successful, False otherwise.

Return type

bool

Example

>>> import pumapy as puma
>>> ws_binary = puma.import_bin(puma.path_to_example_file("fibers_with_orientation.pumapy"))
>>> puma.export_bin("fibers_with_orientation.vti", ws_binary)
pumapy.io.output.export_sparta_implicit_surfaces(filename, ws)[source]

Export a puma.Workspace to binary (.pumapy extension)

Parameters
  • filename (string) – filepath and name

  • ws (Workspace) – to be exported

Returns

True if successful, False otherwise.

Return type

bool

pumapy.io.output.export_stl(filename, ws, cutoff, flag_closed_edges=True, flag_gaussian=False, binary=True)[source]

Export a puma.Workspace to STL

Parameters
  • filename (string) – filepath and name

  • ws (Workspace) – to be exported

  • cutoff (tuple(int, int)) – specify cutoff to binarize material

  • flag_closed_edges (bool, optional) – close the surface edges on the boundaries

  • flag_gaussian (bool, optional) – apply Gaussian filter before creating surface

Returns

True if successful, False otherwise.

Return type

bool

Example

>>> import pumapy as puma
>>> ws_imported = puma.import_3Dtiff(puma.path_to_example_file("200_fiberform.tif"), 1.3e-6)
>>> puma.export_stl('200_fiberform', ws_imported, cutoff=(100, 255), flag_closed_edges=True)
pumapy.io.output.export_vti(filename, dict_data, voxel_length=None)[source]

Export either a puma.Workspace or numpy array to vti

Parameters
  • filename (string) – filepath and name

  • dict_data (dict) – dictionary setup as {“name1”: data1, “name2”: data2 …} containing either Workspaces or ndarrays

  • voxel_length (float, optional) – with voxel length to give to Numpy arrays (if any)

Returns

True if successful, False otherwise.

Return type

bool

Example

>>> import pumapy as puma
>>> ws_vtk = puma.import_vti(puma.path_to_example_file("fibers_with_orientation.vti"))
>>> puma.export_vti("fibers_with_orientation.vti", ws_vtk)