mantidimaging.core.io.utility module

mantidimaging.core.io.utility.find_180deg_proj(sample_dirname: pathlib.Path, image_format: str, logger: Optional[logging.Logger] = None) str[source]
mantidimaging.core.io.utility.find_first_file_that_is_possibly_a_sample(file_path: str) Optional[str][source]
mantidimaging.core.io.utility.find_images(sample_dirname: pathlib.Path, image_type: str, suffix: str, image_format: str, look_without_suffix: bool = False, logger: Optional[logging.Logger] = None) List[str][source]
mantidimaging.core.io.utility.find_images_in_same_directory(sample_dirname: pathlib.Path, type: str, suffix: str, image_format: str) Optional[List[str]][source]
mantidimaging.core.io.utility.find_log(dirname: pathlib.Path, log_name: str, logger: Optional[logging.Logger] = None) str[source]
Parameters
  • dirname – The directory in which the sample images were found

  • log_name – The log name is typically the directory name of the sample

  • logger – The logger that find_log should report back via, should an error occur.

Returns

mantidimaging.core.io.utility.find_projection_closest_to_180(projections: numpy.ndarray, projection_angles: numpy.ndarray) Tuple[numpy.ndarray, float][source]

Finds the projection closest to 180 and returns it with the difference. :param projections: The array of projection images. :param projection_angles: The array of projection angles. :return: The 180 projection/the closest non-180 projection and the difference between its angle and 180.

mantidimaging.core.io.utility.get_candidate_file_extensions(ext: str) List[str][source]

Gets a list of file extensions which can be used to load files. :param ext: User provided file extension :returns: List of extensions in the order they should be tested

mantidimaging.core.io.utility.get_file_extension(file: str) Optional[str][source]
>>> get_file_extension("/home/user/file_path.test")
'test'
>>> get_file_extension("/home/user/file.path.test")
'test'
>>> get_file_extension("/home/")

# above is expecting a None which.. well doesn’t show as anything so just # an empty line with a comment explaining it

mantidimaging.core.io.utility.get_file_names(path: Optional[Union[pathlib.Path, str]], img_format: str, prefix: str = '', essential: bool = True) List[str][source]

Get all file names in a directory with a specific format. :param path: The path to be checked.

Parameters
  • img_format – The image format used as a postfix after the .

  • prefix – A specific prefix for the images

  • essential – Flag indicating if failure to find file should raise and exception

Returns

All the file names, sorted by ascending

mantidimaging.core.io.utility.get_folder_names(path: str) List[str][source]

Get all folder names in a specific path.

Parameters

path – The path to be checked.

Returns

All the folder names, sorted by ascending

mantidimaging.core.io.utility.get_prefix(path: str, separator: str = '_') str[source]