diff --git a/functions/CellSortXCorr.m b/functions/CellSortXCorr.m
index 0f38689..790cffe 100644
--- a/functions/CellSortXCorr.m
+++ b/functions/CellSortXCorr.m
@@ -30,8 +30,8 @@ function CellSortXCorr(inFolder, outFolder, nSubIm, binningFactor)
%go into folder
cd(inFolder);
cd(folders(f).name);
- greenFiles = dir('ChanB_*_*.tif');
- redFiles = dir('ChanA_*_*.tif');
+ greenFiles = dir('ChanA_*_*.tif');
+ redFiles = dir('ChanB_*_*.tif');
%check if fileNumber is the same
if size(greenFiles, 1) ~= size(redFiles, 1)
error(['Unequal number of files in trial folder "', folders(f).name, '"!!']);
diff --git a/functions/matVis.m b/functions/matVis.m
index 3577c38..c3a5b8a 100644
--- a/functions/matVis.m
+++ b/functions/matVis.m
@@ -1,5 +1,5 @@
function varargout = matVis(varargin)
-% matVis(data1, data2, ... , 'PropertyName', PropertyValue, ...)
+%% matVis(data1, data2, ... , 'PropertyName', PropertyValue, ...)
%**************************************************************************
% GUI for displaying data sets of arbitrary dimension using 2D images and
% 1D profiles. Key features of matVis include
@@ -28,7 +28,7 @@
% - Use 'startPar' argument to selectively overwrite configuration
% paramaters (see below for list of start parameters)
% - Check for updates from within the main GUI
-%
+%
% Input Arguments
% -none- Select image file(s) (including matrices
% saved as .mat-file, multi-image tif, Zeiss
@@ -147,7 +147,7 @@
%**************************************************************************
% Copyright 13.06.2012, S. Junek (sjunek@gwdg.de)
%
-versionNumber = 1.101; % Current version number of matVis
+versionNumber = 1.102; % Current version number of matVis
%% Check Matlab version and installed toolboxes
v = version;
% v = num2str(v(1:3));
@@ -274,21 +274,50 @@
data{i} = squeeze(data{i}); %#ok
%Tif (possibly multi-image)
elseif strcmp(ext, '.tif') || strcmp(ext, '.tiff')
- ww = imfinfo([p,f{i}]);
- im1 = imread([p f{i}],1);
- switch ww(1).BitDepth
- case 8
- d{i} = zeros([size(im1),numel(ww)],'uint8'); %#ok
- case 16
- d{i} = zeros([size(im1),numel(ww)],'uint16'); %#ok
- end
- if strcmp(ww(1).PhotometricInterpretation, 'RGB')
- data{i} = imread([p,f{i}]); %#ok
+ tic
+ % Speed optimized version, not tested on color tifs
+ ww = imfinfo([p,f{i}]); % Tif file information
+ nCol = ww(1).SamplesPerPixel; % Number of color channels (NOT TESTED!)
+ nImg = numel(ww); % Number of frames
+ if ww(1).BitsPerSample(1) <= 16
+ out = zeros(ww(1).Height, ww(1).Width,nCol, nImg,'uint16');
else
- for j = 1:numel(ww)
- data{i}(:,:,j) = imread([p,f{i}],j,'Info',ww); %#ok
+ out = zeros(ww(1).Height, ww(1).Width, nCol, nImg);
+ end
+ readLength = [ww(1).Width ww(1).Height]; % order has to be reversed for correct reading of data (don't know why)
+ gl_fid = fopen ([p,f{i}], 'r', 'l');
+ for j=1:nImg
+ for colIdx=1:nCol
+ fseek(gl_fid, ww(j).StripOffsets(colIdx) , 'bof');
+ if ww(j).BitsPerSample(colIdx) <=8
+ out(:,:,colIdx,j) = uint16(fread(gl_fid,readLength, '*uint8'))';
+ elseif ww(j).BitsPerSample(colIdx) <=16
+ out(:,:,colIdx,j) = fread(gl_fid, readLength, '*uint16')';
+ else ww(j).BitsPerSample(colIdx)
+ out(:,:,colIdx,j) = fread(gl_fid,readLength, 'uint32')';
+ end
end
end
+ fclose(gl_fid);
+ data{i} = squeeze(out);
+ clear out;
+ toc
+ % Old (slow) version:
+% ww = imfinfo([p,f{i}]);
+% im1 = imread([p f{i}],1);
+% switch ww(1).BitDepth
+% case 8
+% d{i} = zeros([size(im1),numel(ww)],'uint8'); %#ok
+% case 16
+% d{i} = zeros([size(im1),numel(ww)],'uint16'); %#ok
+% end
+% if strcmp(ww(1).PhotometricInterpretation, 'RGB')
+% data{i} = imread([p,f{i}]); %#ok
+% else
+% for j = 1:numel(ww)
+% data{i}(:,:,j) = imread([p,f{i}],j,'Info',ww); %#ok
+% end
+% end
defaultColormap{i} = []; %#ok
elseif strcmp(ext, '.lsm')
dimNames{1} = 'x';
@@ -484,16 +513,20 @@
withAlpha = 1;
currAlphaMap = [];
case 'dimNames'
- dimNames = val;
- if size(dimNames,1) ~= ndims(varargin{1})
- display(char('Error: Dimension of matrix and number of strings have to be equal!',...
- 'Type "help matVis" for help.'));
- return
+ if length(val) ~= ndims(varargin{1})
+ error(sprintf('Dimension of matrix and number of ''dimNames'' have to be equal!\nUse help matVis for help.'));
end
+ dimNames = val;
case 'dimUnits'
+ if length(val) ~= ndims(varargin{1})
+ error(sprintf('Dimension of ''dimUnits'' mut fit matrix dimension!\nUse help matVis for help.'));
+ end
dimUnits = val;
withDimUnits = 1;
case 'matNames'
+ if length(val) ~= length(data)
+ error(sprintf('Dimension of ''matNames'' mut fit number of provided data sets!\nUse help matVis for help.'));
+ end
varName = val;
allNames = '';
for j=1:length(varName)
@@ -631,6 +664,7 @@
exportWin = []; %Temp. window used for data export
subPlotHandles = []; %Handles to subplot axes in Plots Window
subPlotPlots = []; %Handles to data displayed in Plots Window
+ subPlotPlotsAlpha = []; %Handles to data displayed in Plots Window
posLine = []; %Lines in plots indicating current value of diplayed dimension
lineHorZoom = []; %Handles to position lines in Image and Zoom Windows
lineVertZoom = [];
@@ -666,6 +700,7 @@
exportWin = matlab.ui.Figure.empty; %Temp. window used for data export
subPlotHandles = matlab.graphics.chart.primitive.Line.empty; %Handles to subplot axes in Plots Window
subPlotPlots = matlab.graphics.chart.primitive.Line.empty; %Handles to data displayed in Plots Window
+ subPlotPlotsAlpha = matlab.graphics.chart.primitive.Line.empty; %Handles to data displayed in Plots Window
posLine = matlab.graphics.chart.primitive.Line.empty; %Lines in plots indicating current value of diplayed dimension
lineHorZoom = matlab.graphics.chart.primitive.Line.empty; %Handles to position lines in Image and Zoom Windows
lineVertZoom = matlab.graphics.chart.primitive.Line.empty;
@@ -718,6 +753,7 @@
rgbStretchSldVal = [0 1]; %Slider value for RGB stretch mode
cmap = gray(255); %Current colormap
plotValues = []; %Values used in plots
+plotValuesAlpha = []; %AlphaValues used in plots
isPlaying = 0; %Playing status
playDim = []; %Dimension which was selected for play mode
projMethod = 0; %Number indicating method for projection.
@@ -748,6 +784,7 @@
roiSize = []; %Number of pixels of Roi
roiList = []; %List of Rois
roiLine = []; %Handle to lines indicating Rois
+roiCenterIndicator = []; %Handle to '+' (text) indicating center of current Roi
nRois = 0; %Number of Rois
roiText = []; %Handle to text (numbers) for Rois
roiName = []; %Roi name of currently selected roi above roiAxes
@@ -760,11 +797,15 @@
tbRoiRotate = []; %Handle for toggle button for rotating Rois
tbRoiScale = []; %Handle for toggle button for scaling Rois
tb_newRoi = []; %Handle for toggle buttons to creat new rois
+bt_copyRoi = [];
bt_deleteRoi = [];
bt_roiExport = [];
bt_exportRoiData = [];
-newRoiSize = 5; %Size of "one-click" ROIs (radius, squares will have 2*newRoiSize+1 side length)
-jump2ROIPos_cb = 1; % Handle to checkbox indidacting whether the current position chould be changed when a new ROI is selected (jump to position where ROI was created)
+newRoiSize = 5; %Size of "one-click" ROIs (radius, squares will have 2*newRoiSize+1 side length)
+jump2ROIPos_cb = 1; %Handle to checkbox indidacting whether the current position chould be changed when a new ROI is selected (jump to position where ROI was created)
+etxt_newRoiName = [];
+txt_RoiPropWinTxt = []; %Handle Textfield in Figure for ROI update of ROI settings
+
profilePoints = [];
profileInwork = 0;
profileComplete = 0;
@@ -2371,6 +2412,47 @@
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN;
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN];
icon_Stop = repmat(icon_Stop,[1 1 3]);
+copyRoiBt = [
+ NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN NaN 0 0 0 0 0 0 0 0 0 0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN 0 NaN NaN NaN 1 1 1 1 1 1 1 0 1 NaN NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN 0 NaN NaN 1 NaN NaN NaN NaN NaN NaN NaN 0 NaN 1 NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN 0 NaN NaN 1 NaN NaN NaN NaN NaN NaN NaN 0 NaN 1 NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN NaN 0 0 0 0 0 0 0 0 0 0 NaN NaN 1 NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN NaN NaN NaN 1 NaN NaN NaN NaN NaN NaN NaN NaN NaN 1 NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN NaN NaN NaN 1 NaN NaN NaN NaN NaN NaN NaN NaN NaN 1 NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN NaN NaN NaN NaN 1 1 1 1 1 1 1 1 1 NaN NaN NaN NaN NaN NaN NaN NaN];
+
+copyRoiBt(:,:,2) = [
+ NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN NaN 0 0 0 0 0 0 0 0 0 0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN 0 NaN NaN NaN 0 0 0 0 0 0 0 0 0 NaN NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN 0 NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN 0 NaN 0 NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN 0 NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN 0 NaN 0 NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN NaN 0 0 0 0 0 0 0 0 0 0 NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN NaN NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN NaN NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN NaN NaN NaN NaN 0 0 0 0 0 0 0 0 0 NaN NaN NaN NaN NaN NaN NaN NaN];
+
+copyRoiBt(:,:,3) = [
+ NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN NaN 0 0 0 0 0 0 0 0 0 0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN 0 NaN NaN NaN 0 0 0 0 0 0 0 0 0 NaN NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN 0 NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN 0 NaN 0 NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN 0 NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN 0 NaN 0 NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN NaN 0 0 0 0 0 0 0 0 0 0 NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN NaN NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN NaN NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN NaN NaN 0 NaN NaN NaN NaN NaN NaN NaN;
+ NaN NaN NaN NaN NaN NaN NaN NaN NaN 0 0 0 0 0 0 0 0 0 NaN NaN NaN NaN NaN NaN NaN NaN];
+
+
+
% hand3 = ...
% [NaN NaN NaN NaN NaN NaN NaN 0 0 NaN NaN NaN NaN NaN NaN NaN;
@@ -2554,8 +2636,8 @@
% Toggle button to lock plot x-axes to zoom values
tb_lockPlots2Zoom(i) = uicontrol('Parent',panel_positionControls, 'Style', 'Togglebutton', 'Callback', {@updateZoom,i,'lockBt'}, 'Units', 'Pixel', ...
'Position', [295 (nDim-i+2)*40+9 15 15], 'Value',0 , 'CData', lockOpen,...
- 'BackgroundColor', get(gui, 'Color'),'Tooltipstring', 'Locks x-lim of plot axes to zoom interval. Requires pressed ''x-lim button'' (under plot controls) ',...
- 'Tag', ['Lock x-lim of plot axes to zoom interval.' char(10) 'Requires pressed ''x-lim button'' (under plot controls) ']); %#ok
+ 'BackgroundColor', get(gui, 'Color'),'Tooltipstring', sprintf('Locks x-lim of plot axes to zoom interval. Requires pressed ''x-lim button'' (under plot controls)\nIn RGB-Stretch mode it limits the stretch range.'),...
+ 'Tag', ['Lock x-lim of plot axes to zoom interval.' char(10) 'Requires pressed ''x-lim button'' (under plot controls).' char(10) 'In RGB-Stretch mode it limits the stretch range.']); %#ok
end
if customDimScale
set(panel_positionControls, 'Children',[tb_lockPlots2Zoom cbPlots txt_zoomWidthScale txt_zoomDownScaled txt_zoomUpScaled txt_pxScale txt_zoomWidth btPlayZoom btPlayAll sld_up sld_down sld txt_dimName dimSize flipdim(reshape((cat(1,etxt_down,etxt_up)),[1 2*nDim]),2) etxt(nDim:-1:1)]);
@@ -3367,7 +3449,7 @@ function popCallback(varargin)
else
%Exchange x and y
for ii=1:nMat
- currIm{ii} = currIm{ii}';
+ currIm{ii} = permute(currIm{ii},[2 1 3]);
end
set(pop(1), 'Value', xySel(2));
set(pop(2), 'Value', xySel(1));
@@ -3444,27 +3526,30 @@ function projCallback(varargin)
%Update projection method
prevProjMethod = projMethod;
projMethod = get(projMethodPop, 'Value') - 1;
+ if rgbCount == get(projDimPop,'Value')
+ projMethod =0;
+ set(projMethodPop, 'Enable','off')
+ %set(projMethodPop, 'Value', 1)
+ else
+ set(projMethodPop, 'Enable','on')
+ end
set([sld etxt btPlayAll btPlayZoom cbPlots tb_lockPlots2Zoom], 'Enable', 'on');
if projMethod
if isPlaying
isPlaying = 0;
set(btPlayAll, 'CData', arrow, 'Value', 0);
end
- set(tbSwitchRGB, 'Enable', 'off');
+ %set(tbSwitchRGB, 'Enable', 'off');
set(btMean, 'Enable', 'off', 'CData', squeeze(meanBt{1}));
%Update projection dimension
- s = get(projDimPop, 'String');
- projDim = s{get(projDimPop, 'Value')};
- projDim = find(strcmp(projDim, dimNames));
+ notXY = setdiff(1:nDim, xySel);
+ projDim = notXY(get(projDimPop, 'Value'));
set([sld(projDim) etxt(projDim) btPlayAll(projDim) btPlayZoom(projDim) tb_lockPlots2Zoom(projDim)], 'Enable', 'off');
%Allow no plots other than xy dimension (plot dimensions)
- notXY = 1:nDim;
- notXY(notXY==xySel(1)) = [];
- notXY(notXY==xySel(2)) = [];
set(cbPlots(notXY), 'Value', 0 ,'Enable', 'off'); %necessary when call from WindowCloseRequestFcn
plotSel(notXY) = 0;
else
- set(tbSwitchRGB, 'Enable', 'on');
+ %set(tbSwitchRGB, 'Enable', 'on');
set(btMean, 'Enable', 'on', 'CData', squeeze(meanBt{get(btMean, 'UserData')+1}));
set([tbWin(3) cbPlots tbShowObjects], 'Enable', 'on');
end
@@ -3669,7 +3754,6 @@ function toggleMenuBars(varargin)
%Callback for RGB toggle button
function switchRGB(varargin)
if debugMatVis, debugMatVisFcn(1); end
- nonXY = setdiff(1:nDim, xySel);
rgbCount = mod(rgbCount + 1 , nDim - 1);
%RGB mode off
if rgbCount == 0
@@ -3703,7 +3787,8 @@ function switchRGB(varargin)
if rgbCount == 1 || any(get(bg_colormap, 'SelectedObject')==[cmManual cmImage cmZoom cmThresh])
set(bg_colormap, 'SelectedObject', cmGlobal);
end
- rgbDim = nonXY(rgbCount);
+ notXY = setdiff(1:nDim, xySel);
+ rgbDim = notXY(rgbCount);
set(tbSwitchRGB, 'String', dimNames(rgbDim), 'CData', RGB2, 'FontSize', 7, 'Value', 1);
set(cmImage, 'String', 'Channel','ToolTipString', 'Scale each color channel to its range.');
set(cmManual, 'Visible', 'off');
@@ -3713,7 +3798,13 @@ function switchRGB(varargin)
set([sldMin sldMax], 'Enable', 'on','Callback',@updateImages);
set(popLut, 'Enable', 'off');
set(tbColorbar, 'Enable', 'off', 'Value', 0);
- set(projMethodPop,'Enable', 'off');
+ if rgbCount == get(projDimPop,'Value')
+ projMethod =0;
+ set(projMethodPop,'Enable', 'off');
+ else
+ projMethod = get(projMethodPop, 'Value') - 1;
+ set(projMethodPop,'Enable', 'on');
+ end
% set([sldGamma valSldGamma strGamma], 'Visible', 'off');
set([sldMin sldMax], 'Callback',@updateImages);
set([valSldMin_RGB valSldMax_RGB sldMin_RGB sldMax_RGB], 'Visible', 'on');
@@ -3815,7 +3906,7 @@ function buttonDownGuiHist(varargin)
end
function meanPlots(varargin)
- if debugMatVis, debugMatVisFcn(1); end
+ if debugMatVis, debugMatVisFcn(1); end
if varargin{1} == -1
incr = -1;
else
@@ -3831,7 +3922,7 @@ function meanPlots(varargin)
if ~isempty(plotDim)
updateObjects;
end
- if debugMatVis, debugMatVisFcn(2); end
+ if debugMatVis, debugMatVisFcn(2); end
end
%% Mouse Controls
%Mouse Movement Controls
@@ -4293,7 +4384,7 @@ function buttonDownGui(varargin)
figure(movdata.gui.hvidgen);
figure(movdata.prev.hprev);
end
- if get(roiBtRename, 'UserData')
+ if get(roiBtRename, 'Value')
figure(tempRoiPropWin);
end
end
@@ -4460,15 +4551,32 @@ function buttonDownCallback(varargin)
updateObjects;
case 'open' % Double click: Copy content of current figure to clipboard (only MS Windows)
if strcmp(os(1:5),'PCWIN')
- a = questdlg('Copy as vector graphics (enhanced meta-file) or 8-bit bitmap (bmp) or save as image file?','Copy figure content to clipboard or save to file','Vector graphics','Bitmap','Save','Vector graphics');
+ a = listdlg('PromptString','Copy/save/export figure content:',...
+ 'SelectionMode','single',...
+ 'ListString',{'Clipboard: Vector graphics';'Clipboard: Bitmap';'Save to file';'Export to workspace'});
+% a = questdlg('Copy as vector graphics (enhanced meta-file) or 8-bit bitmap (bmp) or save as image file?','Copy figure content to clipboard or save to file','Vector graphics','Bitmap','Save','Vector graphics');
+
switch a
- case 'Vector graphics'
+ case 1
print(myGcf, '-dmeta'); %#ok
- case 'Bitmap'
+ case 2
print(myGcf, '-dbitmap'); %#ok
- case 'Save'
+ case 3
[fNameFig,pNameFig] = uiputfile({'*.jpg';'*.png';'*.tif';'*.pdf'},'Select file location, name and file type!');
saveas(myGcf, [pNameFig fNameFig]);
+ case 4
+ dataSetIdx = mod(find(myGcf == [zoomWin imageWin plotWin]),numel(data))+1;
+ if isempty(varName{dataSetIdx})
+ wsExportName = 'matVisDataExport';
+ else
+ wsExportName = [varName{dataSetIdx} '_export'];
+ end
+ if any(myGcf == zoomWin)
+ assignin('base','test',myGcf);
+ assignin('base',wsExportName, currIm{dataSetIdx}(zoomVal(xySel(1),1):sum(zoomVal(xySel(1),:))-1,zoomVal(xySel(2),1):sum(zoomVal(xySel(2),:))-1,:));
+ else
+ assignin('base',wsExportName, currIm{dataSetIdx});
+ end
end
end
end
@@ -4722,7 +4830,7 @@ function updateSelection(dimNum)
% Other calls
imageUpdated = 0;
if (numel(dimNum) > 1) ||(numel(dimNum) == 1 && ~any(xySel == dimNum))
- updateImages;
+ updateImages;%(dimNum)
imageUpdated = 1;
if ~isempty(globalHist) && strcmp(get(tbHist, 'Enable'),'on') && ~calculatingGlobalHist
updateHist;
@@ -4747,9 +4855,6 @@ function updateSelection(dimNum)
if any(get(bg_colormap, 'SelectedObject') == [cmImage cmZoom cmThresh]) && ~get(tbSwitchRGB, 'Value')
updateColormap;
end
- if get(tbRoi, 'Value') && ~isempty(plotDim)
- updateRoiProperties(length(plotDim)>1 || any(plotDim ~= dimNum)); % Update properties of ROIs, with plot updates only if necessary
- end
if movdata.rec
vidWriter('append');
end
@@ -4972,43 +5077,66 @@ function updateCurrIm(varargin) %#ok
currAlphaMap{ii} = cA;
end
end
+ elseif get(tbSwitchRGB, 'Value')
+ if (~get(cmStretchRGBMean, 'Value') && ~get(cmStretchRGBMax, 'Value'))
+ imIndex{rgbDim} = mod((currPos(rgbDim)-2:currPos(rgbDim)), dim(rgbDim))+1;
+ else
+ if get(tb_lockPlots2Zoom(rgbDim), 'Value')
+ imIndex{rgbDim} = zoomVal(rgbDim,1):sum(zoomVal(rgbDim,:))-1;
+ else
+ imIndex{rgbDim} = ':';
+ end
+ end
end
if with2DHist
updateAlphaContrast;
end
- %Non-RGB mode
- if get(tbSwitchRGB, 'Value') == 0
% No projection selected
if projMethod == 0
for ii = 1:nMat
c = squeeze(data{ii}(imIndex{:}));
- if xySel(1) > xySel(2)
- currIm{ii} = c';
+ if get(tbSwitchRGB, 'Value')
+ [s,ind] = sort([xySel,rgbDim]);
+ currIm{ii} = ipermute(c, ind);
else
+ if xySel(1) > xySel(2)
+ currIm{ii} = permute(c,[2 1 3]);
+ else
currIm{ii} = c;
+ end
end
end
%Projection of data if selected
else
busy(1);
- imIndex{projDim} = ':';
+ if get(bt_zoomProj, 'Value')
+ imIndex{projDim} = zoomVal(projDim,1):sum(zoomVal(projDim,:))-1;
+ else
+ imIndex{projDim} = ':';
+ end
% Find number of dimension of xySel(1), xySel(2) and projDim with
% respect to extracted 3D data volume
- p = find(projDim == sort([xySel projDim]));
- xx = find(xySel(1) == sort([xySel projDim]));
- yy = find(xySel(2) == sort([xySel projDim]));
+ if get(tbSwitchRGB, 'Value') == 0
+ xx = find(xySel(1) == sort([xySel projDim]));
+ yy = find(xySel(2) == sort([xySel projDim]));
+ p = find(projDim == sort([xySel projDim]));
+ else
+ xx = find(xySel(1) == sort([xySel projDim rgbDim]));
+ yy = find(xySel(2) == sort([xySel projDim rgbDim]));
+ p = find(projDim == sort([xySel projDim rgbDim]));
+ rgb = find(rgbDim == sort([xySel projDim rgbDim]));
+ end
for ii = 1:nMat
% Sort dimension to [xySel(1) xySel(2) projDim]
- c = squeeze(permute(squeeze(data{ii}(imIndex{:})),[xx yy p]));
- if withAlpha
- cA = squeeze(permute(squeeze(alphaMap{ii}(imIndex{:})),[xx yy p]));
- sz1 = size(cA);
- end
- if get(bt_zoomProj, 'Value')
- c = c(:,:,zoomVal(projDim,1):sum(zoomVal(projDim,:))-1);
- if withAlpha
- cA = cA(:,:,zoomVal(projDim,1):sum(zoomVal(projDim,:))-1);
- end
+ if get(tbSwitchRGB, 'Value') == 0
+ c = squeeze(permute(squeeze(data{ii}(imIndex{:})),[xx yy p]));
+ if withAlpha
+ cA = squeeze(permute(squeeze(alphaMap{ii}(imIndex{:})),[xx yy p]));
+ sz1 = size(cA);
+ end
+ else
+ c = squeeze(permute(squeeze(data{ii}(imIndex{:})),[xx yy p rgb]));
+ sz1 = size(c);
end
switch projMethod
case 1 %maximum projection
@@ -5016,6 +5144,11 @@ function updateCurrIm(varargin) %#ok
[currAlphaMap{ii},cAInd] = max(cA, [], 3); %squeeze() % used to be nanmax
cAInd = (1:prod(sz1(1:2)))' + prod(sz1(1:2)) * (cAInd(:)-1);
currIm{ii} = reshape(c(cAInd), sz1(1:2));
+ elseif get(tbSwitchRGB, 'Value')
+ [~,cInd] = max(sum(c,4), [], 3); %squeeze() % used to be nanmax
+ cInd = (1:prod(sz1(1:2)))' + prod(sz1(1:2)) * (cInd(:)-1);
+ c = reshape(c, [prod(sz1(1:3)) sz1(4)]);
+ currIm{ii} = reshape(c(cInd,:), sz1([1 2 4]));
else
currIm{ii} = max(c, [], 3); % used to be nanmax
end
@@ -5023,7 +5156,14 @@ function updateCurrIm(varargin) %#ok
if withAlpha
warning(sprintf('MIN PROJECTION not understood in combination with alphaMap\nmin values of datamatrix is shown instead'))
end
+ if get(tbSwitchRGB, 'Value')
+ [~,cInd] = min(sum(c,4), [], 3); %squeeze() % used to be nanmax
+ cInd = (1:prod(sz1(1:2)))' + prod(sz1(1:2)) * (cInd(:)-1);
+ c = reshape(c, [prod(sz1(1:3)) sz1(4)]);
+ currIm{ii} = reshape(c(cInd,:), sz1([1 2 4]));
+ else
currIm{ii} = min(c, [], 3); % Used to be nanmin
+ end
case 3 %mean projection
if withAlpha
currIm{ii} = sum(c.*cA,3, 'omitnan')./sum(cA.*~isnan(c),3, 'omitnan'); % weighted mean ratio
@@ -5038,6 +5178,11 @@ function updateCurrIm(varargin) %#ok
% standard error of mean: SEM = sum( (x - )^2.*w, 3) ./ sum(w, 3) ./ sz(3)
%currIm{ii} = sqrt( sum( (c - repmat(sum(c.*cA,3, 'omitnan')./sum(cA.*~isnan(c),3, 'omitnan'),[1 1 sz1(3)]) ).^2 .* cA,3, 'omitnan')./sum(cA.*~isnan(c),3, 'omitnan'))./sqrt(sum(~isnan(c),3));
currAlphaMap{ii} = sum(cA.^2,3, 'omitnan') ./sum(cA,3, 'omitnan'); % mean Intensity
+ elseif get(tbSwitchRGB, 'Value')
+ [~,cInd] = std(sum(c,4), [], 3, 'omitnan'); %squeeze() % used to be nanmax
+ cInd = (1:prod(sz1(1:2)))' + prod(sz1(1:2)) * (cInd(:)-1);
+ c = reshape(c, [prod(sz1(1:3)) sz1(4)]);
+ currIm{ii} = reshape(c(cInd,:), sz1([1 2 4]));
else
currIm{ii} = std(double(c), [], 3, 'omitnan');
end
@@ -5046,6 +5191,11 @@ function updateCurrIm(varargin) %#ok
currIm{ii} = sum( (c - repmat(sum(c.*cA,3, 'omitnan')./sum(cA.*~isnan(c),3, 'omitnan'),[1 1 sz1(3)]) ).^2 .* cA,3, 'omitnan')...
./sum(cA.*~isnan(c),3, 'omitnan'); % standard error of currIm{ii} -> SEM ././sqrt(sum(~isnan(A_rr),3))
currAlphaMap{ii} = sum(cA.^2,3, 'omitnan') ./sum(cA,3, 'omitnan'); % mean Intensity
+ elseif get(tbSwitchRGB, 'Value')
+ [~,cInd] = var(sum(c,4), [], 3, 'omitnan');
+ cInd = (1:prod(sz1(1:2)))' + prod(sz1(1:2)) * (cInd(:)-1);
+ c = reshape(c, [prod(sz1(1:3)) sz1(4)]);
+ currIm{ii} = reshape(c(cInd,:), sz1([1 2 4]));
else
currIm{ii} = var(double(c), [], 3, 'omitnan');
end
@@ -5087,10 +5237,13 @@ function updateCurrIm(varargin) %#ok
end
busy(0);
end
+ %Non-RGB mode
+ if get(tbSwitchRGB, 'Value') == 0
currImVal = currIm; % Remember "original" values
if withAlpha
currAlphaMapVal = currAlphaMap;
end
+ % Apply filter
if withFilter && get(popFilter, 'Value')>1
for ii=1:nMat
currIm{ii} = filterImage(currIm{ii});
@@ -5160,11 +5313,6 @@ function updateCurrIm(varargin) %#ok
if (~get(cmStretchRGBMean, 'Value') && ~get(cmStretchRGBMax, 'Value'))
%"Normal" RGB mode (Global, Channel or Image)
for ii = 1:nMat
- imIndex{rgbDim} = mod((currPos(rgbDim)-2:currPos(rgbDim)), dim(rgbDim))+1; %#ok
- % here it would be good to differenciate between currIm and currImVal if dim(rgbDim) == 2
- % I would expect size(currIm, 3)== 2 but size(currImVal, 3)== 3
- % Question is if sz should be size(currIm{ii}) or size(currImVal{ii})
- currIm{ii} = squeeze(data{ii}(imIndex{:}));
sz = size(currIm{ii});
if dim(rgbDim) == 2
currIm{ii}(:,:,3) = min(currIm{ii}(:));
@@ -5173,10 +5321,12 @@ function updateCurrIm(varargin) %#ok
colDim = 3;
end
[s,ind] = sort([xySel,rgbDim]);
- currIm{ii} = ipermute(currIm{ii}, ind);
+ %currIm{ii} = ipermute(currIm{ii}, ind);
% Apply filter
- for jj = 1:size(currIm{ii},3)
+ if withFilter && get(popFilter, 'Value')>1
+ for jj = 1:size(currIm{ii},3)
currIm{ii}(:,:,jj) = filterImage(currIm{ii}(:,:,jj));
+ end
end
currImVal = currIm; % Remember "original" values
switch get(bg_colormap, 'SelectedObject')
@@ -5254,29 +5404,10 @@ function updateCurrIm(varargin) %#ok
% rgbStretchSldVal = [get(sldMin_RGB, 'Value') get(sldMax_RGB, 'Value')];
% set(valSldMin_RGB, 'String', num2str(rgbStretchSldVal(1),'%6.3f'));
% set(valSldMax_RGB, 'String', num2str(rgbStretchSldVal(2),'%6.3f'));
- stackIndex = imIndex;
- stackIndex{rgbDim} = ':';
+ %stackIndex = imIndex;
+ %stackIndex{rgbDim} = ':';
for ii = 1:nMat
- currStack = squeeze(data{ii}(stackIndex{:}));
- % Calculation of histogram removed for speed reasons
- % and lack of usefulness
- % if (forceUpdateGuiHist || updateGuiHistState) && ii==1
- % try
- % histValCurrIm = hist(single(currStack(:)),histXData);
- % catch %#ok
- % histValCurrIm = zeros(length(histXData),size(currStack,3));
- % for iii=1:size(currStack,3)
- % cc = currStack(:,:,iii);
- % histValCurrIm(:,iii) = hist(cc(:),histXData);
- % end
- % histValCurrIm = sum(h,2);
- % end
- % end
- [s,ind] = sort([xySel,rgbDim]);
- currStack = ipermute(currStack, ind);
- if get(bt_zoomProj, 'Value')
- currStack = currStack(:,:,zoomVal(rgbDim,1):sum(zoomVal(rgbDim,:))-1);
- end
+ currStack = currIm{ii};
minVal(ii) = min(currStack(:));
maxVal(ii) = max(currStack(:));
sz = size(currStack);
@@ -5332,8 +5463,10 @@ function updateCurrIm(varargin) %#ok
% currIm{ii} = reshape(currStack,[sz(1:2) 3]);
currIm{ii} = reshape(currStack,[sz(1:2) 3]);
% Apply filter
- for jj = 1:size(currIm{ii},3)
+ if withFilter && get(popFilter, 'Value')>1
+ for jj = 1:size(currIm{ii},3)
currIm{ii}(:,:,jj) = filterImage(currIm{ii}(:,:,jj));
+ end
end
currIm{ii} = rgbContrastAdjust(currIm{ii},min_currStack_rel, max_currStack_rel);
end
@@ -5633,11 +5766,12 @@ function updateRgbStretchPar(varargin)
%Update axes in Image and zoom window
function updateImages(varargin)
if debugMatVis, debugMatVisFcn(1); end
+ %if nargin; dimNum = varargin{1}; end
currGamma(currContrastSel) = get(sldGamma(1), 'Value');
if (~rgbCount || (rgbCount && ~updateGuiHistState)) && (get(tbWin(1), 'Value') == 1 || get(tbWin(2), 'Value') == 1 || get(tbHist,'Value')) % in RGB mode, updateCurrIm is called from updateGuiHist
updateCurrIm(varargin{:});
end
- if updateGuiHistState
+ if updateGuiHistState %&& ~rgbCount % AZ: added '&& ~rgbCount' because 'updateGuiHistVal' was called twice in RGB mode, but this was wrong
updateGuiHistVal;
end
if get(tbWin(1), 'Value') == 1
@@ -5662,6 +5796,17 @@ function updateImages(varargin)
updateColormap;
end
% if
+ if get(tbRoi, 'Value')
+ % after optimizing ROI properties I switched
+ % "updateRoiProperties(1)" off, since it was called twice
+% updateRoiProperties(1); % I do not know, which dim was called + changed
+% if ~isempty(plotDim) && exist('dimNum','var')
+% updateRoiProperties(length(plotDim)>1 || any(plotDim ~= dimNum)); % Update properties of ROIs, with plot updates only if necessary
+% else
+% updateRoiProperties(0);
+% end
+ end
+
if debugMatVis, debugMatVisFcn(2); end
end
@@ -5836,7 +5981,13 @@ function updatePlotValues(varargin)
plotValues{jj,ii,1} = currImVal{jj}(:,currPos(xySel(2)));
plotValues{jj,ii,2} = currIm{jj}(:,currPos(xySel(2)));
else
+ if withAlpha
+ plotValues{jj,ii,kk} = sum(currImVal{jj}(:,plotIndex{xySel(2)}).*currAlphaMapVal{jj}(:,plotIndex{xySel(2)}),2, 'omitnan')./...
+ sum(currAlphaMapVal{jj}(:,plotIndex{xySel(2)}).*~isnan(currImVal{jj}(:,plotIndex{xySel(2)})),2, 'omitnan');
+ plotValuesAlpha{jj,ii,kk} = mean(currAlphaMapVal{jj}(:,plotIndex{xySel(2)}), 2, 'omitnan');
+ else
plotValues{jj,ii,kk} = mean(currImVal{jj}(:,plotIndex{xySel(2)}),2, 'omitnan');
+ end
end
end
% Plot along y direction
@@ -5860,6 +6011,7 @@ function updatePlotValues(varargin)
if withAlpha
plotValues{jj,ii,kk} = sum(currImVal{jj}(plotIndex{xySel(1)},:).*currAlphaMapVal{jj}(plotIndex{xySel(1)},:),1, 'omitnan')./...
sum(currAlphaMapVal{jj}(plotIndex{xySel(1)},:).*~isnan(currImVal{jj}(plotIndex{xySel(1)},:)),1, 'omitnan');
+ plotValuesAlpha{jj,ii,kk} = mean(currAlphaMapVal{jj}(plotIndex{xySel(1)},:), 1, 'omitnan');
else
plotValues{jj,ii,kk} = mean(currImVal{jj}(plotIndex{xySel(1)},:),1, 'omitnan');
end
@@ -5883,6 +6035,7 @@ function updatePlotValues(varargin)
%sum(c.*cA,3, 'omitnan')./sum(cA.*~isnan(c),3, 'omitnan'); % weighted mean ratio
plotValues{jj,ii,kk} = sum(sum(data{jj}(plotIndex{:}) .*alphaMap{jj}(plotIndex{:}), xySel(1), 'omitnan'),xySel(2), 'omitnan')./...
sum(sum(alphaMap{jj}(plotIndex{:}).*~isnan(data{jj}(plotIndex{:})),xySel(1), 'omitnan'),xySel(2), 'omitnan');
+ plotValuesAlpha{jj,ii,kk} = mean(mean(alphaMap{jj}(plotIndex{:}), xySel(1), 'omitnan'),xySel(2), 'omitnan');
else
plotValues{jj,ii,kk} = mean(mean(data{jj}(plotIndex{:}),xySel(1), 'omitnan'),xySel(2), 'omitnan');
end
@@ -5906,6 +6059,7 @@ function updatePlotValues(varargin)
if withAlpha
plotValues{jj,ii,kk} = sum(data{jj}(plotIndex) .*alphaMap{jj}(plotIndex), 1, 'omitnan')./...
sum(alphaMap{jj}(plotIndex).*~isnan(data{jj}(plotIndex)),1, 'omitnan');
+ plotValuesAlpha{jj,ii,kk} = mean(alphaMap{jj}(plotIndex), 1, 'omitnan');
else
plotValues{jj,ii,kk} = mean(data{jj}(plotIndex),1, 'omitnan');
end
@@ -5929,14 +6083,20 @@ function drawPlots(varargin)
else
nPlotCol = 2;
end
- plotValues = [];
+ plotValues = [];plotValuesAlpha = [];
updatePlotValues;
if oldMATLAB
subPlotHandles = [];
subPlotPlots = [];
+ if withAlpha
+ subPlotPlotsAlpha = [];
+ end
else
subPlotHandles = matlab.graphics.chart.primitive.Line.empty; %Handles to subplot axes in Plots Window
subPlotPlots = matlab.graphics.chart.primitive.Line.empty; %Handles to data displayed in Plots Window
+ if withAlpha
+ subPlotPlotsAlpha = matlab.graphics.chart.primitive.Line.empty; %Handles to data displayed in Plots Window
+ end
end
if get(tbRoi, 'Value')
roiSel = get(roiListbox, 'Value');
@@ -5980,19 +6140,44 @@ function drawPlots(varargin)
if ~isempty(plotValues{jj,ii,kk})
if customDimScale
subPlotPlots{jj,ii,kk} = plot(subPlotHandles(jj,ii), linspace(dimScale(plotDim(ii),1),dimScale(plotDim(ii),2),dim(plotDim(ii))),squeeze(plotValues{jj,ii,kk}),...
- 'Color', [kk==1 kk==2 kk==3], 'LineWidth', kk/2);
+ 'Color', [kk==1 kk==2 kk==3], 'LineWidth', kk/2,'LineStyle','-');
+ if withAlpha && ~verLessThan('matlab','9.0')
+ yyaxis(subPlotHandles(jj,ii),'right')
+ subPlotPlotsAlpha{jj,ii,kk} = plot(subPlotHandles(jj,ii), linspace(dimScale(plotDim(ii),1),dimScale(plotDim(ii),2),dim(plotDim(ii))),squeeze(plotValuesAlpha{jj,ii,kk}),...
+ 'Color', [kk==1 kk==2 kk==3], 'LineWidth', kk/2,'LineStyle',':','Marker','none');
+ yyaxis(subPlotHandles(jj,ii),'left')
+ end
else
subPlotPlots{jj,ii,kk} = plot(subPlotHandles(jj,ii), squeeze(plotValues{jj,ii,kk}),...
- 'Color', [kk==1 kk==2 kk==3], 'LineWidth', kk/2);
+ 'Color', [kk==1 kk==2 kk==3], 'LineWidth', kk/2,'LineStyle','-');
+ if withAlpha && ~verLessThan('matlab','9.0')
+ yyaxis(subPlotHandles(jj,ii),'right')
+ subPlotPlotsAlpha{jj,ii,kk} = plot(subPlotHandles(jj,ii),squeeze(plotValuesAlpha{jj,ii,kk}),...
+ 'Color', [kk==1 kk==2 kk==3], 'LineWidth', kk/2,'LineStyle',':','Marker','none');
+ yyaxis(subPlotHandles(jj,ii),'left')
+ end
end
end
end
else
if ~(isequal(roiSel,0) || isempty(roiSel))
if customDimScale
- subPlotPlots{jj,ii,kk} = plot(subPlotHandles(jj,ii), linspace(dimScale(plotDim(ii),1),dimScale(plotDim(ii),2),dim(plotDim(ii))),squeeze(plotValues{jj,ii,kk}),'Color',colorcodePlots(kk,:));
+ subPlotPlots{jj,ii,kk} = plot(subPlotHandles(jj,ii), linspace(dimScale(plotDim(ii),1),dimScale(plotDim(ii),2),dim(plotDim(ii))),squeeze(plotValues{jj,ii,kk}),...
+ 'Color',colorcodePlots(kk,:),'LineStyle','-');
+ if withAlpha && ~verLessThan('matlab','9.0')
+ yyaxis(subPlotHandles(jj,ii),'right')
+ subPlotPlotsAlpha{jj,ii,kk} = plot(subPlotHandles(jj,ii), linspace(dimScale(plotDim(ii),1),dimScale(plotDim(ii),2),dim(plotDim(ii))),squeeze(plotValuesAlpha{jj,ii,kk}),...
+ 'Color', colorcodePlots(kk,:),'LineStyle',':','Marker','none');%, 'LineWidth', kk/2
+ yyaxis(subPlotHandles(jj,ii),'left')
+ end
else
- subPlotPlots{jj,ii,kk} = plot(subPlotHandles(jj,ii), squeeze(plotValues{jj,ii,kk}),'Color',colorcodePlots(kk,:));
+ subPlotPlots{jj,ii,kk} = plot(subPlotHandles(jj,ii), squeeze(plotValues{jj,ii,kk}),'Color',colorcodePlots(kk,:),'LineStyle','-');
+ if withAlpha && ~verLessThan('matlab','9.0')
+ yyaxis(subPlotHandles(jj,ii),'right')
+ subPlotPlotsAlpha{jj,ii,kk} = plot(subPlotHandles(jj,ii), squeeze(plotValuesAlpha{jj,ii,kk}),...
+ 'Color', colorcodePlots(kk,:),'LineStyle',':','Marker','none');%, 'LineWidth', kk/2
+ yyaxis(subPlotHandles(jj,ii),'left')
+ end
end
l{kk} = roiList(roiSel(kk)).name; %Legend strings for roi plots
end
@@ -6062,10 +6247,17 @@ function updatePlots(varargin)
for kk = 1:size(plotValues,3) %Number of plots in one axes (more than 1 for mean plots and rois)
try %For different number of plots in different plot axes
set(subPlotPlots{jj,ii,kk}, 'YData', squeeze(plotValues{jj,ii,kk}));
+ if withAlpha
+ set(subPlotPlotsAlpha{jj,ii,kk}, 'YData', squeeze(plotValuesAlpha{jj,ii,kk}));
+ end
catch %#ok
+ fprintf('''set(subPlotPlots{jj,ii,kk}, ''YData'', squeeze(plotValues{jj,ii,kk}));'' failed\n')
end
try %for dimensions with less plot entries, e.g. rgbDim for RGB plot mode
pV(kk,:) = squeeze(plotValues{jj,ii,kk}); %#ok
+ if withAlpha
+ pVA(kk,:) = squeeze(plotValuesAlpha{jj,ii,kk}); %#ok
+ end
catch %#ok
end
end
@@ -6098,6 +6290,15 @@ function updatePlots(varargin)
if ~isnan(minValY) && minValY ~= maxValY
set(subPlotHandles(jj,ii), 'YLim', [minValY-(maxValY-minValY)/25 maxValY+(maxValY-minValY)/25]);
end
+ if withAlpha && ~verLessThan('matlab','9.0')
+ minValYA = min(min(pVA(:,plotXLim(plotDim(ii),1):plotXLim(plotDim(ii),2))));
+ maxValYA = max(max(pVA(:,plotXLim(plotDim(ii),1):plotXLim(plotDim(ii),2))));
+ if ~isnan(minValYA) && minValYA ~= maxValYA
+ yyaxis(subPlotHandles(jj,ii),'right')
+ set(subPlotHandles(jj,ii), 'YLim', [minValYA-(maxValYA-minValYA)/25 maxValYA+(maxValYA-minValYA)/25]);
+ yyaxis(subPlotHandles(jj,ii),'left')
+ end
+ end
end
% %Apply zoom intervals to axes if "Zoom axes" is selected
% if get(tbPlotsXLim, 'Value') == 1 && sum(plotDim(ii) == xySel) > 0
@@ -6114,7 +6315,7 @@ function updatePlots(varargin)
% set(subPlotHandles(jj,ii),...
% 'YLim', [minVal(jj) maxVal(jj)]);
% end
- clear pV;
+ clear pV pVA
end
if ~isempty(subPlotPlots)
if get(tbMarker, 'Value') == 1
@@ -6878,9 +7079,14 @@ function updateZoom(hObject, event, dimNum, source) %#ok
plotXLimScale(dimNum,:) = dimScale(dimNum,:);
end
end
+ case 'ROIupdate'
+ zoomValXY([1,3]) = zoomVal(xySel(2),:);
+ zoomValXY([2,4]) = zoomVal(xySel(1),:);
+ end
+ for ii = dimNum
+ set(txt_zoomWidth(ii), 'String', [' = ' num2str(zoomVal(ii,2))]);
end
- set(txt_zoomWidth(dimNum), 'String', [' = ' num2str(zoomVal(dimNum,2))]);
- if any(xySel == dimNum) || (projMethod && projDim == dimNum)
+ if length(dimNum) < 3 && (any(xySel == dimNum) || (projMethod && any(projDim == dimNum)))
zoomValXY([1,3]) = zoomVal(xySel(2),:);
zoomValXY([2,4]) = zoomVal(xySel(1),:);
end
@@ -6946,7 +7152,7 @@ function updateZoom(hObject, event, dimNum, source) %#ok
if get(tbHist, 'Value')
updateHist;
end
- if projMethod && get(bt_zoomProj, 'Value') && nargin > 2 && dimNum == projDim
+ if projMethod && get(bt_zoomProj, 'Value') && nargin > 2 && any(projDim == dimNum)
if projMethod == 6
drawImages;
if get(tbRoi, 'Value')
@@ -6960,7 +7166,7 @@ function updateZoom(hObject, event, dimNum, source) %#ok
% updateColormap;
updateObjects; % Adjust length of position lines in zoom window to new zoom setting
end
- if get(tbSwitchRGB, 'Value') && (get(cmStretchRGBMean, 'Value') || get(cmStretchRGBMax, 'Value')) && get(bt_zoomProj, 'Value')
+ if get(tbSwitchRGB, 'Value') && (get(cmStretchRGBMean, 'Value') || get(cmStretchRGBMax, 'Value')) && get(tb_lockPlots2Zoom(rgbDim), 'Value')
updateImages;
end
if get(tbPlotsXLim, 'Value') && get(tbWin(3),'Value')
@@ -7224,7 +7430,7 @@ function hideTifPar(varargin)
set(tbTifPar, 'Value', 0);
end
if isempty(tifParFig)
- tifParFig = figure('name', ['CustomTif Parameter',' (',varName{1},')'], ... %'Number', 'off',...
+ tifParFig = figure('name', ['CustomTif Parameter',' (',varName{1},')'], 'Number', 'off',...
'CloseRequestFcn', @hideTifPar, 'HandleVisibility', 'off');
set(tifParFig, 'HandleVisibility', 'on');
axis off;
@@ -8669,7 +8875,7 @@ function roiGui(varargin)
'WindowButtonDownFcn',@buttonDownCallback,...
'WindowButtonUpFcn','');
drawPlots;
- if get(roiBtRename, 'UserData')
+ if get(roiBtRename, 'Value')
set(tempRoiPropWin, 'Visible','off');
end
@@ -8775,7 +8981,7 @@ function roiGui(varargin)
'FontSize', 6, 'Enable', 'off','ToolTipString','Replace selected ROI by new selection');
%Rename Roi Button
- roiBtRename = uicontrol(roiWin, 'Style', 'Pushbutton','Position', [49,75,32,22],...
+ roiBtRename = uicontrol(roiWin, 'Style', 'Togglebutton','Position', [49,75,32,22],...
'String', 'ROI upd.','Callback', @updateRoiSettings,'FontSize', 6, 'Enable', 'off','UserData',0,...
'ToolTipString','Update settings for selected ROI','Tag','Update settings for selected ROI');
@@ -8795,13 +9001,17 @@ function roiGui(varargin)
uicontrol(roiWin, 'Style', 'Pushbutton','Position', [88,50,32,22],...
'CData', roiImportBt,'Callback', @importRois,'Enable','on','ToolTipString', ' Import Rois ',...
'Tag', 'Import ROIs.');
+ %Copy Roi Button
+ bt_copyRoi = uicontrol(roiWin, 'Style', 'Pushbutton','Position', [10,24,32,22],...
+ 'CData', copyRoiBt,'Callback', @copyRoi,'Enable','on','ToolTipString', ' Copy Roi ',...
+ 'Tag', 'Copy ROI.', 'Enable','off');
if nDim>2
%Popup for Dimension for roi data export
n = dimNames;
n(xySel) = [];
- roiPopDataExport = uicontrol(roiWin, 'Style', 'Popup','Position', [10,24,71 ,22],...
+ roiPopDataExport = uicontrol(roiWin, 'Style', 'Popup','Position', [49,24,32 ,22],...
'Enable','on','String',n,...
- 'Tag', 'Select dimension for ROI data export.');
+ 'Tag', 'Select dimension for ROI data export.','Fontsize',8);
%Export Roi Data Button
bt_exportRoiData = uicontrol(roiWin, 'Style', 'Pushbutton','Position', [88,25,32,22],...
'CData', roiExportDataBt,'Callback', @exportRoiData,'Enable','on','ToolTipString', ' Export Roi data along specified dimension ',...
@@ -8831,11 +9041,15 @@ function roiGui(varargin)
roiImage = imagesc(currIm{1});
end
if withAlpha
- set(roiImage, 'AlphaData', currAlphaMap{1});
+ set(roiImage, 'AlphaData', currAlphaMap{1},'AlphaDataMapping','scaled');
end
axis image;
set(roiAxes,'FontSize',8,'Color','k');
roiLine.roi = line(0,0,'Parent', roiAxes,'Color','w');
+ for iii = 1:numel(data)
+ roiCenterIndicator(1,iii) = text(0,0,'+','Parent',zoomAx(iii),'Color','r','FontWeight','b','FontSize',max([15,max(dim(xySel))/100]),'Visible','off','horizontalAlignment','center');
+ roiCenterIndicator(2,iii) = text(0,0,'+','Parent',imAx(iii),'Color','r','FontWeight','b','FontSize',max([15,max(dim(xySel))/100]),'Visible','off','horizontalAlignment','center');
+ end
set(roiWin, 'HandleVisibility', 'off');
%Set first entry of roi list (so it is not empty - will be
%replaced by 1 when first Roi is selected)
@@ -8845,7 +9059,7 @@ function roiGui(varargin)
end
function resizeRoiWin(varargin)
- if debugMatVis, debugMatVisFcn(1); end
+ if debugMatVis, debugMatVisFcn(1); end
adjustGuiSize(roiWin,-1);
newPos = get(roiWin, 'Position');
if any(newPos(3:4) < [180 250])
@@ -8858,7 +9072,7 @@ function resizeRoiWin(varargin)
set(roiName, 'Position', [5 newPos(4)-90 newPos(3)-150 30]);
set(roiAxes, 'Position', [25 80 newPos(3)-175 newPos(4)-160]);
adjustGuiSize(roiWin);
- if debugMatVis, debugMatVisFcn(2); end
+ if debugMatVis, debugMatVisFcn(2); end
end
function buttonDownRoiGui(varargin)
@@ -8908,7 +9122,7 @@ function updateRoiSize(varargin)
%Choose new Roi (rectangular, ellipsoid or polygonal/free)
function getNewRoi(varargin)
- if debugMatVis, debugMatVisFcn(1); end
+ if debugMatVis, debugMatVisFcn(1); end
roi = [];
% Check if called with left mouse button ("push mode" = single ROI selection)
if nargin == 4 && strcmp(varargin{4},'one')
@@ -8932,7 +9146,7 @@ function getNewRoi(varargin)
set([imageWin zoomWin],'WindowButtonDownFcn',@selectPolyRoi);
end
function selectRectRoi(varargin)
- if debugMatVis, debugMatVisFcn(1); end
+ if debugMatVis, debugMatVisFcn(1); end
roi = []; %Clear old roi position
p = get(myGca, 'CurrentPoint');
p = p(1 ,[1 2]);
@@ -8997,10 +9211,10 @@ function selectRectRoi(varargin)
end
end
addNewRoi(roi,nRois,'new');
- if debugMatVis, debugMatVisFcn(2); end
+ if debugMatVis, debugMatVisFcn(2); end
end
function selectEllipseRoi(varargin)
- if debugMatVis, debugMatVisFcn(1); end
+ if debugMatVis, debugMatVisFcn(1); end
roi = []; %Clear old roi position
p = get(myGca,'CurrentPoint');
p = p(1 ,1:2);
@@ -9034,7 +9248,7 @@ function selectEllipseRoi(varargin)
set(myGcf,'WindowButtonMotionFcn',@updateRoiRect);
end
function updateRoiRect(varargin)
- if debugMatVis, debugMatVisFcn(1); end
+ if debugMatVis, debugMatVisFcn(1); end
p = get(myGca,'CurrentPoint');
p = p(1 ,1:2);
% if customDimScale
@@ -9049,10 +9263,10 @@ function updateRoiRect(varargin)
end
set(tempEllipse, 'Position',[x y w h]);
set(tempRect, 'Position',[x y w h]);
- if debugMatVis, debugMatVisFcn(2); end
+ if debugMatVis, debugMatVisFcn(2); end
end
function finishEllipse(varargin)
- if debugMatVis, debugMatVisFcn(1); end
+ if debugMatVis, debugMatVisFcn(1); end
p2 = get(myGca, 'CurrentPoint');
p2 = p2(1 ,1:2);
if customDimScale
@@ -9073,24 +9287,27 @@ function finishEllipse(varargin)
delete(tempRect);
nRois = nRois + 1;
addNewRoi(roi,nRois,'new');
- if debugMatVis, debugMatVisFcn(2); end
+ if debugMatVis, debugMatVisFcn(2); end
end
- if debugMatVis, debugMatVisFcn(2); end
+ if debugMatVis, debugMatVisFcn(2); end
end
function selectPolyRoi(varargin)
- if debugMatVis, debugMatVisFcn(1); end
+ if debugMatVis, debugMatVisFcn(1); end
if ~any(myGcf==[imageWin zoomWin])
return
end
set(myGcf,'WindowButtonMotionFcn',@freeDraw);
set(myGcf,'WindowButtonUpFcn',@stopFreeDraw);
function freeDraw(varargin)
- if debugMatVis >1, debugMatVisFcn(1); end
+ if debugMatVis >1, debugMatVisFcn(1); end
p = get(myGca, 'CurrentPoint');
p = p(1 ,1:2);
-% if customDimScale
-% p = pixelLocation(p);
-% end
+ %fprintf('p(%f,%f)',p)
+ %if customDimScale
+ % p = pixelLocation(p);
+ % fprintf('\tp(%f,%f)',p)
+ %end
+ %fprintf('\n')
set(tempLine,'XData',[p(1 ,1),p(1 ,1)],'YData',[p(1 ,2),p(1 ,2)]);
roi(:,end+1) = p(1 ,1:2);
set(roiSelLine,'XData',roi(1 ,:),'YData',roi(2,:));
@@ -9120,9 +9337,9 @@ function stopFreeDraw(varargin)
if isempty(tempLine)
p = get(myGca, 'CurrentPoint');
p = p(1 ,1:2);
- if customDimScale
- p = pixelLocation(p);
- end
+ %if customDimScale
+ % p = pixelLocation(p);
+ %end
set(myGcf, 'HandleVisibility', 'on');
tempLine = line(p(1),p(2),'Color','w');
roiSelLine = line(p(1),p(2),'Color','w');
@@ -9209,6 +9426,8 @@ function addNewRoi(roi,numberRoi,newOld)
% end
roiList(numberRoi).mask = false(dim(xySel(1)),dim(xySel(2)));
roiList(numberRoi).mask(inregion) = 1;
+ [maskXIdx, maskYIdx] = find(roiList(numberRoi).mask);
+ roiList(numberRoi).centerOfGravity = [mean(maskXIdx), mean(maskYIdx)];
% toc
if ~any(roiList(numberRoi).mask(:))
roiList(numberRoi) = [];
@@ -9244,6 +9463,7 @@ function addNewRoi(roi,numberRoi,newOld)
else
roiList(numberRoi).corners = roi;
end
+ roiList(numberRoi).cornersPixelDim = roi;
%Determine rectangle surrounding ROI pixels in polygon
%with border of one pixel around rounded values (left,down, right, up)
if customDimScale
@@ -9261,6 +9481,41 @@ function addNewRoi(roi,numberRoi,newOld)
if numel(get(roiListbox,'Value'))==1 %~any(cell2mat(get([tbRoiShift tbRoiRotate tbRoiScale], 'Value')))
roiList(numberRoi).settings.xySel = xySel;
roiList(numberRoi).settings.position = currPos;
+ % replace currPos of projection dim with position of max value
+ % along projection dim
+ if projMethod
+ %updatePlotValues;
+ %Get plot values for fs
+ for m=1:nDim %Fill indices of all dimension with current-position-vectors of length of roi-size
+ plotIndex{m} = currPos(m) * ones(size(roiList(numberRoi).index.x,1),1);
+ end
+ plotIndex{xySel(1)} = roiList(numberRoi).index.x; %Fill xySel dimension indices with roi indices
+ plotIndex{xySel(2)} = roiList(numberRoi).index.y;
+ plotIndex{projDim} = ones(size(roiList(numberRoi).index.x,1),1); %Fill plot-dimension with ones (for first point)
+ if get(tbSwitchRGB, 'Value') && (get(cmStretchRGBMean, 'Value') || get(cmStretchRGBMax, 'Value'))
+ plotIndex{rgbDim} = ones(size(roiList(numberRoi).index.x,1),1); %Fill plot-dimension with ones (for first point)
+ end
+ plotIndex = sub2ind(dim, plotIndex{:}); %Determine linear index of roi pixels for first point
+ plotIndex = repmat(plotIndex, [1 dim(projDim)]); %Replicate linear index
+ deltaIndex = prod(dim(1:projDim-1)); %Difference value of indices along plotted dimension
+ plotIndex = plotIndex + repmat(deltaIndex * (0:dim(projDim)-1),[size(roiList(numberRoi).index.x,1) 1]); %Extend to all other points by adding deltaInd for each step
+ if get(tbSwitchRGB, 'Value') && (get(cmStretchRGBMean, 'Value') || get(cmStretchRGBMax, 'Value'))
+ plotIndex = repmat(plotIndex(:), [1 dim(rgbDim)]); %Replicate linear index
+ deltaIndex = prod(dim(1:rgbDim-1)); %Difference value of indices along plotted dimension
+ plotIndex = plotIndex + repmat(deltaIndex * (0:dim(rgbDim)-1),[size(roiList(numberRoi).index.x,1)*dim(projDim) 1]); %Extend to all other points by adding deltaInd for each step
+ plotIndex = reshape(plotIndex,[size(roiList(numberRoi).index.x,1) dim(projDim) dim(rgbDim)]);
+ pV = mean(sum(data{1}(plotIndex),3, 'omitnan'),1, 'omitnan');
+ else
+ if withAlpha
+ pV = mean(alphaMap{1}(plotIndex), 1, 'omitnan');
+ else
+ pV = mean(data{1}(plotIndex),1, 'omitnan');
+ end
+
+ end
+ [~,pVMaxPos] = max(pV);
+ roiList(numberRoi).settings.position(projDim) = pVMaxPos;
+ end
roiList(numberRoi).settings.zoomVal = zoomVal;
end
%Draw lines and add to list if Roi is new
@@ -9320,6 +9575,7 @@ function addNewRoi(roi,numberRoi,newOld)
set([roiBtRename tbRoiShift tbRoiRotate tbRoiScale roiBtReplace bt_roiExport bt_deleteRoi] , 'Enable', 'on');
% if isempty(bt_exportRoiData)
set(bt_exportRoiData, 'Enable','on')
+ set(bt_copyRoi, 'Enable', 'on');
% end
set(roiBtReplace,'Value',0)
else
@@ -9331,6 +9587,19 @@ function addNewRoi(roi,numberRoi,newOld)
drawPlots;
if debugMatVis, debugMatVisFcn(2); end
end
+
+ function copyRoi(varargin)
+ if debugMatVis, debugMatVisFcn(1); end
+ copyRoiIdx = get(roiListbox, 'Value');
+ for iii = 1:numel(copyRoiIdx)
+ nRois = nRois + 1;
+ addNewRoi(roiList(copyRoiIdx(iii)).cornersPixelDim,nRois,'new');
+ roiList(nRois).settings = roiList(copyRoiIdx(iii)).settings;
+ end
+ set(roiListbox, 'Value',nRois-numel(copyRoiIdx)+1:nRois);
+ updateRoiSelection;
+ if debugMatVis, debugMatVisFcn(2); end
+ end
function deleteRoi(varargin)
if debugMatVis, debugMatVisFcn(1); end
roiSel = get(roiListbox, 'Value');
@@ -9360,54 +9629,76 @@ function deleteRoi(varargin)
if ~isempty(bt_exportRoiData)
set(bt_exportRoiData, 'Enable','off')
end
+ set(bt_copyRoi, 'Enable', 'off');
end
drawPlots;
if debugMatVis, debugMatVisFcn(2); end
end
function updateRoiSettings(varargin)
if debugMatVis, debugMatVisFcn(1); end
- set(roiBtRename, 'UserData',1)
+ if nargin == 3 || ~get(roiBtRename,'Value')
+ set(tempRoiPropWin, 'Visible','off');
+ set(roiBtRename,'Value',0)
+ if debugMatVis, debugMatVisFcn(2); end
+ return
+ end
currRoi = get(roiListbox, 'Value');
ROIpos = roiList(currRoi).settings.position;
nROIDim = length(ROIpos);
ROIZoomVal = roiList(currRoi).settings.zoomVal;
%ROIZoomVal(end+1:nROIDim,2) = dim(size(ROIZoomVal,1)+1:nROIDim);
%ROIZoomVal(end+1:nROIDim,1) = 1;
- ROIStr = sprintf(' Position Zoom Settings');
for np = 1:min(nROIDim,nDim);
- ROIStr = sprintf('%s\nDim%d: %4d %s %4d %4d:%4d %s %4d:%4d',...
- ROIStr,np,ROIpos(np),char(hex2dec('2192')),currPos(np),ROIZoomVal(np,1),sum(ROIZoomVal(np,:))-1,char(hex2dec('2192')),zoomVal(np,1),sum(zoomVal(np,:))-1);
+ ROIStr{np} = sprintf('Dim%d: %4d %s %4d %4d:%4d %s %4d:%4d',...
+ np,ROIpos(np),char(hex2dec('2192')),currPos(np),...
+ ROIZoomVal(np,1),sum(ROIZoomVal(np,:))-1,char(hex2dec('2192')),zoomVal(np,1),sum(zoomVal(np,:))-1);
end
gp = get(gui,'Position');
- tempRoiPropWin = figure('Position', [gp(1)+270, gp(2)-100-25*nROIDim, 320, 25*nROIDim + 50],...
- 'MenuBar', 'none','NumberTitle', 'off', 'Name', 'ROI Properties!');%
-
- uicontrol(tempRoiPropWin,'Style', 'Text', 'Position', [12 25*nROIDim+26 55 18],...
- 'String','ROI name:');
- etxt_newRoiName = uicontrol(tempRoiPropWin,'Style', 'Edit', 'Position', [80 25*nROIDim+25 150 20],...
- 'String',roiList(currRoi).name,'HorizontalAlignment','left');
- uicontrol(tempRoiPropWin,'Style', 'Text', 'Position', [12 35 290 15*nROIDim+15],...
- 'String',ROIStr,'HorizontalAlignment','left','FontName','Courier');%
- btn1 = uicontrol(tempRoiPropWin,'Style', 'pushbutton', 'Position', [12 12 100 20],...
- 'String','Cancle','Callback', {@getNewRoiProps,0});%ROIStr
- btn2 = uicontrol(tempRoiPropWin,'Style', 'pushbutton', 'Position', [200 12 100 20],...
- 'String','Update','Callback', {@getNewRoiProps,1});%ROIStr
- function getNewRoiProps(hO,h,sw)
+ if isempty(tempRoiPropWin)
+ tempRoiPropWin = figure('Position', [gp(1), max(50,gp(2)-444-25*nROIDim), 320, 25*nROIDim + 50],...
+ 'MenuBar', 'none','NumberTitle', 'off', 'Name', 'ROI Properties!');%
+
+ uicontrol(tempRoiPropWin,'Style', 'Text', 'Position', [12 25*nROIDim+26 55 18],...
+ 'String','ROI name:');
+ etxt_newRoiName = uicontrol(tempRoiPropWin,'Style', 'Edit', 'Position', [80 25*nROIDim+25 150 20],...
+ 'String',roiList(currRoi).name,'HorizontalAlignment','left');
+ uicontrol(tempRoiPropWin,'Style', 'Text', 'Position', [12 35 290 15*nROIDim+15],...
+ 'String',' Position Zoom Settings','HorizontalAlignment','left','FontName','Courier');%
+ for np = 1:min(nROIDim,nDim);
+ if projMethod && np == find(projDim == sort([xySel projDim])); myCol = [.5 .5 .5]; else myCol = [0 0 0]; end
+ txt_RoiPropWinTxt(np) = uicontrol(tempRoiPropWin,'Style', 'Text', 'Position', [12 35+15*(nROIDim-np) 290 15],...
+ 'String',ROIStr{np},'HorizontalAlignment','left','FontName','Courier','ForegroundColor',myCol);%
+ end
+ btn1 = uicontrol(tempRoiPropWin,'Style', 'pushbutton', 'Position', [12 12 100 20],...
+ 'String','Close','Callback', {@updateRoiSettings,0});%ROIStr
+ btn2 = uicontrol(tempRoiPropWin,'Style', 'pushbutton', 'Position', [200 12 100 20],...
+ 'String','Update','Callback', {@getNewRoiProps,1});%ROIStr
+ else
+ set(etxt_newRoiName,'String',roiList(currRoi).name)
+ for np = 1:min(nROIDim,nDim);
+ if projMethod && np == find(projDim == sort([xySel projDim])); myCol = [.5 .5 .5]; else myCol = [0 0 0]; end
+ set(txt_RoiPropWinTxt(np),'String',ROIStr{np},'ForegroundColor',myCol);%
+ end
+ set(tempRoiPropWin, 'Visible','on');
+ end
+ function getNewRoiProps(varargin)
if debugMatVis, debugMatVisFcn(1); end
- if sw
- roiList(currRoi).name = get(etxt_newRoiName, 'String');
- roiList(currRoi).settings.xySel = xySel;
- roiList(currRoi).settings.position = currPos;
- roiList(currRoi).settings.zoomVal = zoomVal;
- set(roiText.im(:,currRoi), 'String', roiList(currRoi).name);
- set(roiText.zoom(:,currRoi), 'String', roiList(currRoi).name);
- s = get(roiListbox, 'String');
- s{currRoi} = [s{currRoi}(1:5) roiList(currRoi).name];
- set(roiListbox, 'String', s);
- updateRoiSelection
- end
- delete(tempRoiPropWin);
- set(roiBtRename, 'UserData',0)
+ roiList(currRoi).name = get(etxt_newRoiName, 'String');
+ roiList(currRoi).settings.xySel = xySel;
+ for np = 1:min(nROIDim,nDim);
+ if ~(projMethod && np == find(projDim == sort([xySel projDim])))
+ roiList(currRoi).settings.position(np) = currPos(np);
+ end
+ end
+ roiList(currRoi).settings.zoomVal = zoomVal;
+ set(roiText.im(:,currRoi), 'String', roiList(currRoi).name);
+ set(roiText.zoom(:,currRoi), 'String', roiList(currRoi).name);
+ s = get(roiListbox, 'String');
+ s{currRoi} = [s{currRoi}(1:5) roiList(currRoi).name];
+ set(roiListbox, 'String', s);
+ updateRoiSelection
+ %set(roiBtRename,'Value',0)
+ %updateRoiSettings;
if debugMatVis, debugMatVisFcn(2); end
end
if debugMatVis, debugMatVisFcn(2); end
@@ -9456,6 +9747,15 @@ function updateRoiSelection(numberRoi)
set(roiText.zoom, 'FontWeight', 'normal','Color','w'); %'Color', 'b');
set(roiText.im(:,numberRoi), 'FontWeight', 'bold'); %'Color','r');
set(roiText.zoom(:,numberRoi),'FontWeight', 'bold'); % 'Color','r');
+ if numel(numberRoi) == 1
+ if customDimScale
+ set(roiCenterIndicator(:),'Visible','on','Position',[roiList(numberRoi).centerOfGravity([2 1]).*pxWidth(xySel([2 1])),0]);
+ else
+ set(roiCenterIndicator(:),'Visible','on','Position',[roiList(numberRoi).centerOfGravity([2 1]),0]);
+ end
+ else
+ set(roiCenterIndicator(:),'Visible','off');
+ end
% Color for selected ROIs
colorcodePlots = plotColors(numel(numberRoi));
for ii = 1:numel(numberRoi)
@@ -9470,7 +9770,7 @@ function updateRoiSelection(numberRoi)
set(roiSize, 'String', num2str(sum(roiList(numberRoi(1)).mask(:))));
set(roiImage, 'CData',currIm{1}, 'AlphaData', 5/9*(0.8+roiList(numberRoi(1)).mask));
set(roiAxes, 'Color','k');
- updateRoiProperties(1);
+ updateRoiProperties(0);
if debugMatVis, debugMatVisFcn(2); end
end
function updateRoiProperties(plotUpdate)
@@ -9511,6 +9811,7 @@ function updateRoiProperties(plotUpdate)
updatePlots;
end
end
+ if get(roiBtRename,'Value'); updateRoiSettings; end
end
if debugMatVis, debugMatVisFcn(2); end
end
@@ -9523,10 +9824,12 @@ function listboxCallback(varargin)
matchDims = find([ROIPos(1:matchDims)>dim(1:matchDims) 1],1,'first')-1; % checks if saved ROIpos is larger than data dimension and reduces MATCHDIMS, in case
currPos(1:matchDims) = ROIPos(1:matchDims);
currPos(currPos(1:matchDims)>dim(1:matchDims))=1;
- %ROIZoomVal = roiList(numberRoi).settings.zoomVal;
+ zoomVal = roiList(numberRoi).settings.zoomVal;
+ updateZoom(1,1,1:nDim,'ROIupdate');
updateSelection(1:length(currPos));
end
drawPlots;
+
updateRoiSelection(numberRoi);
if debugMatVis, debugMatVisFcn(2); end
@@ -11584,8 +11887,7 @@ function vidWriter(writetype)
end
if debugMatVis, debugMatVisFcn(2); end
end
-
-% resets figure properties
+%% resets figure properties
function vidGenerator_myHardcopyFigureReset(hh)
if debugMatVis, debugMatVisFcn(1); end
% Reset the axes limit modes
@@ -11627,7 +11929,7 @@ function vidGenerator_myHardcopyFigureReset(hh)
end
if debugMatVis>1, debugMatVisFcn(2); end
end
- %Close all windows
+%% Close all windows
function closeGui(varargin)
if debugMatVis, debugMatVisFcn(1); end
% Set flag to stop execution of calculation of global histogram
@@ -11694,17 +11996,30 @@ function debugMatVisFcn(inOut)
%stopHere
end
if inOut == 1
+ if fctLevel == 1 && isstruct(fctCount)
+ fnames = fieldnames(fctCount);
+ for ii = 1:length(fnames)
+ fctCount.(fnames{ii}).count = 0;
+ end
+ end
if isfield(fctCount,fctName);
fctCount.(fctName).count = fctCount.(fctName).count+1;
+ fctCount.(fctName).countTot = fctCount.(fctName).countTot+1;
else
fctCount.(fctName).count = 1;
+ fctCount.(fctName).countTot = 1;
end
fctCount.(fctName).time = tic;
timeStr = [];
+ fctNameStr = sprintf('%s',fctName, fctName);%fctName
else
timeStr = sprintf('(execution time: %.3f s)',toc(fctCount.(fctName).time));
+ fctNameStr = sprintf('%s',fctName);%fctName
+ end
+ fprintf('%s%s %d/%d:%s %s\n',repmat(sprintf('|\t'), 1, fctLevel-1), inOutStr{inOut},fctCount.(fctName).count,fctCount.(fctName).countTot, fctNameStr, timeStr);
+ if fctLevel == 1 && inOut == 2
+ fprintf('\n')
end
- fprintf('%s%s %d:%s %s\n',repmat(sprintf('|\t'), 1, fctLevel-1), inOutStr{inOut},fctCount.(fctName).count, fctName, timeStr);
end
if debugMatVis, debugMatVisFcn(2); end
end
diff --git a/main.asv b/main.asv
deleted file mode 100644
index f308ac1..0000000
--- a/main.asv
+++ /dev/null
@@ -1,144 +0,0 @@
-%% load files and do cross correlation alignment
-%Choose input folder, where all trial folders are and output folder where
-%shift corrected tiff stacks for each trial shall be generated. You can
-%also choose a binning factor [x, y, t]. nSubIm ist the number of
-%iterations the shift correction will do. The more the better, but of
-%course it is more time consuming. The standard value here is 10.
-inFolder = 'F:\Arbeit\testData\PCAICA';
-outFolder = 'F:\Arbeit\testData\PCAICA\corr';
-binningFactor = [1, 1, 2];
-nSubIm = 10;
-CellSortXCorr(inFolder, outFolder, nSubIm, binningFactor);
-%% load files
-%go to corr folder
-outFolder = 'F:\Arbeit\testData\PCAICA';
-%shifft correction on all frames
-%[data_g, data_r, frames, fn_green, fn_red, fileNamesGreen, fileNamesRed] = CellSortLoadTrials(outFolder);
-%shift correction only on trials
-[data_g, data_r, frames, fn_green, fn_red, fileNamesGreen, fileNamesRed] = CellSortLoadTrialsShiftCorrOnTrials(outFolder);
-%If you want to load single files, use the functions below.
-% fn_green = 'data_g.tif';
-% fn_red = 'data_r.tif';
-% data_g = readTiff(fn_green);
-% data_r = readTiff(fn_red);
-%% Crop Data
-%If you want to crop the data to get rid of the shift correction artifacts,
-%type in the intervals of pixels in x and y directions you want to keep and
-%evaluate this section. Use matVis(data_r) to look at your data.
-xInterval = 40:380;
-yInterval = 40:380;
-
-data_g = data_g(xInterval,yInterval,:);
-data_r = data_r(xInterval,yInterval,:);
-%% 1. PCA
-%calculate PCAs
-nPCs = 100;
-flims = [];
-dSamp = [1 1]; %temporal, spatial downsampling
-[mixedsig, mixedfilters, CovEvals, covtrace, movm, movtm] = ...
- CellsortPCA(fn_green, flims, nPCs, dSamp, [], [], data_g);
-%% 2a. Choose PCs
-%choose PCAs, type f/b in command line to go back or forward. type two number
-%to select the range "1 ENTER 25 ENTER" would select the PCAs from 1 to 25
-
-[PCuse] = CellsortChoosePCs(fn_green, mixedfilters, data_g);
-
-%OR specify the PCAs to use manually:
-%PCuse = [7,8,18,20,21,25,27,30,32,35,36,46];
-%% 2b. Plot PC spectrum
-%optionally, you can display the PC spectrum..
-
-CellsortPlotPCspectrum(fn_green, CovEvals, PCuse, data_g)
-
-%% 3a. ICA
-%calculate ICAs, set mu to a value between 0 and 1, where 1 means pure
-%temporal identification and 0 pure spatial. A value of 0.1-0.2 seems to be
-%best.. make sure that the algorithm converges (see command line). If not
-%run it again
-nIC = length(PCuse);
-mu = 0.2;
-
-[ica_sig, ica_filters, ica_A, numiter] = CellsortICA(mixedsig, mixedfilters, CovEvals, PCuse, mu, nIC);
-
-%% 3b. Plot ICs
-%optionally, plot ICs (you have to use at least 20.. or change the number
-%on the buttom
-tlims = [];
-dt = 0.1;
-
-figure(2)
-CellsortICAplot('series', ica_filters, ica_sig, movm, tlims, dt, [], [], [1:size(ica_sig,1)]);
-
-%% 4a. Segment contiguous regions within ICs
-%search for indepent segments, you have to adjust these values well:
-%smwidth: width of a smoothing filter (1 should be okay)
-%thresh: threshold for normalized standard deviation in ICs (verey
-% sensitive, standard: 2)
-%arealims: limit for the detected areas in pixeks: [min max] or [min]
-%plotting: 1 = yes or 0 = no.. shall a plot be shown or not?
-
-smwidth = 1;
-thresh = 1.3;
-arealims = [200];
-plotting = 1;
-
-[ica_segments, segmentlabel, segcentroid] = CellsortSegmentation(ica_filters, smwidth, thresh, arealims, plotting);
-
-%% 4b. CellsortApplyFilter
-%filter signal and extract regions signals
-cell_sig = CellsortApplyFilter(ica_segments, flims, , data_g);
-
-%% 5. CellsortFindspikes
-%optionally, find spikes in signal
-deconvtau = 0;
-spike_thresh = 2;
-normalization = 1;
-
-[spmat, spt, spc] = CellsortFindspikes(ica_sig, spike_thresh, dt, deconvtau, normalization);
-
-%% Show results
-%optionally, plot signals
-figure(2)
-CellsortICAplot('series', ica_filters, ica_sig, movm, tlims, dt, 1, 2, 1:20, spt, spc);
-%% caluclate correlation matrix for cell_sig
-clusterThreshold = 0.9;
-[ica_segments, cluster, subPlotCols, subPlotWidth, sortedIdx] = calcCorrEff(cell_sig, ica_segments, clusterThreshold);
-%% plot
-%acustic sweep parameters:
-%number of frames after trial begin when first sweep occurrs
-sweepDelay = 100;
-%number of frames between sweeps
-sweepInterval = 30;
-%number of sweeps
-numberOfSweeps = 5;
-%number of frames a sweep lasts
-sweepDuration = 10;
-
-%number of time courses to show when slide bar is used
-clusterSize = 10;
-frameSteps = 20;
-
-cell_sig_merged = alternativePlot(ica_segments, cluster, cell_sig, subPlotCols, sortedIdx, data_r, frames, fileNamesGreen, clusterSize, sweepDelay, sweepInterval, numberOfSweeps, sweepDuration, frameSteps);
-
-%% let user deselect and merge rois
-%merge -> change cluster ->recereate plots
-merge = {[1,2,3], [5,6]};
-delete = [8,4,11];
-figure;
-cluster_new = cluster;
-%delete
-for i = 1:size(delete,2)
- cluster_new{delete(i)} = [];
-end
-%merge
-for i = 1:size(merge, 2)
- for j = 2:size(merge{i},2)
- cluster_new{merge{i}(1)} = [cluster_new{merge{i}(1)}, cluster_new{merge{i}(j)}];
- cluster_new{merge{i}(j)} = [];
- end
-end
-cluster_new = cluster_new(~cellfun(@isempty, cluster_new));
-subPlotCols = size(cluster_new, 2);
-
-%redraw
-cell_sig_merged = alternativePlot(ica_segments, cluster_new, cell_sig, subPlotCols, sortedIdx, data_r);
diff --git a/main.m b/main.m
index b0f7613..a06415b 100644
--- a/main.m
+++ b/main.m
@@ -11,7 +11,7 @@
CellSortXCorr(inFolder, outFolder, nSubIm, binningFactor);
%% load files
%go to corr folder
-outFolder = 'F:\Arbeit\testData\PCAICA';
+outFolder = 'X:\Projects\ICA_PCA\data_dendrites\51EA\day_1';
%shifft correction on all frames
%[data_g, data_r, frames, fn_green, fn_red, fileNamesGreen, fileNamesRed] = CellSortLoadTrials(outFolder);
%shift correction only on trials