physicool.processing

A module to process output PhysiCell files and extract metrics from the data.

Module Contents

Classes

Microenvironment

Functions

read_mat_file_cells(path, variables)

Loads the data from the output mat files into a Pandas DataFrame.

read_physicell_version()

Reads the PhysiCell version number from VERSION.TXT.

convert_version_str_to_tuple(version)

Converts a string with the version number to a tuple to ease version comparison.

check_version_status(version)

Compares the passed version to the first version with the output*_cells.mat format.

get_cell_file_name(version)

Returns the expected file name for cell files based on PhysiCell version number.

get_cell_file_num(output_path, version)

get_cell_data(timestep, variables[, output_path, version])

Reads the PhysiCell output data into a Pandas DataFrame.

get_cells_in_z_slice(data, size)

Returns the cells inside a z-axis slice and returns them.

get_cell_trajectories(output_path[, version])

Reads the PhysiCell output data into a Pandas DataFrame.

get_cell_numbers_over_time([output_path, version])

Returns the number of cells over time (one value for each simulation time point).

get_final_y_position([output_path, version])

Returns the number of cells over time (one value for each simulation time point).

compute_mean_squared_error(model_data, reference_data)

Returns the mean squared error value between the reference and simulated datasets.

Attributes

NEW_OUTPUTS_VERSION

CELL_OUTPUT_LABELS

OutputProcessor

ErrorQuantification

physicool.processing.NEW_OUTPUTS_VERSION = '1.10.3'
physicool.processing.CELL_OUTPUT_LABELS = ['ID', 'position_x', 'position_y', 'position_z', 'total_volume', 'cell_type', 'cycle_model',...
class physicool.processing.Microenvironment(time_point, path)[source]
Parameters:
  • time_point (int) –

  • path (Union[pathlib.Path, str]) –

get_substances()[source]

Returns a list of the substances stored in the XML output files.

get_mesh()[source]

Returns a list with the coordinates of the microenvironment mesh.

get_substance_data(substance)[source]

Returns an array with the substance concentrations for all the planes of the domain.

get_data()[source]

Returns a dictionary with the data for all the substances in the simulation.

physicool.processing.read_mat_file_cells(path, variables)[source]

Loads the data from the output mat files into a Pandas DataFrame.

Parameters:
  • path (str) –

  • variables (List[str]) –

Return type:

pandas.DataFrame

physicool.processing.read_physicell_version()[source]

Reads the PhysiCell version number from VERSION.TXT.

Return type:

str

physicool.processing.convert_version_str_to_tuple(version)[source]

Converts a string with the version number to a tuple to ease version comparison.

Parameters:

version (str) –

Return type:

Tuple[int]

physicool.processing.check_version_status(version)[source]

Compares the passed version to the first version with the output*_cells.mat format.

Parameters:

version (str) –

Return type:

bool

physicool.processing.get_cell_file_name(version)[source]

Returns the expected file name for cell files based on PhysiCell version number.

Parameters:

version (str) –

Return type:

str

physicool.processing.get_cell_file_num(output_path, version)[source]
Parameters:
  • output_path (pathlib.Path) –

  • version (str) –

Return type:

str

physicool.processing.get_cell_data(timestep, variables, output_path=Path('output'), version=NEW_OUTPUTS_VERSION)[source]

Reads the PhysiCell output data into a Pandas DataFrame.

Parameters:
  • timestep (int) – The time point to be read.

  • variables (List[str]) – The variables to be extracted from the file.

  • output_path (Union[str, pathlib.Path]) – The path to where the output files can be found.

  • version (str) –

Returns:

A DataFrame with the passed variables for every cell.

Return type:

pd.DataFrame

physicool.processing.get_cells_in_z_slice(data, size)[source]

Returns the cells inside a z-axis slice and returns them. The slice will be centered at 0 and have the passed size.

Parameters:
  • data (pandas.DataFrame) – A DataFrame with the cells’ coordinates (must contain a column called “position_z”).

  • size (float) – The size of the z-slice.

Returns:

A DataFrame that only contains the cells inside the slice.

Return type:

pd.DataFrame

physicool.processing.get_cell_trajectories(output_path, version=NEW_OUTPUTS_VERSION)[source]

Reads the PhysiCell output data into a Pandas DataFrame.

Parameters:
  • output_path (Union[str, pathlib.Path]) – The path to where the output files can be found.

  • version (str) –

Returns:

A DataFrame with the passed variables for every cell.

Return type:

pd.DataFrame

physicool.processing.OutputProcessor
physicool.processing.get_cell_numbers_over_time(output_path=Path('output'), version=NEW_OUTPUTS_VERSION)[source]

Returns the number of cells over time (one value for each simulation time point).

Parameters:
  • output_path (pathlib.Path) – The path to where the output files can be found.

  • version (str) –

Returns:

An array with the number of cells at every simulation time point.

Return type:

np.ndarray

physicool.processing.get_final_y_position(output_path=Path('output'), version=NEW_OUTPUTS_VERSION)[source]

Returns the number of cells over time (one value for each simulation time point).

Parameters:
  • output_path (pathlib.Path) – The path to where the output files can be found.

  • version (str) –

Returns:

An array with the number of cells at every simulation time point.

Return type:

np.ndarray

physicool.processing.ErrorQuantification
physicool.processing.compute_mean_squared_error(model_data, reference_data)[source]

Returns the mean squared error value between the reference and simulated datasets.

Parameters:
  • model_data (numpy.ndarray) –

  • reference_data (numpy.ndarray) –

Return type:

float