analysis.dimensionality_reduction.fiber_data

Methods for fiber data merging and alignment.

Functions

align_fiber(coords)

Align an array of x, y, z coordinates along the positive y axis.

align_fibers(data)

Align fibers for each time point in the data.

get_merged_data(bucket, series_name, ...[, ...])

Load or create merged data for given conditions and random seeds.

plot_fibers_by_key_and_seed(data[, ...])

Plot simulated fiber data for each condition key and random seed.

reshape_fibers(data)

Reshape data from tidy data format to array of fibers and fiber features.

save_aligned_fibers(data, time_map, ...)

Save aligned fiber data.

get_merged_data(bucket: str, series_name: str, condition_keys: list[str], random_seeds: list[int], align: bool = True) DataFrame[source]

Load or create merged data for given conditions and random seeds.

If merged data (aligned or unaligned) already exists, load the data. Otherwise, iterate through the conditions and seeds to merge the data.

Parameters:
  • bucket – Name of S3 bucket for input and output files.

  • series_name – Name of simulation series.

  • condition_keys – List of condition keys.

  • random_seeds – Random seeds for simulations.

  • align – True if data should be aligned, False otherwise.

Returns:

Merged data.

align_fibers(data: DataFrame) None[source]

Align fibers for each time point in the data.

Parameters:

data – Simulated fiber data.

align_fiber(coords: ndarray) tuple[ndarray, ndarray][source]

Align an array of x, y, z coordinates along the positive y axis.

The function identifies the furthest point in the yz-plane and computes the angle needed to rotate this point to lie on the positive y axis. This rotation angle is applied to all y and z coordinates; x coordinates are not changed. For example, if the furthest point is (0.5, 0, 1), it is rotated to (0.5, 1, 0) with an angle of pi / 2.

Parameters:

coords – Array of x, y, and z positions.

reshape_fibers(data: DataFrame) tuple[ndarray, DataFrame][source]

Reshape data from tidy data format to array of fibers and fiber features.

Parameters:

data – Simulated fiber data.

Returns:

Array of fibers and dataframe of fiber features.

save_aligned_fibers(data: DataFrame, time_map: dict, save_location: str, save_key: str) None[source]

Save aligned fiber data.

Parameters:
  • data – Aligned fiber data.

  • time_map – Map of selected aligned time for each simulator and condition.

  • save_location – Location for output file (local path or S3 bucket).

  • save_key – Name key for output file.

plot_fibers_by_key_and_seed(data: DataFrame, save_location: str | None = None, save_key: str = 'aligned_fibers_by_key_and_seed.png') None[source]

Plot simulated fiber data for each condition key and random seed.

Parameters:
  • data – Simulated fiber data.

  • save_location – Location for output file (local path or S3 bucket).

  • save_key – Name key for output file.