updateScores : updates the raw scores using scoreFunction and coefficients Coefficients are the A or E (can be a neural network) that were created during training. It saves the loaded data (seg files) at the same location with the new scores. INPUT : dirname : directory with seg files xChoice : 'segs' to load _seg.mat files, anything else loads *_seg*.mat coefficients : A (segs) or E (regs), coefficients or network scoreFunction : function used to calculate score Copyright (C) 2016 Wiggins Lab Written by Stella Stylianidou. University of Washington, 2016 This file is part of SuperSegger. SuperSegger is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SuperSegger is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SuperSegger. If not, see <http://www.gnu.org/licenses/>.
0001 function updateScores(dirname,xChoice,coefficients,scoreFunction) 0002 % updateScores : updates the raw scores using scoreFunction and coefficients 0003 % Coefficients are the A or E (can be a neural network) that were created 0004 % during training. 0005 % It saves the loaded data (seg files) at the same location with the new scores. 0006 % 0007 % INPUT : 0008 % dirname : directory with seg files 0009 % xChoice : 'segs' to load _seg.mat files, anything else loads *_seg*.mat 0010 % coefficients : A (segs) or E (regs), coefficients or network 0011 % scoreFunction : function used to calculate score 0012 % 0013 % Copyright (C) 2016 Wiggins Lab 0014 % Written by Stella Stylianidou. 0015 % University of Washington, 2016 0016 % This file is part of SuperSegger. 0017 % 0018 % SuperSegger is free software: you can redistribute it and/or modify 0019 % it under the terms of the GNU General Public License as published by 0020 % the Free Software Foundation, either version 3 of the License, or 0021 % (at your option) any later version. 0022 % 0023 % SuperSegger is distributed in the hope that it will be useful, 0024 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0025 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0026 % GNU General Public License for more details. 0027 % 0028 % You should have received a copy of the GNU General Public License 0029 % along with SuperSegger. If not, see <http://www.gnu.org/licenses/>. 0030 0031 0032 if ~strcmp (xChoice,'segs') && ~strcmp (xChoice,'regs') 0033 disp('no x chosen, optimizing segments'); 0034 xChoice = 'segs'; 0035 end 0036 0037 0038 if strcmp (xChoice,'segs') 0039 contents = dir([dirname,'*_seg.mat']); 0040 else 0041 contents = dir([dirname,'*_seg*.mat']); 0042 end 0043 0044 for i = 1 : numel(contents) 0045 dataname = [dirname,contents(i).name]; 0046 data = load(dataname); 0047 if strcmp (xChoice,'segs') 0048 X = data.segs.info; 0049 [data.segs.scoreRaw] = scoreFunction (X,coefficients)'; 0050 data.regs.score = ones(data.regs.num_regs,1); 0051 else 0052 X = data.regs.info; 0053 [data.regs.scoreRaw] = scoreFunction (X,coefficients)'; 0054 end 0055 % save data with updated scores 0056 save(dataname,'-STRUCT','data'); 0057 end 0058 0059 end 0060