pySpacell package

Submodules

pySpacell.pySpacell module

class pySpacell.pySpacell.Spacell(feature_file, image_label_file, column_objectnumber='ObjectNumber', column_x_y=['x', 'y'])
compute_per_image_analysis(feature_columns, method, neighborhood_matrix_type, neighborhood_p0, neighborhood_p1, **kwargs)

Computes per image spatial analysis tests for the provided features for one neighborhood matrix.

Feature_columns:
 list of str features’ names from feature_table. All features will be tested on the same neighborhood matrix and with the same analysis method.
Method:str can be - ‘assortativity’ or ‘ripley’ (for categorical features), - ‘moran’, ‘geary’, ‘getisord’ (global spatial autocorrelation for continuous features)
Neighborhood_matrix_type:
 str should be ‘k’, ‘radius’, or ‘network’
Neighborhood_min_p0:
 int or float minimum bound for the neighborhood. should be int for ‘k’ or ‘network’. Can be int or float for ‘radius’
Neighborhood_min_p1:
 int or float maximum bound for the neighborhood. should be int for ‘k’ or ‘network’. Can be int or float for ‘radius’
compute_per_object_analysis(feature_columns, method, neighborhood_matrix_type, neighborhood_p0, neighborhood_p1, **kwargs)

Computes per object spatial analysis tests for the provided features for one neighborhood matrix.

Feature_columns:
 list of str features’ names from feature_table. All features will be tested on the same neighborhood matrices and with the same analysis method
Method:str can be ‘moran’ or’getisord’ (local spatial autocorrelation for continuous features)
Neighborhood_matrix_type:
 str should be ‘k’, ‘radius’, or ‘network’
Neighborhood_min_p0:
 int or float minimum bound for the neighborhood. should be int for ‘k’ or ‘network’. Can be int or float for ‘radius’
Neighborhood_min_p1:
 int or float maximum bound for the neighborhood. should be int for ‘k’ or ‘network’. Can be int or float for ‘radius’
correlogram(feature_columns, method, neighborhood_matrix_type, neighborhood_min_p0, neighborhood_max_p1, **kwargs)

Computes a serie of spatial analysis tests for the provided features. Gives one value for the image. The starting and ending neighborhood parameters, neighborhood_p0 and neighborhood_p1, are to be set. 3 modes are available to define the intermediary neighborhood parameters.

Feature_columns:
 list of str features’ names from feature_table. All features will be tested on the same neighborhood matrices and with the same analysis method
Method:str can be - ‘assortativity’ or ‘ripley’ (for categorical features), - ‘moran’, ‘geary’, ‘getisord’ (global spatial autocorrelation for continuous features)
Neighborhood_matrix_type:
 str should be ‘k’, ‘radius’, or ‘network’ Same ‘neighborhood_matrix_type’ for all the points in the correlogram.
Neighborhood_min_p0:
 int or float minimum bound for the neighborhood. should be int for ‘k’ or ‘network’. Can be int or float for ‘radius’
Neighborhood_min_p1:
 int or float maximum bound for the neighborhood. should be int for ‘k’ or ‘network’. Can be int or float for ‘radius’
Neighborhood_step:
 int or float a step in terms of parameters ([p0, p0+step, p0+2step, …p1]) should be int for ‘k’ or ‘network’. Can be int or float for ‘radius’ one of neighborhood_step, nb_pairs_step or nb_test_points should be defined.
Nb_pairs_step:int a step in terms of number of pairs for each test. Overlooked if neighborhood_step is provided.
Nb_test_points:int a number of test points. Overlooked if neighborhood_step or nb_pairs_step are provided.
get_neighborhood_matrix(neighborhood_matrix_type, neighborhood_p0, neighborhood_p1, iterations='None', pysal_object=False, **kwargs)

Return the neighborhood matrix for specified parameters if already computed, thraw a ValueError otherwise. 3 modes are available:

  • ‘k’ for k-nearest neighbors;
  • ‘radius’ for neighbors at an euclidean distance;
  • ‘network’ for neighbors from the object graph (touching objects are neighbors)

For each mode, an interval is requested to know which neighbors to include.

Examples: ‘k’, 2, 4 -> 2nd, 3rd, and 4th-nearest neighbors
‘radius’, 50.75, 100.85 -> neighbors at an euclidean distance falling between 50.75 pixels and 100.85 pixels ‘network’, 0, 1 -> neighbors having boundaries touching
Neighborhood_matrix_type:
 str should be ‘k’, ‘radius’, or ‘network’
Neighborhood_p0:
 int or float minimum bound for the neighborhood. should be int for ‘k’ or ‘network’. Can be int or float for ‘radius’
Neighborhood_p1:
 int or float maximum bound for the neighborhood. should be int for ‘k’ or ‘network’. Can be int or float for ‘radius’
Pysal_object:bool if True, return a pysal.weights object if False, return a tuple (W, L) with W full numpy neighborhood matrix and L list of vertices’ ids
get_suffix(neighborhood_matrix_type, neighborhood_p0, neighborhood_p1, **kwargs)

Returns the suffix for the additionally computed features in the feature_table: local spatial-autocorrelation statistical tests’ outputs, and neighborhood computation’s number of neighbors for each object (‘radius’ or ‘network’ neighborhood matrix type) or distance of last neighbor (‘k’ neighborhood matrix type).

Neighborhood_matrix_type:
 str should be ‘k’, ‘radius’, or ‘network’
Neighborhood_p0:
 int or float minimum bound for the neighborhood. should be int for ‘k’ or ‘network’. Can be int or float for ‘radius’
Neighborhood_p1:
 int or float maximum bound for the neighborhood. should be int for ‘k’ or ‘network’. Can be int or float for ‘radius’
matrix_types = ['k', 'radius', 'network']
precision_float_radius = 3

Module contents

Python Spatial Analysis for Cell Images Library

Documentation

class pySpacell.Spacell(feature_file, image_label_file, column_objectnumber='ObjectNumber', column_x_y=['x', 'y'])
compute_per_image_analysis(feature_columns, method, neighborhood_matrix_type, neighborhood_p0, neighborhood_p1, **kwargs)

Computes per image spatial analysis tests for the provided features for one neighborhood matrix.

Feature_columns:
 list of str features’ names from feature_table. All features will be tested on the same neighborhood matrix and with the same analysis method.
Method:str can be - ‘assortativity’ or ‘ripley’ (for categorical features), - ‘moran’, ‘geary’, ‘getisord’ (global spatial autocorrelation for continuous features)
Neighborhood_matrix_type:
 str should be ‘k’, ‘radius’, or ‘network’
Neighborhood_min_p0:
 int or float minimum bound for the neighborhood. should be int for ‘k’ or ‘network’. Can be int or float for ‘radius’
Neighborhood_min_p1:
 int or float maximum bound for the neighborhood. should be int for ‘k’ or ‘network’. Can be int or float for ‘radius’
compute_per_object_analysis(feature_columns, method, neighborhood_matrix_type, neighborhood_p0, neighborhood_p1, **kwargs)

Computes per object spatial analysis tests for the provided features for one neighborhood matrix.

Feature_columns:
 list of str features’ names from feature_table. All features will be tested on the same neighborhood matrices and with the same analysis method
Method:str can be ‘moran’ or’getisord’ (local spatial autocorrelation for continuous features)
Neighborhood_matrix_type:
 str should be ‘k’, ‘radius’, or ‘network’
Neighborhood_min_p0:
 int or float minimum bound for the neighborhood. should be int for ‘k’ or ‘network’. Can be int or float for ‘radius’
Neighborhood_min_p1:
 int or float maximum bound for the neighborhood. should be int for ‘k’ or ‘network’. Can be int or float for ‘radius’
correlogram(feature_columns, method, neighborhood_matrix_type, neighborhood_min_p0, neighborhood_max_p1, **kwargs)

Computes a serie of spatial analysis tests for the provided features. Gives one value for the image. The starting and ending neighborhood parameters, neighborhood_p0 and neighborhood_p1, are to be set. 3 modes are available to define the intermediary neighborhood parameters.

Feature_columns:
 list of str features’ names from feature_table. All features will be tested on the same neighborhood matrices and with the same analysis method
Method:str can be - ‘assortativity’ or ‘ripley’ (for categorical features), - ‘moran’, ‘geary’, ‘getisord’ (global spatial autocorrelation for continuous features)
Neighborhood_matrix_type:
 str should be ‘k’, ‘radius’, or ‘network’ Same ‘neighborhood_matrix_type’ for all the points in the correlogram.
Neighborhood_min_p0:
 int or float minimum bound for the neighborhood. should be int for ‘k’ or ‘network’. Can be int or float for ‘radius’
Neighborhood_min_p1:
 int or float maximum bound for the neighborhood. should be int for ‘k’ or ‘network’. Can be int or float for ‘radius’
Neighborhood_step:
 int or float a step in terms of parameters ([p0, p0+step, p0+2step, …p1]) should be int for ‘k’ or ‘network’. Can be int or float for ‘radius’ one of neighborhood_step, nb_pairs_step or nb_test_points should be defined.
Nb_pairs_step:int a step in terms of number of pairs for each test. Overlooked if neighborhood_step is provided.
Nb_test_points:int a number of test points. Overlooked if neighborhood_step or nb_pairs_step are provided.
get_neighborhood_matrix(neighborhood_matrix_type, neighborhood_p0, neighborhood_p1, iterations='None', pysal_object=False, **kwargs)

Return the neighborhood matrix for specified parameters if already computed, thraw a ValueError otherwise. 3 modes are available:

  • ‘k’ for k-nearest neighbors;
  • ‘radius’ for neighbors at an euclidean distance;
  • ‘network’ for neighbors from the object graph (touching objects are neighbors)

For each mode, an interval is requested to know which neighbors to include.

Examples: ‘k’, 2, 4 -> 2nd, 3rd, and 4th-nearest neighbors
‘radius’, 50.75, 100.85 -> neighbors at an euclidean distance falling between 50.75 pixels and 100.85 pixels ‘network’, 0, 1 -> neighbors having boundaries touching
Neighborhood_matrix_type:
 str should be ‘k’, ‘radius’, or ‘network’
Neighborhood_p0:
 int or float minimum bound for the neighborhood. should be int for ‘k’ or ‘network’. Can be int or float for ‘radius’
Neighborhood_p1:
 int or float maximum bound for the neighborhood. should be int for ‘k’ or ‘network’. Can be int or float for ‘radius’
Pysal_object:bool if True, return a pysal.weights object if False, return a tuple (W, L) with W full numpy neighborhood matrix and L list of vertices’ ids
get_suffix(neighborhood_matrix_type, neighborhood_p0, neighborhood_p1, **kwargs)

Returns the suffix for the additionally computed features in the feature_table: local spatial-autocorrelation statistical tests’ outputs, and neighborhood computation’s number of neighbors for each object (‘radius’ or ‘network’ neighborhood matrix type) or distance of last neighbor (‘k’ neighborhood matrix type).

Neighborhood_matrix_type:
 str should be ‘k’, ‘radius’, or ‘network’
Neighborhood_p0:
 int or float minimum bound for the neighborhood. should be int for ‘k’ or ‘network’. Can be int or float for ‘radius’
Neighborhood_p1:
 int or float maximum bound for the neighborhood. should be int for ‘k’ or ‘network’. Can be int or float for ‘radius’
class pySpacell.pySpacell._neighborhood_matrix.NeighborhoodMatrixComputation
class pySpacell.pySpacell._assortativity.Assortativity
class pySpacell.pySpacell._ripley.Ripley
class pySpacell.pySpacell._ripley.RipleyObject(classes, count_classes, K, K_cross, K_cross_star, permutations, lambda_i)
class pySpacell.pySpacell._spatial_autocorrelation.SpatialAutocorrelation
class pySpacell.pySpacell._visualization.Visualization