BrownBiomechanics / Autoscoper

Autoscoper is a 2D-3D image registration software package.
https://autoscoper.readthedocs.io
Other
8 stars 5 forks source link

Tracking accuracy #46

Open NicerNewerCar opened 2 years ago

NicerNewerCar commented 2 years ago

image

Overview

We want to get some metric for measuring the accuracy of matching the DRR volume and the radiograph images.

Inputs

The inputs consist of n frames of a radiograph video (8bit tiff images) from two different camera views and m bone volumes (16bit tiff stacks). For each frame a volume is manually aligned with the radiograph images and then PSO and NCC is preformed to automatically improve the alignment of the volume with the radiographs. This process is repeated for all m volumes on every n frames

Outputs

The autoscoper program has a "Save Tracking" button that saves the tracking results into a *.tra file, that contains the x,y,z,yaw,pitch, and roll values for all volumes over all frames. Making sure to select the xyzypr option when saving we can parse this file into pandas dataframes with this python script. We can then compare to some ground truth tra to get an idea on the accuracy of our tracks.

Implementation

Loading of a configuration file (loading of radiographs and DRRs) takes place in the Trial class.

Loading of a saved trial takes place in the main window of the UI.

The tracking of volumes takes place in the Tracker class, this class fits the volume to the radiographs and updates the positional data accordingly.

The saving of the tracking results (xyz roll pitch yaw data) takes place in the main window of the UI.

Inital Positioning

T1 T2
T3 T4

image

Dataset used: JOVE ankle data.

Note: The tibia is note pictured here because even when seeding every other frame the volume still failed to track properly.

Results

Each graph is a Bland-Altman plot, where the X-axis consists of the mean of the two methods and the Y-axis consists of difference between the two methods for each point in the tracking data. Each plot represents a piece of positional data (ie. one plot for X, Y, Z, Roll, Pitch, and Yaw data for every frame). Each bone (Calcaneus and Talus) was tracked in both OpenCL and CUDA while being seeded with the ground truth data every 5 frames. The results were exported from autoscoper in xyzypr format and compared using this script to a ground truth tracking result provided by @BardiyaAk and @amymmorton.

Trial 1

X/Roll Y/Pitch Z/Yaw
Calcaneus x y z
roll pitch yaw
Talus x y z
roll pitch yaw

Trial 2

X/Roll Y/Pitch Z/Yaw
Calcaneus x y z
roll pitch yaw
Talus x y z
roll pitch yaw

Trial 3

X/Roll Y/Pitch Z/Yaw
Calcaneus x y z
roll pitch yaw
Talus x y z
roll pitch yaw

Trial 4

X/Roll Y/Pitch Z/Yaw
Calcaneus x y z
roll pitch yaw
Talus x y z
roll pitch yaw

Registration Error

We took the XYZYPR data for each one of the models and computed the normal vector of the plane that it lies on. We then compared the two normals to each other to get the angle between the two planes and the distance between the planes for every frame. All computation was done with this script.

Angle Between Planes Distance Between Planes
Trial 1 Calcaneus T000AssessmentTrial_calcanus_angle T000AssessmentTrial_calcanus_distance
Trial 1 Talus T000AssessmentTrial_talus_angle T000AssessmentTrial_talus_distance
Trial 2 Calcaneus T0014_hop108_0001_calcanus_angle T0014_hop108_0001_calcanus_distance
Trial 2 Talus T0014_hop108_0001_talus_angle T0014_hop108_0001_talus_distance
Trial 3 Calcaneus T0014_hop108_0002_calcanus_angle T0014_hop108_0002_calcanus_distance
Trial 3 Talus T0014_hop108_0002_talus_angle T0014_hop108_0002_talus_distance
Trial 4 Calcaneus T0019_jog0001_calcanus_angle T0019_jog0001_calcanus_distance
Trial 4 Talus T0019_jog0001_talus_angle T0019_jog0001_talus_distance

Corner Distance

This was suggested by Matt McCormick. We take a bounding box and align it to each plane then compute the euclidean distance between each corner then take the average of those four distances. The computation was computed using this script

Calcaneus Talus
Trial 1 T000AssessmentTrial_calcanus T000AssessmentTrial_talus
Trial 2 T0014_hop108_0001_calcanus T0014_hop108_0001_talus
Trial 3 T0014_hop108_0002_calcanus T0014_hop108_0002_talus
Trial 4 T0019_jog0001_calcanus T0019_jog0001_talus
amymmorton commented 2 years ago

@NicerNewerCar , the Ground truth example of MC2MC3 is not aligned. Can you provide motion trial name and frame number please?

NicerNewerCar commented 2 years ago

Can you provide motion trial name and frame number

This was frame 0 from the flx_ext_m3.tra file that you provided in the email from 10/27

@amymmorton

amymmorton commented 2 years ago

Thanks. The 4x4 transformation outputs are specific to a rigid body. If applying the mc3 tracking to the mc2mc3 body- the results will be incorrect. I can provide the mc2mc3 tra

amymmorton commented 2 years ago

flx_ext_mc2_mc3.txt

You can rename this txt to a .tra

NicerNewerCar commented 2 years ago

Thanks! I will update the graphs by the end of the day.

amymmorton commented 2 years ago

@NicerNewerCar Sorry Anthony. I think you'll need to use the mc2mc3 to seed the mc3 tracking- and then evaluate the mc3 vs mc3 ground truth. I was wondering why are there more data values in the BA plots for rad than there are for mc2mc3?... If these output transforms are from the same motion trial (flex_ext) then there should be the same (400) values.

The mc2mc3 values are incomplete and were only used as a step along the way.

amymmorton commented 2 years ago

Looks like @BardiyaAk also was able to export/save the NCC. flx_ext_rad.txt flx_ext_mc3.txt

amymmorton commented 2 years ago

@NicerNewerCar The ncc values were gathered using the connection to software functions (in our case matlab). https://github.com/BrownBiomechanics/XGen_AutoscoperImageProcessing/blob/main/connection_to_software/getNCC.m

amymmorton commented 2 years ago

mc3_dcm_cropped .txt

change to .tif

This is the input tif stack from which the drr will be rendered for wn00106