Utils
Utils module.
autocorrelation_stack(image, axes, average_z=True)
Compute the autocorrelation of an image stack, averaged over samples.
The input is normalized to SC(Z)YX using axes, autocorrelation is computed
per image, and the results are averaged over the sample dimension. Channels are
kept separate.
Parameters:
-
image(NDArray) –Input image stack.
-
axes(str) –Axes of the input stack, a subset of
STCZYXcontainingYandX. -
average_z(bool, default:True) –If True, compute a 2D (
YX) autocorrelation averaged over the sample andZdimensions. If False, compute a 3D (ZYX) autocorrelation averaged over the sample dimension only. Ignored when the data has noZaxis.
Returns:
-
ndarray–Averaged autocorrelation,
C(Z)YXwith the channel dimension dropped when there is a single channel.
cwd(path)
Change the current working directory to the given path.
This method can be used to generate files in a specific directory, once out of the context, the working directory is set back to the original one.
Parameters:
Returns:
-
Iterator[None]–None values.
Examples:
The context is whcnaged within the block and then restored to the original one.
get_careamics_home()
Return the CAREamics home directory.
CAREamics home directory is a hidden folder in home.
Returns:
-
Path–CAREamics home directory path.
get_logger(name, log_level=logging.INFO, log_path=None)
Create a python logger instance with configured handlers.
Parameters:
-
name(str) –Name of the logger.
-
log_level(int, default:INFO) –Log level (info, error etc.), by default logging.INFO.
-
log_path(Optional[Union[str, Path]], default:None) –Path in which to save the log, by default None.
Returns:
-
Logger–Logger.
get_ram_size()
get_run_version(root_folder, folder_name)
Get the version run based on experiment folder name.
Versioned folder starts at <folder_name>_0 and is incremented based on the content
of the root folder. This method is intended to be used for creating checkpoint
folders for each training run, without mixing up checkpoints. It should mimick the
csv logger.
Parameters:
-
root_folder(str | Path) –The root folder where the versioned folders are located.
-
folder_name(str) –The name of the versioned folder.
Returns:
-
int–The version number for the new run, which is one higher than the highest existing version number. If no versioned folders exist, it returns 0.