0001 function pixFit(x,y,rxn)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 if size(x,2) > size(x,1)
0018 x = x';
0019 end
0020 if size(y,2) > size(y,1)
0021 y = y';
0022 end
0023 xy = [x,y];
0024 xy = unique(xy,'rows');
0025 x = xy(:,1); y = xy(:,2);
0026
0027 if ~all(diff(x)==0)
0028 pixxy = interparc(2000,x,y,'pchip');
0029 pixx = pixxy(:,1);
0030 pixy = pixxy(:,2);
0031 pixy = round(pixy);
0032 pixx = round(pixx);
0033 if size(pixx,2) > size(pixx,1)
0034 pixx = pixx';
0035 end
0036 if size(pixy,2) > size(pixy,1)
0037 pixy = pixy';
0038 end
0039 pixxy = [pixx,pixy];
0040 pixxy = unique(pixxy,'rows');
0041 pixx = pixxy(:,1); pixy = pixxy(:,2);
0042 else
0043 pixy = min(y):max(y);
0044 pixx = ones(1,numel(pixy)).*x(1);
0045 if size(pixx,2) > size(pixx,1)
0046 pixx = pixx';
0047 end
0048 if size(pixy,2) > size(pixy,1)
0049 pixy = pixy';
0050 end
0051 pixxy = [pixx,pixy];
0052 pixxy = unique(pixxy,'rows');
0053 pixx = pixxy(:,1); pixy = pixxy(:,2);
0054 end
0055
0056 path_name = which('Pixdata.mat');
0057 if isempty(path_name)
0058 msgbox({'Pixdata.mat cannot be found!';...
0059 'Make sure the file is present in BiKEGG folder'},'Error','error');
0060 return
0061 end
0062 load(path_name)
0063
0064 if isfield(pix_x,rxn)
0065 fprintf('%s has been replaced with new pixels!\n',rxn)
0066 temp_pixx = pix_x.(rxn);
0067 temp_pixy = pix_y.(rxn);
0068 if size(pixx,2) > size(pixx,1)
0069 pixx = pixx';
0070 end
0071 if size(pixy,2) > size(pixy,1)
0072 pixy = pixy';
0073 end
0074 if size(temp_pixx,2) > size(temp_pixx,1)
0075 temp_pixx = temp_pixx';
0076 end
0077 if size(temp_pixy,2) > size(temp_pixy,1)
0078 temp_pixy = temp_pixy';
0079 end
0080 pixx = [pixx;temp_pixx];
0081 pixy = [pixy;temp_pixy];
0082 pixxy = [pixx,pixy];
0083 pixxy = unique(pixxy,'rows');
0084 pixx = pixxy(:,1); pixy = pixxy(:,2);
0085 pix_x.(rxn) = pixx;
0086 pix_y.(rxn) = pixy;
0087 else
0088 pix_x.(rxn) = pixx;
0089 pix_y.(rxn) = pixy;
0090 end
0091 delete(path_name)
0092 save(path_name,'pix_x','pix_y')
0093