Closed wandell closed 7 years ago
I get the same problem. I tried re-compiling the mex function but got an error:
mex /Users/jonathanwinawer/matlab/toolboxes/vistasoft/fileFilters/nifti/C-code/readFileNifti.c
Building with 'Xcode with Clang'.
Error using mex
Undefined symbols for architecture x86_64:
"_nifti_image_read", referenced from:
_mexFunction in readFileNifti.o
"_nifti_mat44_inverse", referenced from:
_mexFunction in readFileNifti.o
"_nifti_mat44_to_quatern", referenced from:
_mexFunction in readFileNifti.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Currently, I am not sure how to fix this. Attempting to compile with the more verbose output gave me a longer error ;)
mex /Users/jonathanwinawer/matlab/toolboxes/vistasoft/fileFilters/nifti/C-code/readFileNifti.c -v
Verbose mode is on.
... Looking for compiler 'Xcode with Clang' ...
... Looking for environment variable 'DEVELOPER_DIR' ...No.
... Executing command 'xcode-select -print-path' ...Yes ('/Applications/Xcode.app/Contents/Developer').
... Looking for folder '/Applications/Xcode.app/Contents/Developer' ...Yes.
... Executing command 'which xcrun' ...Yes ('/usr/bin/xcrun').
... Looking for folder '/usr/bin' ...Yes.
... Executing command 'defaults read com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense' ...No.
... Executing command 'defaults read /Library/Preferences/com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense' ...Yes ('8.0').
... Executing command '
agreed=8.0
if echo $agreed | grep -E '[\.\"]' >/dev/null; then
lhs=`expr "$agreed" : '\([0-9]*\)[\.].*'`
rhs=`expr "$agreed" : '[0-9]*[\.]\(.*\)$'`
if echo $rhs | grep -E '[\."]' >/dev/null; then
rhs=`expr "$rhs" : '\([0-9]*\)[\.].*'`
fi
if [ $lhs -gt 4 ] || ( [ $lhs -eq 4 ] && [ $rhs -ge 3 ] ); then
echo $agreed
else
exit 1
fi
fi' ...Yes ('8.0').
... Executing command 'xcrun -sdk macosx --show-sdk-path' ...Yes ('/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk').
... Executing command 'xcrun -sdk macosx --show-sdk-version' ...Yes ('10.12').
Found installed compiler 'Xcode with Clang'.
Options file details
-------------------------------------------------------------------
Compiler location: /Applications/Xcode.app/Contents/Developer
Options file: /Applications/MATLAB9.2.app/bin/maci64/mexopts/clang_maci64.xml
CMDLINE200 : /usr/bin/xcrun -sdk macosx10.12 clang -Wl,-twolevel_namespace -undefined error -arch x86_64 -mmacosx-version-min=10.9 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -bundle -Wl,-exported_symbols_list,"/Applications/MATLAB9.2.app/extern/lib/maci64/mexFunction.map" /var/folders/y0/b4yjhcvs1q5fqmftvldrg4zh0000gp/T/mex_24943773908712_53982/readFileNifti.o /var/folders/y0/b4yjhcvs1q5fqmftvldrg4zh0000gp/T/mex_24943773908712_53982/c_mexapi_version.o -O -Wl,-exported_symbols_list,"/Applications/MATLAB9.2.app/extern/lib/maci64/c_exportsmexfileversion.map" -L"/Applications/MATLAB9.2.app/bin/maci64" -lmx -lmex -lmat -lc++ -o readFileNifti.mexmaci64
CC : /usr/bin/xcrun -sdk macosx10.12 clang
CXX : /usr/bin/xcrun -sdk macosx10.12 clang++
DEFINES : -DTARGET_API_VERSION=700 -DUSE_MEX_CMD -DMATLAB_MEX_FILE
MATLABMEX : -DMATLAB_MEX_FILE
MACOSX_DEPLOYMENT_TARGET : 10.9
CFLAGS : -fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
INCLUDE : -I"/Applications/MATLAB9.2.app/extern/include" -I"/Applications/MATLAB9.2.app/simulink/include"
COPTIMFLAGS : -O2 -fwrapv -DNDEBUG
CDEBUGFLAGS : -g
LD : /usr/bin/xcrun -sdk macosx10.12 clang
LDXX : /usr/bin/xcrun -sdk macosx10.12 clang++
LDFLAGS : -Wl,-twolevel_namespace -undefined error -arch x86_64 -mmacosx-version-min=10.9 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -bundle -Wl,-exported_symbols_list,"/Applications/MATLAB9.2.app/extern/lib/maci64/mexFunction.map"
LDBUNDLE : -bundle
FUNCTIONMAP : "/Applications/MATLAB9.2.app/extern/lib/maci64/mexFunction.map"
VERSIONMAP : "/Applications/MATLAB9.2.app/extern/lib/maci64/c_exportsmexfileversion.map"
LINKEXPORT : -Wl,-exported_symbols_list,"/Applications/MATLAB9.2.app/extern/lib/maci64/mexFunction.map"
LINKEXPORTVER : -Wl,-exported_symbols_list,"/Applications/MATLAB9.2.app/extern/lib/maci64/c_exportsmexfileversion.map"
LINKLIBS : -L"/Applications/MATLAB9.2.app/bin/maci64" -lmx -lmex -lmat -lc++
LDOPTIMFLAGS : -O
LDDEBUGFLAGS : -g
OBJEXT : .o
LDEXT : .mexmaci64
SETENV : CC="/usr/bin/xcrun -sdk macosx10.12 clang"
CXX="/usr/bin/xcrun -sdk macosx10.12 clang++"
CFLAGS="-fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -DTARGET_API_VERSION=700 -DUSE_MEX_CMD -DMATLAB_MEX_FILE"
CXXFLAGS="-fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -fobjc-arc -std=c++11 -stdlib=libc++ -DTARGET_API_VERSION=700 -DUSE_MEX_CMD -DMATLAB_MEX_FILE"
COPTIMFLAGS="-O2 -fwrapv -DNDEBUG"
CXXOPTIMFLAGS="-O2 -fwrapv -DNDEBUG"
CDEBUGFLAGS="-g"
CXXDEBUGFLAGS="-g"
LD="/usr/bin/xcrun -sdk macosx10.12 clang"
LDXX="/usr/bin/xcrun -sdk macosx10.12 clang++"
LDFLAGS="-Wl,-twolevel_namespace -undefined error -arch x86_64 -mmacosx-version-min=10.9 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -bundle -Wl,-exported_symbols_list,"/Applications/MATLAB9.2.app/extern/lib/maci64/mexFunction.map" -L"/Applications/MATLAB9.2.app/bin/maci64" -lmx -lmex -lmat -lc++ -Wl,-exported_symbols_list,"/Applications/MATLAB9.2.app/extern/lib/maci64/mexFunction.map""
LDDEBUGFLAGS="-g"
DEVELOPER_DIR_CHECK :
XCODE_DIR : /Applications/Xcode.app/Contents/Developer
XCRUN_DIR : /usr/bin
XCODE_AGREED_VERSION : 8.0
ISYSROOT : /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
SDKVER : 10.12
MATLABROOT : /Applications/MATLAB9.2.app
ARCH : maci64
SRC : /Users/jonathanwinawer/matlab/toolboxes/vistasoft/fileFilters/nifti/C-code/readFileNifti.c;/Applications/MATLAB9.2.app/extern/version/c_mexapi_version.c
OBJ : /var/folders/y0/b4yjhcvs1q5fqmftvldrg4zh0000gp/T/mex_24943773908712_53982/readFileNifti.o;/var/folders/y0/b4yjhcvs1q5fqmftvldrg4zh0000gp/T/mex_24943773908712_53982/c_mexapi_version.o
OBJS : /var/folders/y0/b4yjhcvs1q5fqmftvldrg4zh0000gp/T/mex_24943773908712_53982/readFileNifti.o /var/folders/y0/b4yjhcvs1q5fqmftvldrg4zh0000gp/T/mex_24943773908712_53982/c_mexapi_version.o
SRCROOT : /Users/jonathanwinawer/matlab/toolboxes/vistasoft/fileFilters/nifti/C-code/readFileNifti
DEF : /var/folders/y0/b4yjhcvs1q5fqmftvldrg4zh0000gp/T/mex_24943773908712_53982/readFileNifti.def
EXP : readFileNifti.exp
LIB : readFileNifti.lib
EXE : readFileNifti.mexmaci64
ILK : readFileNifti.ilk
MANIFEST : readFileNifti.mexmaci64.manifest
TEMPNAME : readFileNifti
EXEDIR :
EXENAME : readFileNifti
OPTIM : -O2 -fwrapv -DNDEBUG
LINKOPTIM : -O
CMDLINE100_0 : /usr/bin/xcrun -sdk macosx10.12 clang -c -DTARGET_API_VERSION=700 -DUSE_MEX_CMD -DMATLAB_MEX_FILE -I"/Applications/MATLAB9.2.app/extern/include" -I"/Applications/MATLAB9.2.app/simulink/include" -fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -O2 -fwrapv -DNDEBUG /Users/jonathanwinawer/matlab/toolboxes/vistasoft/fileFilters/nifti/C-code/readFileNifti.c -o /var/folders/y0/b4yjhcvs1q5fqmftvldrg4zh0000gp/T/mex_24943773908712_53982/readFileNifti.o
CMDLINE100_1 : /usr/bin/xcrun -sdk macosx10.12 clang -c -DTARGET_API_VERSION=700 -DUSE_MEX_CMD -DMATLAB_MEX_FILE -I"/Applications/MATLAB9.2.app/extern/include" -I"/Applications/MATLAB9.2.app/simulink/include" -fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -O2 -fwrapv -DNDEBUG /Applications/MATLAB9.2.app/extern/version/c_mexapi_version.c -o /var/folders/y0/b4yjhcvs1q5fqmftvldrg4zh0000gp/T/mex_24943773908712_53982/c_mexapi_version.o
-------------------------------------------------------------------
Building with 'Xcode with Clang'.
/usr/bin/xcrun -sdk macosx10.12 clang -c -DTARGET_API_VERSION=700 -DUSE_MEX_CMD -DMATLAB_MEX_FILE -I"/Applications/MATLAB9.2.app/extern/include" -I"/Applications/MATLAB9.2.app/simulink/include" -fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -O2 -fwrapv -DNDEBUG /Users/jonathanwinawer/matlab/toolboxes/vistasoft/fileFilters/nifti/C-code/readFileNifti.c -o /var/folders/y0/b4yjhcvs1q5fqmftvldrg4zh0000gp/T/mex_24943773908712_53982/readFileNifti.o
/Users/jonathanwinawer/matlab/toolboxes/vistasoft/fileFilters/nifti/C-code/readFileNifti.c:242:43: warning: incompatible pointer types passing 'int [7]' to parameter of type 'const size_t *' (aka 'const unsigned long *') [-Wincompatible-pointer-types]
tmp = mxCreateNumericArray(nim->ndim, dims, dt, cmp);
^~~~
/Applications/MATLAB9.2.app/extern/include/matrix.h:782:53: note: passing argument to parameter 'dims' here
mxCreateNumericArray_730(size_t ndim, const size_t *dims, mxClassID classid, mxComplexity flag);
^
1 warning generated.
/usr/bin/xcrun -sdk macosx10.12 clang -c -DTARGET_API_VERSION=700 -DUSE_MEX_CMD -DMATLAB_MEX_FILE -I"/Applications/MATLAB9.2.app/extern/include" -I"/Applications/MATLAB9.2.app/simulink/include" -fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -O2 -fwrapv -DNDEBUG /Applications/MATLAB9.2.app/extern/version/c_mexapi_version.c -o /var/folders/y0/b4yjhcvs1q5fqmftvldrg4zh0000gp/T/mex_24943773908712_53982/c_mexapi_version.o
/usr/bin/xcrun -sdk macosx10.12 clang -Wl,-twolevel_namespace -undefined error -arch x86_64 -mmacosx-version-min=10.9 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -bundle -Wl,-exported_symbols_list,"/Applications/MATLAB9.2.app/extern/lib/maci64/mexFunction.map" /var/folders/y0/b4yjhcvs1q5fqmftvldrg4zh0000gp/T/mex_24943773908712_53982/readFileNifti.o /var/folders/y0/b4yjhcvs1q5fqmftvldrg4zh0000gp/T/mex_24943773908712_53982/c_mexapi_version.o -O -Wl,-exported_symbols_list,"/Applications/MATLAB9.2.app/extern/lib/maci64/c_exportsmexfileversion.map" -L"/Applications/MATLAB9.2.app/bin/maci64" -lmx -lmex -lmat -lc++ -o readFileNifti.mexmaci64
Error using mex
Undefined symbols for architecture x86_64:
"_nifti_image_read", referenced from:
_mexFunction in readFileNifti.o
"_nifti_mat44_inverse", referenced from:
_mexFunction in readFileNifti.o
"_nifti_mat44_to_quatern", referenced from:
_mexFunction in readFileNifti.o
ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
I can compile it. The mex command you use should include some additional files ...
mex readFileNifti.c nifti1_io.c znzlib.c
But it doesn't run right for me (yet). Very grateful that you are looking this over. May be beyond my reach.
The compiled version doesn't run on Matlab 2016a, by the way. Or 2017a. Sigh.
That helps - now I can compile.
And I notice this:
the newly compiled niftiRead (or readFileNifti) works with .nii files but not with .nii.gz files.
So for example, if I download the sample data set,
mrtInstallSampleData('functional', 'erniePRF');
then this call returns an array with all fields empty:
readFileNifti(fullfile(vistaRootPath, 'local', 'erniePRF', 'Raw', 'ErnieInplane.nii.gz'))
and the message:
nim is NULL! Check to be sure the file exists.
However, if I can uncompress the g-zipped nifti, it works
gunzip(fullfile(vistaRootPath, 'local', 'erniePRF', 'Raw', 'ErnieInplane.nii.gz')) readFileNifti(fullfile(vistaRootPath, 'local', 'erniePRF', 'Raw', 'ErnieInplane.nii'))
This gives me the full file.
ans =
struct with fields:
data: [160×208×24 int16]
fname:
'/Users/jonathanwinawer/matlab/toolboxes/vistasoft/local/erniePRF/Raw/ErnieInplane.nii' ndim: 4 dim: [160 208 24 1] pixdim: [1 1.0000 2.0000 1] scl_slope: 0 scl_inter: 0 cal_min: 0 cal_max: 0 qform_code: 1 sform_code: 0 freq_dim: 2 phase_dim: 1 slice_dim: 3 slice_code: 0 slice_start: 0 slice_end: 23 slice_duration: 0 quatern_b: 0 quatern_c: 0.8699 quatern_d: -0.4932 qoffset_x: 81 qoffset_y: -96.7594 qoffset_z: 70.2365 qfac: 1 qto_xyz: [4×4 double] qto_ijk: [4×4 double] sto_xyz: [4×4 double] sto_ijk: [4×4 double] toffset: 0 xyz_units: 'mm' time_units: 'msec' nifti_type: 1 intent_code: 0 intent_p1: 0 intent_p2: 0 intent_p3: 0 intent_name: '' descrip: 'Nova8_V8 2D IR\GR TR=1540/TE=3.88/FA=8 05-Aug-2015 15:13:21' aux_file: '' num_ext: 0
This is better than total failure but still a problem, since I have tons of gzipped niftis, and the previous version of readFileNifti worked fine with .gz. But maybe it's a clue as to what is wrong.
-J
On Tue, Apr 25, 2017 at 9:01 PM, Brian Wandell notifications@github.com wrote:
I can compile it. The mex command you use should include some additional files ...
mex readFileNifti.c nifti1_io.c znzlib.c
But it doesn't run right for me (yet). Very grateful that you are looking this over. May be beyond my reach.
The compiled version doesn't run on Matlab 2016a, by the way. Or 2017a. Sigh.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vistalab/vistasoft/issues/229#issuecomment-297207777, or mute the thread https://github.com/notifications/unsubscribe-auth/ACBX3nN9nLBipwQHYC3LH5PPM2mQMXRSks5rzpd3gaJpZM4NHBKQ .
-- Jonathan Winawer Assistant Professor of Psychology and Neural Science
New York University 6 Washington Place New York, NY, 10003 (212) 998-7922 (phone) (212) 995-4018 (fax) jonathan.winawer@nyu.edu http://psych.nyu.edu/winawer/
Will try tonight as you say. If that is the only problem, it is wonderful. We can look inside of niftiRead() first. Though I find the whole thing mystifying. Why should there be any issue at all, after all these years of things working well.
After re-compiling, it works fine on Matlab2017a as well as 2016b in the case of .nii, but still fails on .nii.gz (doesn't hang - just returns empty structures).
On Tue, Apr 25, 2017 at 9:26 PM, Brian Wandell notifications@github.com wrote:
Will try tonight as you say. If that is the only problem, it is wonderful. We can look inside of niftiRead() first. Though I find the whole thing mystifying. Why should there be any issue at all, after all these years of things working well.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vistalab/vistasoft/issues/229#issuecomment-297211267, or mute the thread https://github.com/notifications/unsubscribe-auth/ACBX3ph4IFUIAB081ls-hFIpmAUSW8jAks5rzp1WgaJpZM4NHBKQ .
-- Jonathan Winawer Assistant Professor of Psychology and Neural Science
New York University 6 Washington Place New York, NY, 10003 (212) 998-7922 (phone) (212) 995-4018 (fax) jonathan.winawer@nyu.edu http://psych.nyu.edu/winawer/
Given that it is the same c-code, what happened with the .gz case? Maybe we should make a podcast mystery out of it.
When I run mex with Xcode (Version 8.3.2 (8E2002)) on Sierra (10.12) and Matlab 2017a, I get two mex compilation warnings
mex readFileNifti.c nifti1_io.c znzlib.c
Building with 'Xcode with Clang'.
/Users/wandell/Github/vistasoft/fileFilters/nifti/C-code/readFileNifti.c:242:43: warning: incompatible pointer types passing 'int [7]' to parameter of type 'const size_t *' (aka 'const unsigned long *') [-Wincompatible-pointer-types]
tmp = mxCreateNumericArray(nim->ndim, dims, dt, cmp);
^~~~
/Applications/MATLAB_R2017a.app/extern/include/matrix.h:782:53: note: passing argument to parameter 'dims' here
mxCreateNumericArray_730(size_t ndim, const size_t *dims, mxClassID classid, mxComplexity flag);
^
1 warning generated.
MEX completed successfully.
>> mex writeFileNifti.c nifti1_io.c znzlib.c
Building with 'Xcode with Clang'.
/Users/wandell/Github/vistasoft/fileFilters/nifti/C-code/writeFileNifti.c:89:10: warning: incompatible pointer types assigning to 'const int *' from 'const size_t *' (aka 'const unsigned long *') [-Wincompatible-pointer-types]
dims = mxGetDimensions(data);
^ ~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
MEX completed successfully.
And then, when I run on typical t1.nii (ungzip'd) I am returned this error, which seems suspiciously connected to the warning above.
Error using readFileNifti
Requested 1327144894722x4294967554x4294967297 (17179869184.0GB) array exceeds maximum
array size preference. Creation of arrays greater than this limit may take a long
time and cause MATLAB to become unresponsive. See array size limit or preference
panel for more information.
Error in niftiRead (line 44)
ni = readFileNifti(fileName);
This happened to me a few years ago. Last time I compiled these for readFileNifti to be able to open .nii.gz files on OSX the flags: -lz -DHAVE_ZLIB
had to be added to the mex command line.
If -DHAVE_ZLIB is not set the code compiles fine. But the c code will return empty when trying to open a .nii.gz.
Justin
On Wed, Apr 26, 2017 at 2:58 AM Brian Wandell notifications@github.com wrote:
Given that it is the same c-code, what happened with the .gz case? Maybe we should make a podcast mystery out of it.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/vistalab/vistasoft/issues/229#issuecomment-297215684, or mute the thread https://github.com/notifications/unsubscribe-auth/AAtIteLXxdAyqZiP-PTAPS75W4jGmIqBks5rzqTSgaJpZM4NHBKQ .
Great - that fixes it. Thanks!
It also raises questions:
-Can we replace the compiled file, readFileNifti.mexmaci64, in the repository, or will this fail on older environments?
On Wed, Apr 26, 2017 at 2:30 AM, Justin Ales notifications@github.com wrote:
This happened to me a few years ago. Last time I compiled these for readFileNifti to be able to open .nii.gz files on OSX the flags: -lz -DHAVE_ZLIB
had to be added to the mex command line.
If -DHAVE_ZLIB is not set the code compiles fine. But the c code will return empty when trying to open a .nii.gz.
Justin
On Wed, Apr 26, 2017 at 2:58 AM Brian Wandell notifications@github.com wrote:
Given that it is the same c-code, what happened with the .gz case? Maybe we should make a podcast mystery out of it.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <https://github.com/vistalab/vistasoft/issues/229#issuecomment-297215684 , or mute the thread https://github.com/notifications/unsubscribe-auth/AAtIteLXxdAyqZiP- PTAPS75W4jGmIqBks5rzqTSgaJpZM4NHBKQ .
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vistalab/vistasoft/issues/229#issuecomment-297252798, or mute the thread https://github.com/notifications/unsubscribe-auth/ACBX3sXPby7YYEZrA5ibEZCfZc2sKNx2ks5rzuSZgaJpZM4NHBKQ .
-- Jonathan Winawer Assistant Professor of Psychology and Neural Science
New York University 6 Washington Place New York, NY, 10003 (212) 998-7922 (phone) (212) 995-4018 (fax) jonathan.winawer@nyu.edu http://psych.nyu.edu/winawer/
I would suggest hardcoding the define in znzlib.h. Without this defined .nii.gz loading will also fail on linux systems. I don't think the non gz version of readFileNifti is useful as most places I know use .nii.gz not .nii. The silent failure is also totally confusing for people. I think it would be better if the file failled with an error message saying the zlib is missing rather than creating a mex file that doesn't load .nii.gz files. Of course if you add HAVE_ZLIB that requires linking against zlib. Which requires adding an option to the mex command line (the -lz option). Adding options is not a feature of mrvCompile. mrvCompile even has readFileNifti/writeFileNifti listed as needing these options (although I suggest using "-lz" to link against the system zlib instead of linking against a specific matlab bundled file that mrvCompile comment is suggesting). So maybe it's time to let allow options in mrvCompile? I looked and it'll take a small bit of work defaultCFileList.m only allows filenames in the list it creates.
Can you replace the compiled file? I don't know but probably not. Since the function broke when moving to matlab 2017a that's a bad sign. The mex files are usually(but not guaranteed) backwards compatible. Compatibility for newer version compiled files on older systems is not usually expected. I'm still running 10.9 so I can check to see if the mex file runs on an older system.
Justin On Wed, Apr 26, 2017 at 9:03 AM, Jonathan Winawer notifications@github.com wrote:
Great - that fixes it. Thanks!
It also raises questions:
-Can we replace the compiled file, readFileNifti.mexmaci64, in the repository, or will this fail on older environments?
- Should we update mrvCompile to include these flags?
On Wed, Apr 26, 2017 at 2:30 AM, Justin Ales notifications@github.com wrote:
This happened to me a few years ago. Last time I compiled these for readFileNifti to be able to open .nii.gz files on OSX the flags: -lz -DHAVE_ZLIB
had to be added to the mex command line.
If -DHAVE_ZLIB is not set the code compiles fine. But the c code will return empty when trying to open a .nii.gz.
Justin
On Wed, Apr 26, 2017 at 2:58 AM Brian Wandell notifications@github.com wrote:
Given that it is the same c-code, what happened with the .gz case? Maybe we should make a podcast mystery out of it.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <https://github.com/vistalab/vistasoft/issues/229# issuecomment-297215684 , or mute the thread https://github.com/notifications/unsubscribe-auth/AAtIteLXxdAyqZiP- PTAPS75W4jGmIqBks5rzqTSgaJpZM4NHBKQ .
— You are receiving this because you commented. Reply to this email directly, view it on GitHub <https://github.com/vistalab/vistasoft/issues/229#issuecomment-297252798 , or mute the thread https://github.com/notifications/unsubscribe-auth/ ACBX3sXPby7YYEZrA5ibEZCfZc2sKNx2ks5rzuSZgaJpZM4NHBKQ .
-- Jonathan Winawer Assistant Professor of Psychology and Neural Science
New York University 6 Washington Place New York, NY, 10003 (212) 998-7922 (phone) (212) 995-4018 (fax) jonathan.winawer@nyu.edu http://psych.nyu.edu/winawer/
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vistalab/vistasoft/issues/229#issuecomment-297280306, or mute the thread https://github.com/notifications/unsubscribe-auth/AAtItcBwqoAOoMZaF56CmMQ9F5AGtH1jks5rzvpTgaJpZM4NHBKQ .
I pushed a quick branch that implements what I said above. A bit of a kludge in defaultCFileList to interpret strings that start with "-" as options instead of trying to expand the full path of a file.
Branch name: readFileNiftiGzSupportFix
On Wed, Apr 26, 2017 at 3:22 PM, Justin Ales justin.ales@gmail.com wrote:
I would suggest hardcoding the define in znzlib.h. Without this defined .nii.gz loading will also fail on linux systems. I don't think the non gz version of readFileNifti is useful as most places I know use .nii.gz not .nii. The silent failure is also totally confusing for people. I think it would be better if the file failled with an error message saying the zlib is missing rather than creating a mex file that doesn't load .nii.gz files. Of course if you add HAVE_ZLIB that requires linking against zlib. Which requires adding an option to the mex command line (the -lz option). Adding options is not a feature of mrvCompile. mrvCompile even has readFileNifti/writeFileNifti listed as needing these options (although I suggest using "-lz" to link against the system zlib instead of linking against a specific matlab bundled file that mrvCompile comment is suggesting). So maybe it's time to let allow options in mrvCompile? I looked and it'll take a small bit of work defaultCFileList.m only allows filenames in the list it creates.
Can you replace the compiled file? I don't know but probably not. Since the function broke when moving to matlab 2017a that's a bad sign. The mex files are usually(but not guaranteed) backwards compatible. Compatibility for newer version compiled files on older systems is not usually expected. I'm still running 10.9 so I can check to see if the mex file runs on an older system.
Justin
On Wed, Apr 26, 2017 at 9:03 AM, Jonathan Winawer < notifications@github.com> wrote:
Great - that fixes it. Thanks!
It also raises questions:
-Can we replace the compiled file, readFileNifti.mexmaci64, in the repository, or will this fail on older environments?
- Should we update mrvCompile to include these flags?
On Wed, Apr 26, 2017 at 2:30 AM, Justin Ales notifications@github.com wrote:
This happened to me a few years ago. Last time I compiled these for readFileNifti to be able to open .nii.gz files on OSX the flags: -lz -DHAVE_ZLIB
had to be added to the mex command line.
If -DHAVE_ZLIB is not set the code compiles fine. But the c code will return empty when trying to open a .nii.gz.
Justin
On Wed, Apr 26, 2017 at 2:58 AM Brian Wandell <notifications@github.com
wrote:
Given that it is the same c-code, what happened with the .gz case? Maybe we should make a podcast mystery out of it.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <https://github.com/vistalab/vistasoft/issues/229#issuecomme nt-297215684 , or mute the thread https://github.com/notifications/unsubscribe-auth/AAtIteLXxdAyqZiP- PTAPS75W4jGmIqBks5rzqTSgaJpZM4NHBKQ .
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vistalab/vistasoft/issues/229#issuecomme nt-297252798, or mute the thread https://github.com/notifications/unsubscribe-auth/ACBX3sXPb y7YYEZrA5ibEZCfZc2sKNx2ks5rzuSZgaJpZM4NHBKQ .
-- Jonathan Winawer Assistant Professor of Psychology and Neural Science
New York University 6 Washington Place New York, NY, 10003 (212) 998-7922 (phone) (212) 995-4018 (fax) jonathan.winawer@nyu.edu http://psych.nyu.edu/winawer/
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vistalab/vistasoft/issues/229#issuecomment-297280306, or mute the thread https://github.com/notifications/unsubscribe-auth/AAtItcBwqoAOoMZaF56CmMQ9F5AGtH1jks5rzvpTgaJpZM4NHBKQ .
Great. I merged this with my local branch, and also added the newly compiled readFileNifti.mexmaci64 to my local master branch. All seems to work with Matlab2013b - Matlab2017a. I will merge remotely. Seems like the issue is resolved.
-J
On Wed, Apr 26, 2017 at 6:28 PM, Justin Ales notifications@github.com wrote:
I pushed a quick branch that implements what I said above. A bit of a kludge in defaultCFileList to interpret strings that start with "-" as options instead of trying to expand the full path of a file.
Branch name: readFileNiftiGzSupportFix
On Wed, Apr 26, 2017 at 3:22 PM, Justin Ales justin.ales@gmail.com wrote:
I would suggest hardcoding the define in znzlib.h. Without this defined .nii.gz loading will also fail on linux systems. I don't think the non gz version of readFileNifti is useful as most places I know use .nii.gz not .nii. The silent failure is also totally confusing for people. I think it would be better if the file failled with an error message saying the zlib is missing rather than creating a mex file that doesn't load .nii.gz files. Of course if you add HAVE_ZLIB that requires linking against zlib. Which requires adding an option to the mex command line (the -lz option). Adding options is not a feature of mrvCompile. mrvCompile even has readFileNifti/writeFileNifti listed as needing these options (although I suggest using "-lz" to link against the system zlib instead of linking against a specific matlab bundled file that mrvCompile comment is suggesting). So maybe it's time to let allow options in mrvCompile? I looked and it'll take a small bit of work defaultCFileList.m only allows filenames in the list it creates.
Can you replace the compiled file? I don't know but probably not. Since the function broke when moving to matlab 2017a that's a bad sign. The mex files are usually(but not guaranteed) backwards compatible. Compatibility for newer version compiled files on older systems is not usually expected. I'm still running 10.9 so I can check to see if the mex file runs on an older system.
Justin
On Wed, Apr 26, 2017 at 9:03 AM, Jonathan Winawer < notifications@github.com> wrote:
Great - that fixes it. Thanks!
It also raises questions:
-Can we replace the compiled file, readFileNifti.mexmaci64, in the repository, or will this fail on older environments?
- Should we update mrvCompile to include these flags?
On Wed, Apr 26, 2017 at 2:30 AM, Justin Ales notifications@github.com wrote:
This happened to me a few years ago. Last time I compiled these for readFileNifti to be able to open .nii.gz files on OSX the flags: -lz -DHAVE_ZLIB
had to be added to the mex command line.
If -DHAVE_ZLIB is not set the code compiles fine. But the c code will return empty when trying to open a .nii.gz.
Justin
On Wed, Apr 26, 2017 at 2:58 AM Brian Wandell < notifications@github.com
wrote:
Given that it is the same c-code, what happened with the .gz case? Maybe we should make a podcast mystery out of it.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <https://github.com/vistalab/vistasoft/issues/229#issuecomme nt-297215684 , or mute the thread https://github.com/notifications/unsubscribe- auth/AAtIteLXxdAyqZiP- PTAPS75W4jGmIqBks5rzqTSgaJpZM4NHBKQ .
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vistalab/vistasoft/issues/229#issuecomme nt-297252798, or mute the thread https://github.com/notifications/unsubscribe-auth/ACBX3sXPb y7YYEZrA5ibEZCfZc2sKNx2ks5rzuSZgaJpZM4NHBKQ .
-- Jonathan Winawer Assistant Professor of Psychology and Neural Science
New York University 6 Washington Place New York, NY, 10003 (212) 998-7922 (phone) (212) 995-4018 (fax) jonathan.winawer@nyu.edu http://psych.nyu.edu/winawer/
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vistalab/vistasoft/issues/229# issuecomment-297280306, or mute the thread https://github.com/notifications/unsubscribe-auth/ AAtItcBwqoAOoMZaF56CmMQ9F5AGtH1jks5rzvpTgaJpZM4NHBKQ .
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vistalab/vistasoft/issues/229#issuecomment-297559624, or mute the thread https://github.com/notifications/unsubscribe-auth/ACBX3nbgD9vq3X6bJNOy7BHyh0xR0Httks5rz8UHgaJpZM4NHBKQ .
-- Jonathan Winawer Assistant Professor of Psychology and Neural Science
New York University 6 Washington Place New York, NY, 10003 (212) 998-7922 (phone) (212) 995-4018 (fax) jonathan.winawer@nyu.edu http://psych.nyu.edu/winawer/
Did you guys check writeFileNifti, too?
I haven't tested writeFileNifti but I applied the compilation option change to the following files: matToQuat.c writeFileNifti.c readFileNifti.c
There was also a silly typo (missing "}") causing it to fail compilation so I fixed that too.
So in theory those should work.
Justin
On Thu, Apr 27, 2017 at 2:42 AM, Brian Wandell notifications@github.com wrote:
Did you guys check writeFileNifti, too?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vistalab/vistasoft/issues/229#issuecomment-297587906, or mute the thread https://github.com/notifications/unsubscribe-auth/AAtItZAI3OSAnc0OUFtJ6f1jo8fA4ms7ks5rz_KhgaJpZM4NHBKQ .
Re Brian's question about writeFileNifti:
Good point. The mexmaci64 writeFileNifti failed on Matlab2017a. After re-compiling, it succeeds. I pushed the recompiled writeFileNifti.mexmaci64 to the master repository.
More generally, the suite of test functions called by mrvTest now passes using Matlab2013b, Matlab2016b and 2017a, at least on my system (Mac OS 10.12.4). The mrvTest suite functions call niftiRead and niftiWrite many times (which in turn call readFileNifti and writeFileNifti).
-J
On Wed, Apr 26, 2017 at 9:42 PM, Brian Wandell notifications@github.com wrote:
Did you guys check writeFileNifti, too?
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/vistalab/vistasoft/issues/229#issuecomment-297587906, or mute the thread https://github.com/notifications/unsubscribe-auth/ACBX3obtm9amLHyYP4zHTBFL94_4eRbBks5rz_KhgaJpZM4NHBKQ .
-- Jonathan Winawer Assistant Professor of Psychology and Neural Science
New York University 6 Washington Place New York, NY, 10003 (212) 998-7922 (phone) (212) 995-4018 (fax) jonathan.winawer@nyu.edu http://psych.nyu.edu/winawer/
When I ran mrvTest this evening, I had to recompile myCinterp3.c as well. After doing that mrvTest, everything passed on both Matlab2017a and Matlab2016a.
Almost everything passed in Matlab2013b except for this:
test_xformInplaneToVolume
test_xformInplaneToVolume ............................. FAILED in 47.584647 seconds
test_xformInplaneToVolume ................................ FAILED in 47.585416 seconds
It seemed to me best to check in the newly compiled myCinterp3.mexmaci64, and open this issue again. Not sure what is up with the last failure. But Matlab2013b is a while ago.
Heads-up ... I just installed this version of Matlab. The program niftiRead hung, sigh. I will look into it.