├── scripts ├── closeAllAsObjs.m ├── asSaveAllImages.m ├── asSetAllWindows.m ├── asSetAllSelections.m ├── asSetAllTitlesToImageString.m ├── rebuildAsObjs.m ├── asDeleteAllRois.m ├── asGetAllRoiStdev.m ├── asGetAllTitles.m ├── asSetAllRois.m ├── asGetAllRoiMeans.m ├── asCloseAll.m ├── asMean.m ├── asSum.m ├── asMultiview.m ├── asGetAllRoiValues.m ├── asMarkPixel.m ├── asScreenshotCollage.m ├── asMultiOp.m ├── asMultiMask.m ├── asNoiseRoi.m ├── asGlobalValueChanger.m ├── asMultiRoiAnaCsv.m ├── asMultiDiffMaps.m ├── asFileMonitor.m ├── asLineup.m └── asAlgebra.m ├── .gitignore ├── icons ├── lena.mat ├── lock.gif ├── lock.png ├── play.png ├── send.png ├── figure.png ├── filter.png ├── lineup.png ├── lock1.png ├── lock2.png ├── lock3.png ├── lock4.png ├── pause.png ├── upload.png ├── wsObj.png ├── asBrowse.png ├── colorbar.png ├── dontSend.png ├── download.png ├── magnify.png ├── refresh.png ├── rotLeft.png ├── rotRight.png ├── squeeze.png └── showMarker.png ├── testPhan64.mat ├── supportFunctions ├── ftimes.m ├── nop.m ├── martin_phase.m ├── coilCombineMarkus.m ├── complex2rgb.m ├── cPlot.m ├── mydlg.m ├── iconRead.m ├── imageCollage.m ├── humanize.m └── showwindow.m ├── customColormaps ├── NegRedPosGreen.mat ├── blue_darkBlue_red.mat ├── red_darkBlue_blue.mat ├── gray_periodic.m ├── redgreen_periodic.m ├── viridis.m ├── ylgnbu_r.m ├── seismic.m └── rdbu_r.m ├── ab.m ├── cursorPosFcn ├── plotCol.m ├── plotRow.m ├── userCursorPosFcn.m ├── drawPhaseCircle.m ├── phaseCirclePlot.m ├── phasePlot.m ├── plotRowAndCol.m └── plotAlongDim.m ├── createMultiframeTestphan.m ├── LICENSE_1_0.txt ├── README.m ├── asIconClass.m ├── asSendGroupClass.m ├── as.m ├── asInfoTextClass.m ├── asImageTextClass.m ├── asRoiClass.m ├── asCmplxChooserClass.m └── asStatisticsClass.m /scripts/closeAllAsObjs.m: -------------------------------------------------------------------------------- 1 | asCloseAll(); -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | infotextTemp1.txt 2 | infotextTemp2.txt -------------------------------------------------------------------------------- /icons/lena.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/icons/lena.mat -------------------------------------------------------------------------------- /icons/lock.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/icons/lock.gif -------------------------------------------------------------------------------- /icons/lock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/icons/lock.png -------------------------------------------------------------------------------- /icons/play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/icons/play.png -------------------------------------------------------------------------------- /icons/send.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/icons/send.png -------------------------------------------------------------------------------- /testPhan64.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/testPhan64.mat -------------------------------------------------------------------------------- /icons/figure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/icons/figure.png -------------------------------------------------------------------------------- /icons/filter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/icons/filter.png -------------------------------------------------------------------------------- /icons/lineup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/icons/lineup.png -------------------------------------------------------------------------------- /icons/lock1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/icons/lock1.png -------------------------------------------------------------------------------- /icons/lock2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/icons/lock2.png -------------------------------------------------------------------------------- /icons/lock3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/icons/lock3.png -------------------------------------------------------------------------------- /icons/lock4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/icons/lock4.png -------------------------------------------------------------------------------- /icons/pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/icons/pause.png -------------------------------------------------------------------------------- /icons/upload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/icons/upload.png -------------------------------------------------------------------------------- /icons/wsObj.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/icons/wsObj.png -------------------------------------------------------------------------------- /icons/asBrowse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/icons/asBrowse.png -------------------------------------------------------------------------------- /icons/colorbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/icons/colorbar.png -------------------------------------------------------------------------------- /icons/dontSend.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/icons/dontSend.png -------------------------------------------------------------------------------- /icons/download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/icons/download.png -------------------------------------------------------------------------------- /icons/magnify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/icons/magnify.png -------------------------------------------------------------------------------- /icons/refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/icons/refresh.png -------------------------------------------------------------------------------- /icons/rotLeft.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/icons/rotLeft.png -------------------------------------------------------------------------------- /icons/rotRight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/icons/rotRight.png -------------------------------------------------------------------------------- /icons/squeeze.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/icons/squeeze.png -------------------------------------------------------------------------------- /icons/showMarker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/icons/showMarker.png -------------------------------------------------------------------------------- /supportFunctions/ftimes.m: -------------------------------------------------------------------------------- 1 | function out = ftimes(a,b) 2 | out = bsxfun(@times,a,b); 3 | end -------------------------------------------------------------------------------- /scripts/asSaveAllImages.m: -------------------------------------------------------------------------------- 1 | function asSaveAllImages() 2 | arrShow.exportAllGlobalArrayImages(); 3 | end -------------------------------------------------------------------------------- /customColormaps/NegRedPosGreen.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/customColormaps/NegRedPosGreen.mat -------------------------------------------------------------------------------- /customColormaps/blue_darkBlue_red.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/customColormaps/blue_darkBlue_red.mat -------------------------------------------------------------------------------- /customColormaps/red_darkBlue_blue.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsumpf/arrShow/HEAD/customColormaps/red_darkBlue_blue.mat -------------------------------------------------------------------------------- /scripts/asSetAllWindows.m: -------------------------------------------------------------------------------- 1 | function asSetAllWindows(CW) 2 | global asObjs 3 | for i = 1 : length(asObjs) 4 | asObjs(i).window.setCW(CW); 5 | end -------------------------------------------------------------------------------- /scripts/asSetAllSelections.m: -------------------------------------------------------------------------------- 1 | function asSetAllSelections(selection) 2 | global asObjs 3 | for i = 1 : length(asObjs) 4 | asObjs(i).selection.setValue(selection); 5 | end -------------------------------------------------------------------------------- /scripts/asSetAllTitlesToImageString.m: -------------------------------------------------------------------------------- 1 | function asSetAllTitlesToImageString 2 | global asObjs 3 | for i = 1 : length(asObjs) 4 | asObjs(i).toggleTitleAsImageText; 5 | end 6 | -------------------------------------------------------------------------------- /scripts/rebuildAsObjs.m: -------------------------------------------------------------------------------- 1 | function rebuildAsObjs 2 | evalin('base','global asObjs'); 3 | global asObjs; 4 | 5 | for i = 1 :length(asObjs) 6 | asObjs(i) = asObjs(i).rebuildObject; 7 | end -------------------------------------------------------------------------------- /scripts/asDeleteAllRois.m: -------------------------------------------------------------------------------- 1 | global asObjs 2 | for i = 1 : length(asObjs) 3 | if isa(asObjs(i).roi,'asRoiClass') && isvalid(asObjs(i).roi) 4 | asObjs(i).roi.delete; 5 | end 6 | end -------------------------------------------------------------------------------- /scripts/asGetAllRoiStdev.m: -------------------------------------------------------------------------------- 1 | function asGetAllRoiStdev() 2 | 3 | global asObjs 4 | for i = 1 : length(asObjs) 5 | [m,s] = asObjs(i).roi.getMeanAndStd; 6 | fprintf('%f\n',s); 7 | end 8 | -------------------------------------------------------------------------------- /scripts/asGetAllTitles.m: -------------------------------------------------------------------------------- 1 | function asGetAllTitles() 2 | 3 | global asObjs 4 | for i = 1 : length(asObjs) 5 | t = asObjs(i).getFigureTitle; 6 | fprintf('%s\n',t); 7 | 8 | end 9 | -------------------------------------------------------------------------------- /supportFunctions/nop.m: -------------------------------------------------------------------------------- 1 | 2 | 3 | function nop(varargin) 4 | 5 | % Does nothing 6 | % is needed for closing the asObjs without debugging messages 7 | % for debugging messages fprintf is used 8 | 9 | end -------------------------------------------------------------------------------- /scripts/asSetAllRois.m: -------------------------------------------------------------------------------- 1 | function asSetAllRois(pos) 2 | % usage: asSetAllRois(pos) 3 | global asObjs 4 | for i = 1 : length(asObjs) 5 | % asObjs(i).roi.setPosition(pos); 6 | asObjs(i).createRoi(pos); 7 | end 8 | -------------------------------------------------------------------------------- /scripts/asGetAllRoiMeans.m: -------------------------------------------------------------------------------- 1 | function asGetAllRoiMeans() 2 | 3 | global asObjs 4 | for i = 1 : length(asObjs) 5 | [m,s] = asObjs(i).roi.getMeanAndStd; 6 | fprintf('%f\n',m); 7 | % fprintf('%s\n',num2str(m)); 8 | end 9 | -------------------------------------------------------------------------------- /scripts/asCloseAll.m: -------------------------------------------------------------------------------- 1 | function asCloseAll 2 | objs = arrShow.findAllObjects(); 3 | objs = [objs,arrShow.findAllObjects()]; 4 | if ~isempty(objs) 5 | objs.close; 6 | delete(objs); 7 | end 8 | evalin('base','clear global asObjs'); -------------------------------------------------------------------------------- /scripts/asMean.m: -------------------------------------------------------------------------------- 1 | function [sumImg, sumAsObj] = asMean(asObjs, showResultInArrShow) 2 | 3 | if nargin < 2 4 | showResultInArrShow = true; 5 | end 6 | [sumImg, sumAsObj] = asAlgebra(asObjs, 'mean',showResultInArrShow); 7 | 8 | end 9 | -------------------------------------------------------------------------------- /scripts/asSum.m: -------------------------------------------------------------------------------- 1 | function [sumImg, sumAsObj] = asSum(asObjs, showResultInArrShow) 2 | 3 | if nargin < 2 4 | showResultInArrShow = true; 5 | end 6 | [sumImg, sumAsObj] = asAlgebra(asObjs, 'sum',showResultInArrShow); 7 | 8 | end 9 | -------------------------------------------------------------------------------- /scripts/asMultiview.m: -------------------------------------------------------------------------------- 1 | function asMultiview(in, info) 2 | 3 | for i = 1 : length(in) 4 | if nargin > 1 5 | tit = []; 6 | if isfield(info{1},'meanAF'); 7 | tit = ['af=',num2str( info{i}.meanAF)]; 8 | end 9 | as(in{i}, 'info',info{i},'title',tit); 10 | else 11 | as(in{i}); 12 | end 13 | 14 | end -------------------------------------------------------------------------------- /scripts/asGetAllRoiValues.m: -------------------------------------------------------------------------------- 1 | function asGetAllRoiValues(includeTitle) 2 | if nargin < 1 3 | includeTitle = false; 4 | end 5 | 6 | global asObjs 7 | for i = 1 : length(asObjs) 8 | [m,s] = asObjs(i).roi.getMeanAndStd; 9 | 10 | if includeTitle 11 | t = asObjs(i).getFigureTitle; 12 | fprintf('%s, %f, %f\n',t,m,s); 13 | else 14 | fprintf(' %f, %f\n',m,s); 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /supportFunctions/martin_phase.m: -------------------------------------------------------------------------------- 1 | function c = martin_phase(N) 2 | % phase colormap as found in a tool from Martin Uecker (muecker@gwdg.de) 3 | 4 | if nargin < 1 5 | N = 64; 6 | end 7 | 8 | 9 | phase = linspace(0,2*pi,N); 10 | 11 | c = zeros(N,3); 12 | c(:,1) = sin(phase); 13 | c(:,2) = sin(phase + 120 * pi/180); 14 | c(:,3) = sin(phase + 240 * pi/180); 15 | 16 | c = (c + 1)/2; 17 | 18 | end 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /scripts/asMarkPixel.m: -------------------------------------------------------------------------------- 1 | function asMarkPixel(asObjsOrPos, pos) 2 | 3 | if isa(asObjsOrPos,'arrShow'); 4 | if nargin < 2 5 | error('asMarkPixel:missingArgument','Need position vector'); 6 | end 7 | aso = asObjsOrPos; 8 | else 9 | % assume the first input argument to be the position vector 10 | pos = asObjsOrPos; 11 | global asObjs %#ok 12 | aso = asObjs; 13 | end 14 | 15 | for i = 1 : length(aso) 16 | aso(i).markers.add(pos); 17 | end 18 | 19 | 20 | end -------------------------------------------------------------------------------- /scripts/asScreenshotCollage.m: -------------------------------------------------------------------------------- 1 | function collage = asScreenshotCollage(asObjs) 2 | if nargin < 1 3 | global asObjs 4 | end 5 | 6 | nObjs = numel(asObjs); 7 | allScrShots = cell(nObjs,1); 8 | for i = 1 : nObjs 9 | currScrShot = asObjs(i).getScreenshot(); 10 | currImg = rgb2gray(currScrShot.cdata); 11 | allScrShots{i} = currImg; 12 | end 13 | allScrShots = asDataClass.cell2imageMat(allScrShots); 14 | 15 | si = size(allScrShots); 16 | collage = reshape(allScrShots,[si(1),si(2)* si(3)]); 17 | end -------------------------------------------------------------------------------- /ab.m: -------------------------------------------------------------------------------- 1 | % Copyright (C) 2009-2013 Biomedizinische NMR Forschungs GmbH 2 | % http://www.biomednmr.mpg.de 3 | % Author: Tilman Johannes Sumpf 4 | % 5 | % Distributed under the Boost Software License, Version 1.0. 6 | % (See accompanying file LICENSE_1_0.txt or copy at 7 | % http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | function ab(asObjs) 10 | % Shortcut for "asBrowse(asObjs)" 11 | if nargin < 1 12 | asObjs = []; 13 | end 14 | asBrowse(asObjs); 15 | 16 | end -------------------------------------------------------------------------------- /scripts/asMultiOp.m: -------------------------------------------------------------------------------- 1 | function asMultiOp(asObjs, op, createNewWindow) 2 | if nargin < 3 3 | createNewWindow = false; 4 | end 5 | 6 | for i = 1 : length(asObjs) 7 | curr = asObjs(i).getAllImages; 8 | eval(['curr = curr',op,';']); 9 | if createNewWindow 10 | pos = asObjs(i).getFigureOuterPosition; 11 | pos(2) = pos(2) - pos(4); 12 | o = as(asObjs(i)); 13 | o.setMainWindowPosition(pos); 14 | else 15 | o = asObjs(i); 16 | end 17 | o.overwriteImageArray(curr); 18 | end 19 | end -------------------------------------------------------------------------------- /scripts/asMultiMask.m: -------------------------------------------------------------------------------- 1 | function asMultiMask(asObjs, mask, createNewWindow) 2 | if nargin < 3 3 | createNewWindow = false; 4 | end 5 | 6 | for i = 1 : length(asObjs) 7 | curr = asObjs(i).getAllImages; 8 | curr = ftimes(curr,mask); 9 | if createNewWindow 10 | pos = asObjs(i).getFigureOuterPosition; 11 | pos(2) = pos(2) - pos(4); 12 | o = as(asObjs(i)); 13 | % o.setMainWindowPosition(pos); 14 | o.setFigurePosition(pos); 15 | else 16 | o = asObjs(i); 17 | end 18 | o.overwriteImageArray(curr); 19 | end 20 | end -------------------------------------------------------------------------------- /customColormaps/gray_periodic.m: -------------------------------------------------------------------------------- 1 | function c = gray_periodic(N,range) 2 | % returns a colormap ranging from 3 | % black over white to black 4 | if nargin < 2 5 | range = [0,1]; 6 | if nargin < 1 7 | N = 64; 8 | end 9 | end 10 | 11 | equalStartEnd = false; 12 | inc = 2*(range(2) - range(1))/N; 13 | 14 | if equalStartEnd 15 | c1 = range(1) : inc : range(2)-inc; 16 | c2 = range(2)-inc : -inc: range(1); 17 | else 18 | c1 = range(1):inc:range(2); 19 | c2 = range(2)-inc : -inc : range(1)+inc; 20 | end 21 | c = [c1, c2]; 22 | 23 | c = repmat(c',[1,3]); 24 | end 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /cursorPosFcn/plotCol.m: -------------------------------------------------------------------------------- 1 | function plotCol(asObj, pos) 2 | 3 | % get selected image from asObj 4 | currImg = squeeze(asObj.getSelectedImages(false)); 5 | 6 | % assure that its a single 2D image 7 | si = size(currImg); 8 | if numel(si) ~= 2 || si(1) == 1 9 | fprintf('Only single two-dimensional images or single column vectors are currently supported by plotCol\n'); 10 | if isvalid(asObj) 11 | asObj.cursor.togglePlotRowAndCol(false) 12 | end 13 | return 14 | end 15 | 16 | % figure; 17 | cPlot(currImg(:,pos(2))); 18 | 19 | % create plot title 20 | title(['Col ', num2str(pos(2))]); 21 | 22 | % create plot figure title 23 | set(gcf,'name',['Col-Plot: ',asObj.getFigureTitle()]); 24 | end 25 | -------------------------------------------------------------------------------- /cursorPosFcn/plotRow.m: -------------------------------------------------------------------------------- 1 | function plotRow(asObj, pos) 2 | 3 | % get selected image from asObj 4 | currImg = squeeze(asObj.getSelectedImages(false)); 5 | 6 | % assure that its a single 2D image 7 | si = size(currImg); 8 | if numel(si) ~= 2 || si(2) == 1 9 | fprintf('Only single two-dimensional images or single row vectors are currently supported by plotRow\n'); 10 | if isvalid(asObj) 11 | asObj.cursor.togglePlotRowAndCol(false) 12 | end 13 | return 14 | end 15 | 16 | % figure; 17 | cPlot(currImg(pos(1),:)'); 18 | 19 | % create plot title 20 | title(['Row ', num2str(pos(1))]); 21 | 22 | % create plot figure title 23 | set(gcf,'name',['Row-Plot: ',asObj.getFigureTitle()]); 24 | 25 | end 26 | -------------------------------------------------------------------------------- /createMultiframeTestphan.m: -------------------------------------------------------------------------------- 1 | function p = createMultiframeTestphan() 2 | 3 | % load the k-space of a predifined multiecho testphantom from file 4 | basePath = fileparts(mfilename('fullpath')); 5 | dat = load(fullfile(basePath, 'testPhan64.mat')); 6 | p = dat.p; 7 | 8 | % create a movie with different (simulated) shifts of the phantom 9 | NF = 30; % number of frames 10 | dim = size(p,1); 11 | P = zeros([size(p),NF]); 12 | 13 | x = linspace(0,1,dim); 14 | [X,Y] = meshgrid(x,x'); 15 | shiftMax = dim * 2*pi; 16 | shiftInc = shiftMax / NF; 17 | 18 | shift = 0; 19 | for i = 1 : NF 20 | shiftPhX = exp(1i * -shift * X); 21 | shiftPhY = exp(1i * shift * Y); 22 | shift = shift + shiftInc; 23 | currP = ftimes(p,shiftPhX); 24 | currP = ftimes(currP,shiftPhY); 25 | P(:,:,:,i) = currP; 26 | end 27 | 28 | % do a Fourier reconstruction of the data 29 | P = asDataClass.mrIfft(P); 30 | 31 | % simulate 4 different coil profiles 32 | coils = cat(5,X,Y,1-X, 1-Y); 33 | P = ftimes(P,coils); 34 | 35 | % simulate phase perturbations 36 | phase = exp(1i *2 * pi * (1.5 - coils)); 37 | P = ftimes(P,phase); 38 | 39 | % create pseudo k-space data from the fft of the images 40 | p = asDataClass.mrFft(P); 41 | end 42 | -------------------------------------------------------------------------------- /cursorPosFcn/userCursorPosFcn.m: -------------------------------------------------------------------------------- 1 | function userCursorPosFcn(asObj, pos, plotDim) 2 | % Entry function for user-defined cursor position callbacks. 3 | % Use it to call your own cursor position dependent functions. 4 | % A shortcut to edit this file is included to the context menu of the 5 | % arrShow main window. 6 | % 7 | % This function is called from the asObj when pressing 'c', 'C' 8 | % or when selecting the respective option via context menu. 9 | % 10 | % pos = [posY, posX] contains the current cursor position, 11 | % plotDim is the "plot dimension" selected in the data selection panel 12 | try 13 | 14 | % put user cursor position functions here ------------- 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | % ---some examples: 29 | % disp(pos); 30 | plotRow(asObj, pos); 31 | % plotAlongDim(asObj,pos,plotDim); 32 | 33 | % ----------------------------------------------------- 34 | 35 | 36 | 37 | 38 | 39 | 40 | catch err 41 | disp(err); 42 | disp(err.message); 43 | end 44 | end 45 | 46 | 47 | -------------------------------------------------------------------------------- /supportFunctions/coilCombineMarkus.m: -------------------------------------------------------------------------------- 1 | function A_out = coilCombineMarkus(A, dim) 2 | 3 | si = size(A); 4 | order = 1:length(si); 5 | order(dim) = 3; 6 | C = si(dim); 7 | order(3) = dim; 8 | permutsi = si(order); 9 | A = permute(A,order); 10 | A = reshape(A, si(1), si(2), si(dim), []); 11 | 12 | % Get image dimensions and set filter size 13 | filtsize = 7; 14 | filter_ones = ones(filtsize); 15 | A_out = zeros([si(1:2), size(A,4)]); 16 | 17 | for i=1:size(A,4) 18 | tmp1 = A(:,:,:,i); 19 | ctmp1 = conj(tmp1); 20 | tmp2 = zeros(si(1), si(2)); 21 | Rs = zeros(si(1),si(2),C,C); 22 | % Get correlation matrices 23 | for kc1=1:C 24 | for kc2=1:C 25 | Rs(:,:,kc1,kc2) = Rs(:,:,kc1,kc2) + filter2(filter_ones, ... 26 | tmp1(:,:,kc1) .* ctmp1(:,:,kc2), 'same'); 27 | end 28 | end 29 | % Compute and apply filter at each voxel 30 | for kx=1:si(1) 31 | for ky=1:si(2) 32 | % Change suggested by Mark Bydder 33 | [U,~] = svd(squeeze(Rs(kx,ky,:,:))); 34 | myfilt = U(:,1); 35 | tmp2(kx,ky) = myfilt'*squeeze(tmp1(kx,ky,:)); 36 | end 37 | end 38 | A_out(:,:,i) = tmp2; 39 | end 40 | 41 | A_out = reshape(A_out, [permutsi(1), permutsi(2), 1, permutsi(4:end)]); 42 | A_out = permute(A_out, order); 43 | end 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /LICENSE_1_0.txt: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /cursorPosFcn/drawPhaseCircle.m: -------------------------------------------------------------------------------- 1 | function drawPhaseCircle(asObj, pos) 2 | NOP = 40; % number of points for the circle 3 | RADIUSDIV = 15; 4 | CIRCCOL = 'blue'; 5 | 6 | if strcmp(asObj.complexSelect.getSelection,'Pha') 7 | LINECOL = 'white'; 8 | else 9 | LINECOL = 'cyan'; 10 | end 11 | 12 | % get properties from object 13 | % pos = obj.cursor.getPosition; 14 | img = asObj.getSelectedImages(true); 15 | phi = angle(img(pos(1),pos(2))); 16 | 17 | ah = asObj.getCurrentAxesHandle; 18 | 19 | % dim = asObj.getImageDimensions; 20 | z = asObj.getZoom; 21 | dim = diff(z,1,2); 22 | radius = max(dim(1:2))/RADIUSDIV; 23 | 24 | 25 | % derive cartesian coordinates of a line with radius 1 and angle phi\ 26 | [Xl,Yl] = pol2cart([0,phi],[0,radius]); 27 | 28 | % shift to cursor position 29 | Xl = Xl + pos(2); 30 | Yl = Yl + pos(1); 31 | 32 | % derive cartesian coordinates of a unity circle with NOP points 33 | THETA=linspace(0,2*pi,NOP); 34 | RHO=ones(1,NOP) * radius; 35 | [Xc,Yc] = pol2cart(THETA,RHO); 36 | 37 | % shift to cursor position 38 | Xc = Xc + pos(2); 39 | Yc = Yc + pos(1); 40 | 41 | ud = get(ah,'UserData'); 42 | if isfield(ud,'phaseCirc') && ishandle(ud.phaseCirc(1)) 43 | delete(ud.phaseCirc); 44 | end 45 | 46 | % plot both 47 | hold(ah,'on'); 48 | ud.phaseCirc = plot(Xl,Yl,LINECOL,Xc,Yc,CIRCCOL,'Parent',ah); 49 | hold(ah,'off'); 50 | set(ud.phaseCirc,'HitTest','off'); 51 | set(ah,'UserData',ud); 52 | end 53 | -------------------------------------------------------------------------------- /cursorPosFcn/phaseCirclePlot.m: -------------------------------------------------------------------------------- 1 | function phaseCirclePlot(obj) 2 | 3 | DRAWCIRC = true; 4 | NOP = 40; % number of points for the circle 5 | RADIUSDIV = 20; 6 | 7 | % get properties from object 8 | pos = obj.getCursorPosition; 9 | img = obj.getSelectedImages(true); 10 | phi = angle(img(pos(1),pos(2))); 11 | 12 | ah = obj.getCurrentAxesHandle; 13 | 14 | dim = obj.getImageDimensions; 15 | radius = sqrt(prod(dim))/RADIUSDIV; 16 | 17 | 18 | % derive cartesian coordinates of a line with radius 1 and angle phi\ 19 | [Xl,Yl] = pol2cart([0,phi],[0,radius]); 20 | 21 | % shift to cursor position 22 | Xl = Xl + pos(2); 23 | Yl = Yl + pos(1); 24 | 25 | 26 | if DRAWCIRC 27 | % derive cartesian coordinates of a unity circle with NOP points 28 | THETA=linspace(0,2*pi,NOP); 29 | RHO=ones(1,NOP) * radius; 30 | [Xc,Yc] = pol2cart(THETA,RHO); 31 | 32 | % shift to cursor position 33 | Xc = Xc + pos(2); 34 | Yc = Yc + pos(1); 35 | end 36 | 37 | ud = get(ah,'UserData'); 38 | if isfield(ud,'phaseCirc') 39 | delete(ud.phaseCirc); 40 | end 41 | 42 | % plot both 43 | hold(ah,'on'); 44 | if DRAWCIRC 45 | ud.phaseCirc = plot(Xl,Yl,Xc,Yc,'Parent',ah); 46 | else 47 | ud.phaseCirc = plot(Xl,Yl,'Parent',ah); 48 | end 49 | hold(ah,'off'); 50 | set(ah,'UserData',ud); 51 | 52 | end 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /README.m: -------------------------------------------------------------------------------- 1 | % Copyright (C) 2009-2013 Biomedizinische NMR Forschungs GmbH 2 | % http://www.biomednmr.mpg.de 3 | % Author: Tilman Johannes Sumpf 4 | % 5 | % Distributed under the Boost Software License, Version 1.0. 6 | % (See accompanying file LICENSE_1_0.txt or copy at 7 | % http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | %% before the first run, we need to register some paths for arrayShow 10 | % (this needs to be executed only once from within the arrayShow base folder) 11 | disp('Adding arrShow folders to path'); 12 | arrShow.registerPaths(); 13 | 14 | %% Example: %%%%%%%%%%%%%%%%%%%%% 15 | 16 | % create multi-echo, multi-frame, mutli-coil testdata 17 | data1 = createMultiframeTestphan; 18 | 19 | % do a standard Fourier reconstruction 20 | img1 = asDataClass.mrIfft(data1); 21 | 22 | % notice that the data is a 5-dimensional array with 23 | % size(img1, 1) = 64 = read direction 24 | % size(img1, 2) = 64 = phase direction 25 | % size(img1, 3) = 16 = echoes 26 | % size(img1, 4) = 30 = movie frames 27 | % size(img1, 5) = 4 = coils 28 | disp(size(img1)); 29 | 30 | % store some informations in a parameter struct 31 | par.patient = 'Phantom'; 32 | par.study = 'Test'; 33 | par.code = 1.23; 34 | 35 | %% display the images with arrayShow 36 | as(img1, 'info', par); 37 | 38 | %...try using the mouse wheel or the + and - keys to cycle through the different echoes. 39 | % The windowing can be changed by pressing the 3rd mouse button. 40 | % Doubleclick to reset windowing ... 41 | % -------------------------------------------------------------------------------- /scripts/asNoiseRoi.m: -------------------------------------------------------------------------------- 1 | %% draw to rois in asObj 2 | 3 | % asObj = evalin('base','asObj'); 4 | 5 | % get axes handle from asObj 6 | ah = asObj.getCurrentAxesHandle; 7 | 8 | % draw rois 9 | fprintf('draw signal roi...'); 10 | roi{1} = asRoiClass(ah); 11 | fprintf('done!\ndraw noise roi...'); 12 | roi{2} = asRoiClass(ah); 13 | fprintf('done!\n'); 14 | 15 | 16 | %% get roi position matrices 17 | pos{1} = roi{1}.getPosition; 18 | pos{2} = roi{2}.getPosition; 19 | 20 | %% derive noise 21 | 22 | % get image and figure title from asObj 23 | ioi = asObj.getSelectedImages(false); 24 | tit = asObj.getFigureTitle; 25 | 26 | signalArea = roi{1}.createMask; 27 | noiseArea = roi{2}.createMask; 28 | 29 | % calculate SNR 30 | noiseInds = find(ioi & noiseArea); 31 | signalInds = find(ioi & signalArea); 32 | 33 | signal = mean(ioi(signalInds)); 34 | noise = std(ioi(noiseInds)); 35 | 36 | snr = signal / noise; 37 | fprintf('===================\n%s\n',tit); 38 | disp('SNR:'); 39 | disp(snr); 40 | asObj.infotext.setString(['SNR: ',num2str(snr)]); 41 | asObj.infotext.setVisible('on'); 42 | %% noise SD in percent of mean signal 43 | fprintf('===================\n%s\n',tit); 44 | disp('Noise m +- SD:'); 45 | fprintf(' %f +- %f\n',mean(ioi(noiseInds)),noise); 46 | disp('Image m +- SD:'); 47 | fprintf(' %f +- %f\n',signal,std(ioi(signalInds))); 48 | disp('100 * noise SD / mean(signal):'); 49 | fprintf(' %f %% \n',100 * noise / signal); 50 | disp('100 * noise SD / mean(image):'); 51 | fprintf(' %f %% \n',100 * noise / mean(ioi(:))); 52 | disp('100 * noise SD / max(image):'); 53 | fprintf(' %f %% \n',100 * noise / max(ioi(:))); 54 | 55 | %% delete rois 56 | roi{1}.delete; 57 | roi{2}.delete; 58 | 59 | %% create noiseRois from position cell vector 60 | ah = asObj.getCurrentAxesHandle; 61 | roi{1} = asRoiClass(ah,pos{1}); 62 | roi{2} = asRoiClass(ah,pos{2}); 63 | -------------------------------------------------------------------------------- /supportFunctions/complex2rgb.m: -------------------------------------------------------------------------------- 1 | function [rgb, CLim] = complex2rgb(img, N, CLim, incolormap) 2 | 3 | % calculates the cdata from img and the colormap 4 | % 5 | % input arguments: 6 | % img: the image as 2D complex data 7 | % N: the number of colormap tones as scalar 8 | % CLim: the magnitude color limits as 2 element vector 9 | % incolormap: the colormap as n-by-3 matrix 10 | % 11 | % output: 12 | % rgb: the rgb cdata m-by-n-by-3 matrix 13 | % CLim: the colorlimits as 2 element vector 14 | 15 | 16 | switch nargin 17 | case 2 18 | N = 256; 19 | cmap = martin_phase(N); 20 | CLim = []; 21 | case 3 22 | cmap = martin_phase(N); 23 | case 4 24 | if ~ischar(incolormap) 25 | cmap = incolormap; 26 | end 27 | otherwise 28 | end 29 | 30 | m = abs(img); % magnitude 31 | p = angle(img); % phase 32 | 33 | 34 | % get minimum and maximum magnitude value 35 | mi = min(m(:)); 36 | ma = max(m(:)); 37 | 38 | % set the colorlimits 39 | if isempty(CLim) 40 | CLim = [mi, ma]; 41 | end 42 | 43 | if round(mi*1e12) == round(ma*1e12) && ma ~= 0 44 | % set magnitude value to 1 to show a pure phase map 45 | m = ones(size(m)); 46 | else 47 | % scale magnitude image to 0..1 48 | m(m < CLim(1)) = CLim(1); 49 | % m(m > CLim(2)) = CLim(2); 50 | m = (m - CLim(1)) / CLim(2); 51 | m(m > 1) = 1; 52 | 53 | % compensate for rounding errors which sometimes let to negative 54 | % values 55 | m(m<0) = 0; 56 | end 57 | 58 | % scale p from -pi .. pi to int(1 .. N) 59 | p = (N-1) *(p + pi) / (2*pi); 60 | p = round(p + 1); 61 | 62 | % get phase rgb values 63 | p = ind2rgb(p,cmap); 64 | 65 | % get grayscale rgb values for m 66 | rgbm = repmat(m,[1,1,3]); 67 | 68 | % create weighted phase rgb matrix 69 | rgb = rgbm .* p; 70 | 71 | end -------------------------------------------------------------------------------- /supportFunctions/cPlot.m: -------------------------------------------------------------------------------- 1 | function cPlot(x,y,varargin) 2 | mode = 3; % 1 = magnitude and phase, 3 | % 2 = real and imag 4 | % 3 = real and imag in one window 5 | doHolding = false; 6 | plotLegend = 0; 7 | deleteInds = zeros(length(varargin),1); 8 | parent = []; 9 | if nargin == 1 10 | y = x; 11 | x = 1 : length(y); 12 | end 13 | if nargin > 2 14 | for i = 1 : floor(length(varargin)/2) 15 | option = varargin{i*2-1}; 16 | option_value = varargin{i*2}; 17 | 18 | switch lower(option) 19 | case 'hold' 20 | doHolding = option_value; 21 | deleteInds(i*2-1 : i*2) = [1;1]; 22 | case 'mode' 23 | mode = option_value; 24 | deleteInds(i*2-1 : i*2) = [1;1]; 25 | case 'parent' 26 | parent = option_value; 27 | deleteInds(i*2-1 : i*2) = [1;1]; 28 | end 29 | end 30 | end 31 | varargin(deleteInds ~= 0) = []; 32 | 33 | if isempty(parent) 34 | parent = gca; 35 | end 36 | 37 | if doHolding 38 | hold on 39 | end 40 | 41 | switch mode 42 | case 1 43 | subplot(parent,2,1,1) 44 | plot(x,abs(y),varargin{:}); 45 | title('abs'); 46 | subplot(parent,2,1,2) 47 | plot(x,angle(y),varargin{:}); 48 | title('phase'); 49 | case 2 50 | subplot(parent,2,1,1) 51 | plot(x,real(y),varargin{:}); 52 | title('real'); 53 | subplot(parent,2,1,2) 54 | plot(x,imag(y),varargin{:}); 55 | title('imag'); 56 | case 3 57 | % put parent option at the end of varargin vector to allow for a 58 | % preceeding cursor style option (e.g. "x-"); 59 | varargin = [varargin,{'parent'},{parent}]; 60 | 61 | plot(x,[real(y),imag(y)],varargin{:}); 62 | if plotLegend 63 | legend('real','imag'); 64 | end 65 | 66 | end 67 | hold off 68 | end 69 | -------------------------------------------------------------------------------- /cursorPosFcn/phasePlot.m: -------------------------------------------------------------------------------- 1 | function phasePlot(asObj,pos) 2 | INCLUDEMAG = true; 3 | % YLIM = [-180,180]; 4 | YLIM = [-90,90]; 5 | s = asObj.getAllImages; 6 | sel = asObj.selection.getValueAsCell; 7 | 8 | switch length(sel) 9 | case 3 10 | s = squeeze( s( pos(1), pos(2),:) ); 11 | case 4 12 | sel4 = str2double(sel{4}); 13 | s = squeeze( s( pos(1), pos(2),:, sel4) ); 14 | case 5 15 | sel3 = str2double(sel{3}); 16 | sel4 = str2double(sel{4}); 17 | s = squeeze( s( pos(1), pos(2),sel3, sel4,:) ); 18 | end 19 | p = angle(s) * 180/pi; 20 | NE = length(s); 21 | x = 1 : NE; 22 | 23 | xodd = x(1:2:end); 24 | xeven = x(2:2:end); 25 | podd = p(1:2:end); 26 | peven = p(2:2:end); 27 | 28 | 29 | % create plot window below asObject 30 | if isempty(asObj.UserData) ||... 31 | ~isfield(asObj.UserData,'plotFigHandle') ||... 32 | ~ishandle(asObj.UserData.plotFigHandle)||... 33 | ~strcmp(get(asObj.UserData.plotFigHandle,'UserData'),'plotFig') 34 | 35 | figPos = asObj.getFigureOuterPosition; 36 | figPos(2) = figPos(2) - figPos(4) - 26; 37 | asObj.UserData.plotFigHandle = figure('OuterPosition',figPos,... 38 | 'MenuBar','figure',... 39 | 'ToolBar','none',... 40 | 'UserData','plotFig',... 41 | 'name',asObj.getFigureTitle); 42 | asObj.UserData.plotAxisHandle = axes; 43 | figure(asObj.getFigureHandle); 44 | end 45 | ah = asObj.UserData.plotAxisHandle; 46 | 47 | 48 | if INCLUDEMAG 49 | m = abs(s); 50 | ra = YLIM(2) - YLIM(1); 51 | m = (m * ra *.99 / m(1)) + YLIM(1); % norm to pixel decay max 52 | % m = (m * ra *.99 /asObj.statistics.getMax) + YLIM(1); % norm to image max 53 | 54 | plot(ah,xodd,podd,'x',xeven,peven,'o',x,p,'-',x,m,'*'); 55 | ytit = 'signal / phase [au / deg]'; 56 | else 57 | plot(ah,xodd,podd,'x',xeven,peven,'o',x,p,'-'); 58 | % plot(x,p,'x-'); 59 | ytit = 'phase [deg]'; 60 | end 61 | ylim(ah,YLIM); 62 | title(ah,sprintf('Pixel %d / %d',pos(1),pos(2))); 63 | xlabel(ah,'echo number'); 64 | ylabel(ah,ytit); 65 | % legend('odd echoes','even echoes','both') 66 | 67 | 68 | end -------------------------------------------------------------------------------- /scripts/asGlobalValueChanger.m: -------------------------------------------------------------------------------- 1 | function asGlobalValueChanger(asObjs) 2 | 3 | if nargin < 1 4 | global asObjs 5 | end 6 | 7 | protect_distance = true; 8 | 9 | % generate panel 10 | fh = gcf; 11 | set(fh,'WindowScrollWheelFcn',@scollWheelCb); 12 | set(fh,'menubar','none'); 13 | set(fh,'position',[1025,677,116,92]); 14 | 15 | ph = uipanel(fh); 16 | vo = asValueChangerClass(ph,'position',[0 0 1 3],... 17 | 'callback',@mycb,... 18 | 'min',-inf,... 19 | 'max',inf,... 20 | 'colondim1callback',@(varargin)cd1cb,... 21 | 'colondim2callback',@(varargin)cd2cb); 22 | 23 | val = str2double(vo.getStr); 24 | 25 | function cd2cb 26 | protect_distance = false; 27 | end 28 | function cd1cb 29 | protect_distance = true; 30 | end 31 | 32 | function mycb(obj) 33 | newVal = str2double(vo.getStr); 34 | if newVal > val && ~limitExceeded(1) 35 | for i = 1 : length(asObjs) 36 | asObjs(i).selection.increaseCurrentVc(); 37 | end 38 | 39 | elseif newVal < val && ~limitExceeded(-1) 40 | for i = 1 : length(asObjs) 41 | asObjs(i).selection.decreaseCurrentVc(); 42 | end 43 | end 44 | val = newVal; 45 | end 46 | 47 | function bool = limitExceeded(inc) 48 | bool = false; 49 | if ~protect_distance 50 | return 51 | end 52 | for i = 1 : length(asObjs) 53 | currVal = str2double(asObjs(i).selection.getCurrentVcValue(false)); 54 | currVal = currVal + inc; 55 | vc = asObjs(i).selection.getCurrentVc(); 56 | maxVal = vc.getMax; 57 | minVal = vc.getMin; 58 | if currVal > maxVal || currVal < minVal 59 | bool = true; 60 | return; 61 | end 62 | end 63 | end 64 | 65 | function scollWheelCb(src,evnt) 66 | 67 | switch evnt.VerticalScrollCount 68 | case -1 %up 69 | vo.up(); 70 | case 1 % down 71 | vo.down(); 72 | end 73 | end 74 | end -------------------------------------------------------------------------------- /cursorPosFcn/plotRowAndCol.m: -------------------------------------------------------------------------------- 1 | function plotRowAndCol(asObj, pos) 2 | 3 | % get selected image from asObj 4 | img = squeeze(asObj.getSelectedImages(false)); 5 | 6 | % assure that its a single 2D image 7 | if isvector(img) || numel(size(img)) ~= 2 8 | fprintf('Only single two-dimensional images are currently supported by plotRowAndCol\n'); 9 | if isvalid(asObj) 10 | asObj.cursor.togglePlotRowAndCol(false) 11 | end 12 | return 13 | end 14 | 15 | mi = asObj.statistics.getMin; 16 | ma = asObj.statistics.getMax; 17 | if ~isreal(mi); 18 | mi = min([real(mi), imag(mi)]); 19 | ma = max([real(ma), imag(ma)]); 20 | end 21 | yLimits = [mi, ma]; 22 | 23 | 24 | % if this is the first call... 25 | if isempty(asObj.UserData) ||... 26 | ~isfield(asObj.UserData,'plotFigHandle') ||... 27 | ~ishandle(asObj.UserData.plotFigHandle)||... 28 | ~strcmp(get(asObj.UserData.plotFigHandle,'Tag'),'asPlotFig') 29 | 30 | % create plot window 31 | asObj.UserData.plotFigHandle = figure(... 32 | 'MenuBar','figure',... 33 | 'name',['RowAndCol-Plot: ',asObj.getFigureTitle],... 34 | 'ToolBar','none',... 35 | 'Tag','asPlotFig',... 36 | 'IntegerHandle','off',... 37 | 'CloseRequestFcn',@(src, evnt)closeReqCb(src,asObj)); 38 | 39 | % create subplots for row and column 40 | asObj.UserData.colPlotHandle = subplot(2,1,1,'parent',asObj.UserData.plotFigHandle); 41 | asObj.UserData.rowPlotHandle = subplot(2,1,2,'parent',asObj.UserData.plotFigHandle); 42 | end 43 | 44 | % subplot axes handle 45 | ah1 = asObj.UserData.colPlotHandle; 46 | ah2 = asObj.UserData.rowPlotHandle; 47 | 48 | % create col plot 49 | x = 1 : size(img,2); 50 | cPlot(x, img(pos(1),:)','parent',ah1); 51 | ylim(ah1, yLimits); 52 | xlim(ah1, [1,size(img,2)]); 53 | ylabel(ah1, 'pixel intensity'); 54 | xlabel(ah1, 'column'); 55 | 56 | % create plot title 57 | title(ah1, ['Pixel ( ',num2str(pos(1)),' / ',num2str(pos(2)),' )']); 58 | 59 | % create row plot 60 | y = 1 : size(img,1); 61 | cPlot(y, img(:,pos(2)),'parent',ah2); 62 | ylabel(ah2, 'pixel intensity'); 63 | xlabel(ah2, 'row'); 64 | ylim(ah2, yLimits); 65 | xlim(ah2, [1,size(img,1)]); 66 | end 67 | 68 | function closeReqCb(src, asObj) 69 | if isvalid(asObj) 70 | asObj.cursor.togglePlotRowAndCol(false) 71 | end 72 | delete(src); 73 | end -------------------------------------------------------------------------------- /customColormaps/redgreen_periodic.m: -------------------------------------------------------------------------------- 1 | function c = redgreen_periodic 2 | 3 | c =[ 0 0 0; 4 | 0.0625 0 0; 5 | 0.1250 0 0; 6 | 0.1875 0 0; 7 | 0.2500 0 0; 8 | 0.3125 0 0; 9 | 0.3750 0 0; 10 | 0.4375 0 0; 11 | 0.5000 0 0; 12 | 0.5625 0 0; 13 | 0.6250 0 0; 14 | 0.6875 0 0; 15 | 0.7500 0 0; 16 | 0.8125 0 0; 17 | 0.8750 0 0; 18 | 0.9375 0 0; 19 | 1.0000 0 0; 20 | 0.9688 0.0313 0; 21 | 0.9375 0.0625 0; 22 | 0.9063 0.0938 0; 23 | 0.8750 0.1250 0; 24 | 0.8438 0.1563 0; 25 | 0.8125 0.1875 0; 26 | 0.7813 0.2188 0; 27 | 0.7500 0.2500 0; 28 | 0.7188 0.2813 0; 29 | 0.6875 0.3125 0; 30 | 0.6563 0.3438 0; 31 | 0.6250 0.3750 0; 32 | 0.5938 0.4063 0; 33 | 0.5625 0.4375 0; 34 | 0.5313 0.4688 0; 35 | 0.5000 0.5000 0; 36 | 0.4688 0.5313 0; 37 | 0.4375 0.5625 0; 38 | 0.4063 0.5938 0; 39 | 0.3750 0.6250 0; 40 | 0.3438 0.6563 0; 41 | 0.3125 0.6875 0; 42 | 0.2813 0.7188 0; 43 | 0.2500 0.7500 0; 44 | 0.2188 0.7813 0; 45 | 0.1875 0.8125 0; 46 | 0.1563 0.8438 0; 47 | 0.1250 0.8750 0; 48 | 0.0938 0.9063 0; 49 | 0.0625 0.9375 0; 50 | 0.0313 0.9688 0; 51 | 0 1.0000 0; 52 | 0 0.9333 0; 53 | 0 0.8667 0; 54 | 0 0.8000 0; 55 | 0 0.7333 0; 56 | 0 0.6667 0; 57 | 0 0.6000 0; 58 | 0 0.5333 0; 59 | 0 0.4667 0; 60 | 0 0.4000 0; 61 | 0 0.3333 0; 62 | 0 0.2667 0; 63 | 0 0.2000 0; 64 | 0 0.1333 0; 65 | 0 0.0667 0; 66 | 0 0 0]; 67 | end -------------------------------------------------------------------------------- /supportFunctions/mydlg.m: -------------------------------------------------------------------------------- 1 | function R = mydlg(promt, dlg_title, defAns, pos) 2 | % dialog with working standard keypress functions, e.g. return to accept and escape 3 | % to close. 4 | if nargin < 4 5 | pos = [500 500 210 90]; 6 | if nargin < 3 7 | defAns = ''; 8 | if nargin < 2 9 | dlg_title = ''; 10 | if nargin < 1 11 | promt = 'Please enter sth.'; 12 | end 13 | end 14 | end 15 | end 16 | 17 | % Returns a double value. 18 | R = []; % Default, in case user closes GUI. 19 | S.fh = figure('units','pixels',... 20 | 'position',pos,... 21 | 'menubar','none',... 22 | 'numbertitle','off',... 23 | 'name',dlg_title,... % Here is the title. 24 | 'resize','off'); 25 | S.ed = uicontrol('style','edit',... 26 | 'units','pix',... 27 | 'position',[10 35 pos(3)-20 30],... 28 | 'backgroundcolor','w',... 29 | 'horizontalalignment','left',... 30 | 'string',defAns,... 31 | 'keypressfcn',{@ed_kpfcn}); 32 | S.tx = uicontrol('style','text',... 33 | 'units','pix',... 34 | 'position',[10 65 180 20],... 35 | 'backgroundcolor',get(S.fh,'color'),... 36 | 'horizontalalignment','left',... 37 | 'string',promt); % The prompt 38 | S.pb(1) = uicontrol('style','pushbutton',... 39 | 'units','pix',... 40 | 'position',[95 5 50 25],... 41 | 'string','O.k.',... % The O.k. button. 42 | 'callback',{@pb_call,S}); 43 | S.pb(2) = uicontrol('style','pushbutton',... 44 | 'units','pix',... 45 | 'position',[150 5 50 25],... 46 | 'string','Cancel',... % The cancel button. 47 | 'callback',{@pb_call,S}); 48 | uicontrol(S.ed) % Put blinking cursor in edit box. 49 | uiwait(S.fh) % Wait till the GUI closes. 50 | if isempty(R) 51 | R = []; % So we return a double, not an empty string or nan. 52 | else 53 | % R = str2double(R); 54 | end 55 | 56 | function [] = pb_call(varargin) 57 | % Callback for pushbuttons. 58 | if varargin{1}==S.pb(1) 59 | R = get(S.ed,'string'); 60 | end 61 | close(S.fh) 62 | end 63 | 64 | function [] = ed_kpfcn(varargin) 65 | % Keypressfcn for editbox. Could be modified to delete any input 66 | % except for 3 or 4. 67 | switch varargin{2}.Key 68 | case 'return' 69 | drawnow 70 | R = get(S.ed,'string'); 71 | close(S.fh); 72 | case 'escape' 73 | R = []; 74 | close(S.fh); 75 | 76 | end 77 | end 78 | end -------------------------------------------------------------------------------- /scripts/asMultiRoiAnaCsv.m: -------------------------------------------------------------------------------- 1 | function asMultiRoiAnaCsv(asObjs, roiPos, combineCols, file, precision) 2 | %asMultiRoiAnaCsv(asObjs, roiPos, combineCols, file, precision) 3 | 4 | if nargin < 5 5 | precision = '%f'; 6 | if nargin < 4 7 | [fname, fpath] = uiputfile('.csv'); 8 | file = [fpath, fname]; 9 | 10 | if nargin < 3 11 | % mean and stdev in one column? 12 | combineCols = 1; 13 | 14 | end 15 | end 16 | end 17 | 18 | writeMSHeader = 0; %write header with text 'mean stdev' 19 | 20 | % open file for writing 21 | fid = fopen(file,'wt'); 22 | 23 | % get roi names 24 | roiNames = fieldnames(roiPos); 25 | 26 | % write header 27 | fprintf(fid,'title,ROI:\n'); 28 | fprintf(fid,','); % leave one cell for the title 29 | for r = 1 : length(roiNames) 30 | % write roi names 31 | fprintf(fid,'%s,',roiNames{r}); 32 | 33 | if ~combineCols 34 | fprintf(fid,','); % skip one col for stdev 35 | end 36 | end 37 | fprintf(fid,'\n'); % next line 38 | 39 | if ~combineCols && writeMSHeader 40 | fprintf(fid,','); % leave one cell for the title 41 | for r = 1 : length(roiNames) 42 | % mean and stdev header 43 | fprintf(fid,'mean,stdev,'); 44 | end 45 | fprintf(fid,'\n'); % next line 46 | end 47 | 48 | 49 | 50 | 51 | 52 | for a = 1 : length(asObjs) 53 | % for a = 1 : 1 54 | % fprintf('processing asObj %d / %d\n',a,length(asObjs)); 55 | fprintf('processing asObj %d / %d, ROI: ',a,length(asObjs)); 56 | currObj = asObjs(a); 57 | 58 | % write title 59 | fprintf(fid,'%s,',currObj.getFigureTitle); 60 | 61 | for r = 1 : length(roiNames) 62 | fprintf('%d , ',r); 63 | 64 | % set roi to asObj 65 | currPos = getfield(roiPos,roiNames{r}); 66 | currObj.createRoi(currPos); 67 | % currObj.roi.addFilterString('<10000'); 68 | % get mean and stdev 69 | [m,s] = currObj.roi.getMeanAndStd; 70 | 71 | % write roi values to csv 72 | p = precision; 73 | if combineCols 74 | str = [p, ' %c ', p,',']; 75 | fprintf(fid,str,m,177,s); 76 | % fprintf(fid,'%2.1f %c %2.1f,',m,177,s); 77 | else 78 | str = [p, ',', p,',']; 79 | fprintf(fid,str,m,s); 80 | % fprintf(fid,'%f,%f,',m,s); 81 | end 82 | end 83 | fprintf('\n'); 84 | fprintf(fid,'\n'); % next line 85 | 86 | end 87 | 88 | fclose(fid); 89 | fprintf('done\n'); 90 | end 91 | -------------------------------------------------------------------------------- /scripts/asMultiDiffMaps.m: -------------------------------------------------------------------------------- 1 | function asMultiDiffMaps(diffObjs, minVal, maxVal) 2 | 3 | if ~(isa(diffObjs,'arrShow')) 4 | error('first argument has to be an array of class arrShow'); 5 | end 6 | 7 | if nargin < 3 8 | maxVal = Inf; 9 | if nargin < 2 10 | minVal = -Inf; 11 | end 12 | end 13 | 14 | 15 | NO = length(diffObjs); 16 | 17 | if NO < 2 18 | error('need at least 2 arrShow objects'); 19 | end 20 | 21 | refImg = diffObjs(1).getSelectedImages; 22 | 23 | % create mask 24 | mask = ones(size(refImg)); 25 | for i = 1 : NO 26 | currImg = diffObjs(i).getSelectedImages ; 27 | mask(abs(currImg) == 0) = 0; 28 | mode = 'none'; 29 | switch mode 30 | case 't2' 31 | mask(abs(currImg) >400) = 0; 32 | mask(abs(currImg) < 10 ) = 0; 33 | case 'r2' 34 | mask(abs(currImg) <1/400) = 0; 35 | mask(abs(currImg) > 1/10 ) = 0; 36 | case 'none' 37 | mask = ones(size(mask)); 38 | end 39 | end 40 | 41 | % limit refimage 42 | refImg(refImg>maxVal)=maxVal; 43 | refImg(refImgmaxVal)=maxVal; 51 | currImg(currImg can be either a file or: 5 | % : (default) monitors default temporary file 6 | % "stop" : stop previously created timeres are stoped 7 | % "suppress": creates a temporary file in the temp folder to suppress the C 8 | % as function from writing temporary files 9 | % "continue": delete temporary "supress file" 10 | 11 | 12 | per = 0.5; % timer period in seconds 13 | 14 | 15 | % figure out username 16 | [~,usr] = system('whoami'); 17 | usr = usr(1:end-1); 18 | 19 | % define suppress file name 20 | suppressFileName = fullfile(tempdir,[usr,'_asSuppressFile.tmp']); 21 | 22 | % if no filename is given (defaut) automatically define it using the 23 | % username 24 | if nargin < 1 25 | % default coo file name 26 | filename = fullfile(tempdir,[usr,'_asTmpFile.coo']); 27 | end 28 | 29 | % if filename is "stop": 30 | % stop and delete previous timer 31 | if strcmpi(filename,'stop') 32 | % try to find previous timer 33 | T = timerfind('name','asFileMonitorTimer'); 34 | 35 | if isempty(T) 36 | disp('no asFileMonitor found'); 37 | else 38 | stop(T); 39 | delete(T); 40 | disp('asFileMonitor stopped'); 41 | end 42 | return; 43 | end 44 | 45 | % if filename is "suppress": 46 | % create a "suppress file" 47 | if strcmpi(filename,'suppress') 48 | % ...there's probably a more elegant way to do this :) 49 | fclose(fopen(suppressFileName,'w')); 50 | return; 51 | else 52 | % delete "suppress file", if present 53 | if exist(suppressFileName, 'file') 54 | delete(suppressFileName); 55 | end 56 | end 57 | 58 | % if filename is "continue", return (since the suppress file should be 59 | % deleted by now) 60 | if strcmpi(filename,'continue') 61 | return; 62 | end 63 | 64 | 65 | % start timer 66 | global T; 67 | T = timer('Period',per, 'TimerFcn',@(src, evnt)timerCb(src, filename),... 68 | 'ExecutionMode','fixedDelay', 'Name','asFileMonitorTimer'); 69 | start(T); 70 | 71 | fprintf('monitoring file: %s\n',filename); 72 | end 73 | 74 | 75 | % define timer callback 76 | function timerCb(T, filename) 77 | if exist(filename,'file') 78 | stop(T); 79 | try 80 | cooAs(filename,false); 81 | catch err 82 | fprintf(['asFileMonitor: an error occured when executing cooAs on %s!!\n',... 83 | 'Deleting the file...\n'],filename); 84 | delete(filename); 85 | 86 | % restart asFileMonitor 87 | asFileMonitor(filename); 88 | 89 | throw(err); 90 | end 91 | delete(filename); 92 | start(T); 93 | end 94 | end 95 | -------------------------------------------------------------------------------- /asIconClass.m: -------------------------------------------------------------------------------- 1 | % Copyright (C) 2009-2013 Biomedizinische NMR Forschungs GmbH 2 | % http://www.biomednmr.mpg.de 3 | % Author: Tilman Johannes Sumpf 4 | % 5 | % Distributed under the Boost Software License, Version 1.0. 6 | % (See accompanying file LICENSE_1_0.txt or copy at 7 | % http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | 10 | classdef (Sealed) asIconClass floor(fHeight/nRows) 36 | colHeight = floor(fHeight/nRows); 37 | colWidth = colHeight / imgRatio; 38 | end 39 | yBorder2 = floor((fHeight - nRows * colHeight)/2); 40 | xBorder2 = floor((fWidth - nCols * colWidth)/2); 41 | else 42 | yBorder2 = 0; 43 | xBorder2 = 0; 44 | end 45 | 46 | % display 47 | imageHandle = zeros(noFrames,1); 48 | axesHandle = zeros(noFrames,1); 49 | for n=1:noFrames 50 | 51 | % image position 52 | x0 = mod((n-1),nCols) * colWidth + xBorder2; 53 | y0 = fHeight - colHeight - (floor((n-1)/nCols) * colHeight) - yBorder2; 54 | 55 | ah = axes('Parent',parentPanelH,'units','pixel','position',[x0, y0, colWidth, colHeight]); 56 | 57 | if keepTrueSize 58 | pixelPos = get(ah,'position'); 59 | set(ah,'position',[pixelPos(1:2), dimY, dimX]); 60 | end 61 | currImg = imgArr(:,:,n); 62 | 63 | if useQuiver 64 | imageHandle(n) = quiver(real(currImg),imag(currImg),... 65 | 'Parent',ah); 66 | set(ah,'YDir','reverse'); 67 | axis(ah,'tight'); 68 | 69 | % store the original image in the axes handle's userData 70 | ud.selectedImage = currImg; 71 | set(ah,'UserData',ud); 72 | else 73 | 74 | if forceComplex || ~isreal(currImg) 75 | isComplex = true; 76 | [currImg, CLim] = complex2rgb(currImg, 256, [], colormap(ah, colorMap)); 77 | if any(~isfinite(CLim)) 78 | error([mfilename,':ExpectedFinite'],'CLim has to be finite'); 79 | end 80 | else 81 | isComplex = false; 82 | colormap(ah,colorMap); 83 | end 84 | % sssr: matlab 2017b + version does not update colormap without next line 85 | set(ah,'NextPlot','replacechildren'); 86 | imageHandle(n) = imagesc(currImg,'Parent',ah); 87 | 88 | if isComplex 89 | if (CLim(1) == CLim(2)) 90 | if(CLim(1) == 0) 91 | CLim(1) = 1; 92 | CLim(2) = 1; 93 | end 94 | CLim(1) = CLim(1)/2; 95 | end 96 | set(ah,'CLim',CLim); 97 | end 98 | end 99 | if keepAspectRatio 100 | set(ah,'DataAspectRatio',[1,1,1]); 101 | end 102 | 103 | axis(ah,'off'); 104 | axesHandle(n) = ah; 105 | end 106 | set(parentPanelH,'Units',origUnits); 107 | end 108 | -------------------------------------------------------------------------------- /supportFunctions/humanize.m: -------------------------------------------------------------------------------- 1 | classdef humanize 2 | % humanize functions 3 | % collection of static functions to convert si units into 'human readable' 4 | % strings. Currently implemented functions are 5 | % 6 | % humanize.seconds % creates a time string 7 | % humanize.bytes % creates a data size string 8 | % humanize.clock 9 | % 10 | % written by T.Sumpf (tsumpf@gwdg.de) June 2010 11 | 12 | methods (Static) 13 | function str = bytes(nBytes, precision) 14 | if nargin < 2 15 | precision = '%1.3f'; 16 | end 17 | order = log2(nBytes); 18 | order = floor(order/10) * 10; 19 | 20 | unitValue = nBytes / 2^order; 21 | 22 | switch(order) 23 | case 0 24 | str = [num2str(nBytes),' byte']; 25 | case 10 26 | str = [num2str(unitValue,precision),' kB']; 27 | case 20 28 | str = [num2str(unitValue,precision),' MB']; 29 | case 30 30 | str = [num2str(unitValue,precision),' GB']; 31 | otherwise 32 | str = [num2str( nBytes / 2^40,precision),' TB']; 33 | end 34 | 35 | 36 | 37 | end 38 | 39 | function str = seconds(secs, precision) 40 | if nargin < 2 41 | precision = '%1.3f'; 42 | end 43 | 44 | % decimal system 45 | if secs < 1e-3 46 | str = [num2str(secs*1e6,precision),' us']; 47 | return 48 | end 49 | 50 | if secs < 1 51 | str = [num2str(secs*1e3,precision),' ms']; 52 | return 53 | end 54 | 55 | if secs < 60 56 | str = [num2str(secs,precision),'s']; 57 | return 58 | end 59 | 60 | 61 | 62 | % ...else 63 | % "date system" 64 | 65 | remSecs = floor(mod(secs,60)); 66 | mins = mod(floor(secs/60),60); 67 | hours = mod(floor(secs/(60*60)),24); 68 | days = floor(secs/(60*60*24)); 69 | 70 | 71 | 72 | 73 | str = [num2str(remSecs),'s']; 74 | 75 | if secs >= 60 76 | str = [num2str(mins),'min : ',str]; 77 | end 78 | 79 | if secs >= (60 * 60) 80 | str = [num2str(hours),'h : ',str]; 81 | end 82 | 83 | if secs >= (60 * 60 * 24) 84 | str = [num2str(days),'d : ',str]; 85 | end 86 | 87 | end 88 | 89 | 90 | function str = clock(clk, date_time_or_both) 91 | if nargin < 1 92 | date_time_or_both = 'both'; 93 | end 94 | 95 | c = fix(clk); 96 | 97 | d = sprintf('%d.%d.%d',c(3),c(2),c(1)); 98 | t = sprintf('%d:%d:%d',c(4),c(5),c(6)); 99 | 100 | switch lower(date_time_or_both) 101 | case 'date' 102 | str = d; 103 | case 'time' 104 | str = t; 105 | case 'both' 106 | str = [d, ' ' , t]; 107 | end 108 | 109 | 110 | end 111 | end 112 | end -------------------------------------------------------------------------------- /scripts/asLineup.m: -------------------------------------------------------------------------------- 1 | function asLineup(allObjs, M, N, reorder, startTopLeft) 2 | % arranges arrayShow windows in an M x N order. 3 | % 4 | % allObjs: if allObjs is an array of arrayShow objects, 5 | % allObjs(1) is used as the reference. All other 6 | % objects will be set to the same figure size as allObjs(1) and 7 | % arranged in an M x N order. 8 | % 9 | % allObjs = []: 10 | % global asObjs array will be used instead 11 | % 12 | % reorder: 13 | % false: The asObjs will be arranged according to their appearance 14 | % in the allObjs vector. 15 | % true : The asObj with top-leftmost figure position will 16 | % used as a reference and other windows arranged according to their 17 | % previous figure position 18 | % 19 | % 20 | 21 | if nargin == 0 || isempty(allObjs) 22 | global asObjs; 23 | allObjs = asObjs; 24 | end 25 | if nargin < 5 26 | startTopLeft = false; 27 | end 28 | if nargin < 4 || isempty(reorder) 29 | reorder = false; 30 | end 31 | if nargin < 3 || isempty(N) 32 | 33 | if nargin == 2 && isscalar(allObjs) 34 | % allow a special call with only two given scalar arguments... 35 | % assume that we want to lineup global asObjs and treat 36 | % arguments as M and N 37 | N = M; 38 | M = allObjs; 39 | reorder = true; 40 | global asObjs; 41 | allObjs = asObjs; 42 | 43 | 44 | else 45 | N = 1; 46 | if nargin < 2 || isempty(M) 47 | M = 1; 48 | N = length(allObjs); 49 | if nargin < 1 50 | reorder = true; 51 | end 52 | end 53 | end 54 | end 55 | 56 | 57 | NO = length(allObjs); 58 | 59 | if reorder 60 | 61 | % sort in y direction 62 | allObjs = sortObjs(allObjs,2); 63 | 64 | % since y positions are given from bottom to top, invert array order 65 | allObjs = allObjs(end:-1:1); 66 | 67 | % sort N tupel in x direction 68 | for i = 1 : M 69 | rangeStart = (i-1) * N + 1; 70 | rangeStop = i * N; 71 | if rangeStop > NO 72 | rangeStop = NO; 73 | end 74 | range = rangeStart : rangeStop; 75 | allObjs(range) = sortObjs(allObjs(range),1); 76 | end 77 | 78 | end 79 | 80 | % pixel offsets for with and height 81 | if ispc 82 | ow = 0; 83 | oh = 0; 84 | else 85 | ow = 8; 86 | oh = 27; 87 | end 88 | 89 | 90 | refObj = allObjs(1); 91 | 92 | % delete all duplicated copies of refObj from allObjs array 93 | allObjs(allObjs == refObj) = []; 94 | allObjs = [refObj, allObjs]; 95 | NO = length(allObjs); 96 | 97 | refPos = refObj.getFigureOuterPosition; 98 | l0 = refPos(1); 99 | b0 = refPos(2); 100 | w0 = refPos(3); 101 | h0 = refPos(4); 102 | 103 | if M == 1 || startTopLeft 104 | origScreenUnits = get(0,'Units'); 105 | set(0,'Units','pixels'); 106 | scrPos = get(0,'MonitorPositions'); 107 | scrWidth = max(scrPos(:,3)); 108 | scrWidth = scrWidth - l0; 109 | 110 | 111 | if startTopLeft 112 | l0 = 0; 113 | % b0 = scrPos(1,4) - h0; 114 | b0 = scrPos(1,4) - h0; 115 | refObj.setFigureOuterPosition([l0, b0, w0,h0]); 116 | end 117 | 118 | if M == 1 119 | % automatically set M to to avoid leaving the screen horizontally 120 | M = ceil(N * w0 / scrWidth); 121 | N = floor(scrWidth / w0); 122 | end 123 | 124 | set(0,'Units',origScreenUnits); 125 | end 126 | 127 | i = 1; 128 | for m = 1 : M 129 | for n = 1 : N 130 | l = l0 + (n-1) * (w0 + ow); 131 | b = b0 - (m-1) * (h0 + oh); 132 | 133 | if allObjs(i) ~= refObj 134 | allObjs(i).setFigureOuterPosition([l, b, w0, h0]); 135 | end 136 | 137 | i = i + 1; 138 | if i > NO 139 | return; 140 | end 141 | end 142 | end 143 | 144 | 145 | 146 | end 147 | 148 | function outObjs = sortObjs(inObjs, dir) 149 | % dir : 2 = y direction 150 | % 1 = x direction 151 | 152 | NO = length(inObjs); 153 | dirPos = zeros(NO,1); 154 | for i = 1 : NO 155 | pos = inObjs(i).getFigureOuterPosition; 156 | dirPos (i) = pos(dir); 157 | end 158 | [tmp,idx] = sort(dirPos); 159 | outObjs = inObjs(idx); 160 | end 161 | 162 | -------------------------------------------------------------------------------- /supportFunctions/showwindow.m: -------------------------------------------------------------------------------- 1 | function showwindow(name,state) 2 | %SHOWWINDOW Change the state of a window. 3 | % SHOWWINDOW(NAME,STATE) changes the state of the window with a certain NAME 4 | % to the specified STATE. STATE must be one of the following: 5 | % 6 | % 'hide','shownormal','normal','showminimized','showmaximized','maximize', 7 | % 'shownoactivate','show','minimize','showminnoactive','showna','restore', 8 | % 'showdefault','forceminimize','max' 9 | % 10 | % This page describes the difference between these states: 11 | % 12 | % 13 | % 14 | % FORCEMINIMIZE Windows 2000/XP: Minimizes a window, even if the thread that 15 | % owns the window is hung. This flag should only be used when minimizing 16 | % windows from a different thread. 17 | % 18 | % HIDE Hides the window and activates another window. 19 | % 20 | % MAXIMIZE Maximizes the specified window. 21 | % 22 | % MINIMIZE Minimizes the specified window and activates the next top-level 23 | % window in the Z order. 24 | % 25 | % RESTORE Activates and displays the window. If the window is minimized or 26 | % maximized, the system restores it to its original size and position. An 27 | % application should specify this flag when restoring a minimized window. 28 | % 29 | % SHOW Activates the window and displays it in its current size and position. 30 | % 31 | % SHOWDEFAULT Sets the show state based on the SW_ value specified in the 32 | % STARTUPINFO structure passed to the CreateProcess function by the program 33 | % that started the application. 34 | % 35 | % SHOWMAXIMIZED Activates the window and displays it as a maximized window. 36 | % 37 | % SHOWMINIMIZED Activates the window and displays it as a minimized window. 38 | % 39 | % SHOWMINNOACTIVE Displays the window as a minimized window. This value is 40 | % similar to SW_SHOWMINIMIZED, except the window is not activated. 41 | % 42 | % SHOWNA Displays the window in its current size and position. This value is 43 | % similar to SW_SHOW, except the window is not activated. 44 | % 45 | % SHOWNOACTIVATE Displays a window in its most recent size and position. This 46 | % value is similar to SW_SHOWNORMAL, except the window is not actived. 47 | % 48 | % SHOWNORMAL Activates and displays a window. If the window is minimized or 49 | % maximized, the system restores it to its original size and position. An 50 | % application should specify this flag when displaying the window for the 51 | % first time. 52 | % 53 | % Examples: 54 | % >> showwindow('MATLAB','minimize') 55 | % >> showwindow('','minimize') 56 | % >> figure(4); showwindow('Figure No. 4','maximize'); text(.5,.5,'Simoneau') 57 | 58 | % Matthew J. Simoneau 59 | % Copyright 2003 The MathWorks, Inc. 60 | 61 | if ~ispc 62 | % The Task Manager is only on Windows. 63 | return; 64 | end 65 | 66 | if ~libisloaded(mfilename); 67 | loadlibrary('user32.dll',@userproto,'alias',mfilename); 68 | end 69 | 70 | 71 | % From WINUSER.H (via WINDOWS.H): 72 | % ShowWindow() Commands 73 | switch state 74 | case 'hide', flag = 0; 75 | case 'shownormal', flag = 1; 76 | case 'normal', flag = 1; 77 | case 'showminimized', flag = 2; 78 | case 'showmaximized', flag = 3; 79 | case 'maximize', flag = 3; 80 | case 'shownoactivate', flag = 4; 81 | case 'show', flag = 5 ; 82 | case 'minimize', flag = 6 ; 83 | case 'showminnoactive', flag = 7 ; 84 | case 'showna', flag = 8 ; 85 | case 'restore', flag = 9 ; 86 | case 'showdefault', flag = 10; 87 | case 'forceminimize', flag = 11; 88 | case 'max', flag = 11; 89 | otherwise, error('Unknown state "%s".',state); 90 | end 91 | 92 | h = calllib(mfilename,'FindWindowA',[],name); 93 | calllib(mfilename,'ShowWindow',h,flag); 94 | 95 | 96 | %=============================================================================== 97 | function [fcns,structs,enuminfo] = userproto 98 | 99 | fcns=[]; structs=[]; enuminfo=[]; fcns.alias={}; 100 | 101 | % HWND _stdcall FindWindowA(LPCSTR,LPCSTR); 102 | fcns.name{1} = 'FindWindowA'; 103 | fcns.calltype{1} = 'stdcall'; 104 | fcns.LHS{1} = 'voidPtr'; 105 | fcns.RHS{1} = {'int8Ptr', 'string'}; 106 | 107 | % BOOL _stdcall ShowWindow(HWND,int); 108 | fcns.name{2} = 'ShowWindow'; 109 | fcns.calltype{2} = 'stdcall'; 110 | fcns.LHS{2} = 'int32'; 111 | fcns.RHS{2} = {'voidPtr', 'int32'}; 112 | -------------------------------------------------------------------------------- /scripts/asAlgebra.m: -------------------------------------------------------------------------------- 1 | function [sumImg, sumAsObj] = asAlgebra(asObjs, operation, showResultInArrShow) 2 | % Usage: [sumImg, sumAsObj] = asAlgebra(asObjs, operation, showResultInArrShow) 3 | % Performs algebraic operations on the data of the given arrayShow 4 | % objects. 5 | % The operation is performed on the full data array in case the data 6 | % dimensions are equal. Otherwise, the operation is only performed on the 7 | % currently selected image of all as objects. 8 | % 9 | % showResultInArrShow: if true (default) the result is automatically shown 10 | % in a new arrayShow window 11 | % 12 | % Currently implemented operations are: 13 | % sum/plus, diff/minus, mean, min and max 14 | % 15 | 16 | switch lower(operation) 17 | case {'sum', 'plus'} 18 | op = @plus; 19 | case {'minus', 'diff'} 20 | op = @minus; 21 | case {'times', '.*'} 22 | op = @times; 23 | case {'rdivide', './'} 24 | op = @rdivide; 25 | case 'mean' 26 | % Treat the mean as as sum first. 27 | % the division by the number of objects is considered lated 28 | op = @plus; 29 | case 'min' 30 | op = @min; 31 | case 'max' 32 | op = @max; 33 | 34 | otherwise 35 | error('asAlgebra:unknownOperation','Operation %s is not sopported yet',operation); 36 | end 37 | 38 | if nargin < 3 39 | showResultInArrShow = true; 40 | end 41 | 42 | % check input arguments 43 | if ~(isa(asObjs,'arrShow')) 44 | error('first argument has to be an array of class arrShow'); 45 | end 46 | 47 | NO = length(asObjs); 48 | 49 | if NO < 2 50 | error('need at least 2 arrShow objects'); 51 | end 52 | 53 | 54 | % get data dimensions 55 | allSi = size(asObjs(1).getAllImages(true)); 56 | imgSi = asObjs(1).statistics.getDimensions(); 57 | 58 | % get selected complex data part 59 | cplxPart = asObjs(1).complexSelect.getSelection(2); 60 | 61 | % check if the data dimensions and the selected complex part are equal in all asObjs 62 | allDimsAreEqual = true; % be positive 63 | allCplxPartsAreEqual = true; 64 | for i = 2 : NO 65 | 66 | % check if the data dimensions are equal in all asObjs 67 | currAllSi = size(asObjs(i).getAllImages(true)); 68 | currImgSi = asObjs(i).statistics.getDimensions(); 69 | if numel(currAllSi) ~= numel(allSi) || any(currAllSi ~= allSi) 70 | allDimsAreEqual = false; 71 | 72 | % check if at least the dims of the selected images are equal 73 | if numel(currImgSi) ~= numel(imgSi) || any(currImgSi ~= imgSi) 74 | fprintf('Cannot sum images with unequal dimensions\n'); 75 | return; 76 | end 77 | end 78 | 79 | % check if the selected parts are equal 80 | if ~strcmp(cplxPart, asObjs(i).complexSelect.getSelection(2)) 81 | allCplxPartsAreEqual = false; 82 | warning('Different complex parts are selected in the arrayShow objects'); 83 | end 84 | 85 | end 86 | 87 | % assigne a getimg function which either returns all images, if all 88 | % dimensions are equal, or returns only the selected image otherwise... 89 | if allDimsAreEqual 90 | getimg = @(i)asObjs(i).getAllImages(false); 91 | else 92 | getimg = @(i)asObjs(i).getSelectedImages(false); 93 | end 94 | 95 | % start creating a sumImage 96 | sumImg = getimg(1); 97 | 98 | % create an infotext wich is to contain all the summed figure titles 99 | if showResultInArrShow 100 | 101 | % if the an equal complmex part is selected in all arrayShow objects, 102 | % include the complex part to the description 103 | if allCplxPartsAreEqual 104 | funName = [cplxPart, ' ', operation]; 105 | end 106 | 107 | % create a title 108 | tit = ['Image ',funName]; 109 | 110 | % create an info text which contains the names of all summed asObjs 111 | infoTxt = sprintf('%s of:\nFig.%d: %s',... 112 | funName,... 113 | asObjs(1).getFigureNumber(),... 114 | asObjs(1).getFigureTitle()); 115 | end 116 | 117 | % again loop over all asObjs and do the actual data summation 118 | for i = 2 : NO 119 | % the summation 120 | sumImg = op(sumImg, getimg(i)); 121 | 122 | if showResultInArrShow 123 | infoTxt = sprintf('%s\nFig.%d: %s',... 124 | infoTxt,... 125 | asObjs(i).getFigureNumber(),... 126 | asObjs(i).getFigureTitle()); 127 | end 128 | end 129 | 130 | if strcmp(operation, 'mean') 131 | sumImg = sumImg / NO; 132 | end 133 | 134 | % create a new asObj 135 | if showResultInArrShow 136 | refPos = asObjs(i).getFigureOuterPosition; 137 | refPos(2) = refPos(2) - refPos(4); 138 | sumAsObj = as(sumImg, 'title',tit,'info',infoTxt); 139 | sumAsObj.setFigureOuterPosition(refPos); 140 | 141 | % don't flood the workspace with data 142 | if nargout == 0 143 | clear sumImg 144 | end 145 | end 146 | 147 | end 148 | -------------------------------------------------------------------------------- /asSendGroupClass.m: -------------------------------------------------------------------------------- 1 | classdef asSendGroupClass < handle 2 | 3 | properties (GetAccess = private, SetAccess = private) 4 | ph = 0 ; % panel handle 5 | 6 | sg = 1; % send group (the main parameter to controlled) 7 | % can be each positive integer number or -1 for "none" 8 | % and 0 for "all" 9 | 10 | % send group button handle 11 | sgbh = cell(6,1); % send groups 1-4, all, none, userDef 12 | end 13 | 14 | 15 | methods 16 | 17 | function obj = asSendGroupClass(parentPanel) 18 | obj.ph = parentPanel; 19 | 20 | % text height 21 | tHeight = .15; 22 | 23 | % text 24 | uicontrol('Style','Text',... 25 | 'Parent', obj.ph,... 26 | 'String','Send/Rec.-Group',... 27 | 'FontSize',8,... 28 | 'Units','normalized',... 29 | 'HorizontalAlignment','left',... 30 | 'Position',[0,1-tHeight,1,tHeight]); 31 | 32 | % initialize buttons 33 | nsg = length(obj.sgbh); % number of send group buttons 34 | bWidth = 1/nsg; % normalized send group button width 35 | bHeight = .25; % normalized send group button height 36 | % bBot = .32; % normalized send group button bottom position 37 | bBot = 1-bHeight-tHeight; % normalized send group button bottom position 38 | 39 | 40 | % send group 1 to 3 buttons 41 | for c = 1 : 3 42 | obj.sgbh{c} = uicontrol('Style','togglebutton',... 43 | 'Parent', obj.ph,... 44 | 'Units','normalized',... 45 | 'Position',[(c-1)*bWidth, bBot, bWidth, bHeight],... 46 | 'tooltip',['Send group ',num2str(c)],... 47 | 'Callback',@(src,evnt)obj.set(c),... 48 | 'string',num2str(c)); 49 | end 50 | 51 | % send group 0 (send to all) button 52 | c = c + 1; 53 | obj.sgbh{c} = uicontrol('Style','togglebutton',... 54 | 'Parent', obj.ph,... 55 | 'Units','normalized',... 56 | 'Position',[(c-1)*bWidth, bBot, bWidth, bHeight],... 57 | 'tooltip','Send group 0 (= send to all)',... 58 | 'Callback',@(src,evnt)obj.set(0),... 59 | 'string','A'); 60 | 61 | 62 | % send group -1 (send and receive none) 63 | c = c + 1; 64 | obj.sgbh{c} = uicontrol('Style','togglebutton',... 65 | 'Parent', obj.ph,... 66 | 'Units','normalized',... 67 | 'Position',[(c-1)*bWidth, bBot, bWidth, bHeight],... 68 | 'tooltip','Send group -1 (= send and receive none)',... 69 | 'Callback',@(src,evnt)obj.set(-1),... 70 | 'string','-'); 71 | 72 | % user defined send group 73 | c = c + 1; 74 | obj.sgbh{c} = uicontrol('Style','togglebutton',... 75 | 'Parent', obj.ph,... 76 | 'Units','normalized',... 77 | 'Position',[(c-1)*bWidth, bBot, bWidth, bHeight],... 78 | 'tooltip','User defined send group',... 79 | 'Callback',@(src,evnt)obj.set(),... 80 | 'string','...'); 81 | 82 | % activate first send group per default 83 | set(obj.sgbh{1},'value',true); 84 | 85 | end 86 | 87 | function set(obj, groupNo) 88 | 89 | % if no group number is given, open dialog 90 | if nargin < 2 || isempty(groupNo) 91 | groupNo = mydlg('Enter send/rec.-group','Group number input dlg',obj.sg); 92 | groupNo = str2double(groupNo); 93 | if ~isfinite(groupNo) 94 | set(obj.sgbh{6}, 'value', false); 95 | return; 96 | end 97 | end 98 | obj.sg = groupNo; 99 | 100 | % determine the button number that corresponds to the group number 101 | switch(groupNo) 102 | case -1 103 | actButton = 5; % send/receive none 104 | case 0 105 | actButton = 4; % send/receive all-button 106 | case {1, 2, 3} 107 | actButton = groupNo; 108 | otherwise 109 | actButton = 6; % user defined group 110 | end 111 | 112 | % activate the actButton, deactivate all others 113 | for i = 1 : length(obj.sgbh) 114 | set(obj.sgbh{i}, 'value', i==actButton); 115 | end 116 | 117 | if actButton == 6 %(user defined group) 118 | set(obj.sgbh{6}, 'string', num2str(groupNo)); 119 | else 120 | set(obj.sgbh{6}, 'string', '...'); 121 | end 122 | 123 | end 124 | 125 | function groupNo = get(obj) 126 | groupNo = obj.sg; 127 | end 128 | end 129 | end 130 | 131 | -------------------------------------------------------------------------------- /as.m: -------------------------------------------------------------------------------- 1 | % AS Visualize a data array with arrayShow. 2 | % (Shortcut to "arrShow.appendToGlobalAsArray(arr, varargin)") 3 | % The arrShow handle object is hereby appended to the global variable 4 | % 'asObjs' in the workspace, providing easy access to the 5 | % object's methods or properties. 6 | % 7 | % Hint: A list of all current arrShow objects can be displayed with 8 | % the command ab(). 9 | % 10 | % Usage: as(arr, varargin) 11 | % 12 | % arr : Either a numeric array or an arrayShow object 13 | % (e.g. a stored object from a previous Matlab session) 14 | % 15 | % 16 | % varargin: 17 | % optional arguments with the syntax