Utilities module#

class napari_stress.utils.TimelapseConverter#

This class allows converting napari 4D layer data between different formats.

data_to_list_of_data(data, layertype: type) list#

Convert 4D data into a list of 3D data frames

Parameters:
  • data (4D data to be converted)

  • layertype (layerdata type. Can be any of ‘PointsData’, SurfaceData,)

  • ImageData

  • LabelsData

  • List[LayerDataTuple]

  • or (LayerDataTuple)

  • pd.DataFrame.

Raises:

TypeError – Error to indicate that the converter does not support the passed layertype

Returns:

list

Return type:

List of 3D objects of input layertype

list_of_data_to_data(data, layertype: type)#

Function to convert a list of 3D frames into 4D data.

Parameters:
  • data (list of 3D data (time)frames)

  • layertype (layerdata type. Can be any of ‘PointsData’, SurfaceData,)

  • ImageData

  • LabelsData

  • List[LayerDataTuple]

  • or (LayerDataTuple)

  • pd.DataFrame.

Raises:

TypeError – Error to indicate that the converter does not support the passed layertype

Return type:

4D data of type layertype

napari_stress.utils.compile_data_from_layers(results_stress_analysis: list, n_frames: int, time_step: float) list#

Compile data from the results of the stress analysis into a list of dataframes.

Parameters:
  • results_stress_analysis (list) – List of tuples containing the results of the stress analysis

  • n_frames (int) – Number of frames in the data

  • time_step (float) – Time step between frames

Returns:

  • df_over_time (pd.DataFrame) – Dataframe containing the singular values results, e.g. results from the stress analysis that refer to a single value per frame. Columns:

    timefloat

    Time of the frame

    etc.

  • df_nearest_pairs (pd.DataFrame) – Dataframe containing the nearest pair extrema results. Columns:

    timefloat

    Time of the frame

    nearest_pair_distancefloat

    Distance between the nearest pairs of extrema

    nearest_pair_anisotropyfloat

    Stress Anisotropy of the nearest pair

  • df_all_pairs (pd.DataFrame) – Dataframe containing the all pair extrema results. Columns:

    timefloat

    Time of the frame

    all_pair_distancefloat

    Distance between all pairs of extrema

    all_pair_anisotropyfloat

    Stress Anisotropy of all pairs

  • df_autocorrelations (pd.DataFrame) – Dataframe containing the spatial autocorrelation results. Columns:

    timefloat

    Time of the frame

    distancesfloat

    Distances at which the autocorrelation was calculated

    autocorrelation_totalfloat

    Autocorrelation of the total stress

    autocorrelation_cellfloat

    Autocorrelation of the cell stress

    autocorrelation_tissuefloat

    Autocorrelation of the tissue stress

napari_stress.utils.export_settings(settings: dict, parent=None, file_name: str | None = None) None#

Export settings to yaml file.

Parameters:
  • settings (dict) – Dictionary of settings

  • parent (QWidget, optional) – Parent widget for dialog, by default None

napari_stress.utils.frame_by_frame(function: callable, progress_bar: bool = False)#

Decorator to apply a function frame by frame to 4D data.

Parameters:
  • function (callable) –

    Function to be wrapped. If the optional argument use_dask is passed to the function, the function will be parallelized using dask:

    >>> @frame_by_frame(some_function)(argument1, argument2, use_dask=True)
    

    Note: For this to work, the arguments (e.g., the input data) must not be passed as keyword argument. I.e., this works:

    >>> @frame_by_frame(some_function)(argument1, argument2, some_keyword='abc', use_dask=True)
    

    This does not work:

    >>> @frame_by_frame(some_function)(image1=argument1, image2=argument2, some_keyword='abc', use_dask=True)
    

  • progress_bar (bool, optional) – Show progress bar, by default False. Has no effect if use_dask=True is passed as an argument to the input function function.

Returns:

Wrapped function

Return type:

callable

napari_stress.utils.import_settings(parent=None, file_name: str | None = None) dict#

Import settings from yaml file.

Parameters:

parent (QWidget, optional) – Parent widget for dialog, by default None

Returns:

Dictionary of settings

Return type:

dict