yeatmanlab / AFQ

Automated Fiber Quantification
75 stars 52 forks source link

Having trouble running AFQ in deployed (compiled) mode #24

Open soichih opened 6 years ago

soichih commented 6 years ago

We are trying to run AFQ in deployed (compiled via mcc) mode, and having some issue inside AFQ_SegmentFiberGroups.m. It's running which('mrDiffusion.m') that doesn't seem to work in compiled mode.

We basically made following patch to AFQ to make it work.

diff --git a/functions/AFQ_SegmentFiberGroups.m b/functions/AFQ_SegmentFiberGroups.m
index 1968a82..ccb6023 100644
--- a/functions/AFQ_SegmentFiberGroups.m
+++ b/functions/AFQ_SegmentFiberGroups.m
@@ -154,7 +154,9 @@ end
 % Load fiber group - Can be filename or the data
 if ischar(fg), fg = dtiLoadFiberGroup(fg); end
 % Set the directory where templates can be found
-tdir = fullfile(fileparts(which('mrDiffusion.m')), 'templates');
+%tdir = fullfile(fileparts(which('mrDiffusion.m')), 'templates');
+%fix for compiling
+tdir = fullfile(pwd, 'templates');
 % Initialize spm defualts for normalization
 spm_get_defaults; global defaults; 
 % In my case it is not reading the estimate, just the .write, copied this values

I am wondering, this piece of code can be updated to something like.

if isdeployed
    tdir = ...something that works in deployed mode..
else
    tdir = fullfile(fileparts(which('mrDiffusion.m')), 'templates');
end

?

soichih commented 6 years ago

I think I have found a workaround, and probably a more proper way to fix this. I basically needed to include ./mrDiffusion/templates to the compiled binary.

mcc -m -R -nodisplay -a /N/u/brlife/git/vistasoft/mrDiffusion/templates -d compiled main

Now AFQ seems to be finding the templates and executing as it should be.

soichih commented 6 years ago

Sorry, I was wrong.. I am still seeing a different but similar error message.

Please download mrVista and add it to your matlab search path
Whole-brain tractography was already done for subject /N/u/hayashis/Karst/testdata/108323/dtiinit/dtiYou chose to recompute ROIs
Fibers that get as close to the ROIs as 2mm will become candidates for the Mori Groups
** ERROR (nifti_image_read): failed to find header file for 'templates/MNI_JHU_T2.nii.gz'

nim is NULL! Check to be sure the file exists.

Smoothing by 0 & 8mm..
Index exceeds matrix dimensions.

Error in spm_normalise (line 159)

Error in mrAnatComputeSpmSpatialNorm (line 83)

Error in AFQ_SegmentFiberGroups (line 176)

Error in AFQ_run (line 169)

Error in main (line 29)

MATLAB:badsubscript

The nifti_image_read vistasoft/fileFilters/nifti/C-code/nifti1_io.c is a C code and it looks for files in native file system.. not the Matlab's virtual filesystem that comes with the compiled binary.

One possible way to solve this creating a copy of the template file from matlab's virtual directory to local directory (??) and let mrAnatComputeSpmSpatialNorm() to use that local file instead.