Closed emathew4 closed 2 years ago
Hi, As i also said in Issue #10 i dont have acces to a mac system to test. This error is usually due to elastix did not run which can have 2 reasons. The elastix application was not found or elastix did not finisch.
Can you check if the elastix aplication for mac is present in your paclet folder.
SystemOpen[First[PacletFind["QMRITools"]]["Location"]]
If you run the code with the follwing addition you will get some information i can use to understand what goes wrong.
Unprotect[QMRITools`ElastixTools`$debugElastix]
QMRITools`ElastixTools`$debugElastix = True;
dataR = RegisterData[{dataS, mask, vox}, {dataT, vox}, DeleteTempDirectory -> False, Iterations -> 250, MethodReg -> "affine", NumberSamples -> 2000, Resolutions -> 1];
SystemOpen[FileNameJoin[{$TemporaryDirectory, "QMRIToolsReg"}]]
Setting the debugElastix parameter prints the commandline command excecuted by mathematica to run elastix.
for windows it looks something like this.
if it ran correctly the temp folder should contain the following files. The elastix.log will show what went wrong (if it even exists)
You are correct, it seems there is a problem with finding elastix. I did confirm the elastix application is present in the paclet folder. Here is the output from a Windows system using the debugElastix parameter
I think the problem occurs when installing using PacletInstall instead of a manual installation. When checking where FindElastix searches for elastix, it looks within the Applications folder of $UserBaseDirectory and $BaseDirectory; if using PacletInstall, the paclet will be installed to $UserBasePacletsDirectory (which by default is in the Paclets subdirectory of $UserBaseDirectory, leaving the Applications folder empty).
Copying the QMRITools folder into the Applications folder seems to be a simple solution! Alternatively, modifying the FindElastix tool to check the Paclets subdirectory (or wherever elastix is located) also works.
Thank you for the help, and many thanks for the great package!
Great you got it figured out. I never use the paclets myself and indeed the function FindElastix does not work correctly in that case. Im currently refactoring the paclet such that it better works with Mathematica 13. One of the things is better defining the dependencies. I'll try to find some time to rewrite the FindElasix and related functions (FindTransformix and FindDcm2Nii) such the work as they should.
I will let you know when it is solved. Thanks for the feedback!
@emathew4 Hi, i have uploaded a new release 2.7.3. This should fix your issue. The applications are now defined in the PacletInfo.wl ->Extentions -> Asset.
Locations of the executables can now be obtained directly from the pacletObject or with the new function GetAssetLocation[] (e.g. GetAssetLocation["Elastix"]). Would you be able to verify if RegisterData works now if the paclet is installed via PacletInstall["QMRITools-2.7.3.paclet"]? I have tested this on Windows and there it seems to work.
In[4]:= GetAssetLocation["Elastix"]
Out[4]= "..\\Paclets\\Repository\\QMRITools-2.7.3\\Applications\\Windows-x86-64\\elastix.exe"
RegisterData does work correctly now! TransformData seems to have an issue however.
This seems unrelated to the Elastix/RegisterData issue as the path to Transformix is correct and it seems that one of the other command line inputs is empty. I checked using the previous Paclet release (2.6.4) and this error occurs there as well (after adjusting the Elastix path for RegisterData), so it is not due to the most recent changes.
Hi great to hear the functions are working now. Thanks for the feedback.
The issue here is not a bug but me beeing lazy and nog doing proper error catching and reporting. Im almost sure it is because the directory specified in TransformData
is no the same as used in RegisterData
.
TransformData
looks in the specified folder for the latest "TransformParameters.x.txt" file. So if it looks in the wrong directory or RegisterData
is called without the optionDeleteTempDirectory->False
it cannot find the -tp file.
Hope this solves your issue if not let me know and ill dive into it.
You're right, it was just due to a different directory being specified. It looks like everything is working now. Thank you again for all the help!
No problem, have fun with the toolbox and if you need any help regarding other toolbox-related things or features feel free to contact me.
Describe the bug
Very similar to Issue #10, but affects (at least) both macOS and Windows The
Register*
family of functions fails with an import error. The fileresult-3D.nii.gz
is not created in the temporary directory due to an error withStringForm
.To Reproduce Steps to reproduce the behavior:
demo.nb
file and initialize.RegisterData
which will fail with an error.System Information :
There is an "out of range" error appearing regarding StringForm which did not appear in Issue #10. This seems to be the issue and would explain why the error occurs across multiple OS.