Changeset 1329 for framspy/dissimilarity
- Timestamp:
- 12/26/24 01:43:47 (2 days ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
framspy/dissimilarity/density_distribution.py
r1325 r1329 6 6 7 7 class DensityDistribution: 8 """Two dissimilarity measures based on the spatial distribution of two Models. The Model bounding box is divided into a grid of equally-sized cuboids, the number of which is the 'resolution' parameter cubed. Then the Model surface is covered with points; the density of the surface sampling is determined by the 'density' parameter. There are two versions of the measure. In the default version ('frequency'=False), asignature of each cuboid is the centroid and the number of samples. In the 'frequency'=True version, FFT is computed from the vector containing the number of samples in each cuboid. The final result of the dissimilarity measure is the distance between the signatures and it can be computed using EMD, L1, or L2 norms (the 'metric' parameter).8 """Two dissimilarity measures based on the spatial distribution of two Models. The Model bounding box is divided into a grid of equally-sized cuboids, the number of which is the 'resolution' parameter cubed. Then the Model surface is covered with points; the density of the surface sampling is determined by the 'density' parameter. There are two versions of the measure. In the default version ('frequency'=False), the signature of each cuboid is the centroid and the number of samples. In the 'frequency'=True version, FFT is computed from the vector containing the number of samples in each cuboid. The final result of the dissimilarity measure is the distance between the signatures and it can be computed using EMD, L1, or L2 norms (the 'metric' parameter). 9 9 """ 10 10 … … 43 43 def calculateNeighborhood(self,array,mean_coords): 44 44 """ Calculates number of elements for given sample and set ups the center of this sample 45 to the center of mass (calculated by mean of every coordinate) 45 to the center of mass (calculated by mean of every coordinate). 46 46 Args: 47 47 array ([[float,float,float],...,[float,float,float]]): array of voxels that belong to given sample. … … 61 61 62 62 63 def calculateDistPoints(self,point1, point2): 64 """ Returns Euclidean distance between two points 65 Args (distribution): 66 point1 ([float,float,float]) - coordinates of first point 67 point2 ([float,float,float]) - coordinates of second point 63 def calculateDistPoints(self, point1, point2): 64 """ Returns Euclidean distance between two samples (1D for frequency) or points (3D for distribution). 68 65 Args (frequency): 69 66 point1 (float) - value of the first sample 70 67 point2 (float) - value of the second sample 68 Args (distribution): 69 point1 ([float,float,float]) - coordinates of the first point 70 point2 ([float,float,float]) - coordinates of the second point 71 71 72 72 Returns: … … 74 74 """ 75 75 if self.frequency: 76 return abs(point1-point2) # TODO vector instead of scalar returned?76 return abs(point1-point2) 77 77 else: 78 78 return np.linalg.norm(point1-point2, ord=2) 79 79 80 80 81 def calculateDistanceMatrix(self, array1, array2):81 def calculateDistanceMatrix(self, array1, array2): 82 82 """ 83 83 Args: … … 138 138 steps3 ([float,float,float]): [size of interval for x axis, size of interval for y axis, size of interval for y axis] 139 139 140 Returns (frequency): 141 signature np.array(,dtype=np.float64): returns signatuere np.array of coefficients 140 142 Returns (distribution): 141 143 signature [np.array(,dtype=np.float64),np.array(,dtype=np.float64)]: returns signatuere [np.array of points, np.array of weights] 142 Returns (frequency):143 signature np.array(,dtype=np.float64): returns signatuere np.array of coefficients144 144 """ 145 145 edges_x,edges_y,edges_z = edges3 … … 212 212 213 213 def getVoxels(self,geno): 214 """Generates voxels for genotype using frams.ModelGeometry 214 """Generates voxels for genotype using frams.ModelGeometry. 215 215 216 216 Args:
Note: See TracChangeset
for help on using the changeset viewer.