imars3d.backend.dataio package

data handling module for iMars3D.

Submodules

imars3d.backend.dataio.config module

Configuration file handler for the imars3d.

imars3d.backend.dataio.config.save_config(config_dict: dict, filepath: str | Path)[source]

Save a config dict to a file.

Parameters:
  • config_dict (dict) – The config dict to save.

  • filepath (str) – The filepath to save the config dict to.

imars3d.backend.dataio.data module

Data handling for iMars3D.

class imars3d.backend.dataio.data.Foldernames(default=None, search_paths=None, **params)[source]

Bases: Foldername

Parameter that can be set to a string specifying the path of a folder, or a list of such strings.

The string(s) should be specified in UNIX style, but they will be returned in the format of the user’s operating system.

The specified path(s) can be absolute, or relative to either:

  • any of the paths specified in the search_paths attribute (if search_paths is not None);

or

  • any of the paths searched by resolve_dir_path() (if search_paths is None).

class imars3d.backend.dataio.data.load_data(*args, **params)[source]

Bases: ParameterizedFunction

Load data with given input.

Parameters:
  • ct_files (List[str]) – explicit list of radiographs (full path)

  • ob_files (List[str]) – explicit list of open beams (full path)

  • dc_files (Optional[List[str]]) – explicit list of dark current (full path)

  • ct_dir (str, Path) – directory contains radiographs

  • ob_dir (Union[str, Path, List[str, Path]]) – directory, or list of directories, containing open beams

  • dc_dir (Optional[Union[str, Path, List[str, Path]]]) – directory , or list of directories, containing dark current

  • ct_fnmatch (Optional[str]) – Unix shells-style wild card (*.tiff) for selecting radiographs

  • ob_fnmatch (Optional[str]) – Unix shells-style wild card (*.tiff) for selecting open beams

  • dc_fnmatch (Optional[str]) – Unix shells-style wild card (*.tiff) for selecting dark current

  • max_workers (Optional[int]) – maximum number of processes allowed during loading, default to use as many as possible.

  • tqdm_class (panel.widgets.Tqdm) – Class to be used for rendering tqdm progress

Return type:

radiograph stacks, obs, dcs and rotation angles as numpy.ndarray

Notes

There are three main signatures to load the data: 1. load_data(ct_files=ctfs, ob_files=obfs, dc_files=dcfs) 2. load_data(ct_dir=ctdir, ob_dir=obdir, dc_dir=dcdir) 3. load_data(ct_dir=ctdir, ob_files=obfs, dc_files=dcfs)

In all signatures dc_files and dc_dir are optional

The fnmatch selectors are applicable in all signature, which help to down-select files if needed. Default is set to “*”, which selects everything. Also, if ob_fnmatch and dc_fnmatch are set to “None” in the second signature call, the data loader will attempt to read the metadata embedded in the first ct file to find obs and dcs with similar metadata.

Currently, we are using a forgiving reader to load the image where a corrupted file will not block reading other data.

class imars3d.backend.dataio.data.save_checkpoint(*args, **params)[source]

Bases: ParameterizedFunction

Save current state to checkpoint in a datetime stamped directory name.

The filenames will be <outputbase>/<name>_chkpt_YYYYMMDDhhmm/<name>_####.tiff where a canonical outputbase is /HFIR/CG1D/IPTS-23788/shared/processed_data/.

Parameters:
  • data (Array) – array of data to save

  • outputbase (Path) – The parent directory of where to save the output on disk. param.Foldername will warn if the directory does not already exist.

  • name (str) – Used to name file of output, defaults to output_{datetime}

  • rot_angles (Array) – Optional for writing out the array of rotational (omega) angles

Return type:

The directory the files were actually saved in

rot_angles = None
class imars3d.backend.dataio.data.save_data(*args, **params)[source]

Bases: ParameterizedFunction

Save data with given input.

The filenames will be <outputbase>/<name>_YYYYMMDDhhmm/<name>_####.tiff where a canonical outputbase is /HFIR/CG1D/IPTS-23788/shared/processed_data/.

Parameters:
  • data (Array) – array of data to save

  • outputbase (Path) – where to save the output on disk. param.Foldername will warn if the directory does not already exist.

  • name (str) – Used to name file of output, defaults to save_data

  • rot_angles (Array) – Optional for writing out the array of rotational (omega) angles

Return type:

The directory the files were actually saved in

rot_angles = None

imars3d.backend.dataio.phantom module

Provides synthetic data set for demonstration and testing purposes.