megafish.utils module

natural_sort(list_to_sort)[source]

Sorts a list of strings in natural order, where numerical values are ordered as numbers, not as individual characters.

Parameters:

list_to_sort (list of str) – The list of strings to be sorted.

Returns:

A new list sorted in natural order.

Return type:

list of str

Example

natural_sort([‘file2.txt’, ‘file10.txt’, ‘file1.txt’]) -> [‘file1.txt’, ‘file2.txt’, ‘file10.txt’]

get_tile_yx(n_tile_y, n_tile_x, scan_type)[source]

Generates a list of (y, x) coordinates for tiles scanned according to a specified pattern.

Parameters:
  • n_tile_y (int) – The number of tiles in the y direction.

  • n_tile_x (int) – The number of tiles in the x direction.

  • scan_type (str) – The scanning pattern type, e.g., “snake_up_right” or “snake_right_down”.

Returns:

A list of (y, x) coordinates for each tile.

Return type:

list of tuple

Raises:

ValueError – If the scan_type is not supported.

get_round_cycle(n_round, n_cycle)[source]

Generates a list of (round, cycle) pairs for each round and cycle.

Parameters:
  • n_round (int) – The number of rounds.

  • n_cycle (int) – The number of cycles.

Returns:

A list of (round, cycle) pairs for each round and cycle.

Return type:

list of tuple

copy_groups(src_dir, zarr_path, groups)[source]