Shell and process utilities
- library.utilities.utilities_process.convert(img, target_type_min, target_type_max, target_type)
Converts an image from one type to another and also resizes
- Parameters:
img – numpy array
target_type_min – min size
target_type_max – max size
target_type – dtype of array
- Returns:
- library.utilities.utilities_process.convert_size(size_bytes: int) str
Function takes unformatted bytes, calculates human-readable format [with units] and returns string
- Parameters:
size_bytes (int) –
- Returns:
str:
- library.utilities.utilities_process.create_downsample(file_key)
takes a big tif and scales it down to a manageable size. This method is used in PrepCreator For 16bit images, this is a good number near the high end.
- library.utilities.utilities_process.get_cpus()
Helper method to return the number of CPUs to use
- library.utilities.utilities_process.get_hostname() str
Returns hostname of server where code is processed
- Returns:
string of the current workstation
- library.utilities.utilities_process.get_image_size(filepath: str)
Returns width, height of single image
- Parameters:
filepath – path of input file
- Returns:
tuple of int width and height of the file
- library.utilities.utilities_process.read_image(file_path: str)
Reads an image from the filesystem with exceptions
- library.utilities.utilities_process.test_dir(animal: str, directory, section_count, downsample: bool = True, same_size: bool = False) int
Verify image stack directory for section count and max width, height
- Parameters:
animal – string of animal name.
directory – directory we are testing.
section_count – integer how many sections are in the stack
downsample – boolean on whether to downsample or not
same_size – boolean on whether all files are same size
- Returns:
string of error messages
- library.utilities.utilities_process.write_image(file_path, data, message: str = 'Error') None
Writes an image to the filesystem