scallops.io.save_stack_imagej
- scallops.io.save_stack_imagej(uri, data, luts=None, display_ranges=None, resolution=1.0, compress=0, dimensions=None, display_mode='composite')
Taken and modified from https://github.com/blaineylab/OpticalPooledScreens.
Saves data as tiff file with imageJ compatibility.
- Parameters:
uri (str) – Path or url to store the tiff file
data (ndarray) – an array with 5, 4, 3, or 2 dimensions [TxZxCxYxX]
luts (tuple[Sequence[int], ...] | None) – ImageJ lookup table for each channel (e.g, scallops.io.GRAY, scallops.io.GREEN, etc)
display_ranges (tuple[tuple[int, int], ...] | None) – The display range can be set with a list of (min, max) pairs for each channel.
resolution (float) – Resolution of the image in microns per pixel
compress (Literal[0, 1]) – Compress the image. Setting to 1 saves a lot of space for integer masks
dimensions (str) – Dimensionality of the data. Leading dimenstions in order (i.e. TCZ, TC, CT)
display_mode (Literal['composite', 'color', 'grayscale']) – Sets the display mode, where mode is “composite”, “color” or “grayscale”
>>> random_data = np.random.randint(0, 2**16, size=(3, 100, 100), dtype=np.uint16) >>> ramp = list(range(256)) >>> ZERO = [0] * 256 >>> RED = ramp + ZERO + ZERO >>> GREEN = ZERO + ramp + ZERO >>> BLUE = ZERO + ZERO + ramp >>> luts = GREEN, RED, BLUE >>> display_ranges = (0, 60000), (0, 40000), (0, 20000) >>> save_stack_imagej( ... "random_image.tiff", random_data, luts=luts, display_ranges=display_ranges ... )
- Compatible array data types are:
bool (converted to uint8 0, 255) uint8 uint16 float32 float64 (converted to float32)