Closed dyang37 closed 8 months ago
Updated function interfaces (approved by Charlie):
def hdf5_write(image, filename,
recon_description="", alu_description ="", delta_pixel_image=1.0):
""" This function writes a reconstructed image to an HDF5 file containing the 3D reconstructed volume along with optional descriptions of the source data, and units.
Args:
image (float, ndarray): 3D reconstructed image to be saved.
filename (string) Path to save the HDF5 file. Example: "<path_to_directory>/recon.h5".
recon_description (string, optional) [Default=""] description of CT source data.
alu_description (string, optional) [Default=""] description of arbitrary length units (ALU). Example: "1 ALU = 5 mm".
delta_pixel_image (float, optional) [Default=1.0]: Image pixel spacing in ALU.
"""
def hdf5_read(filename):
""" Read the image data as well as its metadata from an HDF5 file.
Args:
filename (string, optional) [Default="recon.h5"] Path to save the HDF5 file.
Returns:
two-element tuple containing:
- **image** (*ndarray*): 3D image data.
- **attributes** (*dict*): A dictionary containing attributes of the HDF5 file.
"""
File content:
The resulting HDF5 file contains the following entries:
Dataset:
- **voxels** (*ndarray*): 3D image to be saved.
Attributes:
- **README** (*string*): describes the contents of HDF5 file.
- **source_data_description** (*string*): description of CT source data.
- **alu_description** (*string*): description of arbitrary length units (ALU). Example: "1 ALU = 5 mm".
- **delta_pixel_image** (*float*): Image pixel spacing in ALU.
- **recon_scale_description** (*string*): description of the reconstruction scale. Example: "mm^{-1}" or "Hounsfield Units".
Close this PR for further modifications.
This PR is regarding the utility functions to save image data into an HDF5 file and read image data from an HDF5 file. This PR contains two functions
mbircone.utils.hdf5_write()
andmbircone.utils.hdf5_read()
, as well as a demo scriptdemo/demo_hdf5_io.py
.hdf5_write()
saves a reconstruction image as an HDF5 file. The file structure is defined as follows: Dataset:hdf5_read()
read the image data as well as its metadata from an HDF5 file.The demo script demonstrates how to save image data as HDF5 file, and how to read image data and metadata from an HDF5 file. It includes:
mbircone.utils.hdf5_write
;mbircone.utils.hdf5_read
;