Closed BramshQamar closed 4 years ago
I played around with your data a bit. First, if you want to force the points to try and find a neighbour/match you can set/tweak the alpha:
reg = DeformableRegistration(**{'X': static, 'Y': moving, 'alpha': 0.01, 'beta': 2})
alpha
should trade between regularizing the deformation and having points matching very closely. The lower you make alpha the more closely the point sets should match. beta
tweaks the smoothness of the deformation.
Lowering alpha
will make your points move, and they will end up closer to the target than when they started! So, we have some progress :).
Your points are really sparse and don't have an obvious way they match. At first I wondered if there just wasn't a great way for them to match and that is why CPD was failing. Then, I wondered if it was just a scaling issue - seems that is likely the case. What I did to remedy is I ran an affine registration, and then took the affine registration output and fed it into a deformable. This gave much better results.
Try something like:
# run affine reg
affine_reg = AffineRegistration(**{'X': static, 'Y': moving})
ty_affine, pr_affine = affine_reg.register()
# look how affine reg compares to your static points.
fig = plt.figure(figsize=(16,9))
ax = fig.add_subplot(111, projection='3d')
ax.scatter(static[:,0], static[:, 1], static[:,2])
ax.scatter(ty_affine[:,0], ty_affine[:,1], ty_affine[:,2])
# now feed points from affine reg into deformable reg
reg = DeformableRegistration(**{'X': static, 'Y': ty_affine, 'alpha': 0.001, 'beta': 5})
ty, pr = reg.register()
# now see how these final points match.
fig = plt.figure(figsize=(16,9))
ax = fig.add_subplot(111, projection='3d')
ax.scatter(static[:,0], static[:, 1], static[:,2])
ax.scatter(ty[:,0], ty[:,1], ty[:,2])
alpha = 0.001
beta = 5
Gave me an excellent match, with one point in no-mans-land between the two point-clouds. I also don't know what I am looking at, so this could be horrible registration - but its something :). Hope this helps!.
An aside note I will make in hopes that it helps clarify the language/code a bit. I got a bit confused reading your code because you interchange the words moving/target/source/static.
These words should be defined like:
X=target=static
Y=source=moving
The source points should be moving to get to the target points. I think your current code is:
X = source = static
Y = target = moving
You end up with your static and moving inputs (to your function) going to the right location(s) when they got passed to the function, but they do so in a confusing way. I found the language confusing when I first started playing with these, so hopefully this is helpful.
Hello @gattia,
Thank you for the quick response.
Changing alpha and beta parameters worked for me. I think performing affine before deformable registration is a good idea!
Thanks again.
Bramsh
Excellent. Because your issue seems to be resolved I'm closing this issue.
Thanks.
Hello,
Very helpful and much-needed package. Thank you for sharing it with the community.
I am trying to run fish_deformable_3D.py example to perform 3D deformation registration on my data.
I made some minor changes in the code to make it work on my data. It doesn't give me any error but I don't see any changes in the final output. Here's the code I am running:
Here's the sample data I tried:
static object:
moving object:
The output I get is the following:
moved object:
There's an extremely small difference in the output. I am wondering if I am doing something wrong or need to change some parameters to make it work?
I tried changing tolerance value but still no difference.
Thank You, Bramsh