Changeset 1266 for framspy


Ignore:
Timestamp:
07/05/23 18:37:46 (17 months ago)
Author:
oriona
Message:

Signature values normalization added.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • framspy/dissimilarity/density-distribution.py

    r1225 r1266  
    231231
    232232
     233    def normalize(self, signature):
     234        """Normalizes the signature values by dividing it by the sum of elements.
     235        Args:
     236            signature np.array(,dtype=float): array of signature values.
     237
     238        Returns:
     239            np.array(,dtype=float): array of normalized signature
     240        """
     241        total = np.sum(signature)
     242        return np.divide(signature, total)
     243
     244
    233245    def calculateDissimforVoxels(self, voxels1, voxels2):
    234246        """Calculates EMD for pair of voxels representing models.
     
    278290
    279291            if self.frequency:
    280                 out = emd(s1,s2,np.array(dist_matrix,dtype=np.float64))
     292                out = emd(self.normalize(s1),self.normalize(s2),np.array(dist_matrix,dtype=np.float64))
    281293            else:
    282                 out = emd(s1[1],s2[1],dist_matrix)
     294                out = emd(self.normalize(s1[1]),self.normalize(s2[1]),dist_matrix)
    283295
    284296            self.libm.feclearexcept(0x04) # restoring default flag values...
Note: See TracChangeset for help on using the changeset viewer.