I tried to load a FSL generated .mat transformation matrix as a transform but the system crashed. The simple goal is to use the .mat matrix to transform vtk objects into a different imaging space; using 3d Slicer, I envision dragging the vtk objects onto the transform node and hardening the transformation and saving the transformed vtk objects.
Instead of saving transform in proprietary Matlab mat file format, could you save the transform into ITK transform file format? Slicer can directly read/write ITK transform files.
Thanks Andras. I believe ITK stores the matrix in LPS format but from what I see in the cli_lineartransformationwrite.m function, there is the option to save transformation matrix in RAS. My images are in RAS so I’m guessing that I’d have to set the transformType to ‘slicer’?
I tried to load the FSL generated .mat transformation matrix into Matlab and got the following error message:
>> a = load('affine_ct_mr.mat')
Error using load
Unable to read MAT-file C:\Users\Vinit\Documents\MATLAB\affine_ct_mr.mat. Not a binary MAT-file. Try load -ASCII to read as text.
So, I had converted the .mat array into a .txt file using FSL and was able to read this into Matlab as a 4x4 array:
Matlab requires all necessary .m files to be in the current working directory or in the path. Either change the working directory to .../MatlabCommander/commandserver or add this folder to the path in Matlab.
As it seems that you are very new to Matlab, I would advise to spend minimum necessary time with it, and instead focus your efforts on learning Python, which is a much more versatile language, with many more libraries, much larger community, and it is completely open-source and free.
Actually, I’m modifying my workflow to include doing intermodality registrations directly in 3d Slicer based on our convos. This way transformations can be directly calculated without requiring an intermediary Matlab step. I fully agree with what you are saying about Python and open-source. I’ve been doing my neuroimaging work in Nipy precisely for the reasons of versatility and support; the very same reasons why I’m using 3d Slicer. Appreciate all your help.