open-discussion > afni_matlab problem
Showing 1-9 of 9 posts
Display:
Results per page:
Apr 15, 2013  03:04 PM | Pouya Ghaemmaghami
afni_matlab problem
Dear Eric,

I'm using mac, and i downloaded the lastest afni_matlab. I have problem with afni_matlab. some of the pestica functions (like apply_PeSTCA2) use afni_matlab BrikLoad function. this function seems not working well (at least in mac) for creating afni dataset. to be precise in line number 423, so i solved the solution as follow:

[us, uw] = unix(stmp);
% if (us),
% ErrMessage = sprintf ('%s: Failed to create afni brick:\n%s',...
% FuncName, uw);
% err = ErrEval(FuncName,'Err_Could not create afni brick');
% return;
% end

so as you see i just commented the lines between 424 to 429 just to avoid producing errors and exceptions. instead for making afni dataset i made it possible by adding some lines to run_pestica.sh script: these are my added lines:

# Added lines
3dcopy resp_PESTICA2.nii ____tmp_resp_PESTICA2
3dcopy card_PESTICA2.nii ____tmp_card_PESTICA2

I added two lines just after this part:

echo ""
echo "Running Stage 2: Coregistration of EPI to MNI space and back-transform of templates, followed by PESTICA estimation"
echo ""
# PESTICA coreg to template
if [ ! -f $epi_mask.crg2mni.nii ] ; then
echo "Coregistration to EPI template"
3dAllineate -automask -prefix ./$epi_mask.crg2mni.nii -source $epi_mask+orig -base $PESTICA_DIR/meanepi_mni.nii -1Dmatrix_save $epi_mask.coreg.mni.1D

cat_matvec $epi_mask.coreg.mni.1D -I -ONELINE > mni.coreg.$epi_mask.1D
3dAllineate -prefix ./resp_PESTICA2.nii -source $PESTICA_DIR/resp_mean_mni.nii -base $epi_mask+orig -1Dmatrix_apply mni.coreg.$epi_mask.1D
3dAllineate -prefix ./card_PESTICA2.nii -source $PESTICA_DIR/card_mean_mni.nii -base $epi_mask+orig -1Dmatrix_apply mni.coreg.$epi_mask.1D
fi

BTW, I think this problem exist just in Mac, and not linux. Before I]ve found something regarding that in afni forums. Now i cant find it! but anyway someguys suggested using 3dcopy in coomand line instead of using matlab_afni for that. so thats why i added those lines to the script

I hope this would not make any further problems
Apr 15, 2013  08:04 PM | Erik Beall
RE: afni_matlab problem
Pouya,
I'm going to check if this is known by the afni_matlab developers and ask if he has a plan for it.
Erik
Apr 16, 2013  08:04 PM | Erik Beall
RE: afni_matlab problem
Pouya, this is probably a setup or filenaming problem.  Ziad Saad was unable to reproduce the problem (he is the primary developer of afni_matlab).  I suspect because its failing while attempting to run a shell command that this could be something related to your setup.  The unix() command you've left uncommented is simply running 3dcopy , and should be running the same as what you ran manually.  Can you remove the semicolon from the end of line 422 (eg. so it will spit out the text for the shell command it will run)?  That will probably tell us whats going on.  Also, did you customize your Mac setup at all?  How do you have AFNI installed?
Erik
Apr 17, 2013  02:04 AM | Pouya Ghaemmaghami
RE: afni_matlab problem
Dear Eric,

i traced again and these are the result while i make all of the linse un commented 

in line 422, stmp has this value: stmp = 3dcopy resp_PESTICA2.nii ./____tmp_resp_PESTICA2

and the result of unix(stmp) in line 423 produce this error: /bin/bash: 3dcopy: command not found

this is so strange! (and thats why i added those lines to the run_pestica.sh just to create the same thing)

my matlab version is R2013a, and i have the lastes afni version, and as i noticed before i dont have any problem with afni commands in my mac terminal. and even with afni_matlab toolbox, this is the only problem that i have.
Apr 17, 2013  02:04 AM | Erik Beall
RE: afni_matlab problem
Ah yes, I have had a similar problem in the past as well and it may be the same thing.  It sounds like your path is not getting set correctly when MATLAB calls unix() to invoke the bash shell - see http://www.mathworks.com/matlabcentral/n...
where you have to edit the matlab startup file to contain:

export PATH=$PATH:/usr/local/desiredpath

where /usr/local/desiredpath is your path to AFNI's 3dcopy and all other afni tools.  Before trying this however, run !echo $PATH and see if it contains the AFNI directories.  It probably won't given your unix() string gives command not found, but good idea to check first.
Erik
Apr 23, 2013  03:04 PM | Pouya Ghaemmaghami
RE: afni_matlab problem
Dear eric,

Although i had afni folder in my path, but as you said i added the folder to my startup.m file:
export PATH=$PATH:/Users/pouya_gh/abin

and just to let you know that my matlab knows where startup.m is i executed the following line:
which startup
/Users/pouya_gh/matlab/startup.m

but i still get this:
unix('3dcopy') /bin/bash: 3dcopy: command not found

and i wonder why this happen.

BTW, Daniel Geln suggested to use 3dcopy outside Matlab to copy the data to AFNI format and then proceed with the BrikLoad function.
http://afni.nimh.nih.gov/afni/community/...

One more point: Obviously, i can run all of the afni commands in my mac terminal.

any help will be appreciated
Best,
Pouya
Apr 29, 2013  02:04 PM | Erik Beall
RE: afni_matlab problem
Hi Pouya,
this appears to be specific to your Mac and MATLAB setup.  Other Macs have been running it with no problem, and given that you've added the path to your matlab startup, it _should_ now be able to see 3dcopy.  I do not understand why it still isn't working but I don't think I can help any further (I'm not a mac user).  I would take it to a local Mac sysadmin or other expert and ask for help.
Erik
Oct 15, 2013  11:10 AM | Hang Joon Jo
RE: afni_matlab problem
In my case, the following command line in ~/matlab/startup.m worked.

setenv('DYLD_LIBRARY_PATH',[ '/opt/X11/lib:/opt/ni_tools/afni:' getenv('DYLD_LIBRARY_PATH') ])

Hope this helps.

- hjj
Dec 8, 2021  06:12 PM | Marlene Tahedl
RE: afni_matlab problem
I had the same problem after upgrading to MATLAB 2021b. This trick solved the problem. Thanks a lot!