ImageD11.forward_model.io module#

ImageD11.forward_model.io.camera_names_ID11()#
ImageD11.forward_model.io.convert_cf_to_fwd_peaks(cf)#

convert cf (generated by forward_projector) to fwd_peaks numpy array.

Parameters:

cf – ImageD11 column file object (generated by forward_projector), e.g. fp.cf_2d or fp.cf_3d

Returns:

an N*25 array containing forward computed peaks

Return type:

fwd_peaks

ImageD11.forward_model.io.convert_fwd_peaks_to_cf(fwd_peaks)#

convert fwd_peaks to ImageD11 column file object.

Parameters:

fwd_peaks – an N*25 array containing forward computed peaks

Returns:

an ImageD11 cf object, see ImageD11.sinograms.dataset.colfile_from_dict

Return type:

cf

ImageD11.forward_model.io.convert_h52_tif(h5name, save_path, prefix_name='proj', save_stack=False, ctrl_name='1.1/measurement/marana3', data_format='uint16', clip_range=None)#

Read images from an h5/hdf5 file and convert to a specified data format (uint16 or uint8) and save to tif images Suitable for convert e.g. nabu_recon hdf5 to tif images

ImageD11.forward_model.io.convert_to_list(input_data)#
ImageD11.forward_model.io.copytree_with_progress(src, dst, skip_keys=None, create_subfolder=True, overwrite=False)#

Copies a folder with all subfolders and files, displaying progress. Skips subfolders containing specified keys.

Main usage is to backup files from the server to local computer by skipping filefolders containing keywords specified by the input “skip_keys” e.g. skip_keys = [‘0_rawdata’, ‘2_difblob’, ‘2_difspot’, ‘6_rendering’, ‘7_fed’, ‘8_analysis’, ‘OAR_log’, ‘RAW_DATA’]

Parameters:
  • src (str) – Source directory path.

  • dst (str) – Destination directory path.

  • skip_keys (list) – List of strings; skip folders containing these keys in their path.

  • create_subfolder (logic) – using the last name of the source directory to create a new sub directory under the destination direction

  • overwrite (logic) – flag for overwriting any existing files in the destination directory, False for skipping

ImageD11.forward_model.io.deep_getsizeof(obj, seen=None)#

Get memory info of a dict, list, tuple or set, it does so recursively so that it can collect memory info of all elements. :param obj: an object, e.g. dict, list, tuple or set

Returns:

size of the object in bytes

Return type:

size

Example to use:

size_bytes = deep_getsizeof(sparse_cuda_dict) print(size_bytes / (1024**3), “GB”)

ImageD11.forward_model.io.delete_file_if_exists(filepath)#
ImageD11.forward_model.io.delete_group_from_h5(h5name, group_name)#
ImageD11.forward_model.io.get_scan_h5(experiment, scan_type=['dct'])#
ImageD11.forward_model.io.guess_camera_name(h5name, scan='1.1')#
ImageD11.forward_model.io.im_fabio(data)#
ImageD11.forward_model.io.im_scaling(im_in, scale=(0.3741496598639456,))#
ImageD11.forward_model.io.is_mat_v7p3(file_path)#
ImageD11.forward_model.io.print_all_keys(d, prefix='')#

Recursively prints all keys in a dictionary, including sub-keys.

Parameters: d (dict): The dictionary to explore. prefix (str): The prefix for nested keys (used internally for recursion).

ImageD11.forward_model.io.read_fsparse(h5_file, group_name='/entry_0000/ESRF-ID11/eiger/data')#

Read fsparse_pks from a sparse h5 peaks file.

Parameters:
  • h5_file (string) – path to the HDF5 file containing the sparse peaks generated from forward_projector.make_projs_and_sparse_file

  • group_name – group name

Returns:

a dictionary containing ‘col’, ‘row’, ‘nnz’, ‘intensity’, ‘dty’, ‘rot’

Return type:

fsparse_pks

ImageD11.forward_model.io.read_fwd_peaks(h5_file, verbose=1)#

Read fwd_peaks data from an h5 file and reconstruct it as an N*24 array.

Parameters:
  • h5_file (string) – path to the HDF5 file containing fwd_peaks data

  • verbose – logging level, 0, 1 or 2

Returns:

an N*25 array containing forward computed peaks

Return type:

fwd_peaks

ImageD11.forward_model.io.read_h5_file(file_path)#

Read all data inside an h5/hdf5 file and return the output as a dictionary

ImageD11.forward_model.io.read_h5_struct(file_path)#

suitable for reading matlab file saved as a struct, e.g. parameters.mat

ImageD11.forward_model.io.read_images_from_h5(h5name, scan='1.1', detector=None, StartIndex=None, EndIndex=None)#
ImageD11.forward_model.io.read_matlab_file(file_path)#
ImageD11.forward_model.io.read_motor_posisitions_from_h5(h5name, scan='1.1')#
ImageD11.forward_model.io.read_tomo_from_hdf5(hdf5name, ctrl_name='/entry0000/reconstruction/results/data', StartIndex=None, EndIndex=None, scale=(1.0,), diffrz_offset=None)#
ImageD11.forward_model.io.write_edf(data, edfname)#
ImageD11.forward_model.io.write_fwd_peaks(fwd_peaks, output_folder=None, fname_prefix=None, fname_with_dty=True, verbose=1)#

Write fwd_peaks to an h5 file with each column as a separate dataset, see how to compute fwd_peaks in forward_projector.py.

Parameters:
  • fwd_peaks (array) – an N*25 array containing forward computed peaks

  • output_folder (string) – output folder

  • fname_prefix (string) – filename prefix, “fpks_” by default

  • fname_with_dty (bool) – filename with dty or not, True by default (for CPU calculation), False for cuda calculated peaks

  • verbose – logging level, 0, 1 or 2

Returns:

None

ImageD11.forward_model.io.write_pct_vol(h5name, data, ctrl_name='/entry0000/reconstruction/results/data')#
ImageD11.forward_model.io.write_xdmf(h5name, xdmf_filename=None, ctrl='recon_mlem', attributes=['recon_mlem'], voxelsize=[0.0002, 0.0002, 0.0002])#