-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Some freesurfer tools (e.g. robust register) output RAS to RAS transforms in .lta format, which is not supported by this extension.
This snippet of Slicer code loads the file and the result appears to be correct, but I don't know how much variability there is in the format or if it's even documented. I don't know if the other lines in the file have any particular meaning.
ltaPath = "/data/affine.lta"
lta = open(ltaPath).read().split("\n")
mat = vtk.vtkMatrix4x4()
for row in range(4):
print(row, lta[8+row])
elems = lta[8+row].split(" ")
for col in range(4):
mat.SetElement(row, col, float(elems[col]))
transform = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLLinearTransformNode")
transform.SetMatrixTransformToParent(mat)
Here's an example .lta file:
# transform file /mnt/c/Users/mbrudfors/Projects/neurosurgical-atlas/Data/Ture-028-2022-10-07-Scene/Data/affine.lta
# created by mbrudfors on Thu Oct 27 11:07:23 2022
type = 1 # LINEAR_RAS_TO_RAS
nxforms = 1
mean = 80.0000 107.0000 116.0000
sigma = 10000.0000
1 4 4
1.004464387893677e+00 6.770147383213043e-02 -1.217468529939651e-01 -1.079803466796875e+00
-9.191786497831345e-02 9.181172251701355e-01 -1.942616552114487e-01 3.466661071777344e+01
1.277457177639008e-01 1.542867422103882e-01 1.004784703254700e+00 3.302518463134766e+01
0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00
src volume info
valid = 1 # volume info valid
filename = /mnt/c/Users/mbrudfors/Projects/neurosurgical-atlas/Data/Ture-028-2022-10-07-Scene/Data/ss_Moving_Volume.nii.gz
volume = 160 220 220
voxelsize = 1.000000000000000e+00 1.000000000000000e+00 1.000000000000000e+00
xras = 1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
yras = 0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00
zras = -0.000000000000000e+00 -0.000000000000000e+00 1.000000000000000e+00
cras = 1.167999267578125e+00 -1.290399932861328e+01 1.227996826171875e+00
dst volume info
valid = 1 # volume info valid
filename = /mnt/c/Users/mbrudfors/Projects/neurosurgical-atlas/Data/Ture-028-2022-10-07-Scene/Data/ss_Fixed_Volume.nii.gz
volume = 512 512 392
voxelsize = 5.077999830245972e-01 5.077999830245972e-01 5.000000000000000e-01
xras = -1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
yras = 0.000000000000000e+00 -1.000000000000000e+00 0.000000000000000e+00
zras = 0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00
cras = -2.550689697265625e+00 2.907742309570312e+01 2.825936889648438e+01
Metadata
Metadata
Assignees
Labels
No labels