core package
Contents
core package¶
Submodules¶
core.dask_cluster module¶
Classes and functions for file management
-
class
core.dask_cluster.DaskCluster(requested_nb_nodes, maximum_load=0.6, memory_per_worker=12000)¶ Bases:
objectUsed to manage parallel run thanks the Dask package
-
create_distributed_client()¶ Instance workers
-
initialize_cluster()¶ Defines the number of threads allocated
-
-
core.dask_cluster.try_get_client()¶ Check if client is alive
- Returns
Client instance or None
- Return type
Dask.Client
core.data_file module¶
Data files module
Manage files operations, depending of DataManager.
-
class
core.data_file.BlockAlignmentFile(relative_shifts, rms_image, contour)¶ Bases:
core.data_file.DataFile-
delete_data()¶
-
save(folder_path, basename)¶
-
-
class
core.data_file.BothImgRbgFile(image1_uncorrected, image2_corrected_raw)¶ Bases:
core.data_file.DataFile-
delete_data()¶
-
save(folder_path, basename)¶ Overlays two images as R and B and saves them to output file
-
-
class
core.data_file.DataFile(data=None)¶ Bases:
object-
delete_data()¶
-
save(folder_path: str, basename: str)¶
-
-
class
core.data_file.EcsvFile(data)¶ Bases:
core.data_file.DataFile-
save(folder_path: str, basename: str)¶
-
-
class
core.data_file.EqualizationHistogramsFile(i_histogram, lower_threshold)¶ Bases:
core.data_file.DataFile-
delete_data()¶
-
save(folder_path, basename)¶ Overlays two images as R and B and saves them to output file
-
-
class
core.data_file.FocalPlaneMatrixFile(data, title)¶ Bases:
core.data_file.DataFile-
save(folder_path: str, basename: str)¶
-
-
class
core.data_file.JsonFile(data)¶ Bases:
core.data_file.DataFile-
save(folder_path: str, basename: str)¶
-
-
class
core.data_file.NpyFile(npy_data, status: str, cycle='', path='', basename='', label='')¶ Bases:
core.data_file.DataFile-
get_root()¶
-
load()¶
-
save(folder_path: str, basename: str)¶
-
-
class
core.data_file.Png2DFile(data)¶ Bases:
core.data_file.DataFile-
save(folder_path: str, basename: str)¶
-
-
class
core.data_file.RefDiff3DSlicesFile(reference_3d, target_uncorrected_3d, target_corrected_3d, reference_cycle=None, target_cycle=None, n_xz_slices=5, n_yz_slices=5)¶ Bases:
core.data_file.DataFile-
delete_data()¶
-
save(folder_path, basename)¶
-
-
class
core.data_file.RefDiffFile(preprocessed_ref, shifted_img, preprocessed_img, reference_cycle=None, target_cycle=None)¶ Bases:
core.data_file.DataFile-
delete_data()¶
-
save(folder_path, basename)¶ Overlays two images as R and B and saves them to output file
-
-
core.data_file.save_json(data, file_name)¶ Save a python dict as a JSON file
- Parameters
data (dict) – Data to save
file_name (str) – Output JSON file name
core.data_manager module¶
core.function_caller module¶
core.parameters module¶
core.pyhim_logging module¶
Classes and functions for pyHiM logging
-
class
core.pyhim_logging.Logger(root_folder, parallel=False, session_name='HiM_analysis', init_msg='')¶ Bases:
object-
setup_logger()¶
-
setup_md_file(session_name: str = 'HiM_analysis')¶
-
-
core.pyhim_logging.print_analyzing_label(text: str)¶
-
core.pyhim_logging.print_dashes()¶
-
core.pyhim_logging.print_framed_text(text: str, frame: str)¶ Example: ================= text =================
- Parameters
text (str) – Text to print in the middle
frame (str) – Template of frame to put in right and left Example: “=================”
-
core.pyhim_logging.print_log(message, status='INFO')¶ Shows message to terminal and logs it to file. Compatible with dask workers. Used the dask logger that used itself logging logger instance before.
- Parameters
message (str) – message.
status (str, optional) – either DEBUG, INFO or WARN. The default is ‘INFO’.
- Returns
- Return type
None.
-
core.pyhim_logging.print_section(section: str)¶
-
core.pyhim_logging.print_session_name(name: str)¶
-
core.pyhim_logging.print_title(title: str)¶
-
core.pyhim_logging.print_unknown_params(unknown_params: dict)¶
-
core.pyhim_logging.write_string_to_file(file_name, text_to_output, attribute='a')¶ write a line of text into a file
- Parameters
file_name (str) – log file
text_to_output (str) – text to write in file
attribute (str, optional) – Open file mode option, by default “a”
core.run_args module¶
pyHiM argument parser module
-
class
core.run_args.RunArgs(command_line_arguments)¶ Bases:
objectStore and check run arguments
-
args_to_str()¶ Print parameters in your shell terminal
- Parameters
dictionary (dict) – Parameters dictionary
-
static
get_2d_commands()¶ Default commands for 2D pipeline
- Returns
Set of 2D commands
- Return type
frozenset
-
static
get_3d_commands()¶ Default commands for 3D pipeline
- Returns
Set of 3D commands
- Return type
frozenset
-
static
get_available_commands()¶ Available commands for pyHiM
- Returns
Set of available commands
- Return type
frozenset
-
classmethod
parse_cmd(cmd)¶ Parse the input command list give by the user as a string (comma-separated)
- Parameters
cmd (str) – A comma-separated human-list of commands
- Returns
A Python list of commands
- Return type
List[str]
-
core.saving module¶
Functions for common image processing
-
core.saving.annotate_heatmap(im, data=None, valfmt='{x:.1f}', textcolors=('black', 'white'), threshold=None, **textkw)¶ A function to annotate a heatmap.
- Parameters
im – The AxesImage to be labeled.
data – Data used to annotate. If None, the image’s data is used. Optional.
valfmt – The format of the annotations inside the heatmap. This should either use the string format method, e.g. “$ {x:.2f}”, or be a matplotlib.ticker.Formatter. Optional.
textcolors – A pair of colors. The first is used for values below a threshold, the second for those above. Optional.
threshold – Value in data units according to which the colors from textcolors are applied. If None (the default) uses the middle of the colormap as separation. Optional.
**kwargs – All other arguments are forwarded to each call to text used to create the text labels.
-
core.saving.display_3d_assembled(images, localizations=None, plotting_range=None, normalize_b=True, masks=None)¶
-
core.saving.heatmap(data, row_labels, col_labels, ax=None, cbar_kw=None, cbarlabel='', fontsize=12, **kwargs)¶ Create a heatmap from a numpy array and two lists of labels.
- Parameters
data – A 2D numpy array of shape (N, M).
row_labels – A list or array of length N with the labels for the rows.
col_labels – A list or array of length M with the labels for the columns.
ax – A matplotlib.axes.Axes instance to which the heatmap is plotted. If not provided, use current axes or create a new one. Optional.
cbar_kw – A dictionary with arguments to matplotlib.Figure.colorbar. Optional.
cbarlabel – The label for the colorbar. Optional.
**kwargs – All other arguments are forwarded to imshow.
-
core.saving.image_show_with_values(matrices, output_name: str = 'tmp.png', cbarlabels: list = None, fontsize=6, verbose: bool = False, title='')¶ Plots a list of matrices with their values in each pixel.
- Parameters
matrices (list) – matrices to plot. Should be 2D numpy arrays
output_name (TYPE, optional) – DESCRIPTION. The default is “tmp.png”.
cbarlabels (list, optional) – titles of subplots. The default is [“focalPlane”].
fontsize (float, optional) – fontsize. The default is 6.
verbose (Boolean, optional) – self explanatory. The default is False.
title (str, optional) – figure title. The default is “”.
- Returns
- Return type
None.
-
core.saving.image_show_with_values_single(ax, matrix, cbarlabel, fontsize, cbar_kw, valfmt='{x:.0f}', cmap='YlGn')¶
-
core.saving.plot_3d_shift_matrices(shift_matrices, fontsize=8, log=False, valfmt='{x:.1f}')¶
-
core.saving.plot_4_images(allimages, titles=None)¶
-
core.saving.plot_raw_images_and_labels(image, label)¶ - Parameters
image (List of numpy ndarray (N-dimensional array)) – 3D raw image of format .tif
label (List of numpy ndarray (N-dimensional array)) – 3D labeled image of format .tif
-
core.saving.save_image_2d_cmd(image, file_name)¶
-
core.saving.save_image_as_blocks(img, full_filename, block_size_xy=256, label='raw_image')¶