Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4DCT / Sequential 3DCT #75

Merged
merged 10 commits into from
Apr 18, 2024

Conversation

NicerNewerCar
Copy link
Contributor

@NicerNewerCar NicerNewerCar commented Dec 20, 2023

@NicerNewerCar NicerNewerCar mentioned this pull request Dec 20, 2023
Closed
2 tasks
@NicerNewerCar NicerNewerCar marked this pull request as ready for review December 20, 2023 19:05
@amymmorton
Copy link
Contributor

amymmorton commented Dec 20, 2023

Testing in release using BN00106

  • Segmentations (mcv1, mc3, tpm, rad) , loaded from stl file
  • Partial volumes generated from neutral CT of segmentation nodes
  • vrg from flexion (4 cameras )
  • cfg generation
  • SAM load

@amymmorton
Copy link
Contributor

sucess_4camFlexB
sucessSegPV_vrg_SAM_cfgload

@amymmorton
Copy link
Contributor

amymmorton commented Dec 20, 2023

track:

  • rad, mc1, tpm

fle_results1

  • compare (in RAD cs), tpm and mc1 resolved MBR

Copy link
Contributor

@amymmorton amymmorton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3D CT workflow operational
still need to

@amymmorton

  • test tracking of single pose
  • load/process 4dct

@NicerNewerCar

  • facilitate more than one (sequence) image/frame in volume node for vrg/cam placment

@NicerNewerCar
Copy link
Contributor Author

NicerNewerCar commented Dec 20, 2023

@NicerNewerCar

  • facilitate more than one (sequence) image/frame in volume node for vrg/cam placement

I am working on writing up a tutorial on how to do this. But if you want to get a head start, feel free to check out sequences within Slicer. As this PR mostly revolves around them.

@NicerNewerCar
Copy link
Contributor Author

4dct-slicer
4dct

@amymmorton
Copy link
Contributor

amymmorton commented Jan 2, 2024

@NicerNewerCar (HNY!)

I am going to evaluate how well the tracking of our 3dct radius tpm and mc1 results compare to previous methods- I'd also like to understand- within the SAM world, (and respective ct dicom from which tiff was generated- where the drrs are).

I'd like both relative measures and absolute measures of how we did.

When cameras are placed- how did you determine world origin? More specifically... the

..\Transforms\Origin2DICOMCenter.tfm
#Insight Transform File V1.0
#Transform 0
Transform: AffineTransform_double_3_3
Parameters: 1 0 0 0 1 0 0 0 1 0.1953125 0.1953125 -87.5
FixedParameters: 0 0 0

To confirm: is this established from my 'reference' volume when we generate the partial volumes?

  • The secondary 3dct 'frame' also loads into slicer with a unified DICOM center as my 'reference' volume (all volumes load with same origin in dicoms)?

@NicerNewerCar
Copy link
Contributor Author

HNY!

The ..\Transforms\Origin2DICOMCenter.tfm transformation is used to transform the volume back to the original dicom location after centering has been done.

To confirm: is this established from my 'reference' volume when we generate the partial volumes?

Been a while since I've looked at the code but I believe I am taking the average center of all the frames in the sequence to compute the centering transform.

Hope this clears things up!

AutoscoperM/AutoscoperM.py Outdated Show resolved Hide resolved
AutoscoperM/AutoscoperM.py Outdated Show resolved Hide resolved
AutoscoperM/AutoscoperM.py Outdated Show resolved Hide resolved
AutoscoperM/AutoscoperM.py Outdated Show resolved Hide resolved
@amymmorton
Copy link
Contributor

Key variable form sequential 3d ct that need to be computed for agreement/ accuracy testing:

  1. From reference pose (slicer volume node used for segmentation/PV creation) to each frame (subsequent slicer volume none - parsed as VRG) the relative motion (helical axis phi and t) of one RB relative to the other.
    (in the test dataset my rb1 == mc1 and rb2 == tpm) rb1 w.r.t rb2 from neutral to flexion

below are the stl surface files in neutral dicom cs
fromSegNeutral_stllocaitonandPVcs_from tfm

inSLicerSegNeutral_stllocaitonandPVcs_from tfm

Outputs from the Autoscoper tracking:
fle_mc1.tra and fle_tpm.tra

Each 1x16 matrix (reshaped into 4x4) is a transform in SAM space of the partial volume to the optimized pose in flexion

(as an example: from bvr wrist data:

fle_rad - Copy.txt
fle_tpm - Copy.txt
fle_mc1 - Copy.txt

But when the stl (in flipped partial volume space) are trnasformed by the respective tra, instead of getting a plausable anatomical pose: (like in bvr wrist)
bvrwrist_appliedtra

The rad and mc1 are not similarly transformed.
sam_3dct_errspace_transformed

Has the tra meaning somehow changed? @NicerNewerCar

@NicerNewerCar
Copy link
Contributor Author

Has the tra meaning somehow changed?

No it shouldn't have as we haven't done any modifications to the save_tracking_results function within Autoscoper base

@amymmorton
Copy link
Contributor

amymmorton commented Feb 6, 2024 via email

@amymmorton
Copy link
Contributor

I'm thinking this has to be the camera placement. In order to create a viable cfg for this 3dxct- the volume flip req was [0 1 1]. Which is odd- as other bvr sets were [0 0 0] - so this to me means the projection is from a different perspective

I checked against a wrist dataset (Wn00108)
Nothing to do with how the partial volumes are generated.
image

@amymmorton
Copy link
Contributor

When loading the flexion dicom (with spatial reference meta data)
image

I visualizing voxels thresholded at 540 and slices at [0,0 50]. The stl from neutral are also plot in this space( and make sense that the green and magenta bones are more proximal .

Transforming the fle ct data by Origin2DICOMCenter, visualized voxel thresh 540, slices ([0,0,0]..
@NicerNewerCar @jcfr This is really keeping me stumped. The tra output transforms don't match the flex dicom (transformed into sam origin) * note the mc1 tra is on the wrong side of the wrist...? flipped in X and Y?

image

From another viewpoint:
image

@NicerNewerCar
Copy link
Contributor Author

@amymmorton

flipped in X and Y?

This may be due to two different coordinate systems LPS vs RAS. I believe the conversion between the two is flipping the X and Y directions. See this page in the Slicer docs for more information.

@jcfr
Copy link
Contributor

jcfr commented Feb 12, 2024

Following up offline discussing with @NicerNewerCar:

Since IO.writeVolume (called from saveSubVolumesFromSegmentation) saves the .tiff file as RAS1 using the itk::TIFFImageIO writer, we need to update generateConfigFile so that it serializes the volumeFlip settings so that if the tiff is loaded back it is loaded using the LPS convention. This will remove the need for the user to guess and manually toggle the checkboxes.

Similarly, if we are loading partial volume in Slicer, these should be done to account for the volumeFlip settings.

The volumeFlip settings should be considered as TIFFToLPS transform

Footnotes

  1. vtkMRMLVolumeArchetypeStorageNode::WriteDataInternal: https://github.com/Slicer/Slicer/blob/59608a21fa8a575a6e887bae056fea4ac476b4c9/Libs/MRML/Core/vtkMRMLVolumeArchetypeStorageNode.cxx#L533-L732

@amymmorton
Copy link
Contributor

amymmorton commented Feb 13, 2024 via email

@amymmorton
Copy link
Contributor

amymmorton commented Feb 13, 2024 via email

@amymmorton
Copy link
Contributor

amymmorton commented Feb 29, 2024

Now that we are firmly rooted for a single pose- it's vital to pivot back to multiple poses ( as in #59 ).

I can use the Sequences module to create a Sequences volume node of multiple 3d cts:

image

I'm attempting to process automatic camera base vrgs, but the proces has thus far taken 20 mins and still going...

Will update tmrw

@NicerNewerCar NicerNewerCar force-pushed the 4dct-new-vrg-pipline branch 2 times, most recently from 75b819d to 71c20a0 Compare March 18, 2024 16:59
AutoscoperM/AutoscoperMLib/IO.py Outdated Show resolved Hide resolved
AutoscoperM/AutoscoperMLib/IO.py Outdated Show resolved Hide resolved
AutoscoperM/AutoscoperM.py Outdated Show resolved Hide resolved
AutoscoperM/AutoscoperM.py Outdated Show resolved Hide resolved
AutoscoperM/AutoscoperM.py Outdated Show resolved Hide resolved
AutoscoperM/AutoscoperM.py Outdated Show resolved Hide resolved
AutoscoperM/AutoscoperM.py Outdated Show resolved Hide resolved
AutoscoperM/AutoscoperM.py Outdated Show resolved Hide resolved
AutoscoperM/AutoscoperM.py Outdated Show resolved Hide resolved
AutoscoperM/AutoscoperMLib/IO.py Show resolved Hide resolved
@NicerNewerCar NicerNewerCar force-pushed the 4dct-new-vrg-pipline branch from 8ebc631 to 33df368 Compare April 5, 2024 17:07
Copy link
Contributor

@amymmorton amymmorton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have students for testing- can we please push to main for extension index availability asap?

@jcfr
Copy link
Contributor

jcfr commented Apr 17, 2024

Will finalize and integrate today

@jcfr jcfr force-pushed the 4dct-new-vrg-pipline branch from 2ee59eb to d494a89 Compare April 18, 2024 20:39
List of changes:

```
$ git shortlog 468324a92..8fe9748ab --no-merges
Anthony Lombardi (1):
      ENH: Update schema to include cliping range
```
@jcfr jcfr merged commit e036c22 into BrownBiomechanics:main Apr 18, 2024
2 checks passed
@jcfr jcfr linked an issue Apr 18, 2024 that may be closed by this pull request
@NicerNewerCar NicerNewerCar deleted the 4dct-new-vrg-pipline branch May 14, 2024 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants