iss_preprocess.io package

Submodules

iss_preprocess.io.load module

iss_preprocess.io.load.find_roi_position_on_cryostat(data_path)

Find the A/P position of each ROI relative to the first collected slice

The section order is guess from the sign of section_thickness_um, positive for antero-posterior slicing (starting from the olfactory bulb), negative for opposite.

Parameters:

data_path (str) – Relative path to the data

Returns:

For each ROI, the slice depth in um relative to the

first collected slice

min_step (float): Minimum thickness between two slices

Return type:

roi_slice_pos_um (dict)

iss_preprocess.io.load.get_channel_round_transforms(data_path, prefix, tile_coors=None, shifts_type='best', load_file=True)

Load the channel and round shifts for a given tile and sequencing acquisition.

Parameters:
  • data_path (str) – Relative path to data.

  • prefix (str) – Prefix of the sequencing round.

  • tile_coors (tuple, optional) – Coordinates of the tile to process. Required if shifts_type is not reference. Defaults to None.

  • corrected_shifts (str, optional) – Which shift to use. One of reference, single_tile, ransac, or best. Defaults to best.

  • load_file (bool, optional) – Whether to load the shifts from file or just return the file name. Defaults to True.

Returns:

Array of channel and round shifts if load_file, else the path

Return type:

np.ndarray | Path

iss_preprocess.io.load.get_pixel_size(data_path, prefix='genes_round_1_1')

Get pixel size from MicroManager metadata.

Parameters:
  • data_path (str) – Relative path to data.

  • prefix (str, optional) – Which acquisition prefix to use. Defaults to “genes_round_1_1”.

Returns:

Pixel size in microns

Return type:

float

iss_preprocess.io.load.get_processed_path(data_path)

Return the path to the processed data.

Parameters:

data_path (str) – Relative path to data

Returns:

Path to processed data

Return type:

pathlib.Path

iss_preprocess.io.load.get_raw_filename(data_path, prefix, tile_coors)

Return the root name of raw data for a tile.

Raw file names may take on different patterns depending on micromanager version.

Parameters:
  • data_path (str) – Relative path to data

  • prefix (str) – Prefix of acquisition to load

  • tile_coors (tuple) – Tile coordinates (roi, xpos, ypos)

Returns:

Root name of the raw data file

Return type:

str

iss_preprocess.io.load.get_raw_path(data_path)

Return the path to the raw data.

Parameters:

data_path (str) – Relative path to data

Returns:

Path to raw data

Return type:

pathlib.Path

iss_preprocess.io.load.get_roi_dimensions(data_path, prefix=None, save=True)

Find imaging ROIs and determine their dimensions.

The output is the maximum index of the file names, which are 0 based. It is therefore the number of tiles in each dimension minus 1.

Create and/or load f”{prefix}_roi_dims.npy”. The default (None for ops[‘reference_prefix’]) should be used for all acquisitions that have the same ROI dimensions (everything except overviews).

Parameters:
  • data_path (str) – Relative path to data

  • prefix (str, optional) – Prefix of acquisition to load. Defaults to None.

  • save (bool, optional) – If True save roi dimensions if they are not already found on disk. Default to True

Returns:

Nroi x 3 array of containing (roi_id, NtilesX, NtilesY) for each

roi

Return type:

numpy.ndarray

iss_preprocess.io.load.get_tile_ome(fname, fmetadata=None, use_indexmap=True)

Load OME TIFF tile.

Parameters:
  • fname (str) – path to OME TIFF

  • fmetadata (str, optional) – path to OME metadata file. Required if use_indexmap is False or None. Defaults to None.

  • use_indexmap (bool, optional) – Whether to use the indexmap from micromanager metadata. If True, the metadata file is not required. Defaults to True.

Returns:

X x Y x C x Z z-stack.

Return type:

numpy.ndarray

iss_preprocess.io.load.get_z_step(data_path, prefix='genes_round_1_1')

Get z step size from MicroManager metadata.

Parameters:
  • data_path (str) – Relative path to data.

  • prefix (str, optional) – Which acquisition prefix to use. Defaults to “genes_round_1_1”.

Returns:

Z step size in microns

Return type:

float

iss_preprocess.io.load.get_zprofile(data_path, prefix, tile_coords)

Load the zprofile for a tile

Parameters:
  • data_path (str) – Relative path to data

  • prefix (str) – Prefix of acquisition to load

  • tile_coords (tuple) – Tile coordinates (roi, xpos, ypos)

Returns:

Z profile for the tile, with ‘std’ and ‘top_1permille’ keys

Return type:

dict

iss_preprocess.io.load.load_correction_image(data_path, projection, prefix, corr_prefix=None)

Load the image for illumination correction

By default, find the appropriate correction image from the ops file. This can be overridden by providing a corr_prefix.

Parameters:
  • data_path (str) – Relative path to dataset.

  • projection (str) – Projection to use, one of max, median.

  • prefix (str) – Prefix to correct, this is the image you want to correct, not the one you use for the correction.

  • corr_prefix (str, optional) – Prefix of the image to use for correction. If provided, this is used instead of the prefix. Defaults to None.

Returns:

X x Y x channels stack.

Return type:

numpy.ndarray

iss_preprocess.io.load.load_hyb_probes_metadata()

Load the hybridisation probes metadata.

Returns:

Contents of hybridisation_probes.yml

Return type:

dict

iss_preprocess.io.load.load_mask_by_coors(data_path, prefix, tile_coors, suffix='corrected')

Load masks for a single tile.

If the corrected mask is not found, the raw mask is loaded instead.

Parameters:
  • data_path (str) – relative path to dataset.

  • prefix (str) – Full folder name prefix, including round number.

  • tile_coors (tuple) – Coordinates of tile to load: ROI, Xpos, Ypos.

  • suffix (str, optional) – Suffix to add to the file name. Defaults to “corrected”.

Returns:

X x Y x channels stack.

Return type:

numpy.ndarray

iss_preprocess.io.load.load_metadata(data_path)

Load the metadata.yml file

This is the user generated file containing ROI and rounds information

Parameters:

data_path (str) – Relative path to data

Returns:

Content of {chamber}_metadata.yml

Return type:

dict

iss_preprocess.io.load.load_micromanager_metadata(data_path, prefix)

Load the metadata.txt of a single acquisition round

This is the detailed metadata from the microscope.

Parameters:
  • data_path (str) – Relative path to data

  • prefix (str) – Acquisition prefix, including round number if applicable

Returns:

Content of the metadata file

Return type:

metadata (dict)

iss_preprocess.io.load.load_ops(data_path, warn_missing=True)

Load the ops.yaml file.

This must be manually generated first. If it is not found, the default options are used.

Parameters:
  • data_path (str) – Relative path to data

  • warn_missing (bool, optional) – Whether to warn if the ops or metadata files are not found. Defaults to True.

Returns:

Options, see config/defaults_ops.yaml for description

Return type:

dict

iss_preprocess.io.load.load_section_position(data_path)

Load the section position information

This is the same for all chambers and is contained in the parent folder of data_path

Parameters:

data_path (str) – Relative path to dataset

Returns:

Slice position info

Return type:

pandas.DataFrame

iss_preprocess.io.load.load_sequencing_rounds(data_path, tile_coors=(1, 0, 0), nrounds=7, suffix='max', prefix='genes_round', specific_rounds=None, correct_illumination=False)

Load processed tile images across rounds

Parameters:
  • data_path (str) – relative path to dataset.

  • tile_coors (tuple, optional) – Coordinates of tile to load: ROI, Xpos, Ypos. Defaults to (1,0,0).

  • nrounds (int, optional) – Number of rounds to load. Used only if specific_rounds is None. Defaults to 7.

  • suffix (str, optional) – File name suffix. Defaults to ‘fstack’.

  • prefix (str, optional) – the folder name prefix, before round number. Defaults to “genes_round”

  • specific_round (list, optional) – if not None, specify which rounds must be loaded and ignores nrounds. Defaults to None

  • correct_illumination (bool, optional) – Whether to correct for illumination Defaults to False.

Returns:

X x Y x channels x rounds stack.

Return type:

numpy.ndarray

iss_preprocess.io.load.load_stack(fname)

Load TIFF stack.

Parameters:

fname (str) – path to TIFF

Returns:

X x Y x Z stack

Return type:

numpy.ndarray

iss_preprocess.io.load.load_tile_by_coors(data_path, tile_coors=(1, 0, 0), suffix='max', prefix='genes_round_1_1', correct_illumination=False)

Load processed tile images

Parameters:
  • data_path (str) – relative path to dataset.

  • tile_coors (tuple, optional) – Coordinates of tile to load: ROI, Xpos, Ypos. Defaults to (1,0,0).

  • suffix (str, optional) – File name suffix. Defaults to “fstack”.

  • prefix (str, optional) – Full folder name prefix, including round number. Defaults to “genes_round_1_1”

  • correct_illumination (bool, optional) – Whether to correct for illumination Defaults to False.

Returns:

X x Y x channels stack. uint16 if not corrected, float otherwise.

Return type:

numpy.ndarray

iss_preprocess.io.save module

iss_preprocess.io.save.save_ome_tiff_pyramid(target, image, pixel_size, subresolutions=3, dtype='uint16', rescale=True, verbose=True, save_thumbnail=False)

Write single image plane as pyramidal ome-tiff

Parameters:
  • target (str) – Path to tif file

  • image (np.array) – 2D array with 8-bit or 16-bit image data

  • pixel_size (float) – Pixel size in microns

  • subresolutions (int, optional) – Number of pyramid levels. Defaults to 3.

  • dtype (str, optional) – Image datatype, can be “uint16” or “uint8”. Defaults to “uint16”.

  • verbose (bool, optional) – Print progress. Defaults to True.

  • save_thumbnail (bool, optional) – Add a thumbnail image. Defaults to False.

Returns:

Last level of the pyramid, most downsampled image

Return type:

np.array

iss_preprocess.io.save.write_stack(stack, fname, bigtiff=False, dtype='uint16', clip=True, compress=True)

Write a stack to file as a multipage TIFF

Parameters:
  • stack (numpy.ndarray) – X x Y x … array (can have multiple channels / zplanes, etc.)

  • fname (str) – save path for the TIFF

  • bigtiff (bool, optional) – use bigtiff format. Default to False

  • dtype (str, optional) – datatype of the output image. Default to ‘uint16’

  • clip (bool, optional) – clip negative values before conversion. Default to True

  • compress (bool, optional) – compress the image using zlib, default to True

Module contents