Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

hdf_to_npy and image_to_npy


The hdf_to_npy function converts a hdf representation into a NumPy .npy file.


Some analyses may require the extraction of voxel data contained within an hdf file and conversion to an internal Python type.

The hdf_to_npy functionality is provided as a command line interface. Providing a HDF file with voxel dataset of interest, image data can be extracted to a separate folder.

Contents of hdf_to_npy.yml:

cli_entry_points:
- hdf_to_npy

hdf_data_path: tests/data/machined_cylinder.h5 #input hdf file
voxel_data_location: VoxelData/machined_cylinder #internal dataset path in hdf file

output_dir: tests/data/output/ # folder to contain folder of images
# image_slice_normal: Z  # not needed for npy conversion
output_type: .npy

hdf_to_image hdf_to_npy.yml produces:

Success: database created from file: hdf_to_npy.yml
key, value, type
---, -----, ----
cli_entry_points, ['hdf_to_npy'], <class 'list'>
hdf_data_path, tests/data/machined_cylinder.h5, <class 'str'>
voxel_data_location, VoxelData/machined_cylinder, <class 'str'>
output_dir, tests/data/output/, <class 'str'>
output_type, .npy, <class 'str'>

The image_to_npy function converts an image stack into a NumPy .npy file.


Some analyses may require the extraction of image stacks to an internal Python type.

The image_to_npy functionality is provided as a command line interface. Providing an image stack path with voxel dataset of interest, image data can be extracted to a separate folder.

Contents of image_to_npy.yml:

cli_entry_points:
- image_to_numpy

# (str) absolute path to images
image_dir: ~/recon3d/tests/data/cylinder_machined_grayscale

# (str) .tif | .tiff options are supported
image_type: .tif

# (str) absolute path for the processed files
out_dir: ~/recon3d/tests/data/output

image_to_npy image_to_npy.yml produces:

This is /opt/hostedtoolcache/Python/3.11.13/x64/lib/python3.11/site-packages/recon3d/image_stack_to_array.py
Processing file: /home/runner/work/recon3d/recon3d/docs/userguide/src/to_npy/image_to_npy.yml
Success: database created from file: /home/runner/work/recon3d/recon3d/docs/userguide/src/to_npy/image_to_npy.yml
{'cli_entry_points': ['image_to_numpy'], 'image_dir': '~/recon3d/tests/data/cylinder_machined_grayscale', 'image_type': '.tif', 'out_dir': '~/recon3d/tests/data/output'}