BrownBiomechanics / SlicerAutoscoperM

This 3D Slicer extension enables users to perform image registration.
https://autoscoperm.slicer.org
MIT License
0 stars 3 forks source link

Auto generated tra offset from correct projection #107

Open amymmorton opened 1 week ago

amymmorton commented 1 week ago

image Using BN00107.

bone coloured volume rendering is a clone of neutral, with invert Origin2DICOM applied.

Yellow segmented stls

Grey - neutral volume rendering (dciom space)

Green in mc1 with (invert) tra applied

image

NicerNewerCar commented 1 week ago

A few clarification points

amymmorton commented 1 week ago

TRA output is from pv gen- yes but they should be in AUT space.

I'm sorry - no more yellow green! oops but yes you're correct. For clarity: here is the (previously green) now blue mc1 translformed from AUT_partial volume by tra inverse image

Yes- red was not modified- its the bone model of where the tiff would be with correct spatial dimensions and no translation.

What should be shown: overlay of the now blue mc1 on the bone-colored neut copy (since it's been transformed by inverse origin2dicom)

NicerNewerCar commented 1 week ago

A few things

For the tra not aligining in Autoscoper

For not being able to load tras back into Slicer

Similar to your images above grey neutral is in dicom space and the white neutral is in slicer world centered space.

Creating the TRA file

To create the TRA file for a PV the following steps are taken.

  1. Get the PV Origin image
  2. Apply the Dicom2Origin transform (Inverse Origin2Dicom). This moves the mc1 from dicom space into the centered worldspace. Note this is NOT Autoscoper space just yet image
  3. Apply the Slicer2Aut transform (Rotate 180 degress on the Roll / X-axis and offset the translation by volSize * volSpacing for the -X direction)
Slicer Centered World Space Autoscoper Space
image image

Loading the TRA file back into Slicer

  1. Load TIFF stack of desired volume (Origin at the world center) CT volumes were hidden for clarity. image

  2. Create a transform node from the tra file

    # Small script to convert a tra file to a Slicer transform :) 
    # Just Copy and paste this into the slicer terminal
    # Make sure to change both of the names in brackets
    import numpy as np
    import vtk
    from itertools import product
    tra = np.loadtxt(<file>, delimiter=",")
    # tra = tra[0] # If there are multiple frames uncomment and change 0 to your frame
    tra = tra.reshape(4,4)
    mat = vtk.vtkMatrix4x4()
    for i,j in product(range(4), range(4)):
    mat.SetElement(i,j, tra[i,j])
    tfmNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLTransformNode", <node name>) 
    tfmNode.SetMatrixTransformToParent(mat)
  3. Apply the AUT2Slicer transform to the PV (Rotate 180 degress on the Yaw / Z-Axis and offset translationaly by volDim * volSpacing in the +X direction) image

  4. Apply the transform loaded in from the TRA file image

TODO

amymmorton commented 1 week ago

The PV, its tfm and its tra need to exist in bvr and 3dct... (in cases with vrg gen and without)....

So perhaps we require camera calibration prior to allowing pv generation?

NicerNewerCar commented 1 week ago

The PV, its tfm and its tra need to exist in bvr and 3dct... (in cases with vrg gen and without)....

So perhaps we require camera calibration prior to allowing pv generation?

Makes sense, I will put together a pop up that will let the user know that, for the case of the auto camera placement, they are required to run that prior to generating the PVs

amymmorton commented 1 week ago

Thanks, Anthony,

I will add a standalone issue for this as well, but I believe we should rearrange the pre-processing tabs, such that the segmentation and partial volumes are one after the other


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

On Tue, Jun 25, 2024 at 8:13 AM Anthony Lombardi @.***> wrote:

The PV, its tfm and its tra need to exist in bvr and 3dct... (in cases with vrg gen and without)....

So perhaps we require camera calibration prior to allowing pv generation?

Makes sense, I will put together a pop up that will let the user know that, for the case of the auto camera placement, they are required to run that prior to generating the PVs

— Reply to this email directly, view it on GitHub https://github.com/BrownBiomechanics/SlicerAutoscoperM/issues/107#issuecomment-2188776109, or unsubscribe https://github.com/notifications/unsubscribe-auth/APUUPFSYHOYBYGGM4ZM2ER3ZJFNHNAVCNFSM6AAAAABJ2FMMBGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBYG43TMMJQHE . You are receiving this because you authored the thread.Message ID: @.***>

NicerNewerCar commented 1 week ago

I was mistaken yesterday when I posted that the Slicer2AUT and AUT2Slicer transform were not the inverse of eachother. They are the same, I believe I was incorrectly applying the inverse of the Slicer2AUT transform originally.

I also confirmed this works with the flexion example (and double checked with the neutral example)

Neutral

  1. Load PV and CT into the scene (CT has already been centered with Dicom2Origin) image

  2. Apply Inverse Slicer2AUT transform [180 rotation about the x axis and an offset of size volDim*volspacing in the +X direction] image

  3. Apply the tra as loaded from Autoscoper image

Flexion

  1. Load PV and CT into the scene (CT has already been centered with Dicom2Origin) image
  2. Apply Inverse Slicer2AUT transform [180 rotation about the x axis and an offset of size volDim*volspacing in the +X direction] image
  3. Apply the tra as loaded from Autoscoper image

Revised TODO