From ffd7cf405bab0ecf2a73318afc257863c335577c Mon Sep 17 00:00:00 2001 From: Robert <52195853+robdahn@users.noreply.github.com> Date: Wed, 5 Jun 2024 13:11:41 +0200 Subject: [PATCH] Refinements. Added average definition for strings and linked output CSV to open it in Matlab. --- cat_io_xml2csv.m | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cat_io_xml2csv.m b/cat_io_xml2csv.m index d1a13b8e..fadfb99f 100644 --- a/cat_io_xml2csv.m +++ b/cat_io_xml2csv.m @@ -227,7 +227,13 @@ if isnumeric(cell2mat(tab(existxml>0,ci))) % for all numberic fields avg{1,ci} = mean( cell2mat(tab(existxml>0,ci)) ); % average existing else - avg{1,ci} = ''; + % try to use spm_str_manip to extract similar starts/endings + try + [avg{1,ci},C] = spm_str_manip( tab(existxml>0,ci) ,'C'); + if all(cellfun('isempty',C.m)); avg{1,ci}(strfind(avg{1,ci},'{,'):end) = []; end + catch + avg{1,ci} = ''; + end end end end @@ -307,7 +313,8 @@ cat_io_csv(fname,table,'','',struct('delimiter',job.delimiter,'komma','.')) if job.verb - fprintf(' Wrote a %dx%d table in "%s".\n',size(table,1)-1,size(table,2),fname); + fprintf(' Wrote a %dx%d table in ',size(table,1)-1,size(table,2)); + fprintf('%s\n',spm_file( fname ,'link',sprintf('open(''%s'')',fname))); end end