pykrait.io package#

Submodules#

pykrait.io.files module#

pykrait.io.files.concat_analysis_files(root_folder: str, filetype: str = 'output') None[source]#

Concatenates all *_analysis_output.csv files in the given root folder and its subdirectories into a single CSV file named experiment_overview.csv.

Parameters:

root_folder (str) – folder where *_analysis_output.csv files are located

Raises:

FileNotFoundError – if no *_analysis_output.csv files are found

pykrait.io.files.get_files_from_folder(folder: str, extension: str = '.czi') list[str][source]#

returns all files from a folder with specified extensions.

Parameters:
  • folder (str) – path to the folder

  • extensions (str) – str of file extension (default is “.czi”)

Returns:

list of file paths with the specified extensions

Return type:

list[str]

pykrait.io.files.get_pykrait_version() str[source]#

returns the current version of pykrait.

pykrait.io.files.read_Txnrois(filepath: str, n_frames: int = None, n_rois: int = None) ndarray[source]#

loads a T x n_roi array to a CSV file with a header to denote the ROIs and a time index

Parameters:
  • filepath (str) – path to the CSV file

  • n_frames (int) – number of frames in the timelapse

Returns:

numpy array of shape (n_frames, n_rois)

Return type:

np.ndarray

pykrait.io.files.save_NroisxF(array: ndarray, filepath: str, header: List[str] = None) None[source]#

Saves a Nrois x F array to a CSV file with an index to denote the ROIs and a header for the features :param array: T x n_roi array to save :type array: np.ndarray :param filename: name of the output file :type filename: str :param frame_interval: frame interval in seconds :type frame_interval: float

pykrait.io.files.save_Txnrois(array: ndarray, frame_interval: float, filepath: str) None[source]#

Saves a T x n_roi array to a CSV file with a header to denote the ROIs and a time index

Parameters:
  • array (np.ndarray) – T x n_roi array to save

  • filename (str) – name of the output file

  • frame_interval (float) – frame interval in seconds

pykrait.io.images module#

pykrait.io.images.get_pixel_contour_from_label_img(label_img: ndarray, orig_shape: tuple = (1, 1), target_shape: tuple = (1, 1)) list[source]#

Generates pixel contours from a labeled image, scaled to a target shape.

Parameters:
  • label_img (np.ndarray) – a label image where each pixel is labeled with an integer representing the ROI it belongs to

  • orig_shape (tuple) – original shape of the image (height, width)

  • target_shape (tuple) – target shape to which the contours should be scaled (height, width)

Returns:

returns a list of polygons representing the scaled contours of each ROI

Return type:

list

pykrait.io.images.load_timelapse_lazy(file_path: str) list[Array, float, float, float][source]#

Load a timelapse image file lazily using AICSImageIO, returning a Dask array of the image data along with the frame interval and pixel sizes.

Currently supports CZI and TIF/TIFF files. The image data is returned as a Dask array with shape (T, C, Y, X) where T is time, C is channels, Y is height, and X is width. The Z dimension is dropped if it has only one slice.

Parameters:

file_path (str) – input file path to the timelapse image file

Raises:
  • TypeError – if filepath is not a string

  • FileNotFoundError – if the file does not exist

  • ValueError – if the extension is not supported

  • ValueError – if the image does not have the expected 5D shape (TCZYX)

  • ValueError – if the image has more than one Z slice and Z cannot be automatically dropped

Returns:

returns a list of a Dask array containing the image data, the frame interval in seconds, and pixel sizes in micrometers (Y, X)

Return type:

list[da.Array, float, float, float]

pykrait.io.images.read_image(file_path: str) ndarray[source]#

Reads a image from a file and returns it as a Dask array.

Parameters:

file_path (str) – path to the image file

Returns:

Dask array of the image

Return type:

da.Array

pykrait.io.images.read_label_image(file_path: str) ndarray[source]#

Reads a label image from a file and returns it as a Dask array.

Parameters:

file_path (str) – path to the label image file

Returns:

Dask array of the label image

Return type:

da.Array

Module contents#