Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit f442d29e authored by Gustavo Pinzon's avatar Gustavo Pinzon
Browse files

verbose option for contactOrientation (too much output)

parent 187108b3
Pipeline #47960 passed with stages
in 23 minutes and 50 seconds
......@@ -471,7 +471,7 @@ def localDetection(subVolGrey,localThreshold,radiusThresh=None):
return CONTACT
def contactOrientations(volBin, volLab, watershed="ITK", peakDistance=1, markerShrink=True):
def contactOrientations(volBin, volLab, watershed="ITK", peakDistance=1, markerShrink=True, verbose=False):
"""
determines contact normal orientation between two particles
uses the random walker implementation from skimage
......@@ -498,6 +498,11 @@ def contactOrientations(volBin, volLab, watershed="ITK", peakDistance=1, markerS
shrinks the markers to contain only one voxel.
For large markers, the segmentation might yield strange results depending on the shape.
Default = True
verbose : boolean (optional, default = False)
True for printing the evolution of the process
False for not printing the evolution of process
Returns
-------
......@@ -555,7 +560,8 @@ def contactOrientations(volBin, volLab, watershed="ITK", peakDistance=1, markerS
markersB, numMarkersB = scipy.ndimage.measurements.label(localMaxiB, structure=struc)
if numMarkersA == 0 or numMarkersB == 0:
notTreatedContact = True
print("spam.contacts.contactOrientations: No grain markers found for this contact. Setting the contact as non-treated")
if verbose:
print("spam.contacts.contactOrientations: No grain markers found for this contact. Setting the contact as non-treated")
return numpy.zeros((3)), 0, notTreatedContact
#Shrink the markers
# The index property should be a list with all the labels encountered, exlucing the label for the backgroun (0).
......@@ -583,7 +589,8 @@ def contactOrientations(volBin, volLab, watershed="ITK", peakDistance=1, markerS
markers[~volRWbin.astype(bool)] = -1
if numpy.max(numpy.unique(markers)) != 2:
notTreatedContact = True
print("spam.contacts.contactOrientations: The grain markers where wrongly computed. Setting the contact as non-treated")
if verbose:
print("spam.contacts.contactOrientations: The grain markers where wrongly computed. Setting the contact as non-treated")
return numpy.zeros((3)), 0, notTreatedContact
probMaps = random_walker(volRWbin, markers, beta=80, mode='cg_mg', return_full_prob=True)
# reset probability of voxels in the void region to 0! (-1 right now, as they were not taken into account!)
......@@ -601,7 +608,8 @@ def contactOrientations(volBin, volLab, watershed="ITK", peakDistance=1, markerS
if len(contactVox) <=2:
#print 'WARNING: not enough contacting voxels (rw).... aborting this calculation'
notTreatedContact = True
print("spam.contacts.contactOrientations: Not enough contacting voxels, aborting this calculation. Setting the contact as non-treated")
if verbose:
print("spam.contacts.contactOrientations: Not enough contacting voxels, aborting this calculation. Setting the contact as non-treated")
return numpy.zeros((3)), 0, notTreatedContact
# get subvoxel precision - using the probability values at the contacting voxels!
......@@ -972,7 +980,7 @@ def localDetectionAssembly(volLab, volGrey, contactList, localThreshold, boundin
return numpy.asarray(contactListRefined)
def contactOrientationsAssembly(volLab, volGrey, contactList, watershed="ITK", peakDistance=5, boundingBoxes=None, NumberOfThreads=1):
def contactOrientationsAssembly(volLab, volGrey, contactList, watershed="ITK", peakDistance=5, boundingBoxes=None, NumberOfThreads=1, verbose=False):
"""
Determines contact normal orientation in an assembly of touching particles
uses either directly the labelled image or the random walker implementation from skimage
......@@ -1007,6 +1015,10 @@ def contactOrientationsAssembly(volLab, volGrey, contactList, watershed="ITK", p
NumberOfThreads : integer, optional
Number of Threads for multiprocessing.
Default = 1
verbose : boolean (optional, default = False)
True for printing the evolution of the process
False for not printing the evolution of process
Returns
-------
......@@ -1049,7 +1061,7 @@ def contactOrientationsAssembly(volLab, volGrey, contactList, watershed="ITK", p
subVolLab, subVolBin, subVolGrey = fetchTwoGrains(volLab, volGrey, labels, boundingBoxes)
contactNormal, intervox, NotTreatedContact = spam.label.contactOrientations(subVolBin, subVolLab, watershed, peakDistance=peakDistance)
contactNormal, intervox, NotTreatedContact = spam.label.contactOrientations(subVolBin, subVolLab, watershed, peakDistance=peakDistance, verbose=verbose)
#TODO work on not treated contacts -- output them!
qResults.put( [ workerNumber, job+1, grainA, grainB, contactNormal[0], contactNormal[1], contactNormal[2], intervox ] )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment