#NEWLINE# def _voxel_centroid( image , pores = None , vox_len = 1e-06 ) : #NEWLINE# #INDENT# '\n    Calculate Pore Centroid from indices of the voronoi voxel image generated\n    in _get_voxel_volume\n    ' #NEWLINE# if ( pores is None ) : #NEWLINE# #INDENT# pores = np . unique ( image ) #NEWLINE# #UNINDENT# centroids = np . zeros ( [ len ( pores ) , 3 ] ) #NEWLINE# for ( i , pore ) in enumerate ( pores ) : #NEWLINE# #INDENT# ( px , py , pz ) = np . where ( ( cz == pore ) ) #NEWLINE# try : #NEWLINE# #INDENT# if ( len ( px ) > 0 ) : #NEWLINE# #INDENT# cx = np . mean ( px ) #NEWLINE# cy = np . mean ( py ) #NEWLINE# cz = np . mean ( pz ) #NEWLINE# #UNINDENT# centroids [ i ] = ( np . array ( [ cx , cy , cz ] ) * vox_len ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# logger . warn ( 'Some centroid data may be invalid, look for zeros' ) #NEWLINE# #UNINDENT# #UNINDENT# return centroids