utils
Utilities
- topostats.utils.convert_path(path: Union[str, pathlib.Path]) pathlib.Path[source]
Ensure path is Path object.
- Parameters
path (Union[str, Path]) – Path to be converted.
- Returns
pathlib Path
- Return type
Path
- topostats.utils.find_images(base_dir: Optional[Union[str, pathlib.Path]] = None, file_ext: str = '.spm') List[source]
Scan the specified directory for images with the given file extension.
- Parameters
base_dir (Union[str, Path]) – Directory to recursively search for files, if not specified the current directory is scanned.
file_ext (str) – File extension to search for.
- Returns
List of files found with the extension in the given directory.
- Return type
List
- topostats.utils.get_mask(image: numpy.array, threshold: float) numpy.array[source]
Calculate a mask for pixels that exceed the threshold
- Parameters
image (np.array) – Numpy array representing image.
threshold (float) – Factor for defining threshold.
- Returns
Numpy array of image with objects coloured.
- Return type
np.array
- topostats.utils.get_threshold(image: numpy.array) float[source]
Returns a threshold value separating the background and foreground of a 2D heightmap.
- Parameters
image (np.array) – Numpy array representing image.
- Returns
Otsu threshold.
- Return type
float
Notes
The Otsu method is used for threshold derivation.
- topostats.utils.update_config(config: dict, args: Union[dict, argparse.Namespace]) Dict[source]
Update the configuration with any arguments
- Parameters
config (dict) – Dictionary of configuration (typically read from YAML file specified with ‘-c/–config <filename>’)
args (Namespace) – Command line arguments
- Returns
Dictionary updated with command arguments.
- Return type
Dict