Commit 6803dce3 authored by zhiguo shang's avatar zhiguo shang
Browse files

Initial commit

parents
%% data loading
fnTr_Orientation = '/project/BICF/BICF_Core/shared/bicf_helpdesk/issue1078_Sammer/data/Train Set for Orientation.xlsx';
fnTe_Orientation = '/project/BICF/BICF_Core/shared/bicf_helpdesk/issue1078_Sammer/data/Test Set for Orientation.xlsx';
fnTr_Screw = '/project/BICF/BICF_Core/shared/bicf_helpdesk/issue1078_Sammer/data/Train Set for Plate Screw.xlsx';
fnTe_Screw = '/project/BICF/BICF_Core/shared/bicf_helpdesk/issue1078_Sammer/data/Test Set for Plate Screw.xlsx';
trO= readtable(fnTr_Orientation,'readvariablenames',false);
teO= readtable(fnTe_Orientation,'readvariablenames',false);
trS= readtable(fnTr_Screw,'readvariablenames',false);
teS= readtable(fnTe_Screw,'readvariablenames',false);
Target_O = [trO.Var2; teO.Var2];
filelist_O = [trO.Var1; teO.Var1];
Target_S = [trS.Var2; teS.Var2];
filelist_S = [trS.Var1; teS.Var1];
fnmrcS = 'datatSn.mrc';
fnmrcO = 'datatOn.mrc';
addpath(genpath('~/code_shang'))
chan = 1;
%data = ReadMRC('datafS0.mrc');
fname = struct();
fname(1).fn = 'datatO.mrc';
fname(2).fn = 'datatOn_centerR.mrc';
fname(3).fn = 'datafS1.mrc';
%ind_remove = [240 246 258 318 319 320 330 1268 1269]; %for HW data
%ind_remove = [240 246 258 318 319 320 330]; %for Orientation data
%data(:,:,ind_remove)=[];
%Target_O(ind_remove)=[];
for fn_i =2%1:2
fnmr = fname(fn_i).fn;
data = ReadMRC(fnmr);
ns = size(data);
datan = zeros(ns(1),ns(2),chan,size(Target_S,1));
%datatOn_centerR.mrc; (segmented-datafS0.mrc; datafS1.mrc),datatSn_centerR.mrc
% raw data (datatS.mrc, datatO.mrc)
%% apply a mask to dataset
ns = size(data);
mask = fuzzymask(ns(1),2,0.48*ns(1),1);
for i = 1:ns(3)
datan(:,:,1,i) = mask.*(data(:,:,i));
end
data = datan;
clear datan;
%imresize(imr,[28 28])
%% ML
%indr = [240 282];
box = 300;
YTrain = categorical([trO.Var2; teO.Var2]);%
XTrain = zeros(box,box,chan,size(YTrain,1));
XTrain(:,:,:,:) = data(150-box/2+1:150+box/2,150-box/2+1:150+box/2,:,1:size(YTrain,1));
%XTrain is a 28-by-28-by-1-by-5000 array
%YTrain is a categorical vector containing the labels for each observation.
ind1 = find(YTrain=='0');
ind2 = find(YTrain=='1');
ind1x = randperm(length(ind1),floor(0.2*length(ind1)));
ind2x = randperm(length(ind2),floor(0.2*length(ind2)));
ind3 = find(YTrain=='2');
ind3x = randperm(length(ind3),floor(0.2*length(ind3)));
idx = [ind1(ind1x)' ind2(ind2x)' ind3(ind3x)'];
%save('idx_O.mat','idx');
load('idx_S.mat');
%idx = randperm(size(XTrain,4),200);
XValidation = XTrain(:,:,:,idx);
XTrain(:,:,:,idx) = [];
YValidation = YTrain(idx);
YTrain(idx) = [];
%Create an imageDataAugmenter object that specifies preprocessing options
%for image augmentation, such as resizing, rotation, translation, and reflection.
imageAugmenter = imageDataAugmenter( ...
'RandRotation',[-22,22], ...
'RandXReflection', true, ...
'RandYReflection', true, ...
'RandXTranslation',[0 0], ...
'RandYTranslation',[0 0]);
imageSize = [box box chan];
augimds = augmentedImageDatastore(imageSize,XTrain,YTrain,'DataAugmentation',...
imageAugmenter);
%Define Network Architecture
%Define the convolutional neural network architecture.
layers = [
imageInputLayer(imageSize)
convolution2dLayer(3,16,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,16,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,16,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,16,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,32,'Padding','same')
batchNormalizationLayer
reluLayer
fullyConnectedLayer(2)
softmaxLayer
classificationLayer];
%
opts = trainingOptions('sgdm', ...
'InitialLearnRate',0.01, ...
'MaxEpochs',100, ...
'MiniBatchSize',128, ...
'Plots','training-progress', ...
'Shuffle','every-epoch', ...
'ValidationFrequency',8, ...
'ValidationPatience',50,...
'Verbose',false, ...
'ValidationData',{XValidation,YValidation});
%% add fearure parameter to CNN net
%% start training
infot=struct();
for i=1%:20
disp(i)
[net, info] = trainNetwork(augimds,layers,opts);
infot(i).info = info;
end
save([fnmr(1:end-4),'_info_100.mat'],'net','infot','-v7.3');
end
return
YPred = classify(net,imdsValidation);
YValidation = imdsValidation.Labels;
accuracy = sum(YPred == YValidation)/numel(YValidation);
%% diplay features
w = net.Layers(2).Weights;
% rescale the weights to the range [0, 1] for better visualization
w = rescale(w);
figure(2)
montage(w)
% rescale the weights to the range [0, 1] for better visualization
wn = net.Layers(10).Weights;
w = wn(:,:,1,:);
w = rescale(w);
figure(3)
montage(w)
%% load targets orientation & plate screw
fnTr_Orientation = '/project/BICF/BICF_Core/shared/bicf_helpdesk/issue1078_Sammer/data/Train Set for Orientation.xlsx';
fnTe_Orientation = '/project/BICF/BICF_Core/shared/bicf_helpdesk/issue1078_Sammer/data/Test Set for Orientation.xlsx';
fnTr_Screw = '/project/BICF/BICF_Core/shared/bicf_helpdesk/issue1078_Sammer/data/Train Set for Plate Screw.xlsx';
fnTe_Screw = '/project/BICF/BICF_Core/shared/bicf_helpdesk/issue1078_Sammer/data/Test Set for Plate Screw.xlsx';
trO= readtable(fnTr_Orientation,'readvariablenames',false);
teO= readtable(fnTe_Orientation,'readvariablenames',false);
trS= readtable(fnTr_Screw,'readvariablenames',false);
teS= readtable(fnTe_Screw,'readvariablenames',false);
Target_O = [trO.Var2; teO.Var2];
filelist_O = [trO.Var1; teO.Var1];
Target_S = [trS.Var2; teS.Var2];
filelist_S = [trS.Var1; teS.Var1];
%% load images
fns = 'mrc';
fnmrcS = 'datatS.mrc';
fnmrcO = 'datatO.mrc';
addpath(genpath('~/code_shang'))
if strcmp(fns,'tif')
fnDir = '/project/BICF/BICF_Core/shared/bicf_helpdesk/issue1078_Sammer/data/TRAIN_AND_TEST';
scripts_dir = pwd;
cd(fnDir)
filelist = dir('**/*.tif');
cd(scripts_dir)
datat = zeros(300,300,size(filelist_O,1));
for i=1:size(filelist_O)
disp(i);
%f = filelist(i);
fn = fullfile(fnDir,char(filelist_O(i)));
v=imread(fn);
if length(size(v))==3
v = squeeze(v(:,:,1));
end
datat(:,:,i)=v;
end
WriteMRC(datat,1,'datatO.mrc');
datat = zeros(300,300,size(filelist_S,1));
for i=1:size(filelist_S)
disp(i);
%f = filelist(i);
fn = fullfile(fnDir,char(filelist_S(i)));
v=imread(fn);
if length(size(v))==3
v = squeeze(v(:,:,1));
end
datat(:,:,i)=v;
end
WriteMRC(datat,1,'datatS.mrc');
else
datatO = ReadMRC(fnmrcO);
datatS = ReadMRC(fnmrcS);
end
%% rotation image to rec according to the frame edge
for k=1%:2
if k==1 ; datat = datatO; fnw = 'datatOn_centerR.mrc'; end
if k==2; datat = datatS; fnw = 'datatSn_cennterR.mrc'; end
nr=5;
href = zeros(300,300,nr);
mask = fuzzymask(300,2,140,1);
for j = 1:nr
for i = 1:300
href(i,:,j)=abs((1:300)-150);
end
href(:,:,j)=0.5*(1-erf(0.3*1.414*(href(:,:,j)-30-j*4))).*mask;
end
%ccc= -1;
ct = 0;
datatn = datat;
[X, Y]=ndgrid(1:300,1:300);
%shf = zeros(2,50);
ccc = zeros(3,size(datat,3))-1;
%% get clear data for rotation align.
datac = datat;
for i=1:size(datat,3)
disp(i);
im = datat(:,:,i);
imb = (im>20);
se = strel('disk',10);
imb = imerode(imb,se);
imb = bwareafilt(imb,1);
se = strel('disk',10);
imbe = imdilate(imb,se);
% detect resize ratio
[indx,indy] = find(imbe(:)>0);
np = length(indy);
pos = [X(indx),Y(indx)];
s_ratio=300/(1+max(max(pos(:,1))-min(pos(:,1)),max(pos(:,2))-min(pos(:,2))));
imr = im.*imbe;
imr = imresize(imr,s_ratio);
ns = floor(size(imr)/2);
datac(:,:,i) = imr(ns(1)-149:ns(1)+150,ns(2)-149:ns(2)+150);
end
%% rotation align
for j=0:2:180
for kk = 1:nr
disp([j kk]);
hrefr = twodrotation(href(:,:,kk),j*pi/180);
hfref=conj(fftn(hrefr));
hrefr1 = twodrotation(href(:,:,kk),(j-90)*pi/180);
hfref1=conj(fftn(hrefr1));
for i=1:size(datat,3)
im = datac(:,:,i);
im = max((im-60),0).*mask;
fx=fftn(im);
%% find rotation angle
% ccc=-1;
hcc=fftshift(real(ifftn(hfref.*fx)));
hmcc = max(hcc(:));
hcc1=fftshift(real(ifftn(hfref1.*fx)));
hmcc1 = max(hcc1(:));
%ct(j/2+1) = (hmcc-hmcc1)/sum(sum(href(:,:,k)));
if (hmcc-hmcc1)/sum(sum(href(:,:,kk))) > ccc(1,i)
ccc(1,i) = (hmcc-hmcc1)/sum(sum(href(:,:,kk)));
ccc(2,i) = j;
[maxval, is, js] = max2d(hcc);
ccc(3,i) = max(100,min(js,200));
end
end
end
end
%% seg,rot,cent images
for i=1:size(datat,3)
disp([i i]);
imf = datac(:,:,i);
imn = zeros(400,400);
imn(51:350,200-149-(ccc(3,i)-150):200+150-(ccc(3,i)-150)) = imf;
imn = twodrotation(imn,-ccc(2,i)*pi/180);
datatn(:,:,i) = imn(51:350,51:350);
end
WriteMRC(datatn,1,fnw);
end
function [map,s,hdr,extraHeader]=ReadMRC(filename,startSlice, numSlices,test) % function map=ReadMRC(filename); --all defaults. Or, % function [map,s]=ReadMRC(filename,startSlice, numSlices,test) or, % function [fh,s]=ReadMRC(filename,startSlice,-1,test) % Read a 3D map from an .mrc file and return a structure containing various parameters read from the file. % This function reads 2d and 3d real maps in byte, int16 and float32 modes. % s.nz gives the total number of slices, and calling [m s]=ReadMRC(name,1,0) % will give you that value. startSlice starts at 1. % If the numSlices argument is negative, no data are read; instead the file % handle fh is returned instead of m. Subsequent calls to fread() will then load the % data. For example, % [h s]=ReadMRC(name,1,-1); % for i=1:s.nz % m1=fread(h,s.nx*s.ny,s.string); % m1=reshape(m1,s.nx,s.ny); % --do something with m1-- % end; % fclose(h); % If a third output argument is specified, the header (as a vector of % int32) is returned. For non-extended files it has 256 entries. % % Added interpretation of the extended header (length = c(2) which is important with imod and % serialEM at Brandeis. lw 15 Aug 07 % Added error tests. fs 2 Sep 07 % Added the ability to read selected slices, and read big-endian files % fs 17 Sep 09 % Changed the a array so that the returned s values are doubles. 5 Nov 09 % Added data mode 6 (unsigned int16) fs 20 Jan 10 % Changed s fields to doubles fs 20 Feb 10 % Added fields s.mx, s.my and s.mz (unit cell dimensions), s.org (origin % offset) along with s.pixA the pixel (voxel) size, which is computed as % s.pixA=s.rez/s.mx. The minimum, maximum and average pixel values are % returned as s.mi, s.ma and s.ma.fs 10 Jul 11 if nargin<2 startSlice=1;end;if nargin<3 numSlices=inf;end;if nargin<4 test=0;end; hdr=[]; % We first try for little-endian dataf=fopen(filename,'r','ieee-le');if f<0 error(['in ReadMRC the file could not be opened: ' filename])end;% Get the first 10 values, which are integers:% nc nr ns mode ncstart nrstart nsstart nx ny nza=fread(f,10,'*int32'); if abs(a(1))>1e5 % we must have the wrong endian data. Try again. fclose(f); f=fopen(filename,'r','ieee-be'); a=fread(f,10,'int32'); % convert to doubles end; if test a(1:10) end; mode=a(4); % Get the next 12 (entries 11 to 23), which are floats. % the first three are the cell dimensions. % xlength ylength zlength alpha beta gamma mapc mapr maps % amin amax amean. [b,cnt]=fread(f,12,'float32'); if test b end; % b(4,5,6) angles s.mi=b(10); % minimum value s.ma=b(11); % maximum value s.av=b(12); % average value s.rez=double(b(1)); % cell size x, in A. % get the next 30, which brings us up to entry no. 52. [c,cnt]=fread(f,30,'*int32'); if test, c(1:3), end; % c(2) is the extended header in bytes. % the next two are supposed to be character strings. [d,cnt]=fread(f,8,'*char'); d=d'; s.chars=d; if test d end; % Two more ints... [e,cnt]=fread(f,2,'*int32'); if test, e, end; % up to 10 strings.... ns=min(e(2),10); for i=1:10 [g,cnt]=fread(f,80,'char'); str(i,:)=char(g)'; end; % disp('header:'); disp(' '); % disp(str(1:ns,:)); % disp(' '); s.header=str(1:ns,:); % Get ready to read the data. s.nx=double(a(1)); s.ny=double(a(2)); s.nz=double(a(3)); s.mx=double(a(8)); s.my=double(a(9)); s.mz=double(a(10)); s.org=double(a(5:7)); s.pixA=s.rez/s.mx; switch mode case 0 string='*uint8'; pixbytes=1; case 1 string='*int16'; pixbytes=2; case 2 string='*float32'; pixbytes=4; case 6 string='*uint16'; otherwise error(['ReadMRC: unknown data mode: ' num2str(mode)]); end; s.string=string; % fseek(f,1024,'bof'); if(c(2)>0) [extraHeader,cnt]=fread(f,c(2)/4,'*float32'); if test disp(['Read extra header of ',num2str(c(2)/4),' floats!']) extraHeader(1:16) end; % disp((ex_header')); end skipbytes=0; if startSlice>1 skipbytes=(startSlice-1)*s.nx*s.ny*pixbytes; fseek(f,skipbytes,'cof'); end; if numSlices<0 map=f; return;end; nz=max(0,min(s.nz-(startSlice-1),numSlices));ndata=s.nx * s.ny *nz; if test string ndataend;%fclose(f);%f=fopen(filename,'r','ieee-le');%map=fread(f,ndata,string);[map,dcnt]=fread(f,ndata,string);if nargout>2 % We read an image of the header frewind(f); [hdr cnt]=fread(f,256+c(2)/4,'*int32'); end; %if dcnt ~= ndata % error('ReadMRC: not enough data in file.'); %end; fclose(f); map=reshape(map,s.nx,s.ny,nz); % % f=fopen(filename,'r','ieee-be'); % fseek(f,1024,'bof'); % % if(c(2)>0) % [extraHeader,cnt]=fread(f,c(2)/4,'*float32'); % disp(['Read extra header of ',num2str(c(2)/4),' floats!']) % % disp((ex_header')); % end % fclose(f);
\ No newline at end of file
function WriteMRC(map,pixA,filename,mode) % function WriteMRC(map,pixA,filename,mode) % Write out a 2D image or a 3D volume as an MRC map file, for example for viewing in % Chimera. 'map' is the 3D array, pixA is the voxel size in angstroms. % Mode sets the data type: % 0: uint8 % 1: int16 % 2: single (default) % 6: uint16 % % fixed for 2D output as well. fs 28 Aug 07 % % % Test program: create an ellipsoid and store it as a map file. % [x y z]=ndgrid(-32:31); % m=(x.^2+(y*1.5).^2+z.^2)>20^2; % WriteMRC(m,1,'maptest.mrc'); if nargin<4 mode=2;end; switch mode case 0 string='uint8'; case 1 string='int16'; case 2 string='float32'; case 6 string='uint16'; otherwise error(['Invalid data mode: ' num2str(mode)]); end;sizes=size(map);if numel(sizes)<3 sizes(3)=1;end; org=-floor(sizes/2); % Default origin f=WriteMRCHeader(map,pixA,filename,sizes(3),org,mode);count2=fwrite(f,map,string);fclose(f); return;
\ No newline at end of file
function handle=WriteMRCHeader(map,pixA,filename,nim,org,mode) % function handle=WriteMRCHeader(map,pixA,filename,nim,org,mode) % Write out the header of an MRC map file, and leave the file open, % returning the file handle, so that data can be written sequentially into % the file and then the file closed. Data are written in little-endian style, % with the datatype specified by mode. By default mode=2, which means % float32 values. Other options are 0: uint8; 1: int16. % If you want to write more slices than are contained in map, give the % total number of slices (or 2d images) in the optional nim argument. The % optional argument org is the starting point of the volume, an integer in % units of voxels. The default value is [c c c] where c=-floor(n/2). % % Example: write out 10,000 random images. % images=randn(64,64,1000); % f=WriteMRCHeader(images,2.8,'test.mrc',10000); % fwrite(f,images,'float32'); % for i=2:10 % images=randn(64,64,1000); % fwrite(f,images,'float32'); % end; % fclose(f); % % Changed Jul2011 to support the origin argument. fs % Changed Dec2011 to support the mode argument. % Files are always written in little-ended format. % Figure out if we have a little-ended machine. q=typecast(int32(1),'uint8'); machineLE=(q(1)==1); % true for little-endian machine hdr=int32(zeros(256,1)); sizes=size(map); if numel(sizes)<3 sizes(3)=1;end; if nargin >3 sizes(3)=nim; end; if nargin<5 org=-floor(sizes/2); % Default origin is such that else org=org(:);end;if nargin<6 mode=2;end; % Get statisticsmap=reshape(map,numel(map),1); % convert it into a 1D vectortheMean=mean(single(map));theSD=std(single(map));theMax=single(max(map));theMin=single(min(map)); % Number of voxels in the map or submaphdr(1:3)=sizes; % number of columns, rows, sectionshdr(4)=mode; % mode: real, float valueshdr(5:7)=org; % origin of the map % Number of voxels in the full unit cellhdr(8:10)=hdr(1:3); % number of intervals along x,y,z% Unit cell sizes and angleshdr(11:13)=typecast(single(single(hdr(8:10))*pixA),'int32'); % Cell dimensionshdr(14:16)=typecast(single([90 90 90]),'int32'); % Angleshdr(17:19)=(1:3)'; % Axis assignments hdr(20:22)=typecast(single([theMin theMax theMean]'),'int32');hdr(23)=0; % Space group 0 (default)if machineLE hdr(53)=typecast(uint8('MAP '),'int32'); hdr(54)=typecast(uint8([68 65 0 0]),'int32'); % LE machine stamp.else hdr(53)=typecast(uint8(' PAM'),'int32'); % LE machine stamp, for writing with BE machine. hdr(54)=typecast(uint8([0 0 65 68]),'int32');end hdr(55)=typecast(single(theSD),'int32'); handle=fopen(filename,'w','ieee-le'); % Here we force little-ended order.if handle<0 error(['File could not be opened for writing: ' filename]);end; count1=fwrite(handle,hdr,'int32');
\ No newline at end of file
%% data loading
fnTr_Orientation = '/project/BICF/BICF_Core/shared/bicf_helpdesk/issue1078_Sammer/data/Train Set for Orientation.xlsx';
fnTe_Orientation = '/project/BICF/BICF_Core/shared/bicf_helpdesk/issue1078_Sammer/data/Test Set for Orientation.xlsx';
fnTr_Screw = '/project/BICF/BICF_Core/shared/bicf_helpdesk/issue1078_Sammer/data/Train Set for Plate Screw.xlsx';
fnTe_Screw = '/project/BICF/BICF_Core/shared/bicf_helpdesk/issue1078_Sammer/data/Test Set for Plate Screw.xlsx';
trO= readtable(fnTr_Orientation,'readvariablenames',false);
teO= readtable(fnTe_Orientation,'readvariablenames',false);
trS= readtable(fnTr_Screw,'readvariablenames',false);
teS= readtable(fnTe_Screw,'readvariablenames',false);
Target_O = [trO.Var2; teO.Var2];
filelist_O = [trO.Var1; teO.Var1];
Target_S = [trS.Var2; teS.Var2];
filelist_S = [trS.Var1; teS.Var1];
fnmrcS = 'datatSn_cennterR.mrc';
fnmrcO = 'datatOn.mrc';
addpath(genpath('~/code_shang'))
%imresize(imr,[28 28])
%% screw images: class 1 feature segmentation based on distribution of densiy
data = ReadMRC(fnmrcS);
ind = find(Target_S == 1);
data1 = data(:,:,ind);
step = 50;
vmin = min(data1(:));
vmax = max(data1(:));
interv = (vmax-vmin)/50;
hist_v = zeros(step,size(data1,3));
for i = 1:size(data1,3)
im = data1(:,:,i);
for j = 1:step
hist_v(j,i) = length(find(im(:)>vmin+j*interv-interv & im(:)<vmin+j*interv));
end
end
figure(3); plot(hist_v(6:end,:));
figure(1); plot(sum(hist_v(6:end,:),2));
%%
ind = find(Target_S == 0);
data1 = data(:,:,ind);
step = 50;
vmin = min(data1(:));
vmax = max(data1(:));
interv = (vmax-vmin)/50;
hist_v0 = zeros(step,size(data1,3));
for i = 1:size(data1,3)
im = data1(:,:,i);
for j = 1:step
hist_v0(j,i) = length(find(im(:)>vmin+j*interv-interv & im(:)<vmin+j*interv));
end
end
figure(4); plot(hist_v0(6:end,:));
figure(2); plot(sum(hist_v0(6:end,:),2));
return
% 26*interv = 160-vmin : 160 is the idea number to sperate the signals for
% channels
data = data - min(data(:));
bmp = data < 160;
dataf = (data.*bmp/160+(1-bmp))*255;
WriteMRC(dataf,1,'datafS0.mrc');
dataf = (data-160).*(1-bmp)/(vmax-vmin-160)*255;
WriteMRC(dataf,1,'datafS1.mrc');
return
%% Orietation images: class 1 feature segmentation based on distribution of densiy
data = ReadMRC(fnmrcO);
ind = find(Target_O == 2);
data1 = data(:,:,ind);
step = 50;
vmin = min(data1(:));
vmax = max(data1(:));
interv = (vmax-vmin)/50;
hist_v = zeros(step,size(data1,3));
for i = 1:size(data1,3)
im = data1(:,:,i);
for j = 1:step
hist_v(j,i) = length(find(im(:)>vmin+j*interv-interv & im(:)<vmin+j*interv));
end
end
figure(3); plot(hist_v(8:end,:));
figure(2); plot(sum(hist_v(8:end,:),2)/length(ind));
%(8 ~ 42)*interv + min(data(:)) = 51 ~269 -33 : 160 is the idea number to sperate the signals for
% channels
data = max(data-18,0);
data = min(data,269-18);
WriteMRC(data,1,'datafO.mrc');
fn1='datatS_info.mat';
fn2='datatSn_centerR_info.mat';
fn3='datafS1_info.mat';
load(fn3);
s1 = infot;
%fn1 = 'datatO_info.mat';
%fn2 = 'datatOn_centerR_info.mat';
load(fn1);
s = infot;
load(fn2);
sn = infot;
a=zeros(20,31);
b=a;
for i=1:20
c = s(i).info.TrainingAccuracy;
cc = [c(1) c(8:8:end)];
a(i,1:length(cc)) = cc;
c = s(i).info.ValidationAccuracy;
cc = [c(1) c(8:8:end)];
b(i,1:length(cc)) = cc;
end
c1=sum(a,1)./sum(a>0,1);
c2=sum(b,1)./sum(b>0,1);
figure(1); plot(c1,'x-b')
figure(1);hold on; plot(c2,'x-r')
for i=1:20
c = sn(i).info.TrainingAccuracy;
cc = [c(1) c(8:8:end)];
a(i,1:length(cc)) = cc;
c = sn(i).info.ValidationAccuracy;
cc = [c(1) c(8:8:end)];
b(i,1:length(cc)) = cc;
end
c1=sum(a,1)./sum(a>0,1);
c2=sum(b,1)./sum(b>0,1);
figure(1); hold on; plot(c1,'o-b')
figure(1);hold on; plot(c2,'o-r')
xlabel('Iteratons (per 8)')
ylabel('Accuracy (%)')
legend('raw train','raw validation','cleaned train','cleaned validation');
set(gca,'fontweight','bold'); set(gca,'fontsize',14,'linewidth',3);
set(gcf,'color','w');
%axis([0 31 80 100]); %90.2,88,8; 97.7, 98.3
return
for i=1:20
c = s1(i).info.TrainingAccuracy;
cc = [c(1) c(8:8:end)];
a(i,1:length(cc)) = cc;
c = s1(i).info.ValidationAccuracy;
cc = [c(1) c(8:8:end)];
b(i,1:length(cc)) = cc;
end
c1=sum(a,1)./sum(a>0,1);
c2=sum(b,1)./sum(b>0,1);
figure(1); hold on; plot(c1,'*-b')
figure(1);hold on; plot(c2,'*-r')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment