Skip to content

Commit

Permalink
Refinements.
Browse files Browse the repository at this point in the history
Added average definition for strings and linked output CSV to open it in Matlab.
  • Loading branch information
robdahn committed Jun 5, 2024
1 parent ef7fec4 commit ffd7cf4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cat_io_xml2csv.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit ffd7cf4

Please sign in to comment.