Skip to content

Commit

Permalink
Grin bigdata tools
Browse files Browse the repository at this point in the history
  • Loading branch information
bradmonk committed Aug 18, 2017
1 parent 4211ad1 commit 693c782
Show file tree
Hide file tree
Showing 5 changed files with 11,806 additions and 22 deletions.
188 changes: 185 additions & 3 deletions GRINtoolboxGUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,9 @@
'Position', [0.53 0.50 0.45 0.20], 'FontSize', 12, 'String', 'Plot Lick',...
'Callback', @plotLick, 'Enable','off');

tempfun1H = uicontrol('Parent', explorepanelH, 'Units', 'normalized', ...
'Position', [0.03 0.25 0.45 0.20], 'FontSize', 12, 'String', 'TBD',...
'Callback', @tempfun1, 'Enable','off');
runPCAh = uicontrol('Parent', explorepanelH, 'Units', 'normalized', ...
'Position', [0.03 0.25 0.45 0.20], 'FontSize', 12, 'String', 'PCA',...
'Callback', @runPCA, 'Enable','off');

tempfun2H = uicontrol('Parent', explorepanelH, 'Units', 'normalized', ...
'Position', [0.53 0.25 0.45 0.20], 'FontSize', 12, 'String', 'TBD',...
Expand Down Expand Up @@ -2151,6 +2151,14 @@ function plotTileStats(hObject, eventdata)
end


%keyboard
% REMOVE AXES CLUTTER
%axh{ii}





legpos = { [0.01,0.95,0.15,0.033], ...
[0.01,0.92,0.15,0.033], ...
[0.01,0.89,0.15,0.033], ...
Expand Down Expand Up @@ -2311,6 +2319,177 @@ function savetilesfun(hObject, eventdata)



%----------------------------------------------------
% RUN PCA
%----------------------------------------------------
function runPCA(hObject, eventdata)
% disableButtons; pause(.02);


t1=[];
t2=[];
t3=[];
t4=[];


hb = round(blockSize / 2);

PIM = IMG( hb:blockSize:end, hb:blockSize:end, : , : );

size(PIM)


CSp = squeeze(PIM(:,:,:,GRINstruct.tf(:,2)));

CSm = squeeze(PIM(:,:,:,GRINstruct.tf(:,1)));


size(CSp)
size(CSm)


CSp = CSp(3:7,3:7,:,:);
CSm = CSm(3:7,3:7,:,:);

szCSp = size(CSp)
szCSm = size(CSm)


CSP = squeeze(reshape(CSp,[],1,szCSp(3),szCSp(4)));
CSM = squeeze(reshape(CSm,[],1,szCSm(3),szCSm(4)));

size(CSP)
size(CSM)

CSplus = CSP;
CSminus = CSM;

% save('GRINDATA.mat','CSplus','CSminus')

keyboard

size(CSP)
size(CSM)


figure
imagesc(CSM(:,:,1))

keyboard

%%
X = [];
Y = [];

Y = rand(10,100) .* .01;

figure
plot(Y')

X = X - mean(X);


covMX = 1/(n-1) * sum((X - mean(X)) * (X - mean(X))');






%%

GRINstruct.TreatmentGroups{1}
size(CSm)

GRINstruct.TreatmentGroups{2}
size(CSp)





% PCAdata = permute(CSM,[3 1 2]);
PCAdata = CSM;

size(PCAdata)


MaxComponents = 10;
opt = statset('pca');
opt.MaxIter = 5000;

[PCAScof,PCAval,PCAlat,PCAtsq,PCAexp,PCAmu] = pca( PCAdata ,...
'Options',opt,'NumComponents',MaxComponents);



disp(PCAexp)


figure
plot(PCAScof(:,1:2))
hold on

figure
plot(PCAval)

x = repmat((1:size(PCAScof,1))',1,2);

scatter( x(:) , PCAScof(:) )



clc
sum(PCASexp(:))

% format shortG
% PCASval(1:5 , :)












% [PCAScof,PCASval,PCAlat,PCAtsq,PCASexp,PCAmu] = pca(...
% PCAdata,'Options',opt,'Algorithm','svd','NumComponents',Ncomps,'Centered',false);

% PCAStopcof = PCAScof(1,:);
% PCAScentered = PCASval*PCAScof';
% PCAStsredu = mahal(PCASval,PCASval);
% PCAStsqdiscard = PCASts - PCAStsredu;


% size(PIM)
% size(IMG)
% size(muIMGS)
% GRINstruct.tf
% XLSdata
% blockSize = str2num(imgblockspopupH.String(imgblockspopupH.Value,:));
% pxl = muIMGS(1:blockSize:end,1:blockSize:end,:,:);
% pixels = squeeze(reshape(pxl,numel(pxl(:,:,1)),[],size(pxl,3),size(pxl,4)));
% CSids = unique(GRINstruct.csus);
% for ii = 1:size(pixels,1)
% tiledatX{ii} = 1:size(pixels,2);
% tiledatY{ii} = squeeze(pixels(ii,:,:));
% pha{ii} = squeeze(pixels(ii,:,:));
% end
% ii = 48;
% PCAdata = squeeze(pixels(ii,:,:))';





enableButtons
memocon('Run custom function completed!')
end




Expand Down Expand Up @@ -4346,6 +4525,8 @@ function enableButtons()
visualexplorerH.Enable = 'on';
getAlignH.Enable = 'on';
setAlignH.Enable = 'on';
runPCAh.Enable = 'on';


if numel(size(IMG)) > 1 && numel(size(IMG)) < 4;
openImageJH.Enable = 'on';
Expand Down Expand Up @@ -4376,6 +4557,7 @@ function disableButtons()
visualexplorerH.Enable = 'off';
getAlignH.Enable = 'off';
setAlignH.Enable = 'off';
runPCAh.Enable = 'off';

end

Expand Down
Loading

0 comments on commit 693c782

Please sign in to comment.