How to apply transform to a nifti file in scalismo 0.90.0

13 views
Skip to first unread message

Catherine N

unread,
Oct 17, 2022, 11:21:34 AM10/17/22
to scal...@googlegroups.com
Dear  Scalismo community
I am trying to align my CT images to a reference CT image.
How would one apply the bestTransform to the CT to obtain a TranslatedCT in the new scalismo version.
Thank you 
val Ref_CT_image = ImageIO.read3DScalarImage[Int](new File("data/CT_Images/CT_images/CT2_HindShinFoot.nii")).get.map(_.toShort)
val refLmks = LandmarkIO.readLandmarksJson[_3D](new File("data/CT_Images/CT_images/Lmks/CT2_image_Lmk.json")).get
//ui.show(targetGroup1, Ref_CT_image, "reference")
//ui.show(targetGroup1, refLmks, "referenceLks")

val referenceCentre = Point3D(Ref_CT_image.domain.boundingBox.oppositeCorner(0) - Ref_CT_image.domain.boundingBox.origin(0).round.toInt,
(Ref_CT_image.domain.boundingBox.oppositeCorner(1) - Ref_CT_image.domain.boundingBox.origin(1)).round.toInt,
(Ref_CT_image.domain.boundingBox.oppositeCorner(2) - Ref_CT_image.domain.boundingBox.origin(2)).round.toInt
)
val CT = ImageIO.read3DScalarImage[Short](new File("data/CT_Images/CT_images/CT1_HindShinFoot.nii")).get
val UnalignedMeshLmks = LandmarkIO.readLandmarksJson[_3D](new File("data/CT_Images/CT_images/Lmks/CT1_image_Lmk.json")).get
//aligment landmarks landmarks
val bestTransform: TranslationAfterRotation[_3D] = LandmarkRegistration.rigid3DLandmarkRegistration(UnalignedMeshLmks, refLmks, referenceCentre)
val translatedvolume = CT.transform(bestTransform)
//New image
val TranslatedCT = DiscreteImage[_3D](translatedvolume.domain, CT.values)



Kind Regards,

Ket  

BME Doctoral Candidate (UCT)
MSc. (UCT) & BSc. (Makerere Uni.) Biomedical Engineering-BME
Mobile no.: +27 63 595 9346 
Skype: catherinenamayega | Twitter: @cnamayega

Andreas Morel-Forster

unread,
Oct 17, 2022, 12:04:02 PM10/17/22
to scal...@googlegroups.com

Hi Ket

Not completely sure about the images, but I think scalismo does not support arbitrary oriented image discretizations, only axis aligned ones. So you have to do a little bit of work for it. I would try somthing like the following as a starting point. It is however untested, so maybe ask again if it is too hard to fix ;-)

val CTinterpolated = CT.interpolate(NearestNeighborInterpolator())

val newDomain: DiscreteImageDomain[_3D] = ??? // new axis aligned discretization, compute axis aligend boundingbox of old bounding box
val newValues = newDomain.pointSet.points.map{ newLocation => CTinterpolated(bestTransform.inverse(newLocation))}
val TranslatedCT = DiscreteImage[_3D](newDomain, newValues)


Best, Andreas


--
You received this message because you are subscribed to the Google Groups "scalismo" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalismo+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scalismo/CA%2BXtdWDEmo9uHb2av1B3CStitW5vCmJTmVkiJiWPmu-NyL11rQ%40mail.gmail.com.
-- 
****************************************
Dr. Andreas Morel-Forster
Departement Mathematik und Informatik
Spiegelgasse 1
CH-4051 Basel
MAIL: Andreas...@unibas.ch
****************************************
Reply all
Reply to author
Forward
0 new messages