mantidimaging.core.io.saver module

mantidimaging.core.io.saver.generate_names(name_prefix: str, indices: Union[List[int], Indices, None], num_images: int, custom_idx: Optional[int] = 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: Optional[int] = None, zfill_len: int = 6, name_postfix: str = '', indices: Union[List[int], Indices, None] = None, pixel_depth: Optional[str] = None, progress: Optional[Progress] = None) Union[str, 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: Optional[str] = None, overwrite_all: bool = False)[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: StrictDataset, path: str, sample_name: str)[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: numpy.ndarray, filename: str, overwrite: bool = False, description: Optional[str] = '')[source]
mantidimaging.core.io.saver.write_img(data: numpy.ndarray, filename: str, overwrite: bool = False, description: Optional[str] = '')[source]
mantidimaging.core.io.saver.write_nxs(data: numpy.ndarray, filename: str, projection_angles: Optional[numpy.ndarray] = None, overwrite: bool = False)[source]