mantidimaging.core.io.saver module#
- mantidimaging.core.io.saver.create_rits_format(tof: ndarray, transmission: ndarray, transmission_error: ndarray) str [source]#
create a RITS format ready for exporting to a .dat file
- Parameters:
tof – time of flight
transmission – transmission value
transmission_error – transmission_error value
- Returns:
RITS format ascii
- mantidimaging.core.io.saver.export_to_dat_rits_format(rits_formatted_data: str, path: Path) None [source]#
export a RITS formatted data to a .dat file
- Parameters:
rits_formatted_data – RITS formatted data
path – path to save the .dat file
- Returns:
None
- mantidimaging.core.io.saver.generate_names(name_prefix: str, indices: list[int] | Indices | None, num_images: int, custom_idx: int | None = None, zfill_len: int = 6, name_postfix: str = '', out_format: str = 'tif') list[str] [source]#
- mantidimaging.core.io.saver.image_save(images: ImageStack, output_dir: str, name_prefix: str = 'image', swap_axes: bool = False, out_format: str = 'tif', overwrite_all: bool = False, custom_idx: int | None = None, zfill_len: int = 6, name_postfix: str = '', indices: list[int] | Indices | None = None, pixel_depth: str | None = None, progress: Progress | None = None) list[str] [source]#
Save image volume (3d) into a series of slices along the Z axis. The Z axis in the script is the ndarray.shape[0].
- Parameters:
images – Data as images/slices stores in numpy array
output_dir – Output directory for the files
name_prefix – Prefix for the names of the images, appended before the image number
swap_axes – Swap the 0 and 1 axis of the images (convert from radiograms to sinograms on saving)
out_format – File format of the saved out images
overwrite_all – Overwrite existing images with conflicting names
custom_idx – Single index to be used for the file name, instead of incremental numbers
zfill_len – This option is ignored if custom_idx is specified! Prepend zeros to the output file names to have a constant file name length. Example: - saving out an image with zfill_len = 6: saved_image000001,…saved_image000201 and so on - saving out an image with zfill_len = 3: saved_image001,…saved_image201 and so on
name_postfix – Postfix for the name after the index
indices – Only works if custom_idx is not specified. Specify the start and end range of the indices which will be used for the file names.
progress – Passed to ensure progress during saving is tracked properly
pixel_depth – Defines the target pixel depth of the save operation so np.float32 or np.int16 will ensure the values are scaled correctly to these values.
- Returns:
The filename/filenames of the saved data.
- mantidimaging.core.io.saver.make_dirs_if_needed(dirname: str | None = None, overwrite_all: bool = False) None [source]#
Makes sure that the directory needed (for example to save a file) exists, otherwise creates it.
- Parameters:
: (dirname) – (output) directory to check
- mantidimaging.core.io.saver.nexus_save(dataset: Dataset, path: str, sample_name: str, save_as_float: bool) None [source]#
Uses information from a StrictDataset to create a NeXus file. :param dataset: The dataset to save as a NeXus file. :param path: The NeXus file path. :param sample_name: The sample name.
- mantidimaging.core.io.saver.write_fits(data: ndarray, filename: str, overwrite: bool = False, description: str | None = '') None [source]#