From 5a966b0f4b7cee5adbd44a9389e438afbccda2bf Mon Sep 17 00:00:00 2001 From: Anthony Androulakis <43938491+AnthonyAndroulakis@users.noreply.github.com> Date: Mon, 25 Nov 2019 14:46:16 -0500 Subject: [PATCH 1/2] NiiStat & nii_xls2mat changed added compatibility for running NiiStat in Octave, spm12 for Octave and the io package are automatically installed, NiiStat GUI in Octave not yet supported --- NiiStat.m | 41 +++++++++++++++++++++++++++++++++++++---- nii_xls2mat.m | 8 +++++--- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/NiiStat.m b/NiiStat.m index ded4696..7f71046 100644 --- a/NiiStat.m +++ b/NiiStat.m @@ -17,8 +17,37 @@ function NiiStat(xlsname, roiIndices, modalityIndices,numPermute, pThresh, minOv %Examples % NiiStat %use graphical interface % NiiStat('LIME.xlsx',1,1,0,0.05,1) -%test +if exist ("OCTAVE_VERSION", "builtin") > 0 %Octave detected + language='octave' + disp('NiiStat for Octave currently does not support GUI') + usesGUI = false; %GUI currently is supported in Octave + if isempty(strfind(evalc("pkg list"),'pkg/io')) %install io pkg if DNE + disp('Installing io package...') + pkg install -forge io %install io package + disp('io package successfully installed') + end + if exist('spm12-r7487')!=7 %install spm for Octave if DNE + disp('Installing spm12 for Octave... (this might take a few minutes)') + unzip('https://github.com/spm/spm12/archive/r7487.zip',pwd); + urlwrite('https://raw.githubusercontent.com/spm/spm-docker/master/octave/spm12_r7487.patch','spm12_r7487.patch'); + system('patch -p3 -d spm12-r7487 < spm12_r7487.patch'); + cd spm12-r7487/src + system('make PLATFORM=octave'); + system('make PLATFORM=octave install'); + cd ../../ + disp('spm12 for Octave successfully installed') + end + NiiStatpath=pwd; + SPM12path=what('spm12-r7487'); + pkg load io + addpath(NiiStatpath) + addpath(SPM12path.path) + addpath(strcat(SPM12path.path,'/src')) + GUI=[]; +else + language='matlab' +end %Added by Roger to ensure right NiiStatGUI cfg file is opened and used %[filepath, name,ext] = which('NiiStatGUI') @@ -55,12 +84,16 @@ function NiiStat(xlsname, roiIndices, modalityIndices,numPermute, pThresh, minOv fprintf('Version 3 March 2017 of %s %s %s\n', mfilename, computer, version); ver; %report complete version information, e.g. "Operating System: Mac OS X Version: 10.11.5 Build: 15F34" if ~isempty(strfind(mexext, '32')), warning('Some features like SVM require a 64-bit computer'); end; -import java.lang.*; +if language=='matlab' + import java.lang.*; +end hemiKey = 0; interhemi = false; %% added by GY at RD's request statname = ''; -repopath=char(System.getProperty('user.home')); -checkForUpdate(fileparts(mfilename('fullpath'))); +if language=='matlab' + repopath=char(System.getProperty('user.home')); + checkForUpdate(fileparts(mfilename('fullpath'))); +end %checkForMostRecentMatFiles(repopath) % updating SPM temportarily disabled by GY because SPM server is down diff --git a/nii_xls2mat.m b/nii_xls2mat.m index 7440e11..076b786 100644 --- a/nii_xls2mat.m +++ b/nii_xls2mat.m @@ -19,13 +19,15 @@ if ~exist('firstColumnText', 'var') firstColumnText = false; end -if verLessThan('matlab', '7.14') - fprintf('You are running an old version of Matlab that has a fragile xlsread. If the script crashes, use Excel to save as an Excel 5.0/''95 format file\n'); +if (exist ("OCTAVE_VERSION", "builtin") > 0)==0 %if using matlab + if verLessThan('matlab', '7.14') + fprintf('You are running an old version of Matlab that has a fragile xlsread. If the script crashes, use Excel to save as an Excel 5.0/''95 format file\n'); + end end % read the Excel file into cell arrays fprintf(' You will get an error if your Excel file does not have a worksheet named "%s" (case sensitive)\n', worksheetname); try - [~, txt, raw] = xlsread (xlsname, worksheetname,'','basic'); + [~, txt, raw] = xlsread (xlsname, worksheetname); catch fprintf('Unable to read worksheet "%s" from "%s"\n',worksheetname, xlsname); return; From 22d210ccde47e742122174ae64c9f5a41d9111cd Mon Sep 17 00:00:00 2001 From: Anthony Androulakis Date: Tue, 26 Nov 2019 12:37:42 -0500 Subject: [PATCH 2/2] small edit --- nii_xls2mat.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nii_xls2mat.m b/nii_xls2mat.m index 076b786..86df358 100644 --- a/nii_xls2mat.m +++ b/nii_xls2mat.m @@ -27,7 +27,11 @@ % read the Excel file into cell arrays fprintf(' You will get an error if your Excel file does not have a worksheet named "%s" (case sensitive)\n', worksheetname); try - [~, txt, raw] = xlsread (xlsname, worksheetname); + if (exist ("OCTAVE_VERSION", "builtin") > 0)==0 %if using matlab + [~, txt, raw] = xlsread (xlsname, worksheetname,'','basic'); + else + [~, txt, raw] = xlsread (xlsname, worksheetname); + end catch fprintf('Unable to read worksheet "%s" from "%s"\n',worksheetname, xlsname); return;