convert_to_cells_file#

convert_to_cells_file(samples: DataFrame, reference: DataFrame, volume_distributions: dict[str, tuple[float, float]], height_distributions: dict[str, tuple[float, float]], critical_volume_distributions: dict[str, tuple[float, float]], critical_height_distributions: dict[str, tuple[float, float]], state_thresholds: dict[str, float]) list[dict][source]#

Convert all samples to cell objects.

For each cell id in samples, current volume and height are rescaled to critical volume and critical height based on distribution means and standard deviations. If reference volume and/or height exist for the cell id, those values are used as the current values to be rescaled. Otherwise, current volume is calculated from the number of voxel samples and current height is calculated from the range of voxel coordinates along the z axis.

Initial cell state and cell state phase for each cell are estimated based on state thresholds, the current cell volume, and the critical cell volume.

Cell object ids are reindexed starting with cell id 1.

Parameters:
  • samples – Sample cell ids and coordinates.

  • reference – Reference values for volumes and heights.

  • volume_distributions – Map of volume means and standard deviations.

  • height_distributions – Map of height means and standard deviations.

  • critical_volume_distributions – Map of critical volume means and standard deviations.

  • critical_height_distributions – Map of critical height means and standard deviations.

  • state_thresholds – Critical volume fractions defining threshold between states.

Returns:

List of cell objects formatted for ARCADE.

convert_to_cell(cell_id: int, samples: DataFrame, reference: dict, volume_distributions: dict[str, tuple[float, float]], height_distributions: dict[str, tuple[float, float]], critical_volume_distributions: dict[str, tuple[float, float]], critical_height_distributions: dict[str, tuple[float, float]], state_thresholds: dict[str, float]) dict[source]#

Convert samples to cell object.

Current volume and height are rescaled to critical volume and critical height based on distribution means and standard deviations. If reference volume and/or height are provided (under the “DEFAULT” key), those values are used as the current values to be rescaled. Otherwise, current volume is calculated from the number of voxel samples and current height is calculated from the range of voxel coordinates along the z axis.

Initial cell state and cell state phase are estimated based on state thresholds, the current cell volume, and the critical cell volume.

Parameters:
  • cell_id – Unique cell id.

  • samples – Sample coordinates for a single object.

  • reference – Reference data for cell.

  • volume_distributions – Map of volume means and standard deviations.

  • height_distributions – Map of height means and standard deviations.

  • critical_volume_distributions – Map of critical volume means and standard deviations.

  • critical_height_distributions – Map of critical height means and standard deviations.

  • state_thresholds – Critical volume fractions defining threshold between states.

Returns:

Cell object formatted for ARCADE.

convert_to_cell_region(region: str, region_samples: DataFrame, reference: dict, volume_distributions: dict[str, tuple[float, float]], height_distributions: dict[str, tuple[float, float]], critical_volume_distributions: dict[str, tuple[float, float]], critical_height_distributions: dict[str, tuple[float, float]]) dict[source]#

Convert region samples to cell region object.

Current region volume and height are rescaled to critical volume and critical height based on distribution means and standard deviations. If reference region volume and/or height are provided, those values are used as the current values to be rescaled. Otherwise, current region volume is calculated from the number of voxel samples and current region height is calculated from the range of voxel coordinates along the z axis.

Parameters:
  • region – Region name.

  • region_samples – Sample coordinates for region of a single object.

  • reference – Reference data for cell region.

  • volume_distributions – Map of volume means and standard deviations.

  • height_distributions – Map of height means and standard deviations.

  • critical_volume_distributions – Map of critical volume means and standard deviations.

  • critical_height_distributions – Map of critical height means and standard deviations.

Returns:

Cell region object formatted for ARCADE.

get_cell_state(volume: float, critical_volume: float, threshold_fractions: dict[str, float]) str[source]#

Estimate cell state based on cell volume.

The threshold fractions dictionary defines the monotonic thresholds between different cell states. For a given volume v, critical volume V, and states X1, X2, …, XN with corresponding, monotonic threshold fractions f1, f2, …, fN, a cell is assigned state Xi such that [f(i - 1) * V] <= v < [fi * V].

Cells with v < f1 * V are assigned state X1.

Cells with v > fN * V are assigned state XN.

Parameters:
  • volume – Current cell volume.

  • critical_volume – Critical cell volume.

  • threshold_fractions – Critical volume fractions defining threshold between states.

Returns:

Cell state.

convert_value_distribution(value: float, source_distribution: tuple[float, float], target_distribution: tuple[float, float]) float[source]#

Estimate target value based on source value and source and target distributions.

Parameters:
  • value – Source value.

  • source_distribution – Average and standard deviation of source value distribution.

  • target_distribution – Average and standard deviation of target value distribution.

Returns:

Estimated critical value.

filter_cell_reference(cell_id: int, reference: DataFrame) dict[source]#

Filter reference data for given cell id.

Parameters:
  • cell_id – Unique cell id.

  • reference – Reference data for conversion.

Returns:

Reference data for given cell id.