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 a98a566a authored by Alessandro's avatar Alessandro
Browse files

some more cleanup

parent 22c669c0
Pipeline #51174 passed with stages
in 12 minutes and 52 seconds
......@@ -80,8 +80,7 @@ print("Rotations : {:.4f}, {:.4f}, {:.4f}".format(*tmp['r']))
# The Gaussian parameters are parameters of the two ellipsoids that fit the two peaks.
print("\nSTEP 1: Get gaussian parameters")
nPhases = 2
gaussianParameters, jointHistogram = spam.DIC.gaussianMixtureParameters(xr[cropWithMargin], neTmp[cropWithMargin], bins=bins, nPhases=nPhases, verbose=True, GRAPHS = True, INTERACTIVE = True)
exit()
gaussianParameters, jointHistogram = spam.DIC.gaussianMixtureParameters(xr[cropWithMargin], neTmp[cropWithMargin], bins=bins, nPhases=nPhases, verbose=True, graphs=True, interactive=True)
plt.figure()
tmp = jointHistogram.copy()
tmp[jointHistogram <= 0] = numpy.nan
......@@ -98,7 +97,7 @@ for gp in gaussianParameters:
# Each peak corresponds to a phase (1 and 2).
# The grey background (points to far away from a peak) is ignored (0).
print("\nSTEP 2: Create phase repartition")
phaseDiagram, actualVoxelCoverage = spam.DIC.phaseDiagram(gaussianParameters, jointHistogram, voxelCoverage=0.8, BINS=bins)
phaseDiagram, actualVoxelCoverage = spam.DIC.phaseDiagram(gaussianParameters, jointHistogram, voxelCoverage=0.8, bins=bins, graphs=True, interactive = True)
plt.figure()
plt.imshow(phaseDiagram.T, origin='lower', extent=[0.0, bins, 0.0, bins], vmin=-0.5, vmax=nPhases + 0.5, cmap=mpl.cm.get_cmap('Set1_r', nPhases + 1))
plt.xlabel("x-ray grey levels")
......@@ -106,12 +105,11 @@ plt.ylabel("neutron grey levels")
plt.colorbar(ticks=numpy.arange(0, nPhases + 1))
for gp in gaussianParameters:
plt.plot(gp[1], gp[2], 'b*')
#############################################################
# And and we use both Gaussian parameters and phase diagram as an input of the registration algorithm
print("\nSTEP 3: Registration")
registration = spam.DIC.multimodalRegistration(xr[crop], ne[crop], phaseDiagram, gaussianParameters,
BINS=bins, PhiInit=PhiGuess, verbose=True, margin=margin)
bins=bins, PhiInit=PhiGuess, verbose=True, graphs=True, interactive=True, margin=margin)
##########################################################
# Final transformation
......
......@@ -64,9 +64,9 @@ argsDict = vars(args)
for key in sorted(argsDict):
print("\t{}: {}".format(key, argsDict[key]))
GRAPHS = args.GRAPHS
INTERACTIVE = args.INTERACTIVE
SHOW_SLICE_AXIS = args.SHOW_SLICE_AXIS
#GRAPHS = args.GRAPHS
#INTERACTIVE = args.INTERACTIVE
#SHOW_SLICE_AXIS = args.SHOW_SLICE_AXIS
# BINS_NPHASES = [(8, 2), (4, 5), (2, 5)]
# BINS_NPHASES = [(4,5),(2,4)]
......@@ -224,7 +224,7 @@ for i, (bin, nPhases) in enumerate(zip(bins, args.PHASES)):
im1threshold=args.IM1_THRESHOLD, im2threshold=args.IM2_THRESHOLD,
distanceMaxima=distanceMaxima,
fitDistance=args.FIT_DISTANCE,
GRAPHS=GRAPHS, INTERACTIVE=INTERACTIVE, sliceAxis=SHOW_SLICE_AXIS,
graphs=args.GRAPHS, interactive=args.INTERACTIVE, sliceAxis=args.SHOW_SLICE_AXIS,
rootPath=rootPath, suffix="bin{}".format(bin))
#tifffile.imsave("{}/GaussianMixture_jointHistogram-bin{}.tif".format(rootPath, bin), jointHistogram.astype('<f4'))
# pickle.dump([gaussianParameters, jointHistogram], open("{}/GaussianMixture_gaussianParameters-bin{}.p".format(rootPath, bin), "w"))
......@@ -238,9 +238,9 @@ for i, (bin, nPhases) in enumerate(zip(bins, args.PHASES)):
jointHistogram,
voxelCoverage,
# sigmaMax=10,
BINS=args.JOINT_HISTO_BINS,
GRAPHS=GRAPHS,
INTERACTIVE=INTERACTIVE,
bins=args.JOINT_HISTO_BINS,
graphs=args.GRAPHS,
interactive=args.INTERACTIVE,
rootPath=rootPath,
suffix="bin{}".format(bin))
#tifffile.imsave("{}/GaussianMixture_phaseDiagram-{:.2f}p-bin{}.tif".format(rootPath, actualVoxelCoverage, bin), phaseDiagram.astype('<u1'))
......@@ -254,13 +254,13 @@ for i, (bin, nPhases) in enumerate(zip(bins, args.PHASES)):
gaussianParameters,
maxIterations=args.GRID_POINT_MAX_ITERATIONS,
PhiInit=PhiGuess.copy(), # 2020-05-26: EA OS AT this should NOT be inv
BINS=args.JOINT_HISTO_BINS,
bins=args.JOINT_HISTO_BINS,
deltaPhiMin=args.GRID_POINT_MIN_PHI_CHANGE,
verbose=True,
margin=margin,
GRAPHS=GRAPHS,
INTERACTIVE=INTERACTIVE,
sliceAxis=SHOW_SLICE_AXIS,
graphs=args.GRAPHS,
interactive=args.INTERACTIVE,
sliceAxis=args.SHOW_SLICE_AXIS,
rootPath=rootPath,
suffix="bin{}".format(bin))
......
......@@ -58,19 +58,20 @@ def register(im1, im2, im1mask=None, PhiInit=None, PhiRigid=False, PhiInitBinRat
im1mask : 3D boolean numpy array, optional
A mask for the zone to correlate in im1 with `False` in the zone to not correlate.
Default = None, `i.e.`, correlate all of im1 minus the margin.
If this is defined, the Phi returned is in the centre of mass of the mask
Default = None (`i.e.`, correlate all of im1 minus the margin)
PhiInit : 4x4 numpy array, optional
Initial deformation to apply to im1.
Default = numpy.eye(4), `i.e.`, no transformation
Default = numpy.eye(4) (`i.e.`, no transformation)
PhiRigid : bool, optional
Run a rigid correlation? Only the rigid part of your PhiInit will be kept.
Default = False
PhiInitBinRatio : float, optional
Change translations in PhiInit, if it's been calculated on a differently-binned image. Default = 1
Change translations in PhiInit, if it's been calculated on a differently-binned image.
Default = 1
margin : int, optional
Margin, in pixels, to take in im1.
......@@ -79,17 +80,20 @@ def register(im1, im2, im1mask=None, PhiInit=None, PhiRigid=False, PhiInitBinRat
Default = None (`i.e.`, 10% of max dimension of im1)
maxIterations : int, optional
Maximum number of quasi-Newton iterations to perform before stopping. Default = 25
Maximum number of quasi-Newton iterations to perform before stopping.
Default = 25
deltaPhiMin : float, optional
Smallest change in the norm of Phi (the transformation operator) before stopping. Default = 0.001
Smallest change in the norm of Phi (the transformation operator) before stopping.
Default = 0.001
updateGradient : bool, optional
Should the gradient of the image be computed (and updated) on the deforming im2?
Default = False (it is computed once on im1)
interpolationOrder : int, optional
Order of the greylevel interpolation for applying Phi to im1 when correlating. Recommended value is 3, but you can get away with 1 for faster calculations. Default = 3
Order of the greylevel interpolation for applying Phi to im1 when correlating. Recommended value is 3, but you can get away with 1 for faster calculations.
Default = 1
interpolator : string, optional
Which interpolation function to use from `spam`.
......@@ -103,8 +107,9 @@ def register(im1, im2, im1mask=None, PhiInit=None, PhiRigid=False, PhiInitBinRat
Pop up a window showing a ``imShowProgress`` slice of the image differences (im1-im2) as im1 is progressively deformed.
Default = False
imShowProgressNewFig : bool, optional (defaul = False)
Make a new plt.figure for each iteration, useful for examples gallery
imShowProgressNewFig : bool, optional
Make a new plt.figure for each iteration, useful for examples gallery
Default = False
Returns
-------
......@@ -185,6 +190,7 @@ def register(im1, im2, im1mask=None, PhiInit=None, PhiRigid=False, PhiInitBinRat
if margin is None:
# sqrt
margin = [1+int(0.1 * max(im1.shape))] * 3
elif type(margin) == list:
pass
else:
......
This diff is collapsed.
......@@ -40,8 +40,8 @@ class testAll(unittest.TestCase):
spam.DIC.gaussianMixtureParameters(xr, ne, bins=bins, nPhases=1, distanceMaxima=None, sliceAxis=2)
gm, jh = spam.DIC.gaussianMixtureParameters(xr, ne, bins=bins, nPhases=1, sliceAxis=1)
spam.DIC.phaseDiagram(gm, jh, BINS=bins)
pd, co = spam.DIC.phaseDiagram(gm, jh, BINS=bins, voxelCoverage=0.70)
spam.DIC.phaseDiagram(gm, jh, bins=bins)
pd, co = spam.DIC.phaseDiagram(gm, jh, bins=bins, voxelCoverage=0.70)
spam.DIC.multimodalRegistration(xr, ne, pd, gm, verbose=True)
......
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