Closed amymmorton closed 1 year ago
NCC values differ opencl / cuda too:
@amymmorton Since there is one NCC value computed for each "view" and in both case (file vs socket) only the first two values are expected to match, which value did you plot (Figure 7 above) ?
Values | |
---|---|
*.ncc |
correlation_0 , correlation_1 , correlation_0 + correlation_1 |
socket |
correlation_0 , correlation_1 [, ..., correlation_N ] |
Worth noting that if we do Implant and are using the OpenCL backend, no value is computed. See below. I am wondering if this could explain some of the differences.
Comparing the input poses used for the tracking in both case may also help understand better.
@jcfr These ncc values were exported from a 'ground truth' set of poses. No optimization was performed / this trial was not re-tracked.
'only the first two values are expected to match, which value did you plot (Figure 7 above) ?' All three values were plotted, but you are correct, we should only concentration the first two returned outputs. Please see below a revised format of the ncc values output pairs of the same data from above.
@amymmorton Let me know if you have any questions!
This is the function used to compute the NCC values for a given frame (both for the PSO and save_ncc functions). This renders the radiographs DRR, and mask into Buffers. It then takes those buffers and runs the ncc calculations through the gpu. https://github.com/BrownBiomechanics/Autoscoper/blob/91e7bc9a76a524f9f373ca4324e2915e6e75999b/libautoscoper/src/Tracker.cpp#L590-L651
Note: Whenever buffers f and g appear together they are the DRR and the Radiograph respectively. If just Buffer f appears then it is used on both the DRR and Radiograph individually.
First, the NCCSum
kernel is run on both the radiograph and DRR buffers. This computes the means of each buffer. Once this is done the main NCC
kernel is called. This computes the NCC values based on the Radiograph, DRR, and mask buffers and the means of the radiograph and the DRR. This is repeated for all views/bone combinations.
Just like the OpenCL kernels the CUDA kernel computes the means of the radiograph and DRR buffers then calculates the NCC value.
NCC values are exported from the GUI, MATLAB, and Python.
Ground truth tracking data was loaded for MC3 and then exported with the GUI, MATLAB, and Python with no optimization being done. The differences were then taken for each camera in each frame. The absolute value of those differences was taken and then plotted.
CUDA Python
and CUDA Matlab
seems to match. This is good.
Next, could you instrument the code to display input and output values. By adding print statement to:
m_mainwindow::getNCC
to display volumeID
and xyzpr
Tracker::trackFrame
to display values in correlations
vectorJust looking at a single frame:
getNCC input:
volumeID: 1, pose: [114.096, 80.5325, 184.475, -168.469, 23.8443, 13.8261]
PyAutoscoper input:
volumeID: 1, pose: [114.0963134765625, 80.53250885009766, 184.47508239746094, -168.46871948242188, 23.844257354736328, 13.826091766357422]
trackFrame output:
1.00758 1.00321
PyAutoscoper output:
ncc: [1.0075845890678465, 1.0032108505256474]
This is consistent across every frame, they are the same values just the Autoscoper C++ code deals with smaller places than the Python code.
The corresponding value from the GUI: 0.474160,0.514982,0.989142
The poses are identical between GUI and the socket too, here are the poses that provided the above results
GUI: frame: 399 pose: [114.096,80.5325,184.475,-168.469,23.8443,13.8261]
Socket C++: Frame: 399 Pose: [114.096, 80.5325, 184.475, -168.469, 23.8443, 13.8261]
Socket Python: Frame: 399 Pose: [114.0963134765625, 80.53250885009766, 184.47508239746094, -168.46871948242188, 23.844257354736328, 13.826091766357422]
@amymmorton Are you calling setFrame
before you get the pose/ncc?
That seems to solve the issue:
from PyAutoscoper.connect import AutoscoperConnection
import numpy as np
s = AutoscoperConnection()
# load trial, filters, and tracking data
nccData = np.zeros((400,2))
for i in range(400):
s.setFrame(i)
pose = s.getPose(1,i)
ncc = s.getNCC(1,pose)
nccData[i] = ncc
I was not previously using setFrame, I'm testing ncc output in matlab now
On Wed, Mar 1, 2023 at 10:16 AM Anthony Lombardi @.***> wrote:
@amymmorton https://github.com/amymmorton Are you calling setFrame before you get the pose/ncc?
That seems to solve the issue:
for i in range(400): s.setFrame(i) pose = s.getPose(1,i) ncc = s.getNCC(1,pose) nccData[i] = ncc
[image: Set Frame] https://user-images.githubusercontent.com/30351234/222181897-f535aa0d-2d4c-45b2-8a66-47e1f868cce2.png
— Reply to this email directly, view it on GitHub https://github.com/BrownBiomechanics/Autoscoper/issues/82#issuecomment-1450321731, or unsubscribe https://github.com/notifications/unsubscribe-auth/APUUPFWWRRJAQDUOVVROEF3WZ5R6VANCNFSM6AAAAAAUOAW344 . You are receiving this because you were mentioned.Message ID: @.***>
Amy Morton, MSc
Sr. Research Engineer, Bioengineering Lab, Department of Orthopaedic Research The Warren Alpert Medical School of Brown University and Rhode Island Hospital 1 Hoppin Street, CORO West, Ste. 404, Providence, RI 02903
Yes- that was the issue- Thank-you for catching Anthony! [image: image.png]
On Wed, Mar 1, 2023 at 11:58 AM Morton, Amy @.***> wrote:
I was not previously using setFrame, I'm testing ncc output in matlab now
On Wed, Mar 1, 2023 at 10:16 AM Anthony Lombardi @.***> wrote:
@amymmorton https://github.com/amymmorton Are you calling setFrame before you get the pose/ncc?
That seems to solve the issue:
for i in range(400): s.setFrame(i) pose = s.getPose(1,i) ncc = s.getNCC(1,pose) nccData[i] = ncc
[image: Set Frame] https://user-images.githubusercontent.com/30351234/222181897-f535aa0d-2d4c-45b2-8a66-47e1f868cce2.png
— Reply to this email directly, view it on GitHub https://github.com/BrownBiomechanics/Autoscoper/issues/82#issuecomment-1450321731, or unsubscribe https://github.com/notifications/unsubscribe-auth/APUUPFWWRRJAQDUOVVROEF3WZ5R6VANCNFSM6AAAAAAUOAW344 . You are receiving this because you were mentioned.Message ID: @.***>
--
Amy Morton, MSc
Sr. Research Engineer, Bioengineering Lab, Department of Orthopaedic Research The Warren Alpert Medical School of Brown University and Rhode Island Hospital 1 Hoppin Street, CORO West, Ste. 404, Providence, RI 02903
Amy Morton, MSc
Sr. Research Engineer, Bioengineering Lab, Department of Orthopaedic Research The Warren Alpert Medical School of Brown University and Rhode Island Hospital 1 Hoppin Street, CORO West, Ste. 404, Providence, RI 02903
The ncc values using AutoscoperCOnnection.m getNCC_ThisFrame are not the same for a given tracked file as the AutoscoperMainWIndow::save_ncc_results