function SLIMfast dbstop if error %FRONTPAGE figure(... 'Tag', 'root',... 'Units','normalized',... 'Position', [0.4 0.9 0.2 eps],... 'Color', get(0,'defaultUicontrolBackgroundColor'),... 'Name', 'SLIMfast Build 1.103e',... 'NumberTitle', 'off',... 'MenuBar', 'none',... 'ToolBar', 'none',... 'Resize', 'off'); h.menuDataLoad =... uimenu(... 'Label', 'Load'); uimenu(... 'Parent', h.menuDataLoad,... 'Label', 'Imagestack',... 'Callback', @loadData); uimenu(... 'Parent', h.menuDataLoad,... 'Label', 'Superstack',... 'Callback', @loadData); uimenu(... 'Parent', h.menuDataLoad,... 'Label', 'Batch',... 'Callback', @batchLocalization); h.menuDataLoadParCoords =... uimenu(... 'Parent', h.menuDataLoad,... 'Label', 'Particle Data',... 'Separator', 'on'); uimenu(... 'Parent', h.menuDataLoadParCoords,... 'Label', 'SLIMfast',... 'Callback', @loadData); uimenu(... 'Parent', h.menuDataLoadParCoords,... 'Label', 'FPALM',... 'Callback', @loadData,... 'Enable', 'off'); uimenu(... 'Parent', h.menuDataLoad,... 'Label', 'Tracking Data',... 'Callback', @loadData); h.menuImageChannels =... uimenu(... 'Label', 'Channels'); h.menuDataMode =... uimenu(... 'Parent', h.menuImageChannels,... 'Label', 'Mode'); uimenu(... 'Parent', h.menuDataMode,... 'Label', 'monoView',... 'Checked', 'on',... 'Callback', @mergeChannels); uimenu(... 'Parent', h.menuDataMode,... 'Label', 'dualView',... 'Callback', @mergeChannels); uimenu(... 'Parent', h.menuDataMode,... 'Label', 'tripleView',... 'Callback', @mergeChannels); h.menuImageChannel(1) =... uimenu(... 'Tag', 'menuRedChannel',... 'Parent', h.menuImageChannels,... 'Label', 'Red Channel',... 'Separator', 'on'); h.menuImageChannel(2) =... uimenu(... 'Tag', 'menuGreenChannel',... 'Parent', h.menuImageChannels,... 'Label', 'Green Channel'); h.menuImageChannel(3) =... uimenu(... 'Tag', 'menuBlueChannel',... 'Parent', h.menuImageChannels,... 'Label', 'Blue Channel'); h.menuImageChannel(4) =... uimenu(... 'Tag', 'menuGrayChannel',... 'Parent', h.menuImageChannels,... 'Label', 'Gray Channel',... 'Enable', 'off'); h.menuTrackChannel =... uimenu(... 'Tag', 'menuTrackChannel',... 'Parent', h.menuImageChannels,... 'Label', 'Track Channel'); % h.menuAnalyse =... % uimenu(... % 'Label', 'Analysis'); % % h.menuAnalyseKinetics =... % uimenu(... % 'Parent', h.menuAnalyse,... % 'Label', 'Kinetics'); % uimenu(... % 'Parent', h.menuAnalyseKinetics,... % 'Label', 'Build Trajectories',... % 'Callback', @buildTracks,... % 'Enable', 'off') % uimenu(... % 'Parent', h.menuAnalyseKinetics,... % 'Label', 'PICS',... % 'Callback', @particleImageCorrelation) % % h.menuAnalyseFilters =... % uimenu(... % 'Parent', h.menuAnalyse,... % 'Label', 'Filters'); % uimenu(... % 'Parent', h.menuAnalyseFilters,... % 'Label', 'Co-Localization',... % 'Callback', @colocFilter) % h.menuAnalyseFilters =... % uimenu(... % 'Parent', h.menuAnalyse,... % 'Label', 'Particle Filters'); % uimenu(... % 'Parent', h.menuAnalyseFilters,... % 'Label', 'Clustering') % uimenu(... % 'Parent', h.menuAnalyseFilters,... % 'Label', 'Cross-Clustering') % uimenu(... % 'Parent', h.menuAnalyseFilters,... % 'Label', 'Co-Localization') % h.menuVisualize =... % uimenu(... % 'Label', 'Visualization'); % % %% scatter plot % h.menuVisualizeScatter =... % uimenu(... % 'Parent', h.menuVisualize,... % 'Label', 'Scatter Plot'); % h.menuVisualizeScatter2D =... % uimenu(... % 'Parent', h.menuVisualizeScatter,... % 'Label', '2-D'); % h.menuVisualizeScatter2DFrame =... % uimenu(... % 'Parent', h.menuVisualizeScatter2D,... % 'Label', 'Image',... % 'Callback', @scatterPlot); % h.menuVisualizeScatter2DMovie =... % uimenu(... % 'Parent', h.menuVisualizeScatter2D,... % 'Label', 'Movie',... % 'Callback', @scatterPlot,... % 'Enable', 'off'); % h.menuVisualizeScatter3D =... % uimenu(... % 'Parent', h.menuVisualizeScatter,... % 'Label', '3-D'); % h.menuVisualizeScatter3DFrame =... % uimenu(... % 'Parent', h.menuVisualizeScatter3D,... % 'Label', 'Image',... % 'Callback', @scatterPlot); % h.menuVisualizeScatter3DMovie =... % uimenu(... % 'Parent', h.menuVisualizeScatter3D,... % 'Label', 'Movie',... % 'Callback', @scatterPlot,... % 'Enable', 'off'); h.extras =... uimenu(... 'Label', 'Extras'); uimenu(... 'Parent', h.extras,... 'Label', 'Help',... 'Callback', @showHelp,... 'Enable', 'off'); uimenu(... 'Parent', h.extras,... 'Label', 'Credits',... 'Callback', @showCredits); uimenu(... 'Parent', h.extras,... 'Label', 'Changelog',... 'Callback', @showChangeLog); %icon grafics icon.Arrow =... [NaN, 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, 0, NaN, NaN, NaN, NaN; ... NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, 0, NaN, NaN, NaN, NaN; ... NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, 0, 0, NaN, NaN, NaN, NaN; ... NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, 0, 0, 0, NaN, NaN, NaN, NaN; ... NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, 0, 0, 0, 0, NaN, NaN, NaN, NaN; ... NaN, NaN, NaN, NaN, NaN, 0, 0, 0, 0, 0, 0, 0, NaN, NaN, NaN, NaN; ... NaN, NaN, NaN, NaN, 0, 0, 0, 0, 0, 0, 0, 0, NaN, NaN, NaN, NaN; ... NaN, NaN, NaN, NaN, 0, 0, 0, 0, 0, 0, 0, 0, NaN, NaN, NaN, NaN; ... NaN, NaN, NaN, NaN, NaN, 0, 0, 0, 0, 0, 0, 0, NaN, NaN, NaN, NaN; ... NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, 0, 0, 0, 0, NaN, NaN, NaN, NaN; ... NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, 0, 0, 0, NaN, NaN, NaN, NaN; ... NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, 0, 0, NaN, NaN, NaN, NaN; ... NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, 0, NaN, NaN, NaN, NaN; ... NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, NaN, NaN, NaN, NaN; ... NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 1 NaN, NaN, NaN, NaN]; icon.roi =... [NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN; NaN,0,0,0,0,NaN,NaN,0,0,0,0,NaN,NaN,NaN,0,NaN; NaN,0,NaN,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN; NaN,0,NaN,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN; NaN,0,NaN,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN; NaN,0,NaN,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN; NaN,0,NaN,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN; NaN,0,0,0,0,NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN; NaN,0,NaN,0,NaN,NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN; NaN,0,NaN,NaN,0,NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN; NaN,0,NaN,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN; NaN,0,NaN,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN; NaN,0,NaN,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN; NaN,0,NaN,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN; NaN,0,NaN,NaN,NaN,0,NaN,0,0,0,0,0,NaN,NaN,0,NaN; NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN;]; icon.colormap =... [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, NaN, 0, 0, 0, NaN, 0, NaN, 0, 0, 0, NaN, 0, 0, NaN;... 0, NaN, NaN, 0, NaN, 0, NaN, 0, NaN, 0, NaN, 0, NaN, 0, NaN, 0,; ... 0, NaN, NaN, 0, NaN, 0, NaN, 0, NaN, 0, NaN, 0, NaN, 0, 0, 0; ... 0, NaN, NaN, 0, NaN, 0, NaN, 0, NaN, 0, NaN, 0, NaN, 0, 0, NaN,; ... 0, 0, NaN, 0, 0, 0, NaN, 0, NaN, 0, 0, 0, NaN, 0, NaN, 0,; ... 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, NaN, 0, 0, NaN, NaN, 0, 0, NaN, NaN, 0, 0, 0, NaN, NaN,; ... 0, NaN, 0, NaN, 0, NaN, 0, NaN, NaN, 0, NaN, 0, NaN, NaN, 0, NaN,; ... 0, NaN, 0, NaN, 0, NaN, 0, NaN, NaN, 0, NaN, 0, NaN, NaN, 0, NaN; ... 0, NaN, NaN, NaN, 0, NaN, 0, 0, 0, 0, NaN, 0, 0, 0, NaN, NaN,; ... 0, NaN, NaN, NaN, 0, NaN, 0, NaN, NaN, 0, NaN, 0, NaN, NaN, NaN, NaN; ... 0, NaN, NaN, NaN, 0, NaN, 0, NaN, NaN, 0, NaN, 0, NaN, NaN, NaN, NaN; ... NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN;]; icon.fit =... [NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN; NaN,0,0,0,0,0,NaN,0,0,NaN,0,0,0,0,0,0; NaN,0,0,0,0,0,NaN,0,0,NaN,0,0,0,0,0,0; NaN,0,0,NaN,NaN,NaN,NaN,0,0,NaN,NaN,NaN,0,0,NaN,NaN; NaN,0,0,NaN,NaN,NaN,NaN,0,0,NaN,NaN,NaN,0,0,NaN,NaN; NaN,0,0,NaN,NaN,NaN,NaN,0,0,NaN,NaN,NaN,0,0,NaN,NaN; NaN,0,0,NaN,NaN,NaN,NaN,0,0,NaN,NaN,NaN,0,0,NaN,NaN; NaN,0,0,0,0,0,NaN,0,0,NaN,NaN,NaN,0,0,NaN,NaN; NaN,0,0,0,0,0,NaN,0,0,NaN,NaN,NaN,0,0,NaN,NaN; NaN,0,0,NaN,NaN,NaN,NaN,0,0,NaN,NaN,NaN,0,0,NaN,NaN; NaN,0,0,NaN,NaN,NaN,NaN,0,0,NaN,NaN,NaN,0,0,NaN,NaN; NaN,0,0,NaN,NaN,NaN,NaN,0,0,NaN,NaN,NaN,0,0,NaN,NaN; NaN,0,0,NaN,NaN,NaN,NaN,0,0,NaN,NaN,NaN,0,0,NaN,NaN; NaN,0,0,NaN,NaN,NaN,NaN,0,0,NaN,NaN,NaN,0,0,NaN,NaN; NaN,0,0,NaN,NaN,NaN,NaN,0,0,NaN,NaN,NaN,0,0,NaN,NaN; NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN;]; icon.options =... [NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN; NaN,0,0,0,0,NaN,0,0,0,0,NaN,0,0,0,0,0; NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN; NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN; NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN; NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN; NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN; NaN,0,NaN,NaN,0,NaN,0,0,0,0,NaN,NaN,NaN,0,NaN,NaN; NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,NaN,NaN,NaN,0,NaN,NaN; NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,NaN,NaN,NaN,0,NaN,NaN; NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,NaN,NaN,NaN,0,NaN,NaN; NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,NaN,NaN,NaN,0,NaN,NaN; NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,NaN,NaN,NaN,0,NaN,NaN; NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,NaN,NaN,NaN,0,NaN,NaN; NaN,0,0,0,0,NaN,0,NaN,NaN,NaN,NaN,NaN,NaN,0,NaN,NaN; NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN;]; icon.opt2txt =... [NaN,0,0,0,0,NaN,0,0,0,0,NaN,0,0,0,0,0; NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN; NaN,0,NaN,NaN,0,NaN,0,0,0,0,NaN,NaN,NaN,0,NaN,NaN; NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,NaN,NaN,NaN,0,NaN,NaN; NaN,0,0,0,0,NaN,0,NaN,NaN,NaN,NaN,NaN,NaN,0,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,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,NaN,NaN,0,0,0,0,NaN,NaN,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,NaN,0,0,0,0,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,NaN,0,NaN,NaN,0,NaN,0,0,0,0,0; NaN,NaN,0,NaN,NaN,NaN,NaN,0,NaN,NaN,NaN,NaN,NaN,0,NaN,NaN; NaN,NaN,0,NaN,NaN,NaN,NaN,NaN,0,NaN,NaN,NaN,NaN,0,NaN,NaN; NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN;]; icon.save =... [NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN; 0,0,0,NaN,0,0,0,NaN,0,NaN,0,NaN,0,0,0,NaN; 0,NaN,NaN,NaN,0,NaN,0,NaN,0,NaN,0,NaN,0,NaN,NaN,NaN; 0,NaN,NaN,NaN,0,NaN,0,NaN,0,NaN,0,NaN,0,NaN,NaN,NaN; 0,NaN,NaN,NaN,0,NaN,0,NaN,0,NaN,0,NaN,0,NaN,NaN,NaN; 0,NaN,NaN,NaN,0,NaN,0,NaN,0,NaN,0,NaN,0,NaN,NaN,NaN; 0,NaN,NaN,NaN,0,NaN,0,NaN,0,NaN,0,NaN,0,NaN,NaN,NaN; 0,NaN,NaN,NaN,0,NaN,0,NaN,0,NaN,0,NaN,0,NaN,NaN,NaN; 0,0,0,NaN,0,0,0,NaN,0,NaN,0,NaN,0,0,0,NaN; NaN,NaN,0,NaN,0,NaN,0,NaN,0,NaN,0,NaN,0,NaN,NaN,NaN; NaN,NaN,0,NaN,0,NaN,0,NaN,0,NaN,0,NaN,0,NaN,NaN,NaN; NaN,NaN,0,NaN,0,NaN,0,NaN,0,NaN,0,NaN,0,NaN,NaN,NaN; NaN,NaN,0,NaN,0,NaN,0,NaN,0,NaN,0,NaN,0,NaN,NaN,NaN; NaN,NaN,0,NaN,0,NaN,0,NaN,0,NaN,0,NaN,0,NaN,NaN,NaN; 0,0,0,NaN,0,NaN,0,NaN,NaN,0,NaN,NaN,0,0,0,NaN; NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN;]; icon.testLoc =... [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,NaN,0,0,0,NaN,0,0,0,0,NaN,0,0,0; NaN,0,NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN,NaN,NaN,NaN,0,NaN; NaN,0,NaN,NaN,0,0,NaN,NaN,0,0,0,0,NaN,NaN,0,NaN; NaN,0,NaN,NaN,0,NaN,NaN,NaN,NaN,NaN,NaN,0,NaN,NaN,0,NaN; NaN,0,NaN,NaN,0,0,0,NaN,0,0,0,0,NaN,NaN,0,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,NaN; NaN,NaN,0,NaN,NaN,NaN,0,0,0,0,NaN,0,0,0,NaN,NaN; NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,NaN; NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,NaN; NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,NaN; NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,NaN; NaN,NaN,0,0,0,NaN,0,0,0,0,NaN,0,0,0,NaN,NaN; NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN;]; icon.locAll =... [NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN; NaN,NaN,0,NaN,NaN,NaN,0,0,0,0,NaN,0,0,0,NaN,NaN; NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,NaN; NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,NaN; NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,NaN; NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,NaN; NaN,NaN,0,0,0,NaN,0,0,0,0,NaN,0,0,0,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,NaN,NaN; NaN,NaN,0,0,0,0,NaN,0,NaN,NaN,NaN,0,NaN,NaN,NaN,NaN; NaN,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0,NaN,NaN,NaN,NaN; NaN,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0,NaN,NaN,NaN,NaN; NaN,NaN,0,0,0,0,NaN,0,NaN,NaN,NaN,0,NaN,NaN,NaN,NaN; NaN,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0,NaN,NaN,NaN,NaN; NaN,NaN,0,NaN,NaN,0,NaN,0,0,0,NaN,0,0,0,NaN,NaN; NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN;]; icon.intDist =... [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; NaN,0,0,0,NaN,0,0,NaN,NaN,NaN,0,NaN,0,0,0,NaN; NaN,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,0,NaN,NaN,0,NaN,NaN; NaN,NaN,0,NaN,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,0,NaN,NaN; NaN,NaN,0,NaN,NaN,0,NaN,NaN,NaN,0,0,NaN,NaN,0,NaN,NaN; NaN,0,0,0,NaN,0,NaN,NaN,NaN,NaN,0,NaN,NaN,0,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,NaN,NaN; 0,0,NaN,NaN,0,0,0,NaN,0,0,0,0,NaN,0,0,0; 0,NaN,0,NaN,NaN,0,NaN,NaN,0,NaN,NaN,NaN,NaN,NaN,0,NaN; 0,NaN,0,NaN,NaN,0,NaN,NaN,0,0,0,0,NaN,NaN,0,NaN; 0,NaN,0,NaN,NaN,0,NaN,NaN,NaN,NaN,NaN,0,NaN,NaN,0,NaN; 0,0,NaN,NaN,0,0,0,NaN,0,0,0,0,NaN,NaN,0,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,NaN;]; icon.s2nDist =... [NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN; 0,0,0,0,NaN,NaN,NaN,NaN,0,NaN,0,0,NaN,NaN,NaN,0; 0,NaN,NaN,NaN,NaN,NaN,NaN,0,0,NaN,0,NaN,0,NaN,NaN,0; 0,0,0,0,NaN,NaN,0,0,NaN,NaN,0,NaN,NaN,0,NaN,0; NaN,NaN,NaN,0,NaN,0,0,NaN,NaN,NaN,0,NaN,NaN,NaN,0,0; 0,0,0,0,NaN,0,NaN,NaN,NaN,NaN,0,NaN,NaN,NaN,NaN,0; 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; NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN; 0,0,NaN,NaN,0,0,0,NaN,0,0,0,0,NaN,0,0,0; 0,NaN,0,NaN,NaN,0,NaN,NaN,0,NaN,NaN,NaN,NaN,NaN,0,NaN; 0,NaN,0,NaN,NaN,0,NaN,NaN,0,0,0,0,NaN,NaN,0,NaN; 0,NaN,0,NaN,NaN,0,NaN,NaN,NaN,NaN,NaN,0,NaN,NaN,0,NaN; 0,0,NaN,NaN,0,0,0,NaN,0,0,0,0,NaN,NaN,0,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,NaN;]; icon.precDist =... [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,NaN,0,0,0,0,NaN,0,0,0,NaN,0,0,0; 0,NaN,0,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0,NaN,NaN; 0,0,0,NaN,0,0,0,0,NaN,0,0,NaN,NaN,0,NaN,NaN; 0,NaN,NaN,NaN,0,NaN,0,NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN; 0,NaN,NaN,NaN,0,NaN,NaN,0,NaN,0,0,0,NaN,0,0,0; 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,NaN,NaN,0,0,0,NaN,0,0,0,0,NaN,0,0,0; 0,NaN,0,NaN,NaN,0,NaN,NaN,0,NaN,NaN,NaN,NaN,NaN,0,NaN; 0,NaN,0,NaN,NaN,0,NaN,NaN,0,0,0,0,NaN,NaN,0,NaN; 0,NaN,0,NaN,NaN,0,NaN,NaN,NaN,NaN,NaN,0,NaN,NaN,0,NaN; 0,0,NaN,NaN,0,0,0,NaN,0,0,0,0,NaN,NaN,0,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,NaN;]; icon.locDist =... [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; NaN,0,NaN,NaN,NaN,NaN,0,0,0,0,NaN,0,0,0,0,NaN; NaN,0,NaN,NaN,NaN,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,NaN; NaN,0,NaN,NaN,NaN,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,NaN; NaN,0,NaN,NaN,NaN,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,NaN; NaN,0,0,0,0,NaN,0,0,0,0,NaN,0,0,0,0,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,NaN; 0,0,NaN,NaN,0,0,0,NaN,0,0,0,0,NaN,0,0,0; 0,NaN,0,NaN,NaN,0,NaN,NaN,0,NaN,NaN,NaN,NaN,NaN,0,NaN; 0,NaN,0,NaN,NaN,0,NaN,NaN,0,0,0,0,NaN,NaN,0,NaN; 0,NaN,0,NaN,NaN,0,NaN,NaN,NaN,NaN,NaN,0,NaN,NaN,0,NaN; 0,0,NaN,NaN,0,0,0,NaN,0,0,0,0,NaN,NaN,0,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,NaN;]; icon.maxProj =... [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,NaN,NaN,NaN,0,NaN,0,0,0,0,NaN,0,NaN,NaN,NaN,0; 0,0,NaN,0,0,NaN,0,NaN,NaN,0,NaN,NaN,0,NaN,0,NaN; 0,NaN,0,NaN,0,NaN,0,NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN; 0,NaN,NaN,NaN,0,NaN,0,0,0,0,NaN,NaN,NaN,0,NaN,NaN; 0,NaN,NaN,NaN,0,NaN,0,NaN,NaN,0,NaN,NaN,0,NaN,0,NaN; 0,NaN,NaN,NaN,0,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0; 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,NaN,0,0,0,0,NaN,0,0,0,NaN,0,0,0; 0,NaN,0,NaN,0,NaN,NaN,0,NaN,0,NaN,0,NaN,NaN,NaN,0; 0,0,0,NaN,0,0,0,0,NaN,0,NaN,0,NaN,NaN,NaN,0; 0,NaN,NaN,NaN,0,NaN,0,NaN,NaN,0,NaN,0,NaN,0,NaN,0; 0,NaN,NaN,NaN,0,NaN,NaN,0,NaN,0,0,0,NaN,NaN,0,NaN; NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN;]; icon.aveProj =... [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; NaN,0,0,0,0,NaN,0,NaN,NaN,NaN,0,NaN,0,0,0,NaN; NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0,NaN,0,NaN,NaN,NaN; NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0,NaN,0,0,NaN,NaN; NaN,0,0,0,0,NaN,0,NaN,NaN,NaN,0,NaN,0,NaN,NaN,NaN; NaN,0,NaN,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,0,NaN,NaN,NaN; NaN,0,NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN,NaN,0,0,0,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,NaN; 0,0,0,NaN,0,0,0,0,NaN,0,0,0,NaN,0,0,0; 0,NaN,0,NaN,0,NaN,NaN,0,NaN,0,NaN,0,NaN,NaN,NaN,0; 0,0,0,NaN,0,0,0,0,NaN,0,NaN,0,NaN,NaN,NaN,0; 0,NaN,NaN,NaN,0,NaN,0,NaN,NaN,0,NaN,0,NaN,0,NaN,0; 0,NaN,NaN,NaN,0,NaN,NaN,0,NaN,0,0,0,NaN,NaN,0,NaN; NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN;]; icon.genMov =... [NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN; NaN,0,0,0,0,NaN,0,0,0,NaN,0,NaN,NaN,NaN,0,NaN; NaN,0,NaN,NaN,NaN,NaN,0,NaN,NaN,NaN,0,0,NaN,NaN,0,NaN; NaN,0,NaN,NaN,NaN,NaN,0,0,NaN,NaN,0,NaN,0,NaN,0,NaN; NaN,0,NaN,0,0,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,0,NaN; NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0,NaN,NaN,NaN,0,NaN; NaN,0,0,0,0,NaN,0,0,0,NaN,0,NaN,NaN,NaN,0,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,NaN; 0,NaN,NaN,NaN,0,NaN,0,0,0,0,NaN,0,NaN,NaN,NaN,0; 0,0,NaN,0,0,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0; 0,NaN,0,NaN,0,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0; 0,NaN,NaN,NaN,0,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0; 0,NaN,NaN,NaN,0,NaN,0,NaN,NaN,0,NaN,NaN,0,NaN,0,NaN; 0,NaN,NaN,NaN,0,NaN,0,0,0,0,NaN,NaN,NaN,0,NaN,NaN; NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN;]; icon.genIm =... [NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN; NaN,0,0,0,0,NaN,0,0,0,NaN,0,NaN,NaN,NaN,0,NaN; NaN,0,NaN,NaN,NaN,NaN,0,NaN,NaN,NaN,0,0,NaN,NaN,0,NaN; NaN,0,NaN,NaN,NaN,NaN,0,0,NaN,NaN,0,NaN,0,NaN,0,NaN; NaN,0,NaN,0,0,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,0,NaN; NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0,NaN,NaN,NaN,0,NaN; NaN,0,0,0,0,NaN,0,0,0,NaN,0,NaN,NaN,NaN,0,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,NaN; NaN,NaN,0,0,0,0,0,NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN; NaN,NaN,NaN,NaN,0,NaN,NaN,NaN,NaN,0,0,NaN,0,0,NaN,NaN; NaN,NaN,NaN,NaN,0,NaN,NaN,NaN,NaN,0,NaN,0,NaN,0,NaN,NaN; NaN,NaN,NaN,NaN,0,NaN,NaN,NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN; NaN,NaN,NaN,NaN,0,NaN,NaN,NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN; NaN,NaN,0,0,0,0,0,NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN; NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN;]; icon.genTraj =... [NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN; NaN,0,0,0,0,NaN,0,0,0,NaN,0,NaN,NaN,NaN,0,NaN; NaN,0,NaN,NaN,NaN,NaN,0,NaN,NaN,NaN,0,0,NaN,NaN,0,NaN; NaN,0,NaN,NaN,NaN,NaN,0,0,NaN,NaN,0,NaN,0,NaN,0,NaN; NaN,0,NaN,0,0,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,0,NaN; NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0,NaN,NaN,NaN,0,NaN; NaN,0,0,0,0,NaN,0,0,0,NaN,0,NaN,NaN,NaN,0,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,NaN; 0,0,0,NaN,0,0,0,0,NaN,0,0,0,NaN,0,0,0; NaN,0,NaN,NaN,0,NaN,NaN,0,NaN,0,NaN,0,NaN,NaN,NaN,0; NaN,0,NaN,NaN,0,0,0,0,NaN,0,0,0,NaN,NaN,NaN,0; NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,0,NaN,0,NaN,0,NaN,0; NaN,0,NaN,NaN,0,NaN,NaN,0,NaN,0,NaN,0,NaN,NaN,0,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,NaN;]; icon.scatter3D = ... [NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN; 0,NaN,NaN,0,NaN,0,NaN,0,0,0,NaN,0,NaN,NaN,NaN,0; 0,NaN,NaN,0,NaN,0,NaN,0,NaN,NaN,NaN,0,NaN,NaN,NaN,0; 0,NaN,NaN,0,NaN,0,NaN,0,0,NaN,NaN,0,NaN,0,NaN,0; 0,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0,NaN,0,NaN,0; NaN,0,NaN,NaN,NaN,0,NaN,0,0,0,NaN,NaN,0,NaN,0,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,NaN; NaN,NaN,NaN,0,0,0,NaN,NaN,NaN,0,0,0,NaN,NaN,NaN,NaN; NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN,NaN,0,NaN,NaN,NaN; NaN,NaN,NaN,NaN,NaN,NaN,0,NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN; NaN,NaN,NaN,NaN,0,0,NaN,NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN; NaN,NaN,NaN,NaN,NaN,NaN,0,NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN; NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN,NaN,0,NaN,NaN,NaN; NaN,NaN,NaN,0,0,0,NaN,NaN,NaN,0,0,0,NaN,NaN,NaN,NaN; NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN;]; icon.playMov =... [NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN; 0,0,0,NaN,0,NaN,NaN,NaN,0,0,0,0,NaN,0,NaN,0; 0,NaN,0,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN,0,NaN,0; 0,0,0,NaN,0,NaN,NaN,NaN,0,0,0,0,NaN,0,0,0; 0,NaN,NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN,NaN,0,NaN; 0,NaN,NaN,NaN,0,NaN,NaN,NaN,0,NaN,NaN,0,NaN,NaN,0,NaN; 0,NaN,NaN,NaN,0,0,0,NaN,0,NaN,NaN,0,NaN,NaN,0,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,NaN; 0,NaN,NaN,NaN,0,NaN,0,0,0,0,NaN,0,NaN,NaN,NaN,0; 0,0,NaN,0,0,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0; 0,NaN,0,NaN,0,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0; 0,NaN,NaN,NaN,0,NaN,0,NaN,NaN,0,NaN,0,NaN,NaN,NaN,0; 0,NaN,NaN,NaN,0,NaN,0,NaN,NaN,0,NaN,NaN,0,NaN,0,NaN; 0,NaN,NaN,NaN,0,NaN,0,0,0,0,NaN,NaN,NaN,0,NaN,NaN; NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN;]; setappdata(1, 'handles', h) setappdata(1, 'icons', icon) setappdata(0, 'searchPath', pwd) end %% DATA function loadData(src, event) icon = getappdata(1, 'icons'); %initialize figure fig = figure('Visible','off'); switch get(src, 'Label') case 'Imagestack' %initialize variables setappdata(fig,'isOwn',1) setappdata(fig,'isLoaded',0) setappdata(fig,'isSuperstack',0) setappdata(fig,'isTrack',0) setappdata(fig,'frame',1) setappdata(fig,'viewMode','monoView') %Loc Options setappdata(fig,'locStart',1) setappdata(fig,'locEnd',inf) setappdata(fig,'errorRate',-6) setappdata(fig,'w2d',7) setappdata(fig,'dfltnLoops',15) setappdata(fig,'minInt',0) setappdata(fig,'locParallel',0) setappdata(fig,'nCores',1) setappdata(fig,'spatialCorrection',0) setappdata(fig,'isRadiusTol',0) setappdata(fig,'radiusTol',50) setappdata(fig,'posTol',1.5) setappdata(fig,'maxOptimIter',50) setappdata(fig,'termTol',-2) %Bar Options setappdata(fig,'isScalebar',0) setappdata(fig,'micronBarLength',1000) setappdata(fig,'isColormap',0) setappdata(fig,'isTimestamp',0) setappdata(fig,'timestampSize',2) setappdata(fig,'timestampInkrement',0.032) setappdata(fig,'colormapWidth',10) %Render Options setappdata(fig,'exfOld',1) setappdata(fig,'exfNew',5) setappdata(fig,'rW',50) setappdata(fig,'rStep',10) setappdata(fig,'rStart',1) setappdata(fig,'rEnd',inf) setappdata(fig,'rLive',0) setappdata(fig,'fps',32) setappdata(fig,'movCompression',1) setappdata(fig,'convMode',1) setappdata(fig,'intWeight',0.01) setappdata(fig,'sizeFac',1) setappdata(fig,'isCumsum',0) %Filter Options setappdata(fig,'isThreshLocPrec',0) setappdata(fig,'minLoc',0) setappdata(fig,'maxLoc',inf) setappdata(fig,'isThreshSNR',0) setappdata(fig,'minSNR',0) setappdata(fig,'maxSNR',inf) setappdata(fig,'isThreshDensity',0) setappdata(fig,'clusterMode',1) %Optics Options setappdata(fig,'pxSize',0.107) setappdata(fig,'cntsPerPhoton',20.2) setappdata(fig,'emWvlnth',567) setappdata(fig,'NA',1.45) setappdata(fig,'psfScale',1.2) setappdata(fig,'psfStd',1.03) [filename, pathname, isOK] = uigetfile(... '*.tif', 'Select Imagestack', getappdata(0,'searchPath')); if isOK setappdata(0, 'searchPath', pathname) setappdata(fig,'pathname',pathname) setappdata(fig,'filename',filename) I = imread([pathname filename],getappdata(fig,'frame')); [height width] = size(I); setappdata(fig,'width',width) setappdata(fig,'height',height) setappdata(fig,'roiX0',0) setappdata(fig,'roiY0',0) setappdata(fig,'roi',[0 0 width height]) setappdata(fig,'hROI',[]) setappdata(fig,'intensityRange',[]) figTitle = ['Frame 1 - ' getappdata(fig,'filename')]; tagIntHist = 'Pixel Intensity'; badToggles = [2:8 20:36]; else return end %if case 'Superstack' menuFig =... figure(... 'Units','normalized',... 'Position', [0.2 0.6 0.4 0.2],... 'Color', get(0,'defaultUicontrolBackgroundColor'),... 'Name', 'Superstack Container',... 'NumberTitle', 'off',... 'MenuBar', 'none',... 'ToolBar', 'none',... 'Resize', 'off'); hList =... uicontrol(... 'Style', 'listbox',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0 0 0.9 1],... 'FontSize', 10); uicontrol(... 'Style', 'pushbutton',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.9 0.8 0.1 0.2],... 'FontSize', 25,... 'String', '+',... 'Callback', {@addStack, hList}) uicontrol(... 'Style', 'pushbutton',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.9 0.6 0.1 0.2],... 'FontSize', 30,... 'String', '-',... 'Callback', {@delStack, hList}) uicontrol(... 'Style', 'pushbutton',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.9 0.4 0.1 0.2],... 'FontSize', 10,... 'String', 'UP',... 'Callback', {@moveUpStack, hList}) uicontrol(... 'Style', 'pushbutton',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.9 0.2 0.1 0.2],... 'FontSize', 10,... 'String', 'DOWN',... 'Callback', {@moveDownStack, hList}) uicontrol(... 'Style', 'pushbutton',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.9 0 0.1 0.2],... 'FontSize', 10,... 'String', 'OK',... 'Callback', {@buildSuperstack, hList}) isOK = false; uiwait(menuFig) case 'SLIMfast' [filename, pathname, isOK] = uigetfile(... '*.mat', 'Select Particle Data', getappdata(0,'searchPath')); if isOK setappdata(0, 'searchPath', pathname) % imageBin = struct([]); load([pathname filename]) setappdata(fig,'pathname',pathname) setappdata(fig,'filename',imageBin.filename) %initialize variables setappdata(fig,'imageName',imageBin.imageName) setappdata(fig,'isOwn',1) setappdata(fig,'isLoaded',1) setappdata(fig,'isSuperstack',imageBin.isSuperstack) setappdata(fig,'isTrack',0) setappdata(fig,'frame',1) setappdata(fig,'viewMode','monoView') %Loc Options if all(isfield(imageBin,{'locStart','locEnd'})) setappdata(fig,'locStart',imageBin.locStart) setappdata(fig,'locEnd',imageBin.locEnd) else %for backward compatibility setappdata(fig,'locStart',imageBin.rStart) setappdata(fig,'locEnd',imageBin.rEnd) end %try setappdata(fig,'errorRate',imageBin.errorRate) setappdata(fig,'w2d',imageBin.w2d) setappdata(fig,'dfltnLoops',imageBin.dfltnLoops) setappdata(fig,'minInt',imageBin.minInt) setappdata(fig,'locParallel',imageBin.locParallel) setappdata(fig,'nCores',imageBin.nCores) setappdata(fig,'spatialCorrection',imageBin.spatialCorrection) setappdata(fig,'isRadiusTol',imageBin.isRadiusTol) setappdata(fig,'radiusTol',imageBin.radiusTol) setappdata(fig,'posTol',imageBin.posTol) setappdata(fig,'maxOptimIter',imageBin.maxOptimIter) setappdata(fig,'termTol',imageBin.termTol) %Bar Options setappdata(fig,'isScalebar',0) setappdata(fig,'micronBarLength',imageBin.micronBarLength) setappdata(fig,'isColormap',0) setappdata(fig,'isTimestamp',0) setappdata(fig,'timestampSize',imageBin.timestampSize) setappdata(fig,'timestampInkrement',imageBin.timestampInkrement) setappdata(fig,'colormapWidth',imageBin.colormapWidth) %Render Options setappdata(fig,'exfOld',imageBin.exfNew) setappdata(fig,'exfNew',imageBin.exfNew) setappdata(fig,'rW',imageBin.rW) setappdata(fig,'rStep',imageBin.rStep) setappdata(fig,'rStart',1) setappdata(fig,'rEnd',numel(imageBin.ctrsN)) setappdata(fig,'rLive',imageBin.rLive) setappdata(fig,'fps',imageBin.fps) setappdata(fig,'movCompression',imageBin.movCompression) setappdata(fig,'convMode',1) setappdata(fig,'intWeight',255) setappdata(fig,'sizeFac',1) setappdata(fig,'isCumsum',imageBin.isCumsum) %Thresh Options setappdata(fig,'isThreshLocPrec',0) setappdata(fig,'minLoc',imageBin.minLoc) setappdata(fig,'maxLoc',imageBin.maxLoc) setappdata(fig,'isThreshSNR',0) setappdata(fig,'minSNR',imageBin.minSNR) setappdata(fig,'maxSNR',imageBin.maxSNR) setappdata(fig,'isThreshDensity',0) setappdata(fig,'clusterMode',1) %Optics Options setappdata(fig,'pxSize',imageBin.pxSize) if isfield(imageBin,'frameSize') setappdata(fig,'frameSize',imageBin.frameSize) else setappdata(fig,'frameSize',32) end %if setappdata(fig,'cntsPerPhoton',imageBin.cntsPerPhoton) setappdata(fig,'emWvlnth',imageBin.emWvlnth) setappdata(fig,'NA',imageBin.NA) setappdata(fig,'psfScale',imageBin.psfScale) setappdata(fig,'psfStd',imageBin.psfStd) %tracking options setappdata(fig,'trackStart',1) setappdata(fig,'trackEnd',inf) setappdata(fig,'Dmax',0.1) setappdata(fig,'searchExpFac',1.2) setappdata(fig,'statWin',10) setappdata(fig,'maxComp',3) setappdata(fig,'maxOffTime',5) setappdata(fig,'intLawWeight',0.9) setappdata(fig,'diffLawWeight',0.5) %ROI Options setappdata(fig,'width',imageBin.width) setappdata(fig,'height',imageBin.height) setappdata(fig,'roiX0',0) setappdata(fig,'roiY0',0) setappdata(fig,'roi',[0 0 imageBin.width imageBin.height]) setappdata(fig,'hROI',[]) setappdata(fig,'intensityRange',[0 255]) setappdata(fig,'ctrsN',imageBin.ctrsN) %rendering roi = [0 0 imageBin.width imageBin.height]; setappdata(fig,'startPnt',0) setappdata(fig,'elements',inf) data = preprocessData(fig,... [1 1 0 0 0 0 0 1 0 0 0 0],roi); [I,width,height,N] = renderImage(data,roi,... getappdata(fig,'exfNew'),... getappdata(fig,'width'),... getappdata(fig,'height'),... getappdata(fig,'intWeight'),... getappdata(fig,'sizeFac'),... getappdata(fig,'pxSize'),... getappdata(fig,'convMode')); figTitle = [getappdata(fig,'filename') ': ' num2str(N) ' rendered']; tagIntHist = 'Particle Intensity'; badToggles = [9:10 13:14 17:19 21:36]; else return end %if case 'FPALM' [filename, pathname,isOK] = uigetfile(... '*.mat', 'Select Particle Coordinates', getappdata(0,'searchPath')); if isOK setappdata(1, 'searchPath', pathname) load([pathname filename],... 'a0_all','xf_all', 'yf_all','r0_all',... 'framenum_all', 'file_info','exf','NA',... 'wvlnth','pix_to_pho','psf_scale','q',... 'nmol_all','total_molecules','x_offset',... 'x_size', 'y_offset', 'y_size',... 'iprod_thresh','bkgn' ) %format conversion [imageBin.filename,imageBin.pathname,isOK] =... uiputfile('' ,'Save converted Data to', pathname); if isOK %Predefined Variables imageBin.isOwn = true; imageBin.isLoaded = true; imageBin.isSuperstack = false; imageBin.isTrack = false; imageBin.frame = 1; %Loc Options imageBin.errorRate = -6; imageBin.w2d = 7; imageBin.dfltnLoops = 15; imageBin.minInt = iprod_thresh; imageBin.locParallel = false; imageBin.nCores = 1; imageBin.spatialCorrection = false; imageBin.isRadiusTol = false; imageBin.radiusTol = 50; imageBin.posTol = 1.5; imageBin.maxOptimIter = 50; imageBin.termTol = -2; %Bar Options imageBin.isScalebar = 0; imageBin.micronBarLength = 1000; imageBin.isColormap = 0; imageBin.colormapWidth = 20; imageBin.isTimestamp = 0; imageBin.timestampSize = 2; imageBin.timestampInkrement = 0.032; %Render Options imageBin.exfOld = exf; imageBin.exfNew = exf; imageBin.rW = 50; imageBin.rStep = 10; imageBin.rStart = nan; imageBin.rEnd = nan; imageBin.rLive = false; imageBin.fps = 32; imageBin.movCompression = 1; imageBin.convMode = 1; imageBin.intWeight = 0.01; imageBin.sizeFac = 1; imageBin.isCumsum = false; %Thresh Options imageBin.isThreshLocPrec = false; imageBin.minLoc = 0; imageBin.maxLoc = inf; imageBin.isThreshSNR = false; imageBin.minSNR = 0; imageBin.maxSNR = inf; imageBin.isThreshDensity = false; %Optics Options imageBin.pxSize = q; imageBin.cntsPerPhoton = pix_to_pho; imageBin.emWvlnth = wvlnth*1000; imageBin.NA = NA; imageBin.psfScale = psf_scale; imageBin.psfStd = psf_scale*0.55*(wvlnth)/NA/1.17/q/2; imageBin.ctrsN = nmol_all'; imageBin.nrI = file_info.stop-file_info.startPnt+1; imageBin.height = y_size; imageBin.width = x_size; imageBin.roi = [x_offset y_offset x_size y_size]; fidY = fopen([imageBin.pathname imageBin.filename '.ctrsY'], 'a+'); fidX = fopen([imageBin.pathname imageBin.filename '.ctrsX'], 'a+'); fidSignal = fopen([imageBin.pathname imageBin.filename '.signal'], 'a+'); fidNoise = fopen([imageBin.pathname imageBin.filename '.noise'], 'a+'); fidRadius = fopen([imageBin.pathname imageBin.filename '.radius'], 'a+'); fidFrame = fopen([imageBin.pathname imageBin.filename '.frame'], 'a+'); fwrite(fidY,yf_all,'real*8'); fwrite(fidX,xf_all,'real*8'); fwrite(fidSignal,a0_all,'real*8'); fwrite(fidNoise,ones(total_molecules,1)*bkgn,'real*8'); fwrite(fidRadius,r0_all/2,'real*8'); % 1/e^2 -> std fwrite(fidFrame,framenum_all,'real*8'); fclose('all'); %preallocate frame I = zeros(imageBin.roi(4)*imageBin.exfNew,... imageBin.roi(3)*imageBin.exfNew); ctrsXY = imageBin.roi(4)*imageBin.exfNew*... uint32((xf_all'-imageBin.roi(1)+1)*imageBin.exfNew)+... uint32((yf_all'-imageBin.roi(2)+1)*imageBin.exfNew); [ctrsXY unused take] = unique(ctrsXY); signal = accumarray(take,a0_all*imageBin.cntsPerPhoton); I(ctrsXY) = signal*imageBin.intWeight; psf = buildPSF(imageBin.sizeFac,... ceil(imageBin.roi(3)*imageBin.exfNew),... ceil(imageBin.roi(4)*imageBin.exfNew)); I = fftshift(ifft2(fft2(I).*psf)); pxRange = [0 255]; figTitle = [imageBin.filename ': ' num2str(total_molecules) ' rendered']; badToggles = [5 6 8 9 10 11 12 13 14 15 16 19 20 21 22 23]; else return end %if else return end %if case 'Tracking Data' [filename, pathname,isOK] = uigetfile(... '*.mat', 'Select Tracking Data', getappdata(0,'searchPath')); if isOK setappdata(0, 'searchPath', pathname) [data,settings,par_per_frame] = deal([]); load([pathname filename]) tracksize = cellfun('size',data.tr,1); data.tr(tracksize < 5) = []; setappdata(fig,'pathname',pathname) setappdata(fig,'tracks',data.tr) setappdata(fig,'nTracks',numel(data.tr)) setappdata(fig,'ctrsN',par_per_frame) setappdata(fig,'isOwn',1) setappdata(fig,'isLoaded',1) setappdata(fig,'isSuperstack',0) setappdata(fig,'isTrack',1) setappdata(fig,'frame',1) setappdata(fig,'viewMode','monoView') setappdata(fig,'trackColorMode',2) setappdata(fig,'trackColor',{[1 1 0],... rand(getappdata(fig,'nTracks'),3)}) setappdata(fig,'trackWidth',1) setappdata(fig,'trackVisibility',1) setappdata(fig,'rW',1) setappdata(fig,'rStep',1) setappdata(fig,'rStart',1) setappdata(fig,'rEnd',settings.Frames) setappdata(fig,'isCumsum',1) setappdata(fig,'isTracksizeThresh',1) setappdata(fig,'minTracksize',15) setappdata(fig,'maxTracksize',inf) setappdata(fig,'pxSize',settings.px2micron) setappdata(fig,'frameSize',settings.Delay*1000) %tracking options setappdata(fig,'trackStart',1) setappdata(fig,'trackEnd',inf) setappdata(fig,'Dmax',... settings.TrackingOptions.MaxDiffusionCoefficient) setappdata(fig,'searchExpFac',... settings.TrackingOptions.ResearchDiameter) setappdata(fig,'statWin',... settings.TrackingOptions.AvaragingTimeWindow) setappdata(fig,'maxComp',... settings.TrackingOptions.CombinationTresh) setappdata(fig,'maxOffTime',... settings.TrackingOptions.BlinkingProbability) setappdata(fig,'intLawWeight',... settings.TrackingOptions.WeightUniformGaussianLaw) setappdata(fig,'diffLawWeight',... settings.TrackingOptions.WeightMaxLocalDiffusion) %ROI Options width = settings.Width; height = settings.Height; setappdata(fig,'width',width) setappdata(fig,'height',height) setappdata(fig,'exfOld',1) setappdata(fig,'roiX0',0) setappdata(fig,'roiY0',0) setappdata(fig,'roi',[0 0 width height]) setappdata(fig,'hROI',[]) I = zeros(height,width); setappdata(fig,'intensityRange',[0 255]) [pathname filename ext] = fileparts(settings.Filename); setappdata(fig,'filename',filename) figTitle = filename; tagIntHist = ''; badToggles = [2:14 17:29 32:36]; end %if end %switch if isOK logInImage(fig,[]) set(fig,... 'Name', figTitle,... 'Units','normalized',... 'Position', figPos(width/height),... 'Color', min(1,unifrnd(0.7,1,1,3)+... double(randperm(RandStream.getDefaultStream,3)==1)),... 'NumberTitle', 'off',... 'MenuBar', 'none',... 'ToolBar', 'figure',... 'DeleteFcn', @logOutImage,... 'DockControls', 'off',... 'Visible', 'on'); ax = ... axes(... 'Parent', fig,... 'Units','normalized',... 'Position', [0.05 0.05 0.9 0.9]); %draw Image iptsetpref('ImshowAxesVisible','off') hImage = imshow(I,getappdata(fig,'intensityRange')); setappdata(fig,'hImage',hImage) if getappdata(fig,'isTrack') %plot tracks tracksize = cellfun('size',data.tr,1); if isinf(getappdata(fig,'maxTracksize')) hasSize = tracksize >= getappdata(fig,'minTracksize'); else hasSize = tracksize >= getappdata(fig,'minTracksize') &... tracksize <= getappdata(fig,'maxTracksize'); end %if cmap =getappdata(fig,'trackColor'); hTracks = zeros(getappdata(fig,'nTracks'),1); for trackID = 1:getappdata(fig,'nTracks') hTracks(trackID) = line(data.tr{trackID}(:,1),... data.tr{trackID}(:,2),... 'Parent', ax,... 'Color', cmap{2}(trackID,:),... 'LineWidth', getappdata(fig,'trackWidth')); end setappdata(fig,'hTracks',hTracks) set(hTracks(~hasSize),'Visible','off') end %if %personalize toolbar hToolBar = findall(fig,'Type','uitoolbar'); uipushtool(... 'Parent', hToolBar,... 'CData', repmat(icon.save, [1 1 3]),... 'ClickedCallback', {@saveImage,I,'8bit'}) uipushtool(... 'Parent', hToolBar,... 'CData', repmat(icon.Arrow, [1 1 3]),... 'ClickedCallback', @previousFrame) uitoggletool(... 'Parent', hToolBar,... 'CData', repmat(icon.playMov, [1 1 3]),... 'ClickedCallback', @showRawStack) uipushtool(... 'Parent', hToolBar,... 'CData', repmat(fliplr(icon.Arrow), [1 1 3]),... 'ClickedCallback', @nextFrame) uitoggletool(... 'Parent', hToolBar,... 'CData', repmat(icon.roi, [1 1 3]),... 'ClickedCallback', @setROI) uitoggletool(... 'Parent', hToolBar,... 'CData', repmat(icon.options, [1 1 3]),... 'ClickedCallback', @setOptions) uipushtool(... 'Parent', hToolBar,... 'Tag', 'max. Intensity',... 'CData', repmat(icon.maxProj, [1 1 3]),... 'ClickedCallback', @zProject,... 'TooltipString', sprintf(['\n' ... 'Do a max. Intensity z-Projection. \n' ... 'Each Pixel in the final Image gets \n' ... 'the max. registered Pixelvalue \n' ... 'from the Imagestack.'])) uipushtool(... 'Parent', hToolBar,... 'Tag', 'mean Intensity',... 'CData', repmat(icon.aveProj, [1 1 3]),... 'ClickedCallback', @zProject) uipushtool(... 'Parent', hToolBar,... 'CData', repmat(icon.colormap, [1 1 3]),... 'ClickedCallback', 'colormapeditor') uipushtool(... 'Parent', hToolBar,... 'Tag', tagIntHist,... 'CData', repmat(icon.intDist, [1 1 3]),... 'ClickedCallback', @intHist) uipushtool(... 'Parent', hToolBar,... 'CData', repmat(icon.testLoc, [1 1 3]),... 'ClickedCallback', @showLocPreview) uipushtool(... 'Parent', hToolBar,... 'CData', repmat(icon.locAll, [1 1 3]),... 'ClickedCallback', @localization) uipushtool(... 'Parent', hToolBar,... 'CData', repmat(icon.precDist, [1 1 3]),... 'ClickedCallback', @locPrec) uipushtool(... 'Parent', hToolBar,... 'CData', repmat(icon.s2nDist, [1 1 3]),... 'ClickedCallback', @snrHist) uipushtool(... 'Parent', hToolBar,... 'CData', repmat(icon.locDist, [1 1 3]),... 'ClickedCallback', @detectionTrace) uipushtool(... 'Parent', hToolBar,... 'CData', repmat(icon.genTraj, [1 1 3]),... 'ClickedCallback', @buildTracks) uipushtool(... 'Parent', hToolBar,... 'Tag', 'Image',... 'CData', repmat(icon.genIm, [1 1 3]),... 'ClickedCallback', @render) uipushtool(... 'Parent', hToolBar,... 'Tag', 'Movie',... 'CData', repmat(icon.genMov, [1 1 3]),... 'ClickedCallback', @render) uipushtool(... 'Parent', hToolBar,... 'Tag', '3D ImScatter',... 'CData', repmat(icon.scatter3D, [1 1 3]),... 'ClickedCallback', @scatterPlot) hToggleList = findall(hToolBar); delete(hToggleList(badToggles)) % jToolbar = get(get(imageBin.hToolBar,'JavaContainer'),'ComponentPeer'); % set(jToolbar,'Background',get(imageBin.hFig,'Color')); else return end %if function addStack(src, event, hList) [stackname, stackpath,isOK] = uigetfile('*.tif',... 'Select Imagestacks', getappdata(0,'searchPath'),... 'MultiSelect', 'on'); if isOK setappdata(0, 'searchPath', stackpath) content = get(hList, 'String'); contentNew = cellstr(strcat(stackpath, stackname)); content = [content',contentNew]; set(hList, 'String', content) else return end %if end function delStack(src, event, hList) bad = get(hList, 'Value'); content = get(hList, 'String'); if isempty(content) return else content(bad) = []; set(hList, 'String', content, 'Value', 1) end %if end function moveUpStack(src, event, hList) pos = get(hList, 'Value'); if pos > 1 content = get(hList, 'String'); content(pos-1:pos) = [content(pos); content(pos-1)]; set(hList, 'String', content, 'Value', pos-1) else return end %if end function moveDownStack(src, event, hList) pos = get(hList, 'Value'); content = get(hList, 'String'); if pos < numel(content) content(pos:pos+1) = [content(pos+1); content(pos)]; set(hList, 'String', content, 'Value', pos+1) else return end %if end function buildSuperstack(src, event, hList) content = get(hList, 'String'); if isempty(content) return else %initialize variables for idx = 1:numel(content) [pathname_, filename_, ext_] = fileparts(content{idx}); pathname{1,idx} = [pathname_ '\']; filename{1,idx} = [filename_ ext_]; end setappdata(fig,'pathname',pathname) setappdata(fig,'filename',filename) setappdata(fig,'isOwn',1) setappdata(fig,'isLoaded',0) setappdata(fig,'isSuperstack',1) setappdata(fig,'isTrack',0) setappdata(fig,'frame',1) setappdata(fig,'stack',1) setappdata(fig,'stackSize',[]) setappdata(fig,'viewMode','monoView') %Loc Options setappdata(fig,'locStart',1) setappdata(fig,'locEnd',inf) setappdata(fig,'errorRate',-6) setappdata(fig,'w2d',7) setappdata(fig,'dfltnLoops',15) setappdata(fig,'minInt',0) setappdata(fig,'locParallel',0) setappdata(fig,'nCores',1) setappdata(fig,'spatialCorrection',0) setappdata(fig,'isRadiusTol',0) setappdata(fig,'radiusTol',50) setappdata(fig,'posTol',1.5) setappdata(fig,'maxOptimIter',50) setappdata(fig,'termTol',-2) %Bar Options setappdata(fig,'isScalebar',0) setappdata(fig,'micronBarLength',1000) setappdata(fig,'isColormap',0) setappdata(fig,'isTimestamp',0) setappdata(fig,'timestampSize',2) setappdata(fig,'timestampInkrement',0.032) setappdata(fig,'colormapWidth',10) %Render Options setappdata(fig,'exfOld',1) setappdata(fig,'exfNew',5) setappdata(fig,'rW',50) setappdata(fig,'rStep',10) setappdata(fig,'rStart',1) setappdata(fig,'rEnd',inf) setappdata(fig,'rLive',0) setappdata(fig,'fps',32) setappdata(fig,'movCompression',1) setappdata(fig,'convMode',1) setappdata(fig,'intWeight',0.01) setappdata(fig,'sizeFac',1) setappdata(fig,'isCumsum',0) %Filter Options setappdata(fig,'isThreshLocPrec',0) setappdata(fig,'minLoc',0) setappdata(fig,'maxLoc',inf) setappdata(fig,'isThreshSNR',0) setappdata(fig,'minSNR',0) setappdata(fig,'maxSNR',inf) setappdata(fig,'isThreshDensity',0) setappdata(fig,'clusterMode',1) %Optics Options setappdata(fig,'pxSize',0.107) setappdata(fig,'cntsPerPhoton',20.2) setappdata(fig,'emWvlnth',567) setappdata(fig,'NA',1.45) setappdata(fig,'psfScale',1.2) setappdata(fig,'psfStd',1.03) I = imread([pathname{1} filename{1}],... getappdata(fig,'frame')); [height width] = size(I); setappdata(fig,'width',width) setappdata(fig,'height',height) setappdata(fig,'roiX0',0) setappdata(fig,'roiY0',0) setappdata(fig,'roi',[0 0 width height]) setappdata(fig,'hROI',[]) setappdata(fig,'intensityRange',[]) figTitle = ['Frame 1 - ' filename{1}]; tagIntHist = 'Pixel Intensity'; badToggles = [2:8 20:36]; close(menuFig) end %if end end function saveImage(src,event,I,mode) switch mode case '8bit' I = uint8(I); case '16bit' I = uint16(I); otherwise end %switch [filename,pathname,isOK] =... uiputfile('.tif' ,'Save to', getappdata(0,'searchPath')); if isOK imwrite(I,[pathname filename]) end %if end function logInImage(src, event) if getappdata(src,'isLoaded') masterBinHandles = getappdata(1, 'handles'); if getappdata(src,'isTrack') uimenu(... 'Parent', masterBinHandles.menuTrackChannel,... 'Label', regexprep(getappdata(src,'filename'),... {'(',')','[',']','{','}','+'}, '_'),... 'Callback', strcat('if strcmp(get(gcbo, ''Checked''),''on'');',... 'set(gcbo, ''Checked'', ''off''); else;',... 'set(gcbo, ''Checked'', ''on''); end'),... 'UserData', src); else h1 =... uimenu(... 'Parent', masterBinHandles.menuImageChannel(1),... 'Label', regexprep(getappdata(src,'filename'),... {'(',')','[',']','{','}','+'}, '_'),... 'Callback', @changeCheckMode,... 'UserData', src); h2 =... uimenu(... 'Parent', masterBinHandles.menuImageChannel(2),... 'Label', regexprep(getappdata(src,'filename'),... {'(',')','[',']','{','}','+'}, '_'),... 'Callback', @changeCheckMode,... 'UserData', src); h3 =... uimenu(... 'Parent', masterBinHandles.menuImageChannel(3),... 'Label', regexprep(getappdata(src,'filename'),... {'(',')','[',']','{','}','+'}, '_'),... 'Callback', @changeCheckMode,... 'UserData', src); if all(strcmp('off', get(allchild(... masterBinHandles.menuImageChannel(1)), 'Checked'))) set(h1, 'Checked', 'on') elseif all(strcmp('off', get(allchild(... masterBinHandles.menuImageChannel(2)), 'Checked'))) set(h2, 'Checked', 'on') elseif all(strcmp('off', get(allchild(... masterBinHandles.menuImageChannel(3)), 'Checked'))) set(h3, 'Checked', 'on') end %if end %if end %if end function logOutImage(src, event) rootFig = findobj(0,'Tag','root'); if ~isempty(rootFig) masterBinHandles = getappdata(1, 'handles'); if getappdata(src,'isTrack') delete(findobj(masterBinHandles.menuTrackChannel,'UserData', src)); else delete(findobj(masterBinHandles.menuImageChannel,'UserData', src)); end %if delete(findobj(allchild(0),'Color',get(src,'Color'))) end %if end function showRawStack(src, event) endOfStack = nextFrame(src, event); pause(0.5) while ~endOfStack && strcmp(get(src,'state'),'on') endOfStack = nextFrame(src, event); pause(0.5) end %while end function previousFrame(src, event) % imageBin = getappdata(hFig, 'imageBin'); fig = gcbf; frame = getappdata(fig,'frame')-1; pathname = getappdata(fig,'pathname'); filename = getappdata(fig,'filename'); if getappdata(fig,'isSuperstack') if frame > 0 I = double(imread([pathname{getappdata(fig,'stack')}... filename{getappdata(fig,'stack')}],frame)); set(fig, 'Name',... ['Frame: ' num2str(frame)... ' - ' filename{getappdata(fig,'stack')}]) else if getappdata(fig,'stack') > 1 %jump to previous stack setappdata(fig,'stack',getappdata(fig,'stack')-1); stackSize = getappdata(fig,'stackSize'); frame = stackSize(getappdata(fig,'stack')); I = double(imread([pathname{getappdata(fig,'stack')}... filename{getappdata(fig,'stack')}],frame)); set(fig, 'Name',... ['Frame: ' num2str(frame)... ' - ' filename{getappdata(fig,'stack')}]) else return end %if end %if else if frame > 0 I = imread([getappdata(fig,'pathname')... getappdata(fig,'filename')],frame); set(fig, 'Name',... ['Frame: ' num2str(frame) ' - ' getappdata(fig,'filename')]) else return end %if end %if setappdata(fig,'frame',frame) set(getappdata(fig,'hImage'), 'CData', I) caxis([min(min(I)) max(max(I))]) end function endOfStack = nextFrame(src, event) fig = gcbf; frame = getappdata(fig,'frame')+1; pathname = getappdata(fig,'pathname'); filename = getappdata(fig,'filename'); endOfStack = false; try if getappdata(fig,'isSuperstack') I = double(imread([pathname{getappdata(fig,'stack')}... filename{getappdata(fig,'stack')}],frame)); set(fig, 'Name',... ['Frame: ' num2str(frame) ' - ' filename{getappdata(fig,'stack')}]) else I = imread([pathname filename],frame); set(fig, 'Name',... ['Frame: ' num2str(frame) ' - ' filename]) end setappdata(fig,'frame',frame) catch if getappdata(fig,'isSuperstack') %jump to following imagestack if getappdata(fig,'stack') < numel(filename) stackSize = getappdata(fig,'stackSize'); stackSize(getappdata(fig,'stack')) = frame -1; setappdata(fig,'stackSize',stackSize) setappdata(fig,'stack',getappdata(fig,'stack')+1); setappdata(fig,'frame',1) I = double(imread([pathname{getappdata(fig,'stack')}... filename{getappdata(fig,'stack')}],1)); set(fig, 'Name',... ['Frame: 1 - ' filename{getappdata(fig,'stack')}]) else warndlg('End of Stack reached', 'Info') endOfStack = true; return end %if else warndlg('End of Stack reached', 'Info') endOfStack = true; return end %if end %if set(getappdata(fig,'hImage'), 'CData', I) caxis([min(min(I)) max(max(I))]) end function setROI(src, event) fig = gcbf; switch get(src,'State') case 'on' ax = findobj(fig,'Type','axes'); %draw user defined ROI hRoi = imrect(ax); setappdata(fig,'hROI',hRoi) hMenu = uicontextmenu; uimenu(hMenu, 'Label', 'Adjust ROI Placement',... 'Callback', @adjustROI); hPatch = findobj(hRoi,'Type','patch'); set(hPatch,'FaceColor', [1 1 1],... 'FaceAlpha', 0.3,... 'UIContextMenu', hMenu) pos = getPosition(hRoi); setappdata(fig,'roi',... [pos(1)-0.5 pos(2)-0.5... pos(3) pos(4)]/getappdata(fig,'exfOld')+... [getappdata(fig,'roiX0') getappdata(fig,'roiY0') 0 0]) hRoiText = text(pos(1), pos(2),... sprintf([' x0 = ' num2str(((pos(1)-0.5)/getappdata(fig,'exfOld')+... getappdata(fig,'roiX0'))*getappdata(fig,'pxSize')) ' µm \n',... ' y0 = ' num2str((pos(2)-0.5)/getappdata(fig,'exfOld')+... getappdata(fig,'roiX0')) ' µm \n',... ' width = ' num2str(pos(3)/getappdata(fig,'exfOld')*... getappdata(fig,'pxSize')) ' µm \n',... ' height = ' num2str(pos(4)/getappdata(fig,'exfOld')*... getappdata(fig,'pxSize')) ' µm']),... 'FontSize', 8,... 'FontWeight', 'bold',... 'Color', [0 1 0],... 'VerticalAlignment', 'top'); setappdata(fig,'hRoiText',hRoiText) addNewPositionCallback(hRoi,@posInfo); cnstrnts = get(ax,{'XLim','YLim'}); fcn = makeConstrainToRectFcn('imrect',... cnstrnts{1}, cnstrnts{2}); setPositionConstraintFcn(hRoi,fcn); case 'off' if ~isempty(getappdata(fig,'hROI')) delete(getappdata(fig,'hROI')) delete(getappdata(fig,'hRoiText')) setappdata(fig,'hROI',[]) setappdata(fig,'roi',... [0 0 getappdata(fig,'width') getappdata(fig,'height')]) end %if end %switch function posInfo(pos) set(hRoiText, 'Position', [pos(1) pos(2) 0],... 'String',sprintf([' x0 = ' num2str(((pos(1)-0.5)/getappdata(fig,'exfOld')+... getappdata(fig,'roiX0'))*getappdata(fig,'pxSize')) ' µm \n',... ' y0 = ' num2str((pos(2)-0.5)/getappdata(fig,'exfOld')+... getappdata(fig,'roiX0')) ' µm \n',... ' width = ' num2str(pos(3)/getappdata(fig,'exfOld')*... getappdata(fig,'pxSize')) ' µm \n',... ' height = ' num2str(pos(4)/getappdata(fig,'exfOld')*... getappdata(fig,'pxSize')) ' µm'])) setappdata(fig,'roi',... [pos(1)-0.5 pos(2)-0.5... pos(3) pos(4)]/getappdata(fig,'exfOld')+... [+getappdata(fig,'roiX0') +getappdata(fig,'roiY0') 0 0]) end function adjustROI(src, event) %% figNew =... figure(... 'Tag', 'home',... 'Units','normalized',... 'Position', [0.8 0.5 0.15 0.15],... 'Color', get(fig,'Color'),... 'NumberTitle', 'off',... 'MenuBar', 'none',... 'ToolBar', 'none',... 'Resize', 'off'); uicontrol(... 'Style', 'pushbutton',... 'Parent', figNew,... 'Units','normalized',... 'Position', [0.33 0.67 0.34 0.33],... 'FontSize', 10,... 'FontWeight', 'bold',... 'FontUnits', 'normalized',... 'String', 'UP',... 'Callback', @moveROI,... 'BackgroundColor', get(fig,'Color')) uicontrol(... 'Style', 'pushbutton',... 'Parent', figNew,... 'Units','normalized',... 'Position', [0.33 0 0.34 0.33],... 'FontSize', 10,... 'FontWeight', 'bold',... 'FontUnits', 'normalized',... 'String', 'DOWN',... 'Callback', @moveROI,... 'BackgroundColor', get(fig,'Color')) uicontrol(... 'Style', 'pushbutton',... 'Parent', figNew,... 'Units','normalized',... 'Position', [0 0.33 0.33 0.33],... 'FontSize', 10,... 'FontWeight', 'bold',... 'FontUnits', 'normalized',... 'String', 'LEFT',... 'Callback', @moveROI,... 'BackgroundColor', get(fig,'Color')) uicontrol(... 'Style', 'pushbutton',... 'Parent', figNew,... 'Units','normalized',... 'Position', [0.67 0.33 0.33 0.33],... 'FontSize', 10,... 'FontWeight', 'bold',... 'FontUnits', 'normalized',... 'String', 'RIGHT',... 'Callback', @moveROI,... 'BackgroundColor', get(fig,'Color')) uicontrol(... 'Style', 'pushbutton',... 'Parent', figNew,... 'Units','normalized',... 'Position', [0 0.67 0.33 0.33],... 'FontSize', 8,... 'FontWeight', 'bold',... 'FontUnits', 'normalized',... 'String', '+width',... 'Callback', @moveROI,... 'BackgroundColor', get(fig,'Color')) uicontrol(... 'Style', 'pushbutton',... 'Parent', figNew,... 'Units','normalized',... 'Position', [0 0 0.33 0.33],... 'FontSize', 8,... 'FontWeight', 'bold',... 'FontUnits', 'normalized',... 'String', '-width',... 'Callback', @moveROI,... 'BackgroundColor', get(fig,'Color')) uicontrol(... 'Style', 'pushbutton',... 'Parent', figNew,... 'Units','normalized',... 'Position', [0.67 0.67 0.33 0.33],... 'FontSize', 8,... 'FontWeight', 'bold',... 'FontUnits', 'normalized',... 'String', '+height',... 'Callback', @moveROI,... 'BackgroundColor', get(fig,'Color')) uicontrol(... 'Style', 'pushbutton',... 'Parent', figNew,... 'Units','normalized',... 'Position', [0.67 0 0.33 0.33],... 'FontSize', 8,... 'FontWeight', 'bold',... 'FontUnits', 'normalized',... 'String', '-height',... 'Callback', @moveROI,... 'BackgroundColor', get(fig,'Color')) uicontrol(... 'Style', 'pushbutton',... 'Parent', figNew,... 'Units','normalized',... 'Position', [0.33 0.33 0.34 0.33],... 'FontSize', 10,... 'FontWeight', 'bold',... 'FontUnits', 'normalized',... 'String', 'sync',... 'Callback', @moveROI,... 'BackgroundColor', get(fig,'Color')) function moveROI(src, event) pos = ceil(getPosition(hRoi)); switch get(src, 'String') case 'UP' if pos(2) > 1 setPosition(hRoi,pos-[0 1 0 0]) end %if case 'DOWN' if pos(2)+pos(4) < cnstrnts{2}(2) setPosition(hRoi,pos+[0 1 0 0]) end %if case 'LEFT' if pos(1) > 1 setPosition(hRoi,pos-[1 0 0 0]) end %if case 'RIGHT' if pos(1)+pos(3) < cnstrnts{1}(2) setPosition(hRoi,pos+[1 0 0 0]) end %if case '+width' if pos(1)+pos(3) < cnstrnts{1}(2) setPosition(hRoi,pos+[0 0 1 0]) end %if case '-width' if pos(3) > 1 setPosition(hRoi,pos-[0 0 1 0]) end %if case '+height' if pos(2)+pos(4) < cnstrnts{2}(2) setPosition(hRoi,pos+[0 0 0 1]) end %if case '-height' if pos(4) > 1 setPosition(hRoi,pos-[0 0 0 1]) end %if case 'sync' figs = findobj(0,'Type', 'figure',... '-not', 'Color', get(fig, 'Color'),... '-not', 'Name','SLIMfast Build 1.103e'); if isempty(figs) warndlg('No ROI found to sync with', 'Info') return else if iscell(figs) figs = cell2mat(figs); end %if [selection,isOK] = listdlg('ListString',... get(figs,'Name'),'Name', 'Sync To:'); if isOK api = iptgetapi(findobj(figs(selection),'Tag', 'imrect')); setPosition(hRoi,api.getPosition()) end %if end %if end %switch end end end %% VISUALIZATION function showLocPreview(src, event) fig = gcbf; I = get(getappdata(fig,'hImage'), 'CData'); %search for ROI if isempty(getappdata(fig,'hROI')) roi = ceil(getappdata(fig,'roi')); else roi = ceil(getappdata(fig,'roi')); I = I(roi(2):roi(2)+roi(4),... roi(1):roi(1)+roi(3)); end optim = [... getappdata(fig,'maxOptimIter') getappdata(fig,'termTol') getappdata(fig,'isRadiusTol') getappdata(fig,'radiusTol') getappdata(fig,'posTol')]; [list dfltI mask good] = ... detect_et_estime_part_1vue_deflt(... double(I),... getappdata(fig,'w2d'),... getappdata(fig,'psfStd'),... chi2inv(1-1/10^(getappdata(fig,'errorRate')*-1),1),... getappdata(fig,'dfltnLoops'),... roi(3),roi(4),... getappdata(fig,'minInt'),... optim); figure(... 'Units','normalized',... 'Position', get(fig, 'Position'),... 'Color', get(fig,'Color'),... 'Name', ['Frame: ' num2str(getappdata(fig,'frame'))... ' (' num2str(good) ' Detections)'],... 'NumberTitle', 'off',... 'MenuBar', 'none',... 'ToolBar', 'figure'); hToolBar = findall(gcf,'Type','uitoolbar'); hToggleList = findall(hToolBar); delete(hToggleList([2 3 4 5 6 7 8 9 10 13 14 15 16 17])) axes(... 'Parent', gcf,... 'Units','normalized',... 'Position', [0.05 0.05 0.9 0.9]); imshow(I, []); rectangle(... 'Position',roi+[0.5 0.5 0 0],... 'EdgeColor', [1 0 0],... 'LineWidth', 1) rho = linspace(0,2*pi,10)'; patch(repmat(1+roi(1)+list(:,2)',10,1)+... cos(rho)*list(:,6)',... repmat(1+roi(2)+list(:,1)',10,1)+... sin(rho)*list(:,6)',... repmat(shiftdim([1 0 0],-1),1,good),... 'EdgeColor', 'none', 'FaceAlpha', 0.5) end function mergeChannels(src, event) if strcmp(get(src,'Label'),'monoView') else masterBinHandles = getappdata(1,'handles'); icon = getappdata(1, 'icons'); %update work mode changeCheckMode(src,[]) figNew = figure(... 'MenuBar', 'none',... 'Toolbar','figure',... 'DockControls', 'off',... 'NumberTitle', 'off',... 'Color', min(1,unifrnd(0.7,1,1,3)+... double(randperm(RandStream.getDefaultStream,3)==1)),... 'Visible', 'off'); if strcmp(get(src,'Label'),'dualView') setappdata(figNew,'viewMode','dualView') elseif strcmp(get(src,'Label'),'tripleView') setappdata(figNew,'viewMode','tripleView') end %if [imScrFig trackSrcFig] = getSelectedFigHandles; imCh = find(~isnan(imScrFig))'; nImCh = numel(imCh); trackCh = find(~isnan(trackSrcFig))'; nTrackCh = numel(trackCh); setappdata(figNew,'imSrcFig',imScrFig) setappdata(figNew,'imCh',imCh) setappdata(figNew,'nImCh',nImCh) setappdata(figNew,'trackSrcFig',trackSrcFig(trackCh)) setappdata(figNew,'nTrackCh',nTrackCh) for ch = imCh I(:,:,ch) = get(getappdata(imScrFig(ch),'hImage'),'CData'); end %for [height width depth] = size(I); I = cat(3,I,zeros(height,width,3-depth)); transferVarList(figNew,imScrFig(imCh),'merge') %open image window set([imScrFig(imCh);trackSrcFig], 'Visible', 'off') set(figNew,... 'Units','normalized',... 'Position', figPos(width/height),... 'DeleteFcn', {@splitChannels, [imScrFig(imCh);trackSrcFig]},... 'Visible', 'on'); axes(... 'Parent', figNew,... 'Units','normalized',... 'Position', [0.05 0.05 0.9 0.9]); %customize toolbar hToolBar = findall(figNew,'Type','uitoolbar'); uipushtool(... 'Parent', hToolBar,... 'CData', repmat(icon.save, [1 1 3]),... 'ClickedCallback', {@saveImage,I,'8bit'}) uitoggletool(... 'Parent', hToolBar,... 'CData', repmat(icon.roi, [1 1 3]),... 'ClickedCallback', @setROI) uitoggletool(... 'Parent', hToolBar,... 'CData', repmat(icon.options, [1 1 3]),... 'ClickedCallback', @setOptions) uipushtool(... 'Parent', hToolBar,... 'Tag', 'Image',... 'CData', repmat(icon.genIm, [1 1 3]),... 'ClickedCallback', @render) uipushtool(... 'Parent', hToolBar,... 'Tag', 'Movie',... 'CData', repmat(icon.genMov, [1 1 3]),... 'ClickedCallback', @render) hToggleList = findall(hToolBar); delete(hToggleList([5 7:15 18:23])) imshow(uint8(I), []); for ch = 1:nTrackCh hTracks = copyobj(getappdata(trackSrcFig(ch),'hTracks'),gca); xdata = get(hTracks,'XData'); set(hTracks,{'XData'}, cellfun(@(x) x*... getappdata(figNew,'exfNew')-1, xdata, 'un',0)) ydata = get(hTracks,'YData'); set(hTracks,{'YData'}, cellfun(@(x) x*... getappdata(figNew,'exfNew')-1, ydata, 'un',0)) end %for end %if function splitChannels(src, event, hFig) set(hFig, 'Visible', 'on') hList = allchild(masterBinHandles.menuDataMode); set(hList(1:3), 'Checked', 'off') set(hList(3), 'Checked', 'on') end end function render(src, event) icon = getappdata(1, 'icons'); fig = gcbf; figNew = figure(... 'MenuBar', 'none',... 'Toolbar','figure',... 'DockControls', 'off',... 'NumberTitle', 'off',... 'Color', get(fig,'Color')-unifrnd(0.09,0.11,1,3),... 'Visible', 'off'); switch getappdata(fig,'viewMode') case 'monoView' transferVarList(figNew,fig,'render-mono') switch get(src, 'Tag') case 'Image' %BUILD IMAGE %framerange selected idx = [-1; cumsum(getappdata(figNew,'ctrsN'))]; if getappdata(fig,'rStart') == 1 setappdata(figNew,'startPnt',0) else setappdata(figNew,'startPnt',... idx(getappdata(fig,'rStart'))+1) end %if if isinf(getappdata(fig,'rEnd')) setappdata(figNew,'rEnd',numel(getappdata(figNew,'ctrsN'))) setappdata(figNew,'elements',inf) else setappdata(figNew,'elements',... idx(getappdata(fig,'rEnd')+1)-... max(1,getappdata(figNew,'startPnt'))+1) end %if %rendering roi = getappdata(fig,'roi'); if getappdata(fig,'convMode') == 1 returnVal = [1 1 0 0 0 0 0 1 0 0 0 0]; else returnVal = [1 1 0 0 0 0 0 1 1 0 0 0]; end %if data = preprocessData(figNew,returnVal,roi); [imRendered,width,height,N] = renderImage(data,roi,... getappdata(figNew,'exfNew'),... getappdata(figNew,'width'),... getappdata(figNew,'height'),... getappdata(figNew,'intWeight'),... getappdata(figNew,'sizeFac'),... getappdata(figNew,'pxSize'),... getappdata(figNew,'convMode')); if getappdata(figNew,'isColormap') imRendered = imprintColormap(... imRendered,... width,... getappdata(fig,'colormapWidth'),... 1); end if getappdata(figNew,'isScalebar') imRendered = imprintScalebar(... imRendered,... width,... height,... getappdata(fig,'exfNew'),... getappdata(fig,'micronBarLength'),... getappdata(fig,'pxSize'),... getappdata(fig,'timestampSize'), 1); end %if setappdata(figNew,'roiX0', roi(1)) setappdata(figNew,'roiY0', roi(2)) setappdata(figNew,'exfOld',getappdata(fig,'exfNew')) logInImage(figNew,[]) set(figNew,... 'Name', sprintf('%s: %d/%d rendered',... getappdata(figNew,'filename'),N,... sum(getappdata(figNew,'ctrsN'))),... 'Units','normalized',... 'Position', figPos(width/height),... 'DeleteFcn', @logOutImage,... 'Visible', 'on') axes(... 'Parent', figNew,... 'Units','normalized',... 'Position', [0.05 0.05 0.9 0.9]); %customize toolbar hToolBar = findall(figNew,'Type','uitoolbar'); uipushtool(... 'Parent', hToolBar,... 'CData', repmat(icon.save, [1 1 3]),... 'ClickedCallback', {@saveImage,imRendered,'8bit'}) uitoggletool(... 'Parent', hToolBar,... 'CData', repmat(icon.roi, [1 1 3]),... 'ClickedCallback', @setROI) uipushtool(... 'Parent', hToolBar,... 'CData', repmat(icon.colormap, [1 1 3]),... 'ClickedCallback', 'colormapeditor') uitoggletool(... 'Parent', hToolBar,... 'CData', repmat(icon.options, [1 1 3]),... 'ClickedCallback', @setOptions) uipushtool(... 'Parent', hToolBar,... 'CData', repmat(icon.opt2txt, [1 1 3]),... 'ClickedCallback', {@exportSettings, 'Image'}) uipushtool(... 'Parent', hToolBar,... 'Tag', 'Particle Intensity',... 'CData', repmat(icon.intDist, [1 1 3]),... 'ClickedCallback', @intHist) uipushtool(... 'Parent', hToolBar,... 'CData', repmat(icon.precDist, [1 1 3]),... 'ClickedCallback', @locPrec) uipushtool(... 'Parent', hToolBar,... 'CData', repmat(icon.s2nDist, [1 1 3]),... 'ClickedCallback', @snrHist) uipushtool(... 'Parent', hToolBar,... 'CData', repmat(icon.locDist, [1 1 3]),... 'ClickedCallback', @detectionTrace) uipushtool(... 'Parent', hToolBar,... 'Tag', 'Image',... 'CData', repmat(icon.genIm, [1 1 3]),... 'ClickedCallback', @render) uipushtool(... 'Parent', hToolBar,... 'Tag', 'Movie',... 'CData', repmat(icon.genMov, [1 1 3]),... 'ClickedCallback', @render) hToggleList = findall(hToolBar); delete(hToggleList([13:21 24:28])) %draw Image hImage = imshow(uint8(imRendered)); setappdata(figNew,'hImage',hImage) case 'Movie' %BUILD MOVIE % create moviepreview roi = getappdata(fig,'roi'); if getappdata(fig,'convMode') == 1 returnVal = [1 1 0 0 0 0 0 1 0 0 0 0]; else returnVal = [1 1 0 0 0 0 0 1 1 0 0 0]; end %if previewFig = buildMoviePreview; colormapeditor uiwait(previewFig) % create movie %preallocate avi-file on harddisk [moviename,moviepath,isOK] =... uiputfile('.avi' ,'Save Movie to',... [getappdata(0,'searchPath') getappdata(fig,'filename')... '_WinSize_' num2str(getappdata(fig,'rW'))... '_Stepsize_' num2str(getappdata(fig,'rStep')) '_movie']); if isOK %set movies colormap and compression method comprssnMethod = {'RLE','MSVC','none'}; hMovie = avifile([moviepath moviename],... 'Colormap', cmap,... 'Compression', comprssnMethod{getappdata(fig,'movCompression')},... 'fps', getappdata(fig,'fps')); % create movieframes hProgressbar = waitbar(0,'Generating Movie...','Color',... get(0,'defaultUicontrolBackgroundColor')); movieFrames = max(ceil((getappdata(fig,'rEnd')-... getappdata(fig,'rStart')+1-... getappdata(fig,'rW'))/getappdata(fig,'rStep')),1); for movieFrame = 1:movieFrames; %set datarange to load for movieframe if movieFrame == 1 setappdata(figNew,'startPnt',... idx(getappdata(figNew,'rStart'))+1); %check 11/03/10 setappdata(figNew,'elements',... idx(getappdata(figNew,'rStart')+... getappdata(figNew,'rW'))-... max(1,getappdata(figNew,'startPnt'))+1); %check 11/03/10 elseif movieFrame == movieFrames if getappdata(figNew,'isCumsum') setappdata(figNew,'startPnt',... idx(getappdata(figNew,'rStart'))+1); %check 11/03/10 else setappdata(figNew,'startPnt',... idx(getappdata(figNew,'rStart')+... (movieFrames-1)*getappdata(figNew,'rStep'))+1); %check 11/03/10 end %if setappdata(figNew,'elements',... idx(getappdata(figNew,'rEnd'))-... getappdata(figNew,'startPnt')+1); %check 11/03/10 else if getappdata(figNew,'isCumsum') setappdata(figNew,'startPnt',... idx(getappdata(figNew,'rStart'))+1); %check 11/03/10 else setappdata(figNew,'startPnt',... idx(getappdata(figNew,'rStart')+... (movieFrame-1)*getappdata(figNew,'rStep'))+1); %check 11/03/10 end %if setappdata(figNew,'elements',... idx(getappdata(figNew,'rStart')+... (movieFrame-1)*getappdata(figNew,'rStep')+... getappdata(figNew,'rW'))-... getappdata(figNew,'startPnt')+1); %check 11/03/10 end %if if getappdata(fig,'convMode') == 1 returnVal = [1 1 0 0 0 0 0 1 0 0 0 0]; else returnVal = [1 1 0 0 0 0 0 1 1 0 0 0]; end %if data = preprocessData(figNew,returnVal,roi); [imMovie,width,height,N] = renderImage(data,roi,... getappdata(fig,'exfNew'),... getappdata(fig,'width'),... getappdata(fig,'height'),... getappdata(fig,'intWeight'),... getappdata(fig,'sizeFac'),... getappdata(fig,'pxSize'),... getappdata(fig,'convMode')); if getappdata(fig,'isColormap') imMovie = imprintColormap(... imMovie,... width,... getappdata(fig,'colormapWidth'),... 1); end if getappdata(fig,'isScalebar') imMovie = imprintScalebar(... imMovie,... width,... height,... getappdata(fig,'exfNew'),... getappdata(fig,'micronBarLength'),... getappdata(fig,'pxSize'),... getappdata(fig,'timestampSize'),... 1); end %if if getappdata(fig,'isTimestamp') imMovie = imprintTimestamp(... imMovie,... width,... height,... movieFrame*getappdata(fig,'timestampInkrement'),... getappdata(fig,'timestampSize'),... 1); end %if hMovie = addframe(hMovie, uint8(imMovie)); waitbar(movieFrame/movieFrames,hProgressbar,... 'Generating Movie...','Color',... get(0,'defaultUicontrolBackgroundColor')); end delete(hProgressbar) %customize movie player hMovie = close(hMovie); mplay([moviepath moviename],... getappdata(fig,'fps')); hList = allchild(gcf); hChilds = allchild(hList(2)); hToolBar = hList(1); copyobj(hChilds(1:4),hToolBar) delete(hList(2)) uipushtool(... 'Parent', hToolBar,... 'CData', repmat(icon.opt2txt, [1 1 3]),... 'ClickedCallback', {@exportSettings, 'Movie'}) set(gcf, 'Units', 'normalized',... 'Position', figPos(width/height),... 'Name', 'rendered Movie', 'DockControls', 'off') set(findall(gcf, 'Type', 'uimenu'), 'Visible', 'off') else return end %if case 'Track Image' case 'Track Movie' end %switch case 'dualView' %receive channel composition srcFig = getappdata(fig,'imSrcFig'); imCh = getappdata(fig,'imCh'); nImCh = getappdata(fig,'nImCh'); trackSrcFig = getappdata(fig,'trackSrcFig'); nTrackCh = getappdata(fig,'nTrackCh'); switch get(src, 'Tag') case 'Image' %BUILD IMAGE for ch = imCh idx{ch} = [-1; cumsum(getappdata(srcFig(ch),'ctrsN'))]; %%framerange selected if getappdata(srcFig(ch),'rStart') == 1 setappdata(srcFig(ch),'startPnt',0) else setappdata(srcFig(ch),'startPnt',... idx{ch}(getappdata(srcFig(ch),'rStart'))+1) end %if if isinf(getappdata(srcFig(ch),'rEnd')) setappdata(srcFig(ch),'elements',inf) else setappdata(srcFig(ch),'elements',... idx{ch}(getappdata(srcFig(ch),'rEnd')+1)-... max(1,getappdata(srcFig(ch),'startPnt'))+1) end %if %rendering roi = getappdata(srcFig(ch),'roi'); if getappdata(srcFig(ch),'convMode') == 1 returnVal = [1 1 0 0 0 0 0 1 0 0 0 0]; else returnVal = [1 1 0 0 0 0 0 1 1 0 0 0]; end %if data = preprocessData(srcFig(ch),returnVal,roi); imRendered(:,:,ch) = renderImage(data,roi,... getappdata(fig,'exfNew'),... getappdata(srcFig(ch),'width'),... getappdata(srcFig(ch),'height'),... getappdata(srcFig(ch),'intWeight'),... getappdata(srcFig(ch),'sizeFac'),... getappdata(srcFig(ch),'pxSize'),... getappdata(srcFig(ch),'convMode')); end %for [height width depth] = size(imRendered); imRendered = cat(3,imRendered,... zeros(height,width,3-depth)); if getappdata(fig,'isColormap') imRendered = imprintColormap(... imRendered,... width,... getappdata(fig,'colormapWidth'),... 2); end if getappdata(fig,'isScalebar') imRendered = imprintScalebar(... imRendered,... width,... height,... getappdata(fig,'exfNew'),... getappdata(fig,'micronBarLength'),... getappdata(fig,'pxSize'),... getappdata(fig,'timestampSize'),... 2); end %if if getappdata(fig,'isTimestamp') imRendered = imprintTimestamp(... imRendered,... width,... height,... 0.000,... getappdata(fig,'timestampSize'),... 2); end %if set(figNew,... 'Name', '',... 'Units','normalized',... 'Position', figPos(width/height),... 'Visible', 'on') axes(... 'Parent', figNew,... 'Units','normalized',... 'Position', [0.05 0.05 0.9 0.9]); %customize toolbar hToolBar = findall(figNew,'Type','uitoolbar'); hToggleList = findall(hToolBar); uipushtool(... 'Parent', hToolBar,... 'CData', repmat(icon.save, [1 1 3]),... 'ClickedCallback', {@saveImage,imRendered,'8bit'}) delete(hToggleList([2:10 13:17])) hImage = imshow(uint8(imRendered)); setappdata(figNew,'hImage',hImage) case 'Movie' %BUILD MOVIE previewFig = buildMoviePreview; answer = questdlg('accept movie settings?',... 'Question','Yes','No','Yes'); delete(previewFig) % create movie switch answer case 'Yes' %preallocate avi-file on harddisk [moviename,moviepath,isOK] =... uiputfile('.avi' ,'Save Movie to',... [getappdata(0,'searchPath')... moviename 'Stepsize_'... num2str(getappdata(fig,'rStep')) '_movie']); if isOK %set movies colormap and compression method hMovie = avifile([moviepath moviename],... 'Compression', 'none',... %no RLE MSVC for true color! 'fps', getappdata(fig,'fps')); % create movieframes if nTrackCh > 0 set(figNew,... 'Units','normalized',... 'Position', [0 0 1 1],... 'ToolBar', 'none',... 'Resize', 'off',... 'Name', 'Movie Preview',... 'Visible', 'on'); ax =... axes(... 'Parent', figNew,... 'Units','normalized',... 'Position', [0 0 1 1]); for ch = 1:nTrackCh tracks{ch} = getappdata(trackSrcFig(ch),'tracks'); movieFrames(3+ch) = ceil((getappdata(trackSrcFig(ch),'rEnd')-... getappdata(trackSrcFig(ch),'rStart')+1-... getappdata(trackSrcFig(ch),'rW'))/getappdata(fig,'rStep')); end else delete(figNew) end %if hProgressbar = waitbar(0,'Generating Movie...','Color',... get(0,'defaultUicontrolBackgroundColor')); for movieFrame = 1:max(movieFrames) imMovie = zeros(height,width,3); for ch = imCh %set datarange to load for movieframe if movieFrame == 1 setappdata(srcFig(ch),'startPnt',... idx{ch}(getappdata(srcFig(ch),'rStart'))+1); %check 11/03/10 setappdata(srcFig(ch),'elements',... idx{ch}(getappdata(srcFig(ch),'rStart')+... getappdata(srcFig(ch),'rW'))-... max(1,getappdata(srcFig(ch),'startPnt'))+1); %check 11/03/10 elseif movieFrame >= movieFrames(ch) if getappdata(srcFig(ch),'isCumsum') setappdata(srcFig(ch),'startPnt',... idx{ch}(getappdata(srcFig(ch),'rStart'))+1); %check 11/03/10 else setappdata(srcFig(ch),'startPnt',... idx{ch}(getappdata(srcFig(ch),'rStart')+... (movieFrames(ch)-1)*getappdata(fig,'rStep'))+1); %check 11/03/10 end %if setappdata(srcFig(ch),'elements',... idx{ch}(getappdata(srcFig(ch),'rEnd'))-... getappdata(srcFig(ch),'startPnt')+1); %check 11/03/10 else if getappdata(srcFig(ch),'isCumsum') setappdata(srcFig(ch),'startPnt',... idx{ch}(getappdata(srcFig(ch),'rStart'))+1); %check 11/03/10 else setappdata(srcFig(ch),'startPnt',... idx{ch}(getappdata(srcFig(ch),'rStart')+... (movieFrame-1)*getappdata(fig,'rStep'))+1); %check 11/03/10 end %if setappdata(srcFig(ch),'elements',... idx{ch}(getappdata(srcFig(ch),'rStart')+... (movieFrame-1)*getappdata(fig,'rStep')+... getappdata(srcFig(ch),'rW'))-... getappdata(srcFig(ch),'startPnt')+1); %check 11/03/10 end %if roi = getappdata(srcFig(ch),'roi'); if getappdata(srcFig(ch),'convMode') == 1 returnVal = [1 1 0 0 0 0 0 1 0 0 0 0]; else returnVal = [1 1 0 0 0 0 0 1 1 0 0 0]; end %if data = preprocessData(srcFig(ch),returnVal,roi); imMovie(:,:,ch) = renderImage(data,roi,... getappdata(fig,'exfNew'),... getappdata(srcFig(ch),'width'),... getappdata(srcFig(ch),'height'),... getappdata(srcFig(ch),'intWeight'),... getappdata(srcFig(ch),'sizeFac'),... getappdata(srcFig(ch),'pxSize'),... getappdata(srcFig(ch),'convMode')); end %for if getappdata(fig,'isColormap') imMovie = imprintColormap(... imMovie,... width,... getappdata(fig,'colormapWidth'),... 2); end if getappdata(fig,'isScalebar') imMovie = imprintScalebar(... imMovie,... width,... height,... getappdata(fig,'exfNew'),... getappdata(fig,'micronBarLength'),... getappdata(fig,'pxSize'),... getappdata(fig,'timestampSize'),... 2); end %if if getappdata(fig,'isTimestamp') imMovie = imprintTimestamp(... imMovie,... width,... height,... movieFrame*getappdata(fig,'timestampInkrement'),... getappdata(fig,'timestampSize'),... 2); end %if if nTrackCh > 0 imshow(uint8(imMovie), 'Parent', ax); for ch = 1:nTrackCh if movieFrame == 1 tracksize = cellfun('size',tracks{ch},1); if isinf(getappdata(trackSrcFig(ch),'maxTracksize')) hasSize = tracksize >= getappdata(trackSrcFig(ch),'minTracksize'); else hasSize = tracksize >= getappdata(trackSrcFig(ch),'minTracksize') &... tracksize <= getappdata(trackSrcFig(ch),'maxTracksize'); end %if tracks{ch} = tracks{ch}(hasSize); cmap = getappdata(trackSrcFig(ch),'trackColor'); switch getappdata(trackSrcFig(ch),'trackColorMode') case 2 trackList{ch} = cell2mat(cellfun(... @(x) x(:,1:4),tracks{ch}','Un',0)); listIdxs = accumarray(trackList{ch}(:,4),... 1:size(trackList{ch},1),[], @(x) {x}); case 1 trackList{ch} = cell2mat(cellfun(... @(x) [x(:,1:3);nan nan nan],tracks{ch}','Un',0)); end %switch if 1 insideRoi{ch} = true(size(trackList{ch},1),1); else insideRoi{ch} =... trackList{ch} > roi(1) &... trackList{ch}(:,1) < roi(1)+roi(3) &... trackList{ch}(:,2) > roi(2) &... trackList{ch}(:,2) < roi(2)+roi(4) |... isnan(trackList{ch}(:,3)); trackList{ch}(:,1) = trackList{ch}(:,1)-roi(1); trackList{ch}(:,2) = trackList{ch}(:,2)-roi(2); end %if good = insideRoi{ch} &... trackList{ch}(:,3) >= getappdata(trackSrcFig(ch),'rStart') &... trackList{ch}(:,3) <= getappdata(trackSrcFig(ch),'rStart')+... getappdata(trackSrcFig(ch),'rW')-1 |... isnan(trackList{ch}(:,3)) ; elseif movieFrame >= movieFrames(3+ch) if getappdata(trackSrcFig(ch),'isCumsum') good = insideRoi{ch} &... trackList{ch}(:,3) >= getappdata(trackSrcFig(ch),'rStart') &... trackList{ch}(:,3) <= getappdata(trackSrcFig(ch),'rEnd') |... isnan(trackList{ch}(:,3)) ; else good = insideRoi{ch} &... trackList{ch}(:,3) >=... (getappdata(trackSrcFig(ch),'rStart')+... movieFrame*getappdata(fig,'rStep')) &... trackList{ch}(:,3) <= getappdata(trackSrcFig(ch),'rEnd') |... isnan(trackList{ch}(:,3)) ; end %if else if getappdata(trackSrcFig(ch),'isCumsum') good = insideRoi{ch} &... trackList{ch}(:,3) >= getappdata(trackSrcFig(ch),'rStart') &... trackList{ch}(:,3) <= getappdata(trackSrcFig(ch),'rStart') +... movieFrame*getappdata(fig,'rStep') +... getappdata(trackSrcFig(ch),'rW')-1 |... isnan(trackList{ch}(:,3)) ; else good = insideRoi{ch} &... trackList{ch}(:,3) >=... (getappdata(trackSrcFig(ch),'rStart') +... movieFrame*getappdata(fig,'rStep')) &... trackList{ch}(:,3) <= getappdata(trackSrcFig(ch),'rStart') +... getappdata(trackSrcFig(ch),'rW')-1 |... isnan(trackList{ch}(:,3)) ; end %if end %if cmap = getappdata(trackSrcFig(ch),'trackColor'); switch getappdata(trackSrcFig(ch),'trackColorMode') case 2 for id = unique(trackList{ch}(good,4))' line(... trackList{ch}(listIdxs{id}(good(listIdxs{id})),1)*getappdata(fig,'exfNew')-1,... trackList{ch}(listIdxs{id}(good(listIdxs{id})),2)*getappdata(fig,'exfNew')-1,... 'Color', cmap{2}(id,:),... 'LineWidth', getappdata(trackSrcFig(ch),'trackWidth'),... 'Parent', ax); end case 1 line(... trackList{ch}(good,1)*getappdata(fig,'exfNew')-1,... trackList{ch}(good,2)*getappdata(fig,'exfNew')-1,... 'Color', cmap{1},... 'LineWidth', getappdata(trackSrcFig(ch),'trackWidth'),... 'Parent', ax); end %switch end %for drawnow tmpImMovie = getframe(ax); hMovie = addframe(hMovie,uint8(tmpImMovie.cdata)); else hMovie = addframe(hMovie, uint8(imMovie)); end %if waitbar(movieFrame/max(movieFrames),hProgressbar,... 'Generating Movie...','Color',... get(0,'defaultUicontrolBackgroundColor')); end %for end %if delete(hProgressbar) %customize movie player %customize movie player hMovie = close(hMovie); mplay([moviepath moviename],... getappdata(fig,'fps')); hList = allchild(gcf); hChilds = allchild(hList(2)); hToolBar = hList(1); copyobj(hChilds(1:4),hToolBar) delete(hList(2)) uipushtool(... 'Parent', hToolBar,... 'CData', repmat(icon.opt2txt, [1 1 3]),... 'ClickedCallback', {@exportSettings, 'Movie'}) set(gcf, 'Units', 'normalized',... 'Position', figPos(width/height),... 'Name', 'rendered Movie', 'DockControls', 'off') set(findall(gcf, 'Type', 'uimenu'), 'Visible', 'off') case 'No' return end %switch end %switch case 'tripleView' %receive channel composition srcFig = getappdata(fig,'imSrcFig'); imCh = getappdata(fig,'imCh'); nImCh = getappdata(fig,'nImCh'); trackSrcFig = getappdata(fig,'trackSrcFig'); nTrackCh = getappdata(fig,'nTrackCh'); switch get(src, 'Tag') case 'Image' %BUILD IMAGE for ch = imCh idx{ch} = [-1; cumsum(getappdata(srcFig(ch),'ctrsN'))]; %%framerange selected if getappdata(srcFig(ch),'rStart') == 1 setappdata(srcFig(ch),'startPnt',0) else setappdata(srcFig(ch),'startPnt',... idx{ch}(getappdata(srcFig(ch),'rStart'))+1) end %if if isinf(getappdata(srcFig(ch),'rEnd')) setappdata(srcFig(ch),'elements',inf) else setappdata(srcFig(ch),'elements',... idx{ch}(getappdata(srcFig(ch),'rEnd')+1)-... max(1,getappdata(srcFig(ch),'startPnt'))+1) end %if %rendering roi = getappdata(srcFig(ch),'roi'); if getappdata(srcFig(ch),'convMode') == 1 returnVal = [1 1 0 0 0 0 0 1 0 0 0 0]; else returnVal = [1 1 0 0 0 0 0 1 1 0 0 0]; end %if data = preprocessData(srcFig(ch),returnVal,roi); imRendered(:,:,ch) = renderImage(data,roi,... getappdata(fig,'exfNew'),... getappdata(srcFig(ch),'width'),... getappdata(srcFig(ch),'height'),... getappdata(srcFig(ch),'intWeight'),... getappdata(srcFig(ch),'sizeFac'),... getappdata(srcFig(ch),'pxSize'),... getappdata(srcFig(ch),'convMode')); end %for [height width depth] = size(imRendered); imRendered = cat(3,imRendered,... zeros(height,width,3-depth)); if getappdata(fig,'isColormap') imRendered = imprintColormap(... imRendered,... width,... getappdata(fig,'colormapWidth'),... 3); end if getappdata(fig,'isScalebar') imRendered = imprintScalebar(... imRendered,... width,... height,... getappdata(fig,'exfNew'),... getappdata(fig,'micronBarLength'),... getappdata(fig,'pxSize'),... getappdata(fig,'timestampSize'),... 3); end %if if getappdata(fig,'isTimestamp') imRendered = imprintTimestamp(... imRendered,... width,... height,... 0.000,... getappdata(fig,'timestampSize'),... 3); end %if set(figNew,... 'Name', '',... 'Units','normalized',... 'Position', figPos(width/height),... 'Visible', 'on') axes(... 'Parent', figNew,... 'Units','normalized',... 'Position', [0.05 0.05 0.9 0.9]); %customize toolbar hToolBar = findall(figNew,'Type','uitoolbar'); hToggleList = findall(hToolBar); uipushtool(... 'Parent', hToolBar,... 'CData', repmat(icon.save, [1 1 3]),... 'ClickedCallback', {@saveImage,imRendered,'8bit'}) delete(hToggleList(2:end)) hImage = imshow(uint8(imRendered)); setappdata(figNew,'hImage',hImage) case 'Movie' %BUILD MOVIE previewFig = buildMoviePreview; answer = questdlg('accept movie settings?',... 'Question','Yes','No','Yes'); delete(previewFig) % create movie switch answer case 'Yes' %preallocate avi-file on harddisk %preallocate avi-file on harddisk [moviename,moviepath,isOK] =... uiputfile('.avi' ,'Save Movie to',... [getappdata(0,'searchPath')... moviename 'Stepsize_'... num2str(getappdata(fig,'rStep')) '_movie']); if isOK %set movies colormap and compression method hMovie = avifile([moviepath moviename],... 'Compression', 'none',... %no RLE MSVC for true color! 'fps', getappdata(fig,'fps')); % create movieframes if nTrackCh > 0 set(figNew,... 'Units','normalized',... 'Position', [0 0 1 1],... 'ToolBar', 'none',... 'Resize', 'off',... 'Name', 'Movie Preview',... 'Visible', 'on'); ax =... axes(... 'Parent', figNew,... 'Units','normalized',... 'Position', [0 0 1 1]); for ch = 1:nTrackCh tracks{ch} = getappdata(trackSrcFig(ch),'tracks'); movieFrames(3+ch) = ceil((getappdata(trackSrcFig(ch),'rEnd')-... getappdata(trackSrcFig(ch),'rStart')+1-... getappdata(trackSrcFig(ch),'rW'))/getappdata(fig,'rStep')); end else delete(figNew) end %if hProgressbar = waitbar(0,'Generating Movie...','Color',... get(0,'defaultUicontrolBackgroundColor')); for movieFrame = 1:max(movieFrames) imMovie = zeros(height,width,3); for ch = imCh %set datarange to load for movieframe if movieFrame == 1 setappdata(srcFig(ch),'startPnt',... idx{ch}(getappdata(srcFig(ch),'rStart'))+1); %check 11/03/10 setappdata(srcFig(ch),'elements',... idx{ch}(getappdata(srcFig(ch),'rStart')+... getappdata(srcFig(ch),'rW'))-... max(1,getappdata(srcFig(ch),'startPnt'))+1); %check 11/03/10 elseif movieFrame >= movieFrames(ch) if getappdata(srcFig(ch),'isCumsum') setappdata(srcFig(ch),'startPnt',... idx{ch}(getappdata(srcFig(ch),'rStart'))+1); %check 11/03/10 else setappdata(srcFig(ch),'startPnt',... idx{ch}(getappdata(srcFig(ch),'rStart')+... (movieFrames(ch)-1)*getappdata(fig,'rStep'))+1); %check 11/03/10 end %if setappdata(srcFig(ch),'elements',... idx{ch}(getappdata(srcFig(ch),'rEnd'))-... getappdata(srcFig(ch),'startPnt')+1); %check 11/03/10 else if getappdata(srcFig(ch),'isCumsum') setappdata(srcFig(ch),'startPnt',... idx{ch}(getappdata(srcFig(ch),'rStart'))+1); %check 11/03/10 else setappdata(srcFig(ch),'startPnt',... idx{ch}(getappdata(srcFig(ch),'rStart')+... (movieFrame-1)*getappdata(fig,'rStep'))+1); %check 11/03/10 end %if setappdata(srcFig(ch),'elements',... idx{ch}(getappdata(srcFig(ch),'rStart')+... (movieFrame-1)*getappdata(fig,'rStep')+... getappdata(srcFig(ch),'rW'))-... getappdata(srcFig(ch),'startPnt')+1); %check 11/03/10 end %if roi = getappdata(srcFig(ch),'roi'); if getappdata(srcFig(ch),'convMode') == 1 returnVal = [1 1 0 0 0 0 0 1 0 0 0 0]; else returnVal = [1 1 0 0 0 0 0 1 1 0 0 0]; end %if data = preprocessData(srcFig(ch),returnVal,roi); imMovie(:,:,ch) = renderImage(data,roi,... getappdata(fig,'exfNew'),... getappdata(srcFig(ch),'width'),... getappdata(srcFig(ch),'height'),... getappdata(srcFig(ch),'intWeight'),... getappdata(srcFig(ch),'sizeFac'),... getappdata(srcFig(ch),'pxSize'),... getappdata(srcFig(ch),'convMode')); end %for if getappdata(fig,'isColormap') imMovie = imprintColormap(... imMovie,... width,... getappdata(fig,'colormapWidth'),... 3); end if getappdata(fig,'isScalebar') imMovie = imprintScalebar(... imMovie,... width,... height,... getappdata(fig,'exfNew'),... getappdata(fig,'micronBarLength'),... getappdata(fig,'pxSize'),... getappdata(fig,'timestampSize'),... 3); end %if if getappdata(fig,'isTimestamp') imMovie = imprintTimestamp(... imMovie,... width,... height,... movieFrame*getappdata(fig,'timestampInkrement'),... getappdata(fig,'timestampSize'),... 3); end %if if nTrackCh > 0 imshow(uint8(imMovie), 'Parent', ax); for ch = 1:nTrackCh if movieFrame == 1 tracksize = cellfun('size',tracks{ch},1); if isinf(getappdata(trackSrcFig(ch),'maxTracksize')) hasSize = tracksize >= getappdata(trackSrcFig(ch),'minTracksize'); else hasSize = tracksize >= getappdata(trackSrcFig(ch),'minTracksize') &... tracksize <= getappdata(trackSrcFig(ch),'maxTracksize'); end %if tracks{ch} = tracks{ch}(hasSize); cmap = getappdata(trackSrcFig(ch),'trackColor'); switch getappdata(trackSrcFig(ch),'trackColorMode') case 2 trackList{ch} = cell2mat(cellfun(... @(x) x(:,1:4),tracks{ch}','Un',0)); listIdxs = accumarray(trackList{ch}(:,4),... 1:size(trackList{ch},1),[], @(x) {x}); case 1 trackList{ch} = cell2mat(cellfun(... @(x) [x(:,1:3);nan nan nan],tracks{ch}','Un',0)); end %switch if 1 insideRoi{ch} = true(size(trackList{ch},1),1); else insideRoi{ch} =... trackList{ch} > roi(1) &... trackList{ch}(:,1) < roi(1)+roi(3) &... trackList{ch}(:,2) > roi(2) &... trackList{ch}(:,2) < roi(2)+roi(4) |... isnan(trackList{ch}(:,3)); trackList{ch}(:,1) = trackList{ch}(:,1)-roi(1); trackList{ch}(:,2) = trackList{ch}(:,2)-roi(2); end %if good = insideRoi{ch} &... trackList{ch}(:,3) >= getappdata(trackSrcFig(ch),'rStart') &... trackList{ch}(:,3) <= getappdata(trackSrcFig(ch),'rStart')+... getappdata(trackSrcFig(ch),'rW')-1 |... isnan(trackList{ch}(:,3)) ; elseif movieFrame >= movieFrames(3+ch) if getappdata(trackSrcFig(ch),'isCumsum') good = insideRoi{ch} &... trackList{ch}(:,3) >= getappdata(trackSrcFig(ch),'rStart') &... trackList{ch}(:,3) <= getappdata(trackSrcFig(ch),'rEnd') |... isnan(trackList{ch}(:,3)) ; else good = insideRoi{ch} &... trackList{ch}(:,3) >=... (getappdata(trackSrcFig(ch),'rStart')+... movieFrame*getappdata(fig,'rStep')) &... trackList{ch}(:,3) <= getappdata(trackSrcFig(ch),'rEnd') |... isnan(trackList{ch}(:,3)) ; end %if else if getappdata(trackSrcFig(ch),'isCumsum') good = insideRoi{ch} &... trackList{ch}(:,3) >= getappdata(trackSrcFig(ch),'rStart') &... trackList{ch}(:,3) <= getappdata(trackSrcFig(ch),'rStart') +... movieFrame*getappdata(fig,'rStep') +... getappdata(trackSrcFig(ch),'rW')-1 |... isnan(trackList{ch}(:,3)) ; else good = insideRoi{ch} &... trackList{ch}(:,3) >=... (getappdata(trackSrcFig(ch),'rStart') +... movieFrame*getappdata(fig,'rStep')) &... trackList{ch}(:,3) <= getappdata(trackSrcFig(ch),'rStart') +... getappdata(trackSrcFig(ch),'rW')-1 |... isnan(trackList{ch}(:,3)) ; end %if end %if cmap = getappdata(trackSrcFig(ch),'trackColor'); switch getappdata(trackSrcFig(ch),'trackColorMode') case 2 for id = unique(trackList{ch}(good,4))' line(... trackList{ch}(listIdxs{id}(good(listIdxs{id})),1)*getappdata(fig,'exfNew')-1,... trackList{ch}(listIdxs{id}(good(listIdxs{id})),2)*getappdata(fig,'exfNew')-1,... 'Color', cmap{2}(id,:),... 'LineWidth', getappdata(trackSrcFig(ch),'trackWidth'),... 'Parent', ax); end case 1 line(... trackList{ch}(good,1)*getappdata(fig,'exfNew')-1,... trackList{ch}(good,2)*getappdata(fig,'exfNew')-1,... 'Color', cmap{1},... 'LineWidth', getappdata(trackSrcFig(ch),'trackWidth'),... 'Parent', ax); end %switch end %for drawnow tmpImMovie = getframe(ax); hMovie = addframe(hMovie,uint8(tmpImMovie.cdata)); else hMovie = addframe(hMovie, uint8(imMovie)); end %if waitbar(movieFrame/max(movieFrames),hProgressbar,... 'Generating Movie...','Color',... get(0,'defaultUicontrolBackgroundColor')); end %for end %if delete(hProgressbar) %customize movie player %customize movie player hMovie = close(hMovie); mplay([moviepath moviename],... getappdata(fig,'fps')); hList = allchild(gcf); hChilds = allchild(hList(2)); hToolBar = hList(1); copyobj(hChilds(1:4),hToolBar) delete(hList(2)) uipushtool(... 'Parent', hToolBar,... 'CData', repmat(icon.opt2txt, [1 1 3]),... 'ClickedCallback', {@exportSettings, 'Movie'}) set(gcf, 'Units', 'normalized',... 'Position', figPos(width/height),... 'Name', 'rendered Movie', 'DockControls', 'off') set(findall(gcf, 'Type', 'uimenu'), 'Visible', 'off') case 'No' return end %switch end %switch end %switch function passCmap(src, event) cmap = get(src, 'Colormap'); end function previewFig = buildMoviePreview switch getappdata(fig,'viewMode') case 'monoView' idx = [-1; cumsum(getappdata(fig,'ctrsN'))]; %first movieframe setappdata(figNew,'startPnt',... idx(getappdata(figNew,'rStart'))+1); %check 11/03/10 setappdata(figNew,'elements',... idx(getappdata(figNew,'rStart')+... getappdata(figNew,'rW'))-... max(1,getappdata(figNew,'startPnt'))+1); %check 11/03/10 data = preprocessData(figNew,returnVal,roi); [movieFrame,width,height,N] = renderImage(data,roi,... getappdata(fig,'exfNew'),... getappdata(fig,'width'),... getappdata(fig,'height'),... getappdata(fig,'intWeight'),... getappdata(fig,'sizeFac'),... getappdata(fig,'pxSize'),... getappdata(fig,'convMode')); %movie z-Projection if getappdata(fig,'rStart') == 1 setappdata(figNew,'startPnt',0) else setappdata(figNew,'startPnt',... idx(getappdata(fig,'rStart'))+1) end %if if isinf(getappdata(fig,'rEnd')) setappdata(figNew,'rEnd',numel(getappdata(fig,'ctrsN'))) setappdata(figNew,'elements',inf) else setappdata(figNew,'elements',... idx(getappdata(fig,'rEnd')+1)-... max(1,getappdata(figNew,'startPnt'))+1) end %if data = preprocessData(figNew,returnVal,roi); movieProj = renderImage(data,roi,... getappdata(fig,'exfNew'),... getappdata(fig,'width'),... getappdata(fig,'height'),... getappdata(fig,'intWeight'),... getappdata(fig,'sizeFac'),... getappdata(fig,'pxSize'),... getappdata(fig,'convMode')); mask = find(poly2mask([0 0 width],... [0 height height], height, width)); movieProj(mask) = movieFrame(mask); if getappdata(fig,'isColormap') movieProj = imprintColormap(... movieProj,... width,... getappdata(fig,'colormapWidth'),... 1); end if getappdata(fig,'isScalebar') movieProj = imprintScalebar(... movieProj,... width,... height,... getappdata(fig,'exfNew'),... getappdata(fig,'micronBarLength'),... getappdata(fig,'pxSize'),... getappdata(fig,'timestampSize'),... 1); end %if if getappdata(fig,'isTimestamp') movieProj = imprintTimestamp(... movieProj,... width,... height,... 0.000,... getappdata(fig,'timestampSize'),... 1); end %if otherwise moviename = []; for ch = imCh idx{ch} = [-1; cumsum(getappdata(srcFig(ch),'ctrsN'))]; roi = getappdata(srcFig(ch),'roi'); if getappdata(srcFig(ch),'convMode') == 1 returnVal = [1 1 0 0 0 0 0 1 0 0 0 0]; else returnVal = [1 1 0 0 0 0 0 1 1 0 0 0]; end %if %first movieframe setappdata(srcFig(ch),'startPnt',... idx{ch}(getappdata(srcFig(ch),'rStart'))+1); %check 11/03/10 setappdata(srcFig(ch),'elements',... idx{ch}(getappdata(srcFig(ch),'rStart')+... getappdata(srcFig(ch),'rW'))-... max(1,getappdata(srcFig(ch),'startPnt'))+1); %check 11/03/10 data = preprocessData(srcFig(ch),returnVal,roi); [movieFrame(:,:,ch),width(ch),height(ch),N(ch)] = renderImage(data,roi,... getappdata(fig,'exfNew'),... getappdata(srcFig(ch),'width'),... getappdata(srcFig(ch),'height'),... getappdata(srcFig(ch),'intWeight'),... getappdata(srcFig(ch),'sizeFac'),... getappdata(srcFig(ch),'pxSize'),... getappdata(srcFig(ch),'convMode')); %%movie z-Projection if getappdata(srcFig(ch),'rStart') == 1 setappdata(srcFig(ch),'startPnt',0) else setappdata(srcFig(ch),'startPnt',... idx{ch}(getappdata(srcFig(ch),'rStart'))+1) end %if if isinf(getappdata(srcFig(ch),'rEnd')) setappdata(srcFig(ch),'elements',inf) else setappdata(srcFig(ch),'elements',... idx{ch}(getappdata(srcFig(ch),'rEnd')+1)-... max(1,getappdata(srcFig(ch),'startPnt'))+1) end %if data = preprocessData(srcFig(ch),returnVal,roi); movieProj(:,:,ch) = renderImage(data,roi,... getappdata(fig,'exfNew'),... getappdata(srcFig(ch),'width'),... getappdata(srcFig(ch),'height'),... getappdata(srcFig(ch),'intWeight'),... getappdata(srcFig(ch),'sizeFac'),... getappdata(srcFig(ch),'pxSize'),... getappdata(srcFig(ch),'convMode')); mask = find(poly2mask([0 0 width(ch)],... [0 height(ch) height(ch)], height(ch), width(ch))); movieProj(mask+(ch-1)*width(ch)*height(ch)) =... movieFrame(mask+(ch-1)*width(ch)*height(ch)); movieFrames(ch) = max(ceil((getappdata(srcFig(ch),'rEnd')-... getappdata(srcFig(ch),'rStart')+1-... getappdata(srcFig(ch),'rW'))/getappdata(fig,'rStep')),1); moviename = [moviename getappdata(srcFig(ch),'filename')... '_WinSize_' num2str(getappdata(srcFig(imCh(1)),'rW')) '_']; end %for [height width depth] = size(movieProj); movieProj = cat(3,movieProj,... zeros(height,width,3-depth)); switch getappdata(fig,'viewMode') case 'dualView' if getappdata(fig,'isColormap') movieProj = imprintColormap(... movieProj,... width,... getappdata(fig,'colormapWidth'),... 2); end if getappdata(fig,'isScalebar') movieProj = imprintScalebar(... movieProj,... width,... height,... getappdata(fig,'exfNew'),... getappdata(fig,'micronBarLength'),... getappdata(fig,'pxSize'),... getappdata(fig,'timestampSize'),... 2); end %if if getappdata(fig,'isTimestamp') movieProj = imprintTimestamp(... movieProj,... width,... height,... 0.000,... getappdata(fig,'timestampSize'),... 2); end %if case 'tripleView' if getappdata(fig,'isColormap') movieProj = imprintColormap(... movieProj,... width,... getappdata(fig,'colormapWidth'),... 3); end if getappdata(fig,'isScalebar') movieProj = imprintScalebar(... movieProj,... width,... height,... getappdata(fig,'exfNew'),... getappdata(fig,'micronBarLength'),... getappdata(fig,'pxSize'),... getappdata(fig,'timestampSize'),... 3); end %if if getappdata(fig,'isTimestamp') movieProj = imprintTimestamp(... movieProj,... width,... height,... 0.000,... getappdata(fig,'timestampSize'),... 3); end %if end %switch end %switch %open preview window previewFig = figure(... 'Units','normalized',... 'Position', figPos(width/height),... 'Name', 'Movie Preview',... 'ToolBar', 'none',... 'Menubar', 'none',... 'DockControls', 'off',... 'NumberTitle', 'off',... 'DeleteFcn', @passCmap,... 'Visible', 'on'); previewAx =... axes(... 'Parent', previewFig,... 'Units','normalized',... 'Position', [0 0 1 1]); imshow(uint8(movieProj),... 'Parent',previewAx); line([0 width],[0 height],... 'Color', [1 1 1], 'LineWidth', 3) text(0.25*width,0.75*height,'Frame 1',... 'Fontsize',15, 'Color', [1 1 1],... 'HorizontalAlignment','center') text(0.75*width,0.25*height,'Accumulate',... 'Fontsize',15, 'Color', [1 1 1],... 'HorizontalAlignment','center') end end function [rI,width,height,N] =... renderImage(data,roi,exf,width,height,intWeight,sizeFac,pxSize,mode) %calculate right-sided edges of pixels for superres image edgeY = (1:height*exf)/exf; edgeX = (1:width*exf)/exf; %calculate size of superres image y0 = find(edgeY >= roi(2), 1, 'first'); y1 = find(edgeY >= roi(2)+roi(4), 1, 'first'); x0 = find(edgeX >= roi(1), 1, 'first'); x1 = find(edgeX >= roi(1)+roi(3), 1, 'first'); %preallocate superres image height = y1-y0+1; width = x1-x0+1; rI = zeros(height,width); if ~isempty(data.ctrsX) &&... ~isempty(data.ctrsY) &&... ~isempty(data.photons) switch mode case 2 %dynamic lp2pix = (data.precision/(pxSize/exf)).^2*sizeFac^2; [cntY yc] = histc(data.ctrsY, edgeY(y0:y1)); [cntX xc] = histc(data.ctrsX, edgeX(x0:x1)); N=0; for i=1:numel(xc) w = ceil(6*sqrt(lp2pix(i))); if xc(i) - w >= 1 &&... xc(i) + w < ceil(roi(3)*exf) &&... yc(i) - w >= 1 &&... yc(i) + w < ceil(roi(4)*exf) N = N+1; refi = (1:w)-floor(w/2)+yc(i); ii = (refi-(data.ctrsY(i)-roi(2))*exf)' * ones(1,w) ; refj = (1:w)-floor(w/2)+xc(i); jj = ones(w,1) * (refj-(data.ctrsX(i)-roi(1))*exf) ; rI((1:w)-floor(w/2)+yc(i),... (1:w)-floor(w/2)+xc(i)) = ... rI((1:w)-floor(w/2)+yc(i),... (1:w)-floor(w/2)+xc(i)) +... intWeight*data.photons(i)/(2*pi*lp2pix(i))*... exp(-(1/(2*lp2pix(i)))*(ii.*ii + jj.*jj)) ; end %if end %for case 1 %fixed N = numel(data.photons); %count # rendered particles %calculate linear indices of particle detection for 2d-matrix [cntY idxY] = histc(data.ctrsY, edgeY(y0:y1)); [cntX idxX] = histc(data.ctrsX, edgeX(x0:x1)); linIdx = idxX*height+idxY+1; [linIdx unused good] = unique(linIdx); rI(linIdx) = accumarray(good,intWeight); psf = buildPSF(sizeFac,width,height); rI = fftshift(ifft2(fft2(rI).* psf)); end %switch end %if end function I = imprintColormap(I, width, mapHeight, mode) if mode == 1 colorRamp = repmat(round(linspace(0, 255, width)),... mapHeight,1); I(end-mapHeight+1:end,:) = colorRamp; else cmapWidth = floor(width/4); colorRamp = round(linspace(0, 255, cmapWidth)); colorRamp = repmat([colorRamp,... ones(1,cmapWidth)*255, fliplr(colorRamp),... zeros(1,width-3*cmapWidth)],mapHeight,1); if mode == 3 colorRamp3D = repmat(round(linspace(0, 255,... mapHeight))',1,width); I(end-mapHeight+1:end,:,:) =... cat(3,colorRamp, fliplr(colorRamp), colorRamp3D); else I(end-mapHeight+1:end,:,:) =... cat(3,colorRamp, fliplr(colorRamp), colorRamp*0); end %if end %if end function I = imprintScalebar(I, width, height,... exf, barLength, pxSize, sizeFac, mode) barUnit = pxChars(height,width,... [num2str(barLength) 'nm'],sizeFac); pxBarLength = round(barLength/(1000*pxSize/exf)); pxBarHeight = ceil(max(exf/3,pxBarLength/20)); bar = ones(pxBarHeight,pxBarLength); tmp = size(bar,2)-size(barUnit,2); if tmp > 0 bar = [[zeros(size(barUnit,1),floor(tmp/2)),... barUnit, zeros(size(barUnit,1),ceil(tmp/2))];... zeros(2,size(bar,2)); bar]; elseif tmp < 0 bar = [barUnit;zeros(2,size(barUnit,2));... [zeros(pxBarHeight,floor(-tmp/2)),bar,... zeros(pxBarHeight,ceil(-tmp/2))]]; else bar = [barUnit;zeros(2,size(bar,2));bar]; end %sif barOffsetX = 4*pxBarHeight; barOffsetY = 4*pxBarHeight; offset = height*(width-(size(bar,2)+barOffsetX))+barOffsetY; idx = find([bar;zeros(height-size(bar,1),... size(bar,2))])+offset; if mode == 1 I(idx) = 255; else I([idx;idx+height*width;idx+2*height*width]) = 255; end %if end function I = imprintTimestamp(I, width, height,... time, sizeFac, mode) stamp = pxChars(height,width,... [strrep(num2str(time, '%.3f'),'.','p') '_S'],... sizeFac); barOffsetX = ceil(max(sizeFac*2,size(stamp,2)/5)); barOffsetY = barOffsetX; idx = find([stamp;zeros(height-size(stamp,1),size(stamp,2))])+... barOffsetX*height+barOffsetY; if mode == 1 I(idx) = 255; else I([idx;idx+height*width;idx+2*height*width]) = 255; end %if end function zProject(src, event) icon = getappdata(1, 'icons'); fig = gcbf; %search for ROI if isempty(getappdata(fig,'hROI')) roi = [1 1 ... getappdata(fig,'width') getappdata(fig,'height')]; else roi = ceil(getappdata(fig,'roi')); end region = {[roi(2) roi(2)+roi(4)-1],... [roi(1) roi(1)+roi(3)-1]}; hProgressbar = waitbar(0,'Processing...','Color',... get(0,'defaultUicontrolBackgroundColor')); imageName = strcat(getappdata(fig,'pathname'),... getappdata(fig,'filename')); if getappdata(fig,'isSuperstack') for stack = 1:numel(imageName) info = imfinfo(imageName{stack}); frames = numel(info); if stack == 1 %initialize image I = double(imread(imageName{stack}, 1,... 'info', info, 'PixelRegion', region)); end %if for frame = 2:frames switch get(src, 'Tag') case 'max. Intensity' I = max(I,double(imread(imageName{stack},... frame, 'info', info, 'PixelRegion', region))); case 'mean Intensity' I = (I + double(imread(imageName{stack},... frame, 'info', info, 'PixelRegion', region)))/2; end %switch waitbar(frame/frames,hProgressbar,... 'Processing...','Color',... get(0,'defaultUicontrolBackgroundColor')); end %for end %for delete(hProgressbar) else info = imfinfo(imageName); frames = numel(info); I = double(imread(imageName, 1,... 'info', info, 'PixelRegion', region)); for frame = 2:frames switch get(src, 'Tag') case 'max. Intensity' I = max(I,double(imread(imageName,... frame, 'info', info, 'PixelRegion', region))); case 'mean Intensity' I = (I + double(imread(imageName,... frame, 'info', info, 'PixelRegion', region)))/2; end %switch waitbar(frame/frames,hProgressbar,... 'Processing...','Color',... get(0,'defaultUicontrolBackgroundColor')); end %for delete(hProgressbar) end %if I = fix((I-min(I(:)))/(max(I(:))-min(I(:)))*255); figNew =... figure(... 'Units','normalized',... 'Position', figPos(roi(3)/roi(4)),... 'Color', get(fig,'Color')-unifrnd(0.09,0.11,1,3),... 'Name', ['z-Projection (' ... get(src,'Tag') ') - ' get(fig,'Name')],... 'NumberTitle', 'off',... 'MenuBar', 'none',... 'ToolBar', 'figure'); axes(... 'Parent', figNew,... 'Units','normalized',... 'Position', [0.05 0.05 0.9 0.9]); hToolBar = findall(figNew,'Type','uitoolbar'); uipushtool(... 'Parent', hToolBar,... 'CData', repmat(icon.save, [1 1 3]),... 'ClickedCallback', {@saveImage,I,'8bit'}) uipushtool(... 'Parent', hToolBar,... 'CData', repmat(icon.colormap, [1 1 3]),... 'ClickedCallback', 'colormapeditor') hToggleList = findall(hToolBar); delete(hToggleList([4:12 15:19])) imshow(uint8(I)) end function scatterPlot(src, event) fig = imgcf; encodeType = {'x-coordinate [px]','y-coordinate [px]','signal amplitude [counts]',... 'noise amplitude [counts]','background level [counts]','psf radius [px]','detection time [frames]',... '# collected photons','localization precision [micron]','signal to noise ratio',... 'signal to background ratio','cluster','z-coordinate [px]','channel'}; menuFig =... figure(... 'Units','normalized',... 'Position', [0.3 0.25 0.4 0.5],... 'Color', get(0,'defaultUicontrolBackgroundColor'),... 'Name', 'Encoding Style',... 'NumberTitle', 'off',... 'MenuBar', 'none',... 'ToolBar', 'none',... 'Resize', 'off'); uicontrol(... 'Style', 'text',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.8 0.9 0.2 0.1],... 'FontSize', 15,... 'String', 'weight') uicontrol(... 'Style', 'text',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.05 0.8 0.2 0.1],... 'FontSize', 15,... 'String', '1st dim.:') hxDim =... uicontrol(... 'Style', 'popupmenu',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.25 0.8 0.55 0.1],... 'FontSize', 15,... 'String', encodeType,... 'Value', 1,... 'BackgroundColor', [1 1 1]); hxDimWeight =... uicontrol(... 'Style', 'edit',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.85 0.8 0.1 0.1],... 'FontSize', 15,... 'String', 1,... 'BackgroundColor', [1 1 1]); uicontrol(... 'Style', 'text',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.05 0.65 0.2 0.1],... 'FontSize', 15,... 'String', '2nd dim.:') hyDim =... uicontrol(... 'Style', 'popupmenu',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.25 0.65 0.55 0.1],... 'FontSize', 15,... 'String', encodeType,... 'Value', 2,... 'BackgroundColor', [1 1 1]); hyDimWeight =... uicontrol(... 'Style', 'edit',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.85 0.65 0.1 0.1],... 'FontSize', 15,... 'String', 1,... 'BackgroundColor', [1 1 1]); uicontrol(... 'Style', 'text',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.05 0.5 0.2 0.1],... 'FontSize', 15,... 'String', '3rd dim.:') hzDim =... uicontrol(... 'Style', 'popupmenu',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.25 0.5 0.55 0.1],... 'FontSize', 15,... 'String', encodeType,... 'Value', 7,... 'BackgroundColor', [1 1 1]); hzDimWeight =... uicontrol(... 'Style', 'edit',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.85 0.5 0.1 0.1],... 'FontSize', 15,... 'String', 1,... 'BackgroundColor', [1 1 1]); uicontrol(... 'Style', 'text',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.05 0.35 0.2 0.1],... 'FontSize', 15,... 'String', 'expansion:') hExp =... uicontrol(... 'Style', 'popupmenu',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.25 0.35 0.55 0.1],... 'FontSize', 15,... 'String', encodeType,... 'Value', 9,... 'BackgroundColor', [1 1 1]); hExpWeight =... uicontrol(... 'Style', 'edit',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.85 0.35 0.1 0.1],... 'FontSize', 15,... 'String', 1,... 'BackgroundColor', [1 1 1]); uicontrol(... 'Style', 'text',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.05 0.2 0.2 0.1],... 'FontSize', 15,... 'String', 'color:') hColor =... uicontrol(... 'Style', 'popupmenu',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.25 0.2 0.55 0.1],... 'FontSize', 15,... 'String', encodeType,... 'Value', 7,... 'BackgroundColor', [1 1 1]); hColorWeight =... uicontrol(... 'Style', 'edit',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.85 0.2 0.1 0.1],... 'FontSize', 15,... 'String', 1,... 'BackgroundColor', [1 1 1]); uicontrol(... 'Style', 'pushbutton',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.25 0.05 0.5 0.1],... 'FontSize', 15,... 'String', 'accept settings',... 'Callback', {@buildScatterPlot,... [hxDim,hyDim,hzDim,hExp,hColor... hxDimWeight,hyDimWeight,hzDimWeight,hExpWeight,hColorWeight],... get(src, 'Tag')}) function buildScatterPlot(src,event,hList,mode) take = cell2mat(get(hList(1:5),'Value')); weight = str2double(get(hList(6:10),'String')); close(get(src,'Parent')) returnVar = zeros(1,14); returnVar(take) = true; varNames = {'ctrsX','ctrsY','signal','noise','offset','radius','frame',... 'photons','precision','snr','sbr','class','ctrsZ','channel'}; figNew = figure(... 'MenuBar', 'none',... 'Toolbar','figure',... 'DockControls', 'off',... 'NumberTitle', 'off',... 'Color', get(fig,'Color')-unifrnd(0.09,0.11,1,3),... 'Visible', 'off'); switch mode case '2D ImScatter' switch getappdata(fig,'viewMode') case 'monoView' transferVarList(figNew,fig,'render-mono') if ~getappdata(fig,'isLoaded') localization(figNew); end %framerange selected idx = [-1; cumsum(getappdata(figNew,'ctrsN'))]; if getappdata(fig,'rStart') == 1 setappdata(figNew,'startPnt',0) else setappdata(figNew,'startPnt',... idx(getappdata(fig,'rStart'))+1) end %if if isinf(getappdata(fig,'rEnd')) setappdata(figNew,'rEnd',numel(getappdata(figNew,'ctrsN'))) setappdata(figNew,'elements',inf) else setappdata(figNew,'elements',... idx(getappdata(fig,'rEnd')+1)-... max(1,getappdata(figNew,'startPnt'))+1) end %if %get ROI roi = getappdata(fig,'roi'); data = preprocessData(figNew,returnVar(1:12),roi); setappdata(figNew,'roiX0', roi(1)) setappdata(figNew,'roiY0', roi(2)) setappdata(figNew,'exfOld',getappdata(fig,'exfNew')) set(figNew,... 'Name', ['2D Scatter: ' num2str(numel(data.(varNames{take(1)})))... '\' num2str(sum(getappdata(fig,'ctrsN'))) ' rendered'],... 'NumberTitle', 'off',... 'MenuBar', 'none',... 'ToolBar', 'figure',... 'Visible', 'on'); axes(... 'Parent', figNew,... 'Units','normalized',... 'Fontsize',15); hToolBar = findall(figNew,'Type','uitoolbar'); hToggleList = findall(hToolBar); delete(hToggleList([2 3 4 5 6 7 8 9 10 13 14 16 17 18])) color = jet(256); cCtrs = linspace(min(weight(5)*data.(varNames{take(5)})),... max(weight(5)*data.(varNames{take(5)})),256); [unused cIdx] = histc(weight(5)*data.(varNames{take(5)}),cCtrs); rho = linspace(0,2*pi,10)'; patch(repmat((weight(1)*data.(varNames{take(1)}))',10,1)+... weight(4)*cos(rho)*data.(varNames{take(4)})',... repmat((weight(2)*data.(varNames{take(2)}))',10,1)+... weight(4)*sin(rho)*data.(varNames{take(4)})',... shiftdim(color(cIdx,:),-1),... 'EdgeColor', 'none', 'FaceAlpha', 0.5) axis ('equal','ij') set(gca,'CLim', [min(weight(5)*data.(varNames{take(5)}))... max(weight(5)*data.(varNames{take(5)}))]) xlabel(encodeType{take(1)}); ylabel(encodeType{take(2)}); hCBar = colorbar; set(get(hCBar, 'YLabel'),'String', encodeType{take(5)}, 'FontSize', 15) case 'dualView' case 'tripleView' end %switch case '3D ImScatter' switch getappdata(fig,'viewMode') case 'monoView' transferVarList(figNew,fig,'render-mono') %framerange selected idx = [-1; cumsum(getappdata(figNew,'ctrsN'))]; if getappdata(fig,'rStart') == 1 setappdata(figNew,'startPnt',0) else setappdata(figNew,'startPnt',... idx(getappdata(fig,'rStart'))+1) end %if if isinf(getappdata(fig,'rEnd')) setappdata(figNew,'rEnd',numel(getappdata(figNew,'ctrsN'))) setappdata(figNew,'elements',inf) else setappdata(figNew,'elements',... idx(getappdata(fig,'rEnd')+1)-... max(1,getappdata(figNew,'startPnt'))+1) end %if %get ROI roi = getappdata(fig,'roi'); data = preprocessData(figNew,returnVar(1:12),roi); setappdata(figNew,'roiX0', roi(1)) setappdata(figNew,'roiY0', roi(2)) setappdata(figNew,'exfOld',getappdata(fig,'exfNew')) pnts = numel(data.(varNames{take(1)})); set(figNew,... 'Name', ['3D Scatter: ' num2str(pnts)... '\' num2str(sum(getappdata(fig,'ctrsN'))) ' rendered'],... 'NumberTitle', 'off',... 'MenuBar', 'none',... 'ToolBar', 'figure',... 'Visible', 'on'); axes(... 'Parent', figNew,... 'Units','normalized',... 'FontSize', 15,... 'Box', 'on',... 'Projection', 'perspective',... 'TickDir', 'in'); hToolBar = findall(figNew,'Type','uitoolbar'); hToggleList = findall(hToolBar); delete(hToggleList([2 3 4 5 6 7 8 13 14 16 17 18])) x = [1 0; 1 1; 1 0; 1 -1; 1 0; 1 0]*... [weight(1)*data.(varNames{take(1)}),... weight(4)*data.(varNames{take(4)})]'; y = [1 0; 1 0; 1 1; 1 0; 1 -1; 1 0]*... [weight(2)*data.(varNames{take(2)}),... weight(4)*data.(varNames{take(4)})]'; z = [1 1; 1 0; 1 0; 1 0; 1 0; 1 -1]*... [weight(3)*data.(varNames{take(3)}),... weight(4)*data.(varNames{take(4)})]'; vertices = [x(:) y(:) z(:)]; faceIdx = repmat([1 2 3; 1 3 4; 1 4 5; 1 5 2;... 6 2 3; 6 3 4; 6 4 5; 6 5 2],pnts,1); face = reshape(repmat(0:6:6*(pnts-1),24,1),[3 pnts*8]); face = faceIdx+face'; color = jet(256); cCtrs = linspace(min(weight(5)*data.(varNames{take(5)})),... max(weight(5)*data.(varNames{take(5)})),256); [unused cIdx] = histc(weight(5)*data.(varNames{take(5)}),cCtrs); cIdx = reshape(repmat(cIdx',8,1),[1 8*pnts]); patch('Faces',face,'Vertices',vertices,... 'FaceVertexCData', color(cIdx,:),... 'FaceColor', 'flat'); view(3) axis ('vis3d') set(gca,'CLim', [min(weight(5)*data.(varNames{take(5)}))... max(weight(5)*data.(varNames{take(5)}))]) %xlabel(encodeType{take(1)}); %ylabel(encodeType{take(2)}); %zlabel(encodeType{take(3)}) hCBar = colorbar; set(get(hCBar, 'YLabel'),'String',... encodeType{take(5)}, 'FontSize', 15) case 'dualView' %check for tracking data if imageBin{2}.isTrack n = 1; m = 1; else n = 2; m = 0; end %if %get ROI hRoi = findobj(hFig,'Tag', 'roi'); if isempty(hRoi) roi = imageBin{1}.roi; else roi =... get(hRoi,'UserData')/imageBin{1}.exfOld; end fig =... figure(... 'Units','normalized',... 'Position', figPos(imageBin{1}.roi(3)/imageBin{1}.roi(4)),... 'Color', get(hFig,'Color'),... 'NumberTitle', 'off',... 'MenuBar', 'none',... 'ToolBar', 'figure'); ax =... axes(... 'Parent', fig,... 'Units','normalized',... 'FontSize', 15,... 'Box', 'on',... 'Projection', 'perspective',... 'TickDir', 'in',... 'NextPlot', 'add'); hToolBar = findall(fig,'Type','uitoolbar'); hToggleList = findall(hToolBar); delete(hToggleList([2 3 4 5 6 7 8 13 14 16 17 18])) for ch = 1:n idx{ch} = [-1; cumsum(imageBin{ch}.ctrsN)]; %framerange selected if isnan(imageBin{ch}.rStart) startPnt = 0; else startPnt = idx{ch}(imageBin{ch}.rStart)+1; end %if if isnan(imageBin{ch}.rEnd) elements = inf; else elements = idx{ch}(imageBin{ch}.rEnd+1)-max(1,startPnt)+1; end %if data = preprocessData(returnVar(1:12),imageBin{ch},startPnt,elements); pnts = numel(data.(varNames{take(1)})); x = [1 0; 1 1; 1 0; 1 -1; 1 0; 1 0]*... [weight(1)*data.(varNames{take(1)}),weight(4)*data.(varNames{take(4)})]'; y = [1 0; 1 0; 1 1; 1 0; 1 -1; 1 0]*... [weight(2)*data.(varNames{take(2)}),weight(4)*data.(varNames{take(4)})]'; z = [1 1; 1 0; 1 0; 1 0; 1 0; 1 -1]*... [weight(3)*data.(varNames{take(3)}),weight(4)*data.(varNames{take(4)})]'; vertices = [x(:) y(:) z(:)]; faceIdx = repmat([1 2 3; 1 3 4; 1 4 5; 1 5 2;... 6 2 3; 6 3 4; 6 4 5; 6 5 2],pnts,1); face = reshape(repmat(0:6:6*(pnts-1),24,1),[3 pnts*8]); face = faceIdx+face'; if strcmp(varNames{take(5)},'channel') color = [0 0 0]; color(ch) = 1; cIdx = 1; else color = jet(256); cCtrs = linspace(min(weight(5)*data.(varNames{take(5)})),... max(weight(5)*data.(varNames{take(5)})),256); [unused cIdx] = histc(weight(5)*data.(varNames{take(5)}),cCtrs); cIdx = reshape(repmat(cIdx',8,1),[1 8*pnts]); end %if patch('Faces',face,'Vertices',vertices,... 'FaceVertexCData', color(cIdx,:),... 'FaceColor', 'flat','Parent', ax); end %for view(3) axis ('vis3d','tight') % set(ax,'CLim', [min(weight(5)*data.(varNames{take(5)}))... % max(weight(5)*data.(varNames{take(5)}))]) % xlabel(encodeType{take(1)}); ylabel(encodeType{take(2)}); % zlabel(encodeType{take(3)}) hCBar = colorbar; set(get(hCBar, 'YLabel'),'String', encodeType{take(5)}, 'FontSize', 15) % set(fig, 'Name', ['3D Scatter: ' num2str(pnts)... % '\' num2str(sum(imageBin.ctrsN)) ' rendered']) case 'tripleView' end %switch end %switch end end %% ANALYSIS function intHist(src, event) fig = gcbf; figNew =... figure(... 'Units','normalized',... 'Position', figPos(1)+[0 0 0.1 0],... 'Color', get(fig,'Color'),... 'Name', 'Intensitydistribution',... 'NumberTitle', 'off',... 'MenuBar', 'none',... 'ToolBar', 'figure'); hToolBar = findall(figNew,'Type','uitoolbar'); hToggleList = findall(hToolBar); delete(hToggleList([2 3 4 5 6 7 8 9 10 13 14 16 17 18])) switch get(src, 'Tag') case 'Pixel Intensity' set(figNew, 'Name', 'Pixel Intensity') if getappdata(fig,'isSuperstack') pathname = getappdata(fig,'pathname'); filename = getappdata(fig,'filename'); I = double(imread([pathname{getappdata(fig,'stack')}... filename{getappdata(fig,'stack')}],getappdata(fig,'frame'))); else I = double(imread([getappdata(fig,'pathname')... getappdata(fig,'filename')],getappdata(fig,'frame'))); end %if ax =... axes(... 'Parent', figNew,... 'Units','normalized',... 'FontSize', 15,... 'NextPlot', 'add'); buildHistogram(ax,I(:),'counts') xlabel(ax,'Pixelintensity [counts]') case 'Particle Intensity' icon = getappdata(1, 'icons'); uipushtool(... 'Parent', hToolBar,... 'CData', repmat(icon.fit, [1 1 3]),... 'ClickedCallback', @fitDist,... 'Separator', 'on') ax =... subplot(20,1,[14,1],... 'Parent', figNew,... 'Units','normalized',... 'FontSize', 20,... 'NextPlot', 'add',... 'XTickLabel',''); idx = [-1; cumsum(getappdata(fig,'ctrsN'))]; if getappdata(fig,'rStart') == 1 setappdata(fig,'startPnt',0) else setappdata(fig,'startPnt',... idx(getappdata(fig,'rStart'))+1) end %if if isinf(getappdata(fig,'rEnd')) setappdata(fig,'rEnd',numel(getappdata(fig,'ctrsN'))) setappdata(fig,'elements',inf) else setappdata(fig,'elements',... idx(getappdata(fig,'rEnd')+1)-... max(1,getappdata(fig,'startPnt'))+1) end %if %get roi roi = getappdata(fig,'roi'); data = preprocessData(fig,[0 0 0 0 0 0 0 1 0 0 0 0],roi); [freq, ctrs] = hist(data.photons,calcnbins(data.photons,'fd')); hStair = stairs(ctrs,freq); set(hStair, ... 'Tag', 'Intensityhistogram',... 'Userdata', {freq,ksdensity(data.photons,ctrs)}) set(fig, 'Name', ['Particle Intensity: ' num2str(numel(data.photons)) '\'... num2str(sum(getappdata(fig,'ctrsN'))) ' rendered']) axis tight ylabel('Frequency'); errAx =... subplot(20,1,16:19,... 'Parent', figNew,... 'Units','normalized',... 'FontSize', 20,... 'NextPlot', 'add'); ylabel('Residuals'); xlabel('Particleintensity [photons]'); linkaxes([ax errAx],'x') end %switch function fitDist(src, event) fitFig =... figure(... 'Units','normalized',... 'Position', [0.6 0.4 0.3 0.4],... 'Color', get(fig,'Color'),... 'Name', 'Fit',... 'NumberTitle', 'off',... 'MenuBar', 'none',... 'ToolBar', 'none'); uicontrol(... 'Style', 'text',... 'Parent', fitFig,... 'Units','normalized',... 'Position', [0.1 0.9 0.8 0.07],... 'FontSize', 15,... 'String', 'Subpopulations:') hTable =... uitable(... 'Parent', fitFig,... 'Units','normalized',... 'Position', [0.05 0.15 0.9 0.6],... 'ColumnName', {'Fraction', 'Photons', 'Error'},... 'ColumnFormat', {'numeric','numeric','numeric'},... 'ColumnWidth', {104},... 'data', cell(3,3),... 'FontSize', 10); hSubpops(1) =... uicontrol(... 'Style', 'popupmenu',... 'Parent', fitFig,... 'Units','normalized',... 'Position', [0.3 0.8 0.6 0.06],... 'FontSize', 15,... 'String', {'1x constraint'... '1x constraint + 1x free', '2x constraint',.... '2x constraint + 1x free', '3x constraint',... '3x constraint + 1x free', '4x constraint'},... 'Value', 3); hSubpops(2) =... uicontrol(... 'Style', 'popupmenu',... 'Parent', fitFig,... 'Units','normalized',... 'Position', [0.3 0.8 0.6 0.06],... 'FontSize', 15,... 'String', {'Scan for optimal # of fractions',... 'Set # of fractions w\o initial guess',... 'Set # of fractions with initial guess'},... 'Value', 1,... 'Visible','off'); hMethod =... uicontrol(... 'Style', 'popupmenu',... 'Parent', fitFig,... 'Units','normalized',... 'Position', [0.1 0.8 0.2 0.06],... 'FontSize', 15,... 'String', {'OLS','MLE'},... 'Value', 1,... 'Callback', @changeMethod); uicontrol(... 'Style', 'pushbutton',... 'Parent', fitFig,... 'Units','normalized',... 'Position', [0.1 0.05 0.8 0.06],... 'FontSize', 15,... 'String', 'FIT',... 'Callback', @estimatePar) function changeMethod(src,event) set(hSubpops,'Visible','off') set(hSubpops(get(src,'Value')),'Visible','on') vals = get(hStair,'UserData'); set(hStair,'YData',vals{get(src,'Value')}) delete(findobj(ax, 'Tag', 'fit')) axis(ax,'tight') end function estimatePar(src, event) switch get(hMethod,'Value') case 1 switch get(hSubpops(1), 'Value') case 1 fractions = 1; f = fittype('gauss1'); preVal = getappdata(fig,'preVal'); if isempty(preVal) preOpt = fitoptions('method','NonlinearLeastSquares'); preFit = fit(ctrs',freq',f,preOpt); preVal = cellstr(num2str(coeffvalues(preFit)')); end answer =... inputdlg(... coeffnames(f),... 'StartValues',1,... preVal); setappdata(fig,'preVal',answer) startPnts = str2num(strvcat(answer{:})); lBnd = [0,startPnts(2)-startPnts(2)/100,0]; uBnd = [inf,startPnts(2)+startPnts(2)/100,inf]; case 2 fractions = 2; f = fittype('gauss2'); preVal = getappdata(fig,'preVal'); if isempty(preVal) || numel(preVal) ~= 3*fractions preOpt = fitoptions('method','NonlinearLeastSquares'); preFit = fit(ctrs',freq',f,preOpt); preVal = cellstr(num2str(coeffvalues(preFit)')); end answer =... inputdlg(... coeffnames(f),... 'StartValues',1,... preVal); setappdata(fig,'preVal',answer) startPnts = str2num(strvcat(answer{:})); lBnd = [0,0,0,... 0,startPnts(5)-startPnts(5)/100,0]; uBnd = [inf,inf,inf,... inf,startPnts(5)+startPnts(5)/100,inf]; case 3 fractions = 2; f = fittype('gauss2'); preVal = getappdata(fig,'preVal'); if isempty(preVal) || numel(preVal) ~= 3*fractions preOpt = fitoptions('method','NonlinearLeastSquares'); preFit = fit(ctrs',freq',f,preOpt); preVal = cellstr(num2str(coeffvalues(preFit)')); end answer =... inputdlg(... coeffnames(f),... 'StartValues',1,... preVal); setappdata(fig,'preVal',answer) startPnts = str2num(strvcat(answer{:})); lBnd = [0,startPnts(2)-startPnts(2)/100,0,... 0,startPnts(5)-startPnts(5)/100,0]; uBnd = [inf,startPnts(2)+startPnts(2)/100,inf,... inf,startPnts(5)+startPnts(5)/100,inf]; case 4 fractions = 3; f = fittype('gauss3'); preVal = getappdata(fig,'preVal'); if isempty(preVal) || numel(preVal) ~= 3*fractions preOpt = fitoptions('method','NonlinearLeastSquares'); preFit = fit(ctrs',freq',f,preOpt); preVal = cellstr(num2str(coeffvalues(preFit)')); end answer =... inputdlg(... coeffnames(f),... 'StartValues',1,... preVal); setappdata(fig,'preVal',answer) startPnts = str2num(strvcat(answer{:})); lBnd = [0,0,0,... 0,startPnts(5)-startPnts(5)/100,0,... 0,startPnts(8)-startPnts(8)/100,0]; uBnd = [inf,inf,inf,... inf,startPnts(5)+startPnts(5)/100,inf,... inf,startPnts(8)+startPnts(8)/100,inf]; case 5 fractions = 3; f = fittype('gauss3'); preVal = getappdata(fig,'preVal'); if isempty(preVal) || numel(preVal) ~= 3*fractions preOpt = fitoptions('method','NonlinearLeastSquares'); preFit = fit(ctrs',freq',f,preOpt); preVal = cellstr(num2str(coeffvalues(preFit)')); end answer =... inputdlg(... coeffnames(f),... 'StartValues',1,... preVal); setappdata(fig,'preVal',answer) startPnts = str2num(strvcat(answer{:})); lBnd = [0,startPnts(2)-startPnts(2)/100,0,... 0,startPnts(5)-startPnts(5)/100,0,... 0,startPnts(8)-startPnts(8)/100,0]; uBnd = [inf,startPnts(2)+startPnts(2)/100,inf,... inf,startPnts(5)+startPnts(5)/100,inf,... inf,startPnts(8)+startPnts(8)/100,inf]; case 6 fractions = 4; f = fittype('gauss4'); preVal = getappdata(fig,'preVal'); if isempty(preVal) || numel(preVal) ~= 3*fractions preOpt = fitoptions('method','NonlinearLeastSquares'); preFit = fit(ctrs',freq',f,preOpt); preVal = cellstr(num2str(coeffvalues(preFit)')); end answer =... inputdlg(... coeffnames(f),... 'StartValues',1,... preVal); setappdata(fig,'preVal',answer) startPnts = str2num(strvcat(answer{:})); lBnd = [0,0,0,... 0,startPnts(5)-startPnts(5)/100,0,... 0,startPnts(8)-startPnts(8)/100,0,... 0,startPnts(11)-startPnts(11)/100,0]; uBnd = [inf,inf,inf,... inf,startPnts(5)+startPnts(5)/100,inf,... inf,startPnts(8)+startPnts(8)/100,inf,... inf,startPnts(11)+startPnts(11)/100,inf]; case 7 fractions = 4; f = fittype('gauss4'); preVal = getappdata(fig,'preVal'); if isempty(preVal) || numel(preVal) ~= 3*fractions preOpt = fitoptions('method','NonlinearLeastSquares'); preFit = fit(ctrs',freq',f,preOpt); preVal = cellstr(num2str(coeffvalues(preFit)')); end answer =... inputdlg(... coeffnames(f),... 'StartValues',1,... preVal); setappdata(fig,'preVal',answer) startPnts = str2num(strvcat(answer{:})); lBnd = [0,startPnts(2)-startPnts(2)/100,0,... 0,startPnts(5)-startPnts(5)/100,0,... 0,startPnts(8)-startPnts(8)/100,0,... 0,startPnts(11)-startPnts(11)/100,0]; uBnd = [inf,startPnts(2)+startPnts(2)/100,inf,... inf,startPnts(5)+startPnts(5)/100,inf,... inf,startPnts(8)+startPnts(8)/100,inf,... inf,startPnts(11)+startPnts(11)/100,inf]; end %switch delete(findobj(ax, 'Tag', 'fit')) cla(errAx) opt = fitoptions('method','NonlinearLeastSquares',... 'StartPoint', startPnts,... 'Lower', lBnd, 'Upper', uBnd); [fitFractions statsFraction outpuFractions] =... fit(ctrs',freq',f,opt); plot(ax, ctrs, feval(fitFractions,ctrs),... 'Color', [1 0 0], 'LineWidth', 2, 'Tag', 'fit'); stem(errAx, ctrs, outpuFractions.residuals) legend(errAx, ['RMSE = ' num2str(statsFraction.rmse)]) results = transpose(reshape(coeffvalues(fitFractions),... 3,fractions)); case 2 options = statset('MaxIter',1000); switch get(hSubpops(2), 'Value') case 1 fractions = str2double(... inputdlg('max. # Fractions:','Scan Options')); AIC = zeros(1,fractions); mixComponents = cell(1,fractions); for k = 1:fractions mixComponents{k} = ... gmdistribution.fit(data.photons,k,... 'Options', options); AIC(k)= mixComponents{k}.AIC; end [minAIC,fractions] = min(AIC); mixComponents = mixComponents{fractions}; case 2 fractions = str2double(... inputdlg('# of Fractions:','Fit Options')); mixComponents = ... gmdistribution.fit(data.photons,fractions,... 'Options', options); case 3 end %switch delete(findobj(ax, 'Tag', 'fit')) cla(errAx) % [P,nlogl] = posterior(mixComponents,data.photons); plot(ax, ctrs', pdf(mixComponents,ctrs'),... 'Color', [1 0 0], 'LineWidth', 2, 'Tag', 'fit'); results = [mixComponents.PComponents'./... sqrt(2*pi*mixComponents.Sigma(:)),... mixComponents.mu,... sqrt(mixComponents.Sigma(:))]; end gauss = @(x,a,b,c) a*exp(-((x-b)/c).^2); ctrsInterp = linspace(min(ctrs),max(ctrs),10*numel(ctrs))'; freqSub = zeros(fractions,numel(ctrsInterp)); for N = 1:fractions freqSub(N,:) = gauss(ctrsInterp,... results(N,1),results(N,2),results(N,3)); plot(ax, ctrsInterp, freqSub(N,:), 'r', 'Tag', 'fit') end %for axis(ax,'tight') switch get(hMethod,'Value') case 1 set(hTable, 'data', [sum(freqSub,2)/sum(freq) results(:,2:3)]) case 2 set(hTable, 'data', [mixComponents.PComponents' results(:,2:3)]) end %switch end end end function locPrec(src, event) fig = gcbf; idx = [-1; cumsum(getappdata(fig,'ctrsN'))]; if getappdata(fig,'rStart') == 1 setappdata(fig,'startPnt',0) else setappdata(fig,'startPnt',... idx(getappdata(fig,'rStart'))+1) end %if if isinf(getappdata(fig,'rEnd')) setappdata(fig,'rEnd',numel(getappdata(fig,'ctrsN'))) setappdata(fig,'elements',inf) else setappdata(fig,'elements',... idx(getappdata(fig,'rEnd')+1)-... max(1,getappdata(fig,'startPnt'))+1) end %if %get ROI roi = getappdata(fig,'roi'); data = preprocessData(fig,[0 0 0 0 0 0 0 0 1 0 0 0],roi); figNew =... figure(... 'Units','normalized',... 'Position', figPos(1)+[0 0 0.2 0],... 'Color', get(fig,'Color'),... 'Name', ['Loc. Precision: ' num2str(numel(data.precision)) '\'... num2str(sum(getappdata(fig,'ctrsN'))) ' rendered'],... 'NumberTitle', 'off',... 'MenuBar', 'none',... 'ToolBar', 'figure'); hToolBar = findall(figNew,'Type','uitoolbar'); hToggleList = findall(hToolBar); delete(hToggleList([2 3 4 5 6 7 8 9 10 13 14 16 17 18])) ax =... axes(... 'Parent', figNew,... 'Units','normalized',... 'FontSize', 15,... 'NextPlot', 'add'); buildHistogram(ax,data.precision*1000,'nm') xlabel(ax,'Localization Precision [nm]') end function snrHist(src, event) fig = gcbf; idx = [-1; cumsum(getappdata(fig,'ctrsN'))]; if getappdata(fig,'rStart') == 1 setappdata(fig,'startPnt',0) else setappdata(fig,'startPnt',... idx(getappdata(fig,'rStart'))+1) end %if if isinf(getappdata(fig,'rEnd')) setappdata(fig,'rEnd',numel(getappdata(fig,'ctrsN'))) setappdata(fig,'elements',inf) else setappdata(fig,'elements',... idx(getappdata(fig,'rEnd')+1)-... max(1,getappdata(fig,'startPnt'))+1) end %if %get ROI roi = getappdata(fig,'roi'); data = preprocessData(fig,[0 0 0 0 0 0 0 0 0 1 0 0],roi); figNew =... figure(... 'Units','normalized',... 'Position', figPos(1)+[0 0 0.2 0],... 'Color', get(fig,'Color'),... 'Name', ['Loc. Precision: ' num2str(numel(data.snr)) '\'... num2str(sum(getappdata(fig,'ctrsN'))) ' rendered'],... 'NumberTitle', 'off',... 'MenuBar', 'none',... 'ToolBar', 'figure'); hToolBar = findall(figNew,'Type','uitoolbar'); hToggleList = findall(hToolBar); delete(hToggleList([2 3 4 5 6 7 8 9 10 13 14 16 17 18])) ax =... axes(... 'Parent', figNew,... 'Units','normalized',... 'FontSize', 15,... 'NextPlot', 'add'); buildHistogram(ax,data.snr,'') xlabel(ax,'Signal to Noise Ratio') end function detectionTrace(src, event) fig = gcbf; figNew =... figure(... 'Units','normalized',... 'Position', figPos(1)+[0 0 0.2 0],... 'Color', get(fig,'Color'),... 'Name', 'Detectiontrace',... 'NumberTitle', 'off',... 'MenuBar', 'none',... 'ToolBar', 'figure'); hToolBar = findall(figNew,'Type','uitoolbar'); hToggleList = findall(hToolBar); delete(hToggleList([2 3 4 5 6 7 8 9 10 13 14 16 17 18])) ax(1) =... subplot(2,1,1,... 'Parent', figNew,... 'FontSize', 20,... 'NextPlot', 'add'); ctrsN = getappdata(fig,'ctrsN'); plot(ax(1), ctrsN) plot(ax(1), smooth(ctrsN,0.25,'loess'),... 'Color', [1 0 0], 'LineWidth', 2) axis tight xlabel('Frame'); ylabel('Particledetections'); ax(2) =... subplot(2,1,2,... 'Parent', figNew,... 'FontSize', 20); buildHistogram(ax(2),ctrsN,'') xlabel(ax(2),'Particledetections') end function interactionStudy(src,event) end function colocFilter(src,event) fig = imgcf; srcFig = getappdata(fig,'imSrcFig'); imCh = getappdata(fig,'imCh'); nImCh = getappdata(fig,'nImCh'); returnValue = [1 1 0 0 0 0 1 1 0 0 0 0]; for ch = 1:nImCh %load whole list setappdata(srcFig(imCh(ch)),'startPnt',0) setappdata(srcFig(imCh(ch)),'endPnt',inf) roi = [0 0 ... getappdata(srcFig(imCh(ch)),'width')... getappdata(srcFig(imCh(ch)),'height')]; data{ch} =... preprocessData(srcFig(imCh(ch)),returnValue,roi); end %for width = getappdata(srcFig(imCh(1)),'width'); height = getappdata(srcFig(imCh(1)),'height'); %max. allowed distance [px] thresh = 2; hProgressbar = waitbar(0,'Generating Images...','Color',... get(0,'defaultUicontrolBackgroundColor')); for frame = 1:getappdata(srcFig(imCh(1)),'rEnd') [idx{1} idx{2}] = filterData(data); nColoc(frame) = numel(idx{1}); if nColoc(frame) > 0 %calculate linear indices of particle detection for 2d-matrix [cntY idxY] = histc(data{1}.ctrsY(idx{1}),1:height); [cntX idxX] = histc(data{1}.ctrsX(idx{1}),1:width); linIdx = idxX*height+idxY+1; [linIdx unused subs] = unique(linIdx); imRendered = zeros(height,width); imRendered(linIdx) = accumarray(subs,data{1}.photons(idx{1})*20.2); psf = buildPSF(1,width,height); imRendered = fftshift(ifft2(fft2(imRendered).* psf)); imwrite(uint8(imRendered),... [getappdata(srcFig(imCh(1)),'pathname')... getappdata(srcFig(imCh(1)),'filename') '_faked.tif'],'compression','none',... 'Writemode', 'append') [cntY idxY] = histc(data{2}.ctrsY(idx{2}),1:height); [cntX idxX] = histc(data{2}.ctrsX(idx{2}),1:width); linIdx = idxX*height+idxY+1; [linIdx unused subs] = unique(linIdx); imRendered = zeros(height,width); imRendered(linIdx) = accumarray(subs,data{1}.photons(idx{1})*20.2); psf = buildPSF(1,width,height); imRendered = fftshift(ifft2(fft2(imRendered).* psf)); imwrite(uint8(imRendered),... [getappdata(srcFig(imCh(2)),'pathname')... getappdata(srcFig(imCh(2)),'filename') '_faked.tif'],'compression','none',... 'Writemode', 'append') else imRendered = zeros(height,width,'uint8'); imwrite(imRendered,... [getappdata(srcFig(imCh(1)),'pathname')... getappdata(srcFig(imCh(1)),'filename') '_faked.tif'],'compression','none',... 'Writemode', 'append') imwrite(imRendered,... [getappdata(srcFig(imCh(2)),'pathname')... getappdata(srcFig(imCh(2)),'filename') '_faked.tif'],'compression','none',... 'Writemode', 'append') continue end %if waitbar(frame/getappdata(srcFig(imCh(1)),'rEnd'),... hProgressbar,'Generating Images...','Color',... get(0,'defaultUicontrolBackgroundColor')); end %for delete(hProgressbar) [outputname,outputpath,isOK] = uiputfile(... '.txt' ,'Save #CoLoc/Frame to', getappdata(0,'searchPath')); fid = fopen([outputpath outputname], 'wt'); fprintf(fid,'%.0f \n',nColoc) fclose(fid); function [idxCh1 idxCh2] = filterData(data) good{1} = (data{1}.frame == frame); good{2} = (data{2}.frame == frame); sizey1 = numel(data{1}.ctrsY(good{1})); sizey2 = numel(data{2}.ctrsY(good{2})); y1Mat = repmat(data{1}.ctrsY(good{1}),1,sizey2); y2Mat = repmat(data{2}.ctrsY(good{2})',sizey1,1); yDiffMat = (y1Mat-y2Mat).^2; sizex1 = numel(data{1}.ctrsX(good{1})); sizex2 = numel(data{2}.ctrsX(good{2})); x1Mat = repmat(data{1}.ctrsX(good{1}),1,sizex2); x2Mat = repmat(data{2}.ctrsX(good{2})',sizex1,1); xDiffMat = (x1Mat-x2Mat).^2; d = sqrt(yDiffMat+xDiffMat); good = min(d,1) & min(d,2); [idxCh1 idxCh2] = find(d <= thresh & good); end end function particleImageCorrelation(src,event) fig = imgcf; %set correlation sampling rate samplingRate = 5; %[px^-1] dMax = 15; %[px] roi = getappdata(fig,'roi'); %reduce field of view to obtain %true distribution of step sizes up %to a distance dMax roi = [max(roi(1:2),dMax),... min(roi(3:4),... [getappdata(fig,'width') ... getappdata(fig,'height')]-dMax)]; data = preprocessData(fig,[1 1 0 0 0 0 1 0 0 0 0 0],roi); nIm = numel(getappdata(fig,'ctrsN')); nPnts = numel(data.ctrsX); %generate 2d-projected tree pntList = [data.ctrsX data.ctrsY]; tree = kdtree_build(pntList); %average particle # for increasing dt pntsPerFrame = accumarray(data.frame,1); muPnts = zeros(1,nIm-1); for dt = 1:nIm-1 muPnts(dt) = mean(pntsPerFrame(1:nIm-dt)); end Ccum = zeros(dMax,nIm-1); for d = 1:ceil(dMax*samplingRate) %reset count matrix cnts = zeros(nPnts,nIm-1); for pnt = 1:nPnts iNN = kdtree_ball_query(tree,... pntList(pnt,:),d/samplingRate); dt = data.frame(iNN)-data.frame(pnt); %allow only temporal forward correlation good = (dt>0); if any(good) %overlap integral for image pairs separated %by dt cnts(pnt,:) = accumarray(dt(good),1,[nIm-1 1]); end %if end %for %average over n*dt and normalize to average %particle # for n*dt Ccum(d,:) = (sum(cnts)./(nIm-1:-1:1))./muPnts; end %for kdtree_delete(tree) %calculate spatial correction term z = []; x = []; y = []; for dt = 1:nIm-1 linStart = find(Ccum(:,dt)>1,1,'first'); z = [z; Ccum(linStart:end,dt)]; y = [y; ((linStart:dMax*samplingRate)/samplingRate)']; x = [x; ones(dMax*samplingRate-linStart+1,1)*dt]; end [b,bint,r,rint,stats] =... regress(z,[ones(size(z)) x y.^2]); [XFIT,YFIT] = meshgrid(1:nIm-1,... ((1:ceil(dMax*samplingRate))/samplingRate).^2); ZHAT = b(2)*XFIT + b(3)*YFIT; Ccum = Ccum-ZHAT; %control figure % figure; % surf(XFIT(1,:),YFIT(:,1),... % Ccum,'EdgeColor','flat','FaceAlpha', 0.9) % hold on % plot3(x, y.^2, z, 'm.') % plot3(XFIT,YFIT,ZHAT+b(1), 'r-') end %% LOCALIZATION function localization(src,event) fig = gcbf; imageBin = getappdata(fig); imageBin.imageName = strcat(imageBin.pathname,... imageBin.filename); %select localization output filename if iscell(imageBin.filename) %if there are multiple filenames, find their union cnt = 1; while all(strncmp(imageBin.filename{1},... imageBin.filename,cnt)) cnt = cnt+1; end %while if cnt > 1 imageBin.filename = imageBin.filename{1}(1:cnt-1); else %no union imageBin.filename = []; end %if else imageBin.filename = imageBin.filename(1:end-4); end %if [imageBin.filename,imageBin.pathname,isOK] =... uiputfile('','Save to',... [getappdata(0,'searchPath')... imageBin.filename]); if isOK %check if filename already existent in folder [imageBin.filename, imageBin.pathname, abort] =... checkNameExistance(imageBin.filename,imageBin.pathname); if abort return end %if else return end %if %search for ROI if isempty(getappdata(fig,'hROI')) imageBin.roi =... [1 1 getappdata(fig,'width')... getappdata(fig,'height')]; else imageBin.roi = ceil(getappdata(fig,'roi')); end tic if getappdata(fig,'isSuperstack') N = 0; findStartPnt = 1; foundEndPnt = 0; for file = 1:numel(imageBin.imageName) info = imfinfo(imageBin.imageName{file}); N = N + numel(info); if findStartPnt if N >= getappdata(fig,'locStart') startPnt = getappdata(fig,'locStart')-... (N-numel(info)); findStartPnt = 0; else %loop until startPnt is inside actual stack continue end %if else startPnt = 1; end %if if isinf(getappdata(fig,'locEnd')) endPnt = numel(info); else if N > getappdata(fig,'locEnd') endPnt = numel(info)-... (N-getappdata(fig,'locEnd')); foundEndPnt = 1; elseif N == getappdata(fig,'locEnd') endPnt = numel(info); foundEndPnt = 1; else endPnt = numel(info); end %if end %if imageBin.ctrsN{file} = localizeParticles(imageBin.imageName{file},... startPnt,endPnt,info,imageBin); if foundEndPnt break end %if end %for imageBin.ctrsN = vertcat(imageBin.ctrsN{:}); else info = imfinfo(imageBin.imageName); if isnan(getappdata(fig,'locStart')) startPnt = 1; else startPnt = getappdata(fig,'locStart'); end %if if isinf(getappdata(fig,'locEnd')) endPnt = numel(info); else endPnt = getappdata(fig,'locEnd'); end %if imageBin.ctrsN = localizeParticles(imageBin.imageName,... startPnt,endPnt,info,imageBin); end toc %save localization matrix saveSettingsToDisk(imageBin) function saveSettingsToDisk(imageBin) save([imageBin.pathname imageBin.filename '.mat'],'imageBin') end end function batchLocalization(src,event) menuFig =... figure(... 'Units','normalized',... 'Position', [0 0 1 1],... 'Color', get(0,'defaultUicontrolBackgroundColor'),... 'Name', 'Batch Container',... 'NumberTitle', 'off',... 'MenuBar', 'none',... 'ToolBar', 'none',... 'Resize', 'on'); hList =... uicontrol(... 'Style', 'listbox',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0 0 0.8 1],... 'FontSize', 15,... 'Backgroundcolor', [1 1 1],... 'Callback', @updatePanelVisibility); uicontrol(... 'Style', 'pushbutton',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.8 0.18 0.05 0.1],... 'FontSize', 25,... 'String', '+',... 'Callback', {@addStack, hList}) uicontrol(... 'Style', 'pushbutton',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.85 0.18 0.05 0.1],... 'FontSize', 30,... 'String', '-',... 'Callback', {@delStack, hList}) uicontrol(... 'Style', 'pushbutton',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.9 0.18 0.05 0.1],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'UP',... 'Callback', {@moveUpStack, hList}) uicontrol(... 'Style', 'pushbutton',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.95 0.18 0.05 0.1],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'DOWN',... 'Callback', {@moveDownStack, hList}) uicontrol(... 'Style', 'pushbutton',... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.8 0 0.2 0.18],... 'FontSize', 20,... 'FontUnits', 'normalized',... 'String', 'START',... 'Callback', {@processBatch, hList}) hLocOptPanel =... uipanel(... 'Parent', menuFig,... 'Units','normalized',... 'Position', [0.8 0.58 0.2 0.42],... 'FontSize', 10,... 'FontWeight', 'bold',... 'Title','Localization'); uicontrol(... 'Parent', hLocOptPanel,... 'Style', 'text',... 'Units','normalized',... 'Position', [0.01 0.9 0.7 0.05],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Error Rate [10^]:',... 'HorizontalAlignment', 'left',... 'ToolTipString', sprintf(['\n'... 'This Value limits the Probability for Type One Error (False H0 Rejection), \n'... 'while estimation of the generalized likelihood ratio test. \n'... 'These Ratios follow aproximated a chi^2 distribution\n'... 'with degree of freedom (3 [signal, offset, noise]-2[offset, noise]) = 1'])); uicontrol(... 'Parent', hLocOptPanel,... 'Tag', 'errRate',... 'Style', 'edit',... 'Units','normalized',... 'Position', [0.71 0.89 0.28 0.06],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'Backgroundcolor', [1 1 1],... 'String', -6); uicontrol(... 'Parent', hLocOptPanel,... 'Style', 'text',... 'Units','normalized',... 'Position', [0.01 0.82 0.7 0.05],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Detection Box [px]:',... 'HorizontalAlignment', 'left',... 'ToolTipString', sprintf(['\n'... 'Size of 2 dimensional sliding box inside whom a \n'... 'generalized likelihood ratio test (H0/H1) is performed with: \n'... 'H0 = no target (offset and noise) \n'... 'H1 = presence of target (signal, offset and noise) \n'... 'followed by subpixel estimation via Gauss-Newton Approximation'])); uicontrol(... 'Parent', hLocOptPanel,... 'Tag', 'w2d',... 'Style', 'edit',... 'Units','normalized',... 'Position', [0.71 0.81 0.28 0.06],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'Backgroundcolor', [1 1 1],... 'String', 7); uicontrol(... 'Parent', hLocOptPanel,... 'Style', 'text',... 'Units','normalized',... 'Position', [0.01 0.74 0.7 0.05],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Deflation Loops:',... 'HorizontalAlignment', 'left',... 'ToolTipString', sprintf(['\n'... 'This Value determines how often the detection process will be iterated. \n'... 'After each Iteration the detected Particles represented by their \n'... 'gaussian Intensity Profile will be subtracted from the Image. \n'... 'In this way small peaks initially covered can be detected.'])); uicontrol(... 'Parent', hLocOptPanel,... 'Tag', 'dfltnLoops',... 'Style', 'edit',... 'Units','normalized',... 'Position', [0.71 0.73 0.28 0.06],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'Backgroundcolor', [1 1 1],... 'String', 5); uicontrol(... 'Parent', hLocOptPanel,... 'Style', 'text',... 'Units','normalized',... 'Position', [0.01 0.66 0.7 0.05],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Intensity Thresh [cnts]:',... 'HorizontalAlignment', 'left',... 'ToolTipString', sprintf(['\n'... 'Defines the min. Signal Intensity expressed as'... 'offset-corrected amplitude of the Gaussian.'])); uicontrol(... 'Parent', hLocOptPanel,... 'Tag', 'minInt',... 'Style', 'edit',... 'Units','normalized',... 'Position', [0.71 0.65 0.28 0.06],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'Backgroundcolor', [1 1 1],... 'String', 0); uicontrol(... 'Parent', hLocOptPanel,... 'Tag', 'locParallel',... 'Style', 'checkbox',... 'Units','normalized',... 'Position', [0.01 0.58 0.7 0.05],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'use multiple cores',... 'Value', false,... 'HorizontalAlignment', 'left',... 'ToolTipString', sprintf(['\n'... 'If this option is checked the programm will perform \n'... 'the particle localization process using the specefied \n'... 'number of processor cores. \n'... 'The maximum of available cores will be used by default.'])); uicontrol(... 'Parent', hLocOptPanel,... 'Tag', 'nCores',... 'Style', 'popupmenu',... 'Units','normalized',... 'Position', [0.71 0.57 0.28 0.06],... 'FontSize', 7,... 'FontUnits', 'normalized',... 'Backgroundcolor', [1 1 1],... 'String', {'max' '2' '3'},... 'Value', 1); uicontrol(... 'Parent', hLocOptPanel,... 'Style', 'text',... 'Units','normalized',... 'Position', [0.01 0.45 0.7 0.05],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'FontWeight', 'bold',... 'String', 'Optimization Settings',... 'HorizontalAlignment', 'left'); uicontrol(... 'Parent', hLocOptPanel,... 'Style', 'text',... 'Units','normalized',... 'Position', [0.01 0.37 0.7 0.05],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'max. # iterations:',... 'HorizontalAlignment', 'left'); uicontrol(... 'Parent', hLocOptPanel,... 'Tag', 'maxOptimIter',... 'Style', 'edit',... 'Units','normalized',... 'Position', [0.71 0.36 0.28 0.06],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'Backgroundcolor', [1 1 1],... 'String', 50); uicontrol(... 'Parent', hLocOptPanel,... 'Style', 'text',... 'Units','normalized',... 'Position', [0.01 0.29 0.7 0.05],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'term. tol. [10^]:',... 'HorizontalAlignment', 'left'); uicontrol(... 'Parent', hLocOptPanel,... 'Tag', 'termTol',... 'Style', 'edit',... 'Units','normalized',... 'Position', [0.71 0.28 0.28 0.06],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'Backgroundcolor', [1 1 1],... 'String', -2); uicontrol(... 'Parent', hLocOptPanel,... 'Tag', 'isRadiusTol',... 'Style', 'checkbox',... 'Units','normalized',... 'Position', [0.01 0.21 0.7 0.05],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'r0 tolerance [%]:',... 'Value', false,... 'HorizontalAlignment', 'left',... 'ToolTipString', sprintf(['\n'... 'If this option is checked the programm will optimize for \n'... 'the gaussian radius approximating the point spreads function std. \n'.... 'If the tolerancelevel set is exceeded the particle will be discarded.'])); uicontrol(... 'Parent', hLocOptPanel,... 'Tag', 'radiusTol',... 'Style', 'edit',... 'Units','normalized',... 'Position', [0.71 0.2 0.28 0.06],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'Backgroundcolor', [1 1 1],... 'String', 10); uicontrol(... 'Parent', hLocOptPanel,... 'Style', 'text',... 'Units','normalized',... 'Position', [0.01 0.13 0.7 0.05],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'max. pos. refinement [px]:',... 'HorizontalAlignment', 'left'); uicontrol(... 'Parent', hLocOptPanel,... 'Tag', 'posTol',... 'Style', 'edit',... 'Units','normalized',... 'Position', [0.71 0.12 0.28 0.06],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'Backgroundcolor', [1 1 1],... 'String', 1.5); function addStack(src, event, hList) [stackname, stackpath,isOK] = uigetfile('*.tif',... 'Select Imagestacks', getappdata(0,'searchPath'),... 'MultiSelect', 'on'); if isOK setappdata(0, 'searchPath', stackpath) content = get(hList, 'String'); contentNew = cellstr(strcat(stackpath, stackname)); content = [content', contentNew]; set(hList, 'String', content, 'Value', 1) for file = 1:numel(contentNew) set(findobj(get(src,'Parent'),... 'Title','Optics'),'Visible','off') hOpticsPanel =... uipanel(... 'Parent', get(src,'Parent'),... 'Tag', contentNew{file},... 'Units','normalized',... 'Position', [0.8 0.28 0.2 0.3],... 'FontSize', 10,... 'FontWeight', 'bold',... 'Title','Optics'); uicontrol(... 'Parent', hOpticsPanel,... 'Style', 'text',... 'Units','normalized',... 'Position', [0.01 0.84 0.7 0.07],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Pixel Size [µm]:',... 'HorizontalAlignment', 'left',... 'ToolTipString', sprintf(['\n'... 'This Value is used to estimate the pixel to micron conversion factor. \n'... 'In Theory: pixel size = phys. pixel size / total magnification(objectiv*ocular)\n'... '60, 1x = 0.267µm per pixel \n 60, 1.6x = 0.167µm per pixel \n'... '150, 1x = 0.107µm per pixel \n 150, 1.6x = 0.067µm per pixel'])); uicontrol(... 'Parent', hOpticsPanel,... 'Tag', 'pxSize',... 'Style', 'edit',... 'Units','normalized',... 'Position', [0.71 0.83 0.28 0.08],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'Backgroundcolor', [1 1 1],... 'String', 0.107,... 'Callback', @calcPSF); uicontrol(... 'Parent', hOpticsPanel,... 'Style', 'text',... 'Units','normalized',... 'Position', [0.01 0.72 0.7 0.07],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Emission [nm]:',... 'HorizontalAlignment', 'left'); uicontrol(... 'Parent', hOpticsPanel,... 'Tag', 'emWvlnth',... 'Style', 'edit',... 'Units','normalized',... 'Position', [0.71 0.71 0.28 0.08],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'Backgroundcolor', [1 1 1],... 'String', 567,... 'Callback', @calcPSF); uicontrol(... 'Parent', hOpticsPanel,... 'Style', 'text',... 'Units','normalized',... 'Position', [0.01 0.6 0.7 0.07],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'N.A.:',... 'HorizontalAlignment', 'left'); uicontrol(... 'Parent', hOpticsPanel,... 'Tag', 'NA',... 'Style', 'edit',... 'Units','normalized',... 'Position', [0.71 0.59 0.28 0.08],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'Backgroundcolor', [1 1 1],... 'String', 1.45,... 'Callback', @calcPSF); uicontrol(... 'Parent', hOpticsPanel,... 'Style', 'text',... 'Units','normalized',... 'Position', [0.01 0.48 0.66 0.07],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'PSF Scaling:',... 'HorizontalAlignment', 'left'); uicontrol(... 'Parent', hOpticsPanel,... 'Tag', 'psfScale',... 'Style', 'edit',... 'Units','normalized',... 'Position', [0.71 0.47 0.28 0.08],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'Backgroundcolor', [1 1 1],... 'String', 1.2,... 'Callback', @calcPSF); uicontrol(... 'Parent', hOpticsPanel,... 'Style', 'text',... 'Units','normalized',... 'Position', [0.01 0.36 0.7 0.07],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'PSF Std [px]:',... 'HorizontalAlignment', 'left',... 'ToolTipString', sprintf(['\n'... 'Standard deviation of the Gaussian modelling the \n'... 'Microscope associated Point Spread Function.'])); uicontrol(... 'Parent', hOpticsPanel,... 'Tag', 'psfStd',... 'Style', 'edit',... 'Units','normalized',... 'Position', [0.71 0.35 0.28 0.08],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'Backgroundcolor', [1 1 1],... 'String', 1.03,... 'Enable', 'off'); uicontrol(... 'Parent', hOpticsPanel,... 'Style', 'text',... 'Units','normalized',... 'Position', [0.01 0.24 0.7 0.07],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Counts/Photon:',... 'HorizontalAlignment', 'left'); uicontrol(... 'Parent', hOpticsPanel,... 'Tag', 'cntsPerPhoton',... 'Style', 'edit',... 'Units','normalized',... 'Position', [0.71 0.23 0.28 0.08],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'Backgroundcolor', [1 1 1],... 'String', 20.2); uicontrol(... 'Parent', hOpticsPanel,... 'Tag', 'spatialCorrection',... 'Style', 'checkbox',... 'Units','normalized',... 'Position', [0.01 0.12 0.7 0.07],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'apply spatial correction',... 'Value', false,... 'HorizontalAlignment', 'left',... 'Callback', @setSpatialCorrPath,... 'ToolTipString', sprintf(['\n'... 'If this option is checked the programm will perform \n'... 'a spatial transformation on the particle coordinates\n'... 'when the localization process is finished. \n'... 'The spatial transformation corrects for rotation and transition \n'... 'between image channels'])); end %for else return end %if end function delStack(src, event, hList) bad = get(hList, 'Value'); content = get(hList, 'String'); if isempty(content) return else delete(findobj(get(src,'Parent'),... 'Tag',content{bad})) content(bad) = []; set(hList, 'String', content, 'Value', []) end %if end function moveUpStack(src, event, hList) pos = get(hList, 'Value'); if pos > 1 content = get(hList, 'String'); content(pos-1:pos) = [content(pos); content(pos-1)]; set(hList, 'String', content, 'Value', pos-1) else return end %if end function moveDownStack(src, event, hList) pos = get(hList, 'Value'); content = get(hList, 'String'); if pos < numel(content) content(pos:pos+1) = [content(pos+1); content(pos)]; set(hList, 'String', content, 'Value', pos+1) else return end %if end function updatePanelVisibility(src, event) if isempty(get(src,'String')) return else set(findobj(get(src,'Parent'),... 'Title','Optics',... '-and','Type','Uipanel'),'Visible','off') content = get(src,'String'); set(findobj(get(src,'Parent'),... 'Tag',content{get(src,'Value')},... '-and','Type','Uipanel'),'Visible','on') end end function calcPSF(src,event) hOpticsPanel = get(src,'Parent'); psfStd = str2double(get(findobj(hOpticsPanel,'Tag','psfScale'),'String'))*... 0.55*(0.001*str2double(get(findobj(hOpticsPanel,'Tag','emWvlnth'),'String')))/... str2double(get(findobj(hOpticsPanel,'Tag','NA'),'String'))/1.17/... str2double(get(findobj(hOpticsPanel,'Tag','pxSize'),'String'))/2; set(findobj(hOpticsPanel,... 'Tag','psfStd'),'String',psfStd); end function setSpatialCorrPath(src,event) if get(src,'Value') [tMatName, tMatPath, isOK] = uigetfile(... '*.mat', 'Select spatial Transformationmatrix',... getappdata(0,'searchPath')); if isOK set(src,'UserData',[tMatPath tMatName]) end %if else %clear userdata set(src,'UserData',[]) end %if end function processBatch(src, event, hList) files = get(hList,'String'); for file = 1:numel(files) %Predefined Variables imageBin.isOwn = true; imageBin.isLoaded = true; imageBin.isSuperstack = false; imageBin.isTrack = false; imageBin.frame = 1; %Loc Options hLocPanel = findobj(get(src,'Parent'),... 'Title','Localization', '-and', 'Type', 'Uipanel'); imageBin.locStart = 1; imageBin.locEnd = inf; imageBin.errorRate = str2double(get(findobj(hLocPanel,'Tag','errRate'),'String')); imageBin.w2d = str2double(get(findobj(hLocPanel,'Tag','w2d'),'String')); imageBin.dfltnLoops = str2double(get(findobj(hLocPanel,'Tag','dfltnLoops'),'String')); imageBin.minInt = str2double(get(findobj(hLocPanel,'Tag','minInt'),'String')); imageBin.locParallel = get(findobj(hLocPanel,'Tag','locParallel'),'Value'); imageBin.nCores = get(findobj(hLocPanel,'Tag','nCores'),'Value'); imageBin.isRadiusTol = get(findobj(hLocPanel,'Tag','isRadiusTol'),'Value'); imageBin.radiusTol = str2double(get(findobj(hLocPanel,'Tag','radiusTol'),'String')); imageBin.posTol = str2double(get(findobj(hLocPanel,'Tag','posTol'),'String')); imageBin.maxOptimIter = str2double(get(findobj(hLocPanel,'Tag','maxOptimIter'),'String')); imageBin.termTol = str2double(get(findobj(hLocPanel,'Tag','termTol'),'String')); %Bar Options imageBin.isScalebar = 0; imageBin.micronBarLength = 1000; imageBin.isColormap = 0; imageBin.colormapWidth = 20; imageBin.isTimestamp = 0; imageBin.timestampSize = 2; imageBin.timestampInkrement = 0.032; %Render Options imageBin.exfOld = 5; imageBin.exfNew = 5; imageBin.rW = 50; imageBin.rStep = 10; imageBin.rStart = 1; imageBin.rEnd = inf; imageBin.rLive = false; imageBin.fps = 32; imageBin.movCompression = 1; imageBin.convMode = 1; imageBin.intWeight = 0.01; imageBin.sizeFac = 1; imageBin.isCumsum = false; %Thresh Options imageBin.isThreshLocPrec = false; imageBin.minLoc = 0; imageBin.maxLoc = inf; imageBin.isThreshSNR = false; imageBin.minSNR = 0; imageBin.maxSNR = inf; imageBin.isThreshDensity = false; %Optics Options hOpticsPanel = findobj(get(src,'Parent'),... 'Tag',files{file}, '-and', 'Type', 'Uipanel'); imageBin.pxSize = str2double(get(findobj(hOpticsPanel,'Tag','pxSize'),'String')); imageBin.cntsPerPhoton = str2double(get(findobj(hOpticsPanel,'Tag','cntsPerPhoton'),'String')); imageBin.emWvlnth = str2double(get(findobj(hOpticsPanel,'Tag','emWvlnth'),'String')); imageBin.NA = str2double(get(findobj(hOpticsPanel,'Tag','NA'),'String')); imageBin.psfScale = str2double(get(findobj(hOpticsPanel,'Tag','psfScale'),'String')); imageBin.psfStd = str2double(get(findobj(hOpticsPanel,'Tag','psfStd'),'String')); imageBin.spatialCorrection = get(findobj(hOpticsPanel,'Tag','spatialCorrection'),'Value'); if imageBin.spatialCorrection imageBin.spatialCorrPath = get(findobj(hOpticsPanel,'Tag','spatialCorrection'),'UserData'); end %if imageBin.imageName = files{file}; [imageBin.pathname, imageBin.filename, ext] = fileparts(imageBin.imageName); imageBin.pathname = [imageBin.pathname '\']; startPnt = 1; if 0 for subfile = 1:numel(imageBin.imageName) info = imfinfo(imageBin.imageName{subfile}); imageBin.width = info(1).Width; imageBin.height = info(1).Height; imageBin.roi =... [1 1 imageBin.width imageBin.height]; if file == 1 N = numel(info)-startPnt+1; else startPnt = 1; N = N + numel(info); if N > endPnt endPnt = N - endPnt; end %if end %if imageBin = localizeParticles(imageBin.imageName{subfile},roi,... startPnt,endPnt,info,imageBin); end %for else info = imfinfo(imageBin.imageName); endPnt = numel(info); imageBin.width = info(1).Width; imageBin.height = info(1).Height; imageBin.roi =... [1 1 imageBin.width imageBin.height]; imageBin.ctrsN = localizeParticles(imageBin.imageName,... startPnt,endPnt,info,imageBin); end %if %save localization matrix save ([imageBin.pathname... imageBin.filename '.mat'], 'imageBin') clear imageBin end %for msgbox('Done!') end end function ctrsN = localizeParticles(... imagename,startPnt,endPnt,info,imageBin) region = {[imageBin.roi(2) imageBin.roi(2)+imageBin.roi(4)-1],... [imageBin.roi(1) imageBin.roi(1)+imageBin.roi(3)-1]}; if imageBin.locParallel %startPnt localization procedure data = cell(endPnt-startPnt+1,1); ctrsN = cell(endPnt-startPnt+1,1); switch imageBin.nCores case 1 matlabpool local case 2 matlabpool 2 case 3 matlabpool 3 end %switch roiWidth = imageBin.roi(3); roiHeight = imageBin.roi(4); w2d = imageBin.w2d; psfStd = imageBin.psfStd; errorRate = imageBin.errorRate; dfltnLoops = imageBin.dfltnLoops; minInt = imageBin.minInt; optim = [imageBin.maxOptimIter,imageBin.termTol,... imageBin.isRadiusTol,imageBin.radiusTol,... imageBin.posTol]; parfor frame = startPnt:endPnt [data{frame} unused unused ctrsN{frame}] = ... detect_et_estime_part_1vue_deflt(... double(imread(imagename,... frame, 'info', info, 'PixelRegion', region)),... w2d, psfStd,chi2inv(1-1/10^(errorRate*-1),1),... dfltnLoops,roiWidth,roiHeight,minInt,optim); end %for matlabpool close time = []; for frame = startPnt:endPnt time = [time;ones(ctrsN{frame},1)*frame]; end %for data = [vertcat(data{:}) time]; if imageBin.spatialCorrection data(:,1:2) = fliplr(tformfwd(imageBin.tMat,data(:,2),data(:,1))); bad = data(:,2)<=roi(1) & data(:,2)>=roi(1)+roi(3)-1 &... data(:,1)<=roi(2) & data(:,1)>=roi(2)+roi(4)-1; data(bad,:) = []; end %if streamToDisk(data,... [imageBin.pathname imageBin.filename]) ctrsN = vertcat(ctrsN{:}); else %linear computation iter = 0; hProgressbar = waitbar(0,'Localization...','Color',... get(0,'defaultUicontrolBackgroundColor')); for frame = startPnt:endPnt iter = iter+1; I = imread(imagename,... frame, 'info', info, 'PixelRegion', region); optim = [imageBin.maxOptimIter,imageBin.termTol,... imageBin.isRadiusTol,imageBin.radiusTol,... imageBin.posTol]; [data deflatedIm binaryIm ctrsN(iter,1)] = ... detect_et_estime_part_1vue_deflt(... double(I),imageBin.w2d, imageBin.psfStd,... chi2inv(1-1/10^(imageBin.errorRate*-1),1),... imageBin.dfltnLoops,imageBin.roi(3),... imageBin.roi(4),imageBin.minInt,optim); if 0 imwrite(uint16(deflatedIm),... [imagename(1:end-4) '_deflated.tif'],... 'compression','none','writemode','append') imwrite(uint16(binaryIm),... [imagename(1:end-4) '_binary.tif'],... 'compression','none','writemode','append') end if imageBin.rLive if frame == startPnt fig =... figure(... 'Units','normalized',... 'Position', figPos(imageBin.roi(3)/imageBin.roi(4)),... 'Color', get(0,'defaultUicontrolBackgroundColor'),... 'Name', 'Live Localization',... 'NumberTitle', 'off',... 'MenuBar', 'none',... 'ToolBar', 'none'); ax =... axes(... 'Parent', fig,... 'Units','normalized',... 'Position', [0 0 1 1]); liveView = imshow(imadjust(I),[]); rho = [0;0.69;1.39;2.09;2.79;3.49;4.18;4.88;5.58;6.28]; hDots = patch(repmat(1+data(:,2)',10,1)+cos(rho)*data(:,6)',... repmat(1+data(:,1)',10,1)+sin(rho)*data(:,6)',... repmat(shiftdim([1 0 0],-1),1,ctrsN(iter)),... 'EdgeColor', 'none', 'FaceAlpha', 0.5,... 'Parent', ax); drawnow elseif frame == endPnt set(liveView, 'CData', imadjust(I)) rho = [0;0.69;1.39;2.09;2.79;3.49;4.18;4.88;5.58;6.28]; set(hDots, 'XData', repmat(1+data(:,2)',10,1)+... cos(rho)*data(:,6)', 'YData', repmat(1+data(:,1)',10,1)+... sin(rho)*data(:,6)', 'CData', repmat(shiftdim([1 0 0],-1),1,... ctrsN(iter))) drawnow close(fig) else set(liveView, 'CData', imadjust(I)) rho = [0;0.69;1.39;2.09;2.79;3.49;4.18;4.88;5.58;6.28]; set(hDots, 'XData', repmat(1+data(:,2)',10,1)+... cos(rho)*data(:,6)', 'YData', repmat(1+data(:,1)',10,1)+... sin(rho)*data(:,6)', 'CData', repmat(shiftdim([1 0 0],-1),1,... ctrsN(iter))) drawnow end %if end %if %correct for imageBin.roi(crop) %data(:,1:2) = [data(:,1)+imageBin.roi(2)-1,data(:,2)+imageBin.roi(1)-1]; %apply a nonreflective similarity transformation (correct for %scale, rotation and translation) if imageBin.spatialCorrection data(:,1:2) = fliplr(tformfwd(imageBin.tMat,data(:,2),data(:,1))); bad = data(:,2)<=imageBin.roi(1) & data(:,2)>=imageBin.roi(1)+imageBin.roi(3)-1 &... data(:,1)<=imageBin.roi(2) & data(:,1)>=imageBin.roi(2)+imageBin.roi(4)-1; data(bad,:) = []; end %if streamToDisk([data ones(ctrsN(iter),1)*frame],... [imageBin.pathname imageBin.filename]) waitbar(iter/(endPnt-startPnt+1),hProgressbar,... 'Localization...','Color',... get(0,'defaultUicontrolBackgroundColor')); end %for delete(hProgressbar) end %if function streamToDisk(data,outputname) %stream data to harddisc fidY = fopen([outputname '.ctrsY'], 'a+'); fidX = fopen([outputname '.ctrsX'], 'a+'); fidSignal = fopen([outputname '.signal'], 'a+'); fidNoise = fopen([outputname '.noise'], 'a+'); fidOffset = fopen([outputname '.offset'], 'a+'); fidRadius = fopen([outputname '.radius'], 'a+'); fidFrame = fopen([outputname '.frame'], 'a+'); fwrite(fidY,data(:,1),'real*8'); %y-coordinate fwrite(fidX,data(:,2),'real*8'); %x-coordinate fwrite(fidSignal,data(:,3)/sqrt(pi)./data(:,6),'real*8'); %peak amplitude fwrite(fidNoise,sqrt(data(:,4)),'real*8'); %noise std fwrite(fidOffset,data(:,5),'real*8'); %background level fwrite(fidRadius,data(:,6),'real*8'); %gaussian radius. fwrite(fidFrame,data(:,8),'real*8'); %detected frame fclose('all'); end end function [lestime, input_deflt, dfin, ctrsN] =... detect_et_estime_part_1vue_deflt(input, wn, r0, pfa, n_deflt,... w,h,minInt,optim) [lest,ldec,dfin] = detect_et_estime_part_1vue (input, wn, r0, pfa, optim) ; input_deflt = deflat_part_est(input, lest, wn); lestime = lest ; if n_deflt == 0 border = ceil(wn/2); good = lestime(:,7) & ... (lestime(:,4)/sqrt(pi)./lestime(:,6)>minInt) & ... (lestime(:,1)>border) & (lestime(:,1)border) & (lestime(:,2)minInt) & ... (lestime(:,1)>border) & (lestime(:,1)border) & (lestime(:,2) Ni-bord) || ... (ldetect(n,detect_j) < bord) || (ldetect(n,detect_j) > Nj-bord) ; if ((ldetect(n,alpha) > 0.0) && (~test_bord) ) Nestime = Nestime + 1 ; lestime(Nestime, :) = estim_param_part_GN(input, wn, ldetect(n,:), r0, optim) ; end%if end%for % a la bonne taille if (Nestime==0) lestime = zeros(1,Nparam) ; else lestime = lestime(1:Nestime,:) ; end%if end%function function [carte_MV, liste_detect, detect_pfa] = carte_H0H1_1vue(im, rayon, wn_x, wn_y, s_pfa) [N,M] = size(im) ; T = wn_x*wn_y ; % nombre de pixel dans la fenetre %% Hypothese H0 %% pas de particule dans la fenetre m = ones(wn_x,wn_y) ; hm = expand_w(m, N, M) ; tfhm = fft2(hm) ; tfim = fft2(im) ; m0 = real(fftshift(ifft2(tfhm .* tfim))) /T ; im2 = im .* im ; tfim2 = fft2(im2) ; Sim2 = real(fftshift(ifft2(tfhm .* tfim2))); %% H0 = T/2*log(2*pi*sig0^2)-T/2 ; T_sig0_2 = Sim2 - T*m0.^2 ; %% Hypothèse H1 %% une particule est au centre de la fenetre %% amplitude inconnue, rayon fixe %% generation masque gaussien de largeur (sigma) %% egal a rayon %%g = gausswin2(rayon, wn_x, wn_y) ; g = gausswin2(rayon, wn_x, wn_y, 0, 0) ; gc = g - sum(g(:))/T ; Sgc2 = sum(gc(:).^2) ; hgc = expand_w(gc, N, M) ; tfhgc = fft2(hgc) ; alpha = real(fftshift(ifft2(tfhgc .* tfim))) / Sgc2 ; %% H1 = T/2*log(2*pi*sig1^2)-T/2 ; %%sig1_2 = sig0_2 - alpha.^2 * Sgc2 / T ; %% pour test %sig1_2 = T_sig0_2/T - alpha.^2 * Sgc2 / T ; %%imagesc(T_sig0_2/T); %imagesc(sig1_2); %%imagesc(sig1_2 ./ (T_sig0_2/T)); %% carte_MV = -0.5*(H0 - H1) ; % carte_MV = - T * log(1 - (Sgc2 * alpha.^2) ./ T_sig0_2) ; test = 1 - (Sgc2 * alpha.^2) ./ T_sig0_2 ; test = (test > 0) .* test + (test <= 0) ; carte_MV = - T * log(test) ; carte_MV(isnan(carte_MV)) = 0; %CPR %% detection et recherche des maximas %% s_pfa = 28 ; detect_masque = carte_MV > s_pfa ; if (sum(detect_masque(:))==0) % warning('No target detected !') ; %#ok liste_detect = zeros(1,6) ; detect_pfa = zeros(size(detect_masque)) ; % ajout AS 4/12/7 else detect_pfa = all_max_2d(carte_MV) & detect_masque ; [di, dj] = find(detect_pfa) ; n_detect = size(di, 1) ; vind = N*(dj-1)+di ; valpha = alpha(:) ; alpha_detect = valpha(vind) ; sig1_2 = ( T_sig0_2 - alpha.^2 * Sgc2 ) / T ; vsig1_2 = sig1_2(:) ; sig2_detect = vsig1_2(vind) ; %% g de puissance unitaire %%RSBdB_detect = 10*log10(alpha_detect.^2 ./ sig2_detect) ; %%liste_detect = [(1:n_detect)', di, dj, alpha_detect, sqrt(sig2_detect), RSBdB_detect] ; liste_detect = [(1:n_detect)', di, dj, alpha_detect, sig2_detect, rayon*ones(n_detect,1),ones(n_detect,1)] ; end%if end %function function out = expand_w(in, N, M) [N_in, M_in] = size(in) ; out = zeros(N,M) ; %nc = 1+floor(N/2 - N_in/2) ; %mc = 1+floor(M/2 - M_in/2) ; %out(nc:(nc+N_in-1) , mc:(mc+M_in-1)) = in ; nc = floor(N/2 - N_in/2) ; mc = floor(M/2 - M_in/2) ; out((nc+1):(nc+N_in) , (mc+1):(mc+M_in)) = in ; end %function function carte_max = all_max_2d(input) [N,M] = size(input) ; ref = input(2:N-1, 2:M-1) ; pos_max_h = input(1:N-2, 2:M-1) < ref & ... input(3:N , 2:M-1) < ref; pos_max_v = input(2:N-1, 1:M-2) < ref & ... input(2:N-1, 3:M ) < ref; pos_max_135 = input(1:N-2, 1:M-2) < ref & ... input(3:N , 3:M ) < ref; pos_max_45 = input(3:N , 1:M-2) < ref & ... input(1:N-2, 3:M ) < ref; carte_max = zeros(N,M) ; carte_max(2:N-1, 2:M-1) = pos_max_h & pos_max_v & pos_max_135 & pos_max_45 ; carte_max = carte_max .* input ; end %function function liste_param = estim_param_part_GN(im, wn, liste_info_param, r0, optim) Pi = liste_info_param(2) ; Pj = liste_info_param(3) ; di = (1:wn)+Pi-floor(wn/2) ; dj = (1:wn)+Pj-floor(wn/2) ; im_part = im(di, dj) ; if 0 options = optimset(... 'Algorithm', 'Active-Set',... 'Display','off',... 'UseParallel', 'always'); if 0 guess = [0,0,r0]; bounds = [-1.5,-1.5,r0-r0*0.1;1.5,1.5,r0+r0*0.6]; liste_param = gaussMLE(im_part,guess,bounds,options); else guess = [0,0,r0,0,r0]; bounds = [-1.5,-1.5,r0-r0*0.1,0,r0-r0*0.1;... 1.5,1.5,r0+r0*0.6,0.8,r0+r0*0.6]; liste_param = gaussEllipticMLE(im_part,guess,bounds,options); end liste_param(1:2) = liste_param(1:2)+[Pi Pj]; else %limits for optimization bornes_ijr(1) = -optim(5) ; bornes_ijr(2) = optim(5) ; bornes_ijr(3) = -optim(5) ; bornes_ijr(4) = optim(5) ; bornes_ijr(5) = r0-optim(4)*r0/100 ; bornes_ijr(6) = r0+optim(4)*r0/100 ; r = r0 ; i = 0.0 ; j = 0.0 ; dr = 1 ; di = 1 ; dj = 1 ; fin = 10^optim(2) ; sig2 = inf ; cpt = 0 ; test = 1 ; ITER_MAX = optim(1) ; while (test) %%[r, i, j, dr, di, dj, alpha, sig2] = deplt_GN_estimation (r, i, j, im_part) ; [r, i, j, dr, di, dj, alpha, sig2, offset] = deplt_GN_estimation (r, i, j, im_part, sig2, dr, di, dj, optim) ; cpt = cpt + 1 ; if optim(3) test = max([abs(di), abs(dj), abs(dr)]) > fin ; else test = max([abs(di), abs(dj)]) > fin ; end %if if (cpt > ITER_MAX) test = 0 ; end%if %% on stop si l_on sort des bornes result_ok = ~((i < bornes_ijr(1)) || (i > bornes_ijr(2)) || ... (j < bornes_ijr(3)) || (j > bornes_ijr(4)) || ... (r < bornes_ijr(5)) || (r > bornes_ijr(6)) ) ; test = test & result_ok ; end%while % liste_info_param = [num, i, j, alpha, sig^2] % liste_param = [num, i, j, alpha, sig^2, rayon, ok] liste_param = [Pi+i , ... %y-coordinate Pj+j , ... %x-coordinate alpha , ... %mean amplitude sig2 , ... %noise power offset, ... %background level r , ... %r0 result_ok ]; end %if end%fonction function [n_r, n_i, n_j, dr, di, dj, alpha, sig2 m] = ... deplt_GN_estimation(p_r, p_i, p_j, x, sig2init, p_dr, p_di, p_dj, optim) %% p_di, p_dj les precedents deplacements %% qui ont conduit a p_r, p_i, p_j r0 = p_r ; i0 = p_i ; j0 = p_j ; prec_rel = 10^optim(2) ; verif_crit = 1 ; pp_r = r0 - p_dr ; pp_i = i0 - p_di ; pp_j = j0 - p_dj ; [wn_i, wn_j] = size(x) ; N = wn_i * wn_j ; refi = 0.5 + (0:(wn_i-1)) - wn_i/2 ; refj = 0.5 + (0:(wn_j-1)) - wn_j/2 ; %% on boucle, en diminuant les deplacements %% tand que le nouveau critere en plus grand again = 1 ; while (again) i = refi - i0 ; j = refj - j0 ; ii = i' * ones(1,wn_j) ; %' jj = ones(wn_i,1) * j ; %% puissance unitaire iiii = ii.*ii ; jjjj = jj.*jj ; iiii_jjjj = iiii + jjjj ; g = (1/(sqrt(pi)*r0)) * exp(-(1/(2*r0^2))*(iiii_jjjj)) ; gc = g - sum(g(:))/N ; Sgc2 = sum(gc(:).^2) ; g_div_sq_r0 = inv(r0^2) * g ; %% alpha estime MV if (Sgc2 ~= 0) alpha = sum(sum(x .* gc)) / Sgc2 ; else alpha = 0 ; end%if %% m estime MV x_alphag = x - alpha.*g ; m = sum(sum(x_alphag))/N ; err = x_alphag - m ; %% critere avant deplacement sig2 = sum(sum(err.^2)) / N ; if ((verif_crit) && (sig2 > sig2init)) p_di = p_di / 10.0 ; p_dj = p_dj / 10.0 ; i0 = pp_i + p_di ; j0 = pp_j + p_dj ; if optim(3) p_dr = p_dr / 10.0 ; r0 = pp_r + p_dr ; else p_dr = 0; r0 = pp_r; end %if if (max([abs(p_dr), abs(p_di), abs(p_dj)]) > prec_rel) % if (max([abs(p_di), abs(p_dj)]) > prec_rel) n_r = p_r ; n_i = p_i ; n_j = p_j ; dr = 0 ; di = 0 ; dj = 0 ; return ; end%if else again = 0 ; end%if end%while %% der_g der_g_i0 = ii .* g_div_sq_r0 ; der_g_j0 = jj .* g_div_sq_r0 ; %% derder_g derder_g_i0 = (-1 + inv(r0^2)*iiii) .* g_div_sq_r0 ; derder_g_j0 = (-1 + inv(r0^2)*jjjj) .* g_div_sq_r0 ; %% der_J /2 der_J_i0 = alpha * sum(sum(der_g_i0 .* err)) ; der_J_j0 = alpha * sum(sum(der_g_j0 .* err)) ; %% derder_J /2 derder_J_i0 = alpha * sum(sum(derder_g_i0 .* err)) - alpha^2 * sum(sum(der_g_i0.^2)) ; derder_J_j0 = alpha * sum(sum(derder_g_j0 .* err)) - alpha^2 * sum(sum(der_g_j0.^2)) ; %% deplacement par Gauss-Newton if optim(3) der_g_r0 = (-inv(r0) + inv(r0^3)*(iiii_jjjj)) .* g ; derder_g_r0 = (1 - 3*inv(r0^2)*iiii_jjjj) .* g_div_sq_r0 ... + (-inv(r0) + inv(r0^3)*(iiii_jjjj)) .* der_g_r0 ; der_J_r0 = alpha * sum(sum(der_g_r0 .* err)) ; derder_J_r0 = alpha * sum(sum(derder_g_r0 .* err)) - alpha^2 * sum(sum(der_g_r0.^2)) ; dr = - der_J_r0 / derder_J_r0 ; n_r = abs(r0 + dr) ; %% r0 > 0 else dr = 0; n_r = r0; end %if di = - der_J_i0 / derder_J_i0 ; dj = - der_J_j0 / derder_J_j0 ; n_i = i0 + di ; n_j = j0 + dj ; end %function function output = deflat_part_est(input, liste_est, wn) [idim, jdim] = size(input) ; nb_part = size(liste_est, 1) ; output = input ; %% parametre dans liste_est : %% liste_param = [num, i, j, alpha, sig^2, rayon, ok] for part=1:nb_part if (liste_est(part, 7) == 1) i0 = liste_est(part, 1) ; j0 = liste_est(part, 2) ; alpha = liste_est(part, 3) ; r0 = liste_est(part, 6) ; wn = ceil(6*r0); % by CPR: 99% of Gaussian pos_i = round(i0) ; dep_i = i0 - pos_i ; pos_j = round(j0) ; dep_j = j0 - pos_j ; alpha_g = alpha * gausswin2(r0, wn, wn, dep_i, dep_j) ; dd = (1:wn) - floor(wn/2) ; di = dd + pos_i ; iin = di > 0 & di < idim+1; dj = dd + pos_j ; jin = dj > 0 & dj < jdim+1; output(di(iin), dj(jin)) = ... output(di(iin), dj(jin)) - alpha_g(iin,jin) ; end%if end%for end%function function g = gausswin2(sig, wn_i, wn_j, offset_i, offset_j) if (nargin < 5) offset_i = 0.0 ; offset_j = 0.0 ; end%if if (nargin < 3) wn_j = wn_i ; end%if refi = 0.5 + (0:(wn_i-1)) - wn_i/2 ; i = refi - offset_i ; refj = 0.5 + (0:(wn_j-1)) - wn_j/2 ; j = refj - offset_j ; ii = i' * ones(1,wn_j) ; %' jj = ones(wn_i,1) * j ; %%% puissance unitaire g = (1/(sqrt(pi)*sig)) * exp(-(1/(2*sig^2))*(ii.*ii + jj.*jj)) ; end %function function output = gaussMLE(raw,guess,bounds,options) [wn_i, wn_j] = size(raw) ; N = wn_i * wn_j ; refi = 0.5 + (0:(wn_i-1)) - wn_i/2 ; refj = 0.5 + (0:(wn_j-1)) - wn_j/2 ; alpha = []; m = []; [x,fval,flag] = fmincon(@modelfun,guess,[],[],[],[],... bounds(1,:),bounds(2,:),[],options); output = [x(1) x(2) alpha fval m x(3) flag-flag+1]; function sig2 = modelfun(x) i = refi - x(1) ; j = refj - x(2) ; ii = i' * ones(1,wn_j) ; jj = ones(wn_i,1) * j ; %% noise model iiii = ii.*ii ; jjjj = jj.*jj ; iiii_jjjj = iiii + jjjj ; g = (1/(sqrt(pi)*x(3)))*... exp(-(1/(2*x(3)^2))*(iiii_jjjj)) ; gc = g - sum(g(:))/N ; Sgc2 = sum(gc(:).^2) ; %% mean amplitude alpha = sum(sum(raw .* gc)) / Sgc2 ; %% offset x_alphag = raw - alpha.*g ; m = sum(sum(x_alphag))/N ; %% residuals err = x_alphag - m ; %% noise power sig2 = sum(sum(err.^2)) / N ; end end function output = gaussEllipticMLE(raw,guess,bounds,options) [wn_i, wn_j] = size(raw) ; N = wn_i * wn_j ; refi = 0.5 + (0:(wn_i-1)) - wn_i/2 ; refj = 0.5 + (0:(wn_j-1)) - wn_j/2 ; ii = refi' * ones(1,wn_j) ; jj = ones(wn_i,1) * refj ; %% noise model iiii = ii.*ii ; jjjj = jj.*jj ; iiii_jjjj = iiii + jjjj ; alpha = []; m = []; [x,fval,flag] = fmincon(@modelfun,guess,[],[],[],[],... bounds(1,:),bounds(2,:),[],options); output = [x(1) x(2) alpha fval m x(3) flag-flag+1]; [V, D] = eig([x(3),x(4);x(4),x(5)]); t = linspace(0, 2*pi, 20); u = [cos(t(:))'; sin(t(:))']; w = (V * sqrt(D)) * u; z = repmat([x(1); x(2)], [1 20]) + w; figure; imagesc(raw) colormap gray patch(z(1,:)+5,z(2,:)+5,[1 0 0],... 'FaceAlpha', 0.6) waitforbuttonpress delete(gcf) function sig2 = modelfun(x) g = reshape(2*sqrt(pi)*... mvnpdf(sqrt([iiii(:) jjjj(:)]),... [x(1) x(2)],[x(3),x(4);x(4),x(5)]),... [wn_i, wn_j]) ; gc = g - sum(g(:))/N ; Sgc2 = sum(gc(:).^2) ; %% mean amplitude alpha = sum(sum(raw .* gc)) / Sgc2 ; %% offset x_alphag = raw - alpha.*g ; m = sum(sum(x_alphag))/N ; %% residuals err = x_alphag - m ; %% noise power sig2 = sum(sum(err.^2)) / N ; end end %% TRACKING function buildTracks(src,event) global tab_param ; global tab_var ; global tab_moy ; fig = gcbf; settings.Width = getappdata(fig,'width'); settings.Height = getappdata(fig,'height'); settings.px2micron = getappdata(fig,'pxSize'); settings.Delay = getappdata(fig,'frameSize')/1000; seuil_detec_1vue = chi2inv(1-10^getappdata(fig,'errorRate'),1); settings.TrackingOptions.FinalDetectionTresh = seuil_detec_1vue; wn = getappdata(fig,'w2d'); settings.TrackingOptions.SizeDetectionBox = wn; r0 = getappdata(fig,'psfStd'); settings.TrackingOptions.GaussianRadius = r0; seuil_alpha = getappdata(fig,'minInt'); settings.TrackingOptions.ValidationTresh = seuil_alpha; nb_defl = getappdata(fig,'dfltnLoops'); settings.TrackingOptions.NumberDeflationLoops = nb_defl; T = getappdata(fig,'statWin'); settings.TrackingOptions.AvaragingTimeWindow = T; assignin('base', 'T', T) T_off = getappdata(fig,'maxOffTime')*-1; settings.TrackingOptions.BlinkingProbability = T_off; assignin('base', 'T_off', T_off) sig_free = sqrt(getappdata(fig,'Dmax')/... getappdata(fig,'pxSize')^2*... 4*getappdata(fig,'frameSize')/1000); settings.TrackingOptions.MaxDiffusionCoefficient =... getappdata(fig,'Dmax'); assignin('base', 'sig_free', sig_free) Boule_free = getappdata(fig,'searchExpFac'); settings.TrackingOptions.ResearchDiameter = Boule_free; assignin('base', 'Boule_free', Boule_free) Nb_combi = getappdata(fig,'maxComp'); settings.TrackingOptions.CombinationTresh = Nb_combi; assignin('base', 'Nb_combi', Nb_combi) Poids_melange_aplha = getappdata(fig,'intLawWeight'); settings.TrackingOptions.WeightUniformGaussianLaw = Poids_melange_aplha; assignin('base', 'Poids_melange_aplha', Poids_melange_aplha) Poids_melange_diff = getappdata(fig,'diffLawWeight'); settings.TrackingOptions.WeightMaxLocalDiffusion = Poids_melange_diff; assignin('base', 'Poids_melange_diff', Poids_melange_diff) ctrsN = getappdata(fig,'ctrsN'); Nb_STK = numel(ctrsN); assignin('base', 'Nb_STK', Nb_STK) %t == T-T_off dans les tab_x reduits t_red = T-T_off ; assignin('base', 't_red', t_red) filename = getappdata(fig,'imageName'); info = imfinfo(filename); im_t = double(imread(filename, 1, 'info', info)) ; assignin('base', 'im_t', im_t) idx = [-1; cumsum(getappdata(fig,'ctrsN'))]; if getappdata(fig,'trackStart') == 1 setappdata(fig,'startPnt',0) else setappdata(fig,'startPnt',... idx(getappdata(fig,'trackStart'))+1) end %if if isinf(getappdata(fig,'trackEnd')) setappdata(fig,'trackEnd',... numel(getappdata(fig,'ctrsN'))) setappdata(fig,'elements',inf) else setappdata(fig,'elements',... idx(getappdata(fig,'trackEnd')+1)-... max(1,getappdata(fig,'startPnt'))+1) end %if settings.Frames = getappdata(fig,'trackEnd')-... getappdata(fig,'trackStart')+1; %get ROI roi = getappdata(fig,'roi'); data = preprocessData(fig,[1 1 1 1 1 1 1 0 0 0 0 0],roi); trackID = 1:size(data.signal); hProgressbar = waitbar(0,['Processing Frame: ' num2str(1) ':'... num2str(Nb_STK)],'Color', get(0,'defaultUicontrolBackgroundColor')); for t = getappdata(fig,'trackStart'):getappdata(fig,'trackEnd') %first iteration if t == getappdata(fig,'trackStart') %fake detection list ind_valid = data.frame == 1; par_per_frame(t) = sum(ind_valid); lest = [(1:par_per_frame(t))' data.ctrsY(ind_valid) data.ctrsX(ind_valid)... data.signal(ind_valid)*sqrt(pi).*data.radius(ind_valid)... data.noise(ind_valid).^2 data.radius(ind_valid) ones(par_per_frame(t),1)]; %preallocate tables tab_param = zeros(par_per_frame(t), 1+7*(t_red+1)); tab_var = tab_param; %tab_moy = zeros(ctrsN, 1+7*(t_red+1)) ; %% initialize parameter tables tab_param(:,1) = (1:par_per_frame(t))' ; tab_param(:,2+7*(t_red-1):1+7*(t_red)) = [ones(par_per_frame(t),1), ... lest(:,[2,3,4,6]), zeros(par_per_frame(t),1), Nb_STK*ones(par_per_frame(t),1)]; tab_param(:,2+7*(t_red)) = 2*ones(par_per_frame(t),1) ; tab_var(:,1) = (1:par_per_frame(t))' ; tab_var(:,2+7*(t_red-1):1+7*(t_red)) = [ones(par_per_frame(t),1), ... zeros(par_per_frame(t),4), lest(:,5), Nb_STK*ones(par_per_frame(t),1)]; tab_var(:,2+7*(t_red)) = 2*ones(par_per_frame(t),1) ; tab_moy = tab_var ; %% set initial variance guess (20% by default) -> nested by CPR init_tab; %% initialize tracks trackList = cell(1,par_per_frame(t)); for track = tab_param(:,1)' if tab_param(track,1+7*(t_red))>0 trackList{trackID(track)}(1,:) =... [tab_param(track,7*(t_red-1)+[4 3 2])... trackID(track) tab_param(track,7*(t_red-1)+5)... tab_var(track,7*(t_red-1)+[7 3 5])]; end %if end %for continue end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% CYCLE THROUGH ACTIVE TRAJECTORIES %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% im_t = double(imread(filename, t, 'info', info)) ; assignin('base', 'im_t', im_t) ind_valid = data.frame == t; par_per_frame(t) = sum(ind_valid); lest = [(1:sum(ind_valid))' data.ctrsY(ind_valid) data.ctrsX(ind_valid)... data.signal(ind_valid)*sqrt(pi).*data.radius(ind_valid)... data.noise(ind_valid).^2 data.radius(ind_valid) ones(par_per_frame(t),1)]; nb_traj_active = 0 ; nb_traj_blink = 0 ; isClosed = (tab_param(:,7*(t_red-1)+8) == T_off); if any(isClosed) trackID(find(isClosed)) = []; tab_param(isClosed,:) = []; tab_var(isClosed,:) = []; tab_moy(isClosed,:) = []; end %if if ~isempty(tab_param) tab_param(:,1) = 1:size(tab_param,1); tab_var(:,1) = tab_param(:,1); tab_moy(:,1) = tab_param(:,1); %from longest ON to longest OFF(blink) [unused, part_ordre_blk] = sort(-tab_param(:,7*(t_red-1)+8)) ; for traj = part_ordre_blk' %% reconnection test if (tab_param(traj, 7*(t_red-1)+8) > T_off) part = reconnect_part(traj, t_red-1, lest, wn) ; nb_traj_active = nb_traj_active + 1 ; if part == 0 nb_traj_blink = nb_traj_blink + 1 ; %counts # of trajectories with BLINK status end%if else %no testing if trajectory is already terminated part = 0; end %if %% update tables if (part>0) tab_param(traj, 7*(t_red)+[3 4 5 6]) =... lest(part, [2 3 4 6]); tab_var(traj, 7*(t_red)+7) = lest(part, 5); if (tab_param(traj, 7*(t_red-1)+8) > 0) %trajectory was not OFF [LV_traj_part, flag_full_alpha] = rapport_detection(traj, t_red-1, lest, part, wn) ; %increase BLINK value by Nb_STK tab_param(traj, 7*(t_red)+8) = tab_param(traj, 7*(t_red-1)+8) + Nb_STK ; if (flag_full_alpha==1) %full ON %increase BLINK value by 1 tab_param(traj, 7*(t_red)+8) = tab_param(traj, 7*(t_red)+8) + 1 ; else tab_param(traj, 7*(t_red)+8) = ... tab_param(traj, 7*(t_red)+8) - mod(tab_param(traj, 7*(t_red)+8), Nb_STK); end%if else %set BLINK value to initial ON value tab_param(traj, 7*(t_red)+8) = Nb_STK ; end %if else tab_param(traj, 7*(t_red)+[3 4 5 6]) =... [tab_param(traj, 7*(t_red-1)+[3 4]) 0 0]; tab_var(traj, 7*(t_red)+7) = 0; %decrease BLINK value if (tab_param(traj, 7*(t_red-1)+8) < 0) tab_param(traj, 7*(t_red)+8) = tab_param(traj, 7*(t_red-1)+8)-1; %blink -1 else %set BLINK value to initial OFF value tab_param(traj, 7*(t_red)+8) = -1 ; end %if %% 11/07/06 %% test for ephemerid detection if (t>3) if (tab_param(traj, 7*(t_red-2)+8) == 0) tab_param(traj, 7*(t_red)+8) = T_off ; end %if end %if end %if %take reconnected particle out of game if (part>0) lest(part, 2) = -lest(part, 2) ; lest(part, 3) = -lest(part, 3) ; end %if end %for end %if % nb_traj_on = sum(tab_param(:, 7*(t_red)+8) > 0) ; % set(h.activeTracksInfo,'String', sprintf('# elongated Trajectories: %g',nb_traj_on)) % nb_traj_off = sum(tab_param(:, 7*(t_red)+8) <= T_off); % set(h.terminatedTracksInfo,'String', sprintf('# terminated Trajectories: %g',nb_traj_off)) % set(h.blinkingTracksInfo,'String', sprintf('# blinking Trajectories: %g',... % sum(tab_param(:, 7*(t_red)+8) < 0)-nb_traj_off)) %nb_non_affectees = sum(lest(:,2) > 0) ; % # particles not belonging to a trajectory nb_traj_avant_new = size(tab_param, 1) ; %check on particles not assigned to an active trajectory %and in case initiate a new one nb_non_aff_detect = false(par_per_frame(t),1); for p=1:par_per_frame(t) if (lest(p, 2) > 0) glrt_1vue = rapport_detection(0, 0, lest, p, wn) ; if ((glrt_1vue > seuil_detec_1vue) && (lest(p,4)/(sqrt(pi)*r0) > seuil_alpha)) nb_non_aff_detect(p) = true; end %if end %if end %for new_traj = sum(nb_non_aff_detect) ; % set(h.newTracksInfo,'String', sprintf('# initiated Trajectories: %g',new_traj)) tab_param_new = [(1:new_traj)'+nb_traj_avant_new, zeros(new_traj,7*(t_red)),... [ones(new_traj,1)*t, lest(nb_non_aff_detect, [2 3 4 6]),... zeros(new_traj,1) ones(new_traj,1)*Nb_STK]]; %by CPR tab_param = [tab_param; tab_param_new]; tab_var = [tab_var; zeros(new_traj,7*(t_red+1)+1)]; tab_moy = [tab_moy; zeros(new_traj,7*(t_red+1)+1)]; tab_var((1:new_traj)+nb_traj_avant_new, 7*(t_red)+7) =... lest(nb_non_aff_detect, 5) ; %sig2_b %% shift tables one step to the left new_nb_traj = size(tab_param, 1) ; tab_param = [tab_param(:,1), ... tab_param(:,2+7*(1):1+7*(t_red+1)), ... (t+1)*ones(new_nb_traj,1), zeros(new_nb_traj,6)] ;%correction arnauld tab_var = [tab_var(:,1), ... tab_var(:,2+7*(1):1+7*(t_red+1)), ... (t+1)*ones(new_nb_traj,1), zeros(new_nb_traj,6)] ; tab_moy = [tab_moy(:,1), ... tab_moy(:,2+7*(1):1+7*(t_red+1)), ... (t+1)*ones(new_nb_traj,1), zeros(new_nb_traj,6)] ; init_tab((1+nb_traj_avant_new):new_nb_traj) ; %nested by CPR; mise_a_jour_tab %nested by CPR; %% update tracks trackList = [trackList cell(1,new_traj)]; for track = tab_param(:,1)' if tab_param(track,1+7*(t_red))>0 trackList{trackID(track)}(end+1,:) =... [tab_param(track,7*(t_red-1)+[4 3 2])... trackID(track) tab_param(track,7*(t_red-1)+5)... tab_var(track,7*(t_red-1)+[7 3 5])]; end %if end %for waitbar(t/Nb_STK,hProgressbar,['Processing Frame: ' num2str(t) ':'... num2str(Nb_STK)],'Color',get(0,'defaultUicontrolBackgroundColor')); end %%for delete(hProgressbar) [filename,pathname,isOK] =... uiputfile('.mat' ,'Save Tracking Data to',... [getappdata(0,'searchPath')... getappdata(fig,'filename') '_tracked']); settings.Filename = [pathname filename]; if isOK setappdata(0,'searchPath',pathname) clear('data') data.tr = trackList; par_per_frame = ctrsN; save ([pathname filename],... 'data', 'settings', 'par_per_frame') end %if function init_tab(new_traj) % EN/ initialisation of tables of values % mean of parameters and variances (std) % % if input new_traj non null % then only this traj is init % otherwise all trajectories are (at the beginning) if (nargin < 1) tab_traj = 1:par_per_frame(t) ; new = 0 ; else tab_traj = new_traj ; new = 1 ; end%if %% boucle sur les particules for iTraj = tab_traj ; %% alpha local_param = tab_param(iTraj, 7*(t_red-1)+5) ; % alpha tab_moy(iTraj, 7*(t_red-1)+5) = local_param + sqrt(-1)*local_param ;% moyenne,max tab_var(iTraj, 7*(t_red-1)+5) = 0.2*local_param ; % std %% r local_param = tab_param(iTraj, 7*(t_red-1)+6) ; tab_moy(iTraj, 7*(t_red-1)+6) = local_param ; tab_var(iTraj, 7*(t_red-1)+6) = 0.2*local_param ; %% i,j tab_var(iTraj, 7*(t_red-1)+3) = sig_free ; tab_var(iTraj, 7*(t_red-1)+4) = sig_free ; %% blink pour info tab_moy(iTraj, 7*(t_red-1)+8) = tab_param(iTraj, 7*(t_red-1)+8) ; tab_var(iTraj, 7*(t_red-1)+8) = tab_param(iTraj, 7*(t_red-1)+8) ; %% affection identique a (t_red-1)-1 %% pour compat avec mise_a_jour_tab if (new) %% alpha local_param = tab_param(iTraj, 7*(t_red-1)+5) ; % alpha tab_moy(iTraj, 7*((t_red-1)-1)+5) = local_param + sqrt(-1)*local_param ;% moyenne,max tab_var(iTraj, 7*((t_red-1)-1)+5) = 0.2*local_param ; % std %% r local_param = tab_param(iTraj, 7*(t_red-1)+6) ; tab_moy(iTraj, 7*((t_red-1)-1)+6) = local_param ; tab_var(iTraj, 7*((t_red-1)-1)+6) = 0.2*local_param ; %% i,j tab_var(iTraj, 7*((t_red-1)-1)+3) = sig_free ; tab_var(iTraj, 7*((t_red-1)-1)+4) = sig_free ; %% blink pour info tab_moy(iTraj, 7*((t_red-1)-1)+8) = tab_param(iTraj, 7*(t_red-1)+8) ; tab_var(iTraj, 7*((t_red-1)-1)+8) = tab_param(iTraj, 7*(t_red-1)+8) ; end %if end %for end %function function mise_a_jour_tab % EN/ update of the tables of values % mean of parameters and variances (std) %fprintf(stderr,"in maj\n"); %% boucle sur les particules for iTraj=1:new_nb_traj if (tab_param(iTraj, 7*(t_red-1)+8)>T_off) %% alpha %% modif le 12-11-07 %% compatibilite avec rapport_detection %% suite a la prise en compte de la loi %% uniforme + gaussien pour alpha %% si modif verifer rapport_detection.m %% %%param = 5 ; %%[moy, sig] = calcul_reference(iTraj, (t_red-1), param, T) ; %%tab_moy(iTraj, 7*(t_red-1)+param) = moy ;%% test modif 160307 %%tab_var(iTraj, 7*(t_red-1)+param) = sig ; [moy, sig_alpha] = calcul_reference(5) ; alpha_moy = real(moy) ; alpha_max = imag(moy) ; %% on ne met a jour des stats mean var %% que si on est en hypothese gaussienne %% sinon on bloque les stats %% determination du mode par vraisemblance LV_uni = -T*log(alpha_max) ; LV_gauss = -T/2*(1+log(2*pi*sig_alpha^2)) ; if (LV_gauss > LV_uni) %% gaussienne (1) tab_moy(iTraj, 7*(t_red-1)+5) = alpha_moy + sqrt(-1)*alpha_max ; tab_var(iTraj, 7*(t_red-1)+5) = sig_alpha ; else %% uniforme (2) tab_moy(iTraj, 7*(t_red-1)+5) = tab_moy(iTraj, 7*((t_red-1)-1)+5) ; tab_var(iTraj, 7*(t_red-1)+5) = tab_var(iTraj, 7*((t_red-1)-1)+5) ; end%if %% r [moy, sig] = calcul_reference(6) ; tab_moy(iTraj, 7*(t_red-1)+6) = moy ; tab_var(iTraj, 7*(t_red-1)+6) = sig ; %% i,j [moy, sig_i] = calcul_reference(3) ; [moy, sig_j] = calcul_reference(4) ; %%tab_moy(iTraj, 7*(t_red-1)+4) = moy ; %% inutile sig_ij = sqrt(0.5*(sig_i^2+sig_j^2)) ; if (sig_free < sig_ij) %% borne a diff libre sig_ij = sig_free ; end%if tab_var(iTraj, 7*(t_red-1)+3) = sig_ij ; tab_var(iTraj, 7*(t_red-1)+4) = sig_ij ; %% blink pour info tab_moy(iTraj, 7*(t_red-1)+8) = tab_param(iTraj, 7*(t_red-1)+8) ; tab_var(iTraj, 7*(t_red-1)+8) = tab_param(iTraj, 7*(t_red-1)+8) ; end %if end %for function [param_ref, sig_param] = calcul_reference(param) %% determine la reference (parametre moyen) %% et ecart type du param %% determine sur la derniere zone de non blink %% et limite a une longueur T %% moy_alpha et sig_alpha (resp r) gardent leur valeur pendant un blink %% moy_i/j ne sert pas %% sig_i/j %% sig_i/j voient leur valeur augmenter pendant le blink %% en suivant la variation sqrt(nb_blink)*sig_i_avant_blink %% pris en compte dans sigij_blink %% param = 5 : alpha %% param = 6 : r %% param = 3 : i %% param = 4 : j %% offset de zone de blink nb_blink==(-offset) if (tab_param(iTraj, 7*(t_red-1)+8) < 0) offset = tab_param(iTraj, 7*(t_red-1)+8) ; else offset = 0 ; end %if %% duree de la derniere partie ON de la iTraj nb_on = floor(tab_param(iTraj, 7*((t_red-1)+offset)+8) / Nb_STK) ; %% correct bug suite modif if (nb_on > T) nb_on = T ; end %if seuil = 3+1 ; %T/2 if (nb_on >= seuil) n=0:(nb_on-1) ; local_param = tab_param(iTraj, 7*((t_red-1)+offset-n)+param) ; sum_param = sum(local_param) ; sum_param2 = sum(local_param.^2) ; param_max = max(local_param) ; %% 160307 param_ref = sum_param / nb_on ; sig_param = sqrt( sum_param2 / nb_on - param_ref^2) ; %% si alpha, il faut aussi la valeur max %% en plus de la valeur moyenne %% on le met sur l'axe imaginaire! 160307 if (param == 5) param_ref = param_ref + sqrt(-1)*param_max ; end%if else %% On bloque la valeur a la derniere valeur avant zone de blink %% la derniere info valable dans le passe if (offset == 0) pos_info = 1 ;% la valeur precedente else pos_info = -offset ; % la derniere valeur avant blink end%if param_ref = tab_moy(iTraj, 7*((t_red-1)-pos_info)+param) ; sig_param = tab_var(iTraj, 7*((t_red-1)-pos_info)+param) ; end %if end %function end %function end function part = reconnect_part(traj, t, lest, wn) % EN/ function that search/detect the particle % among those pre-detected, which best corresponds % to the given trajectory % returns the number of the particle in lest %% evite les allocations sur des constantes % global tab_param ; % global tab_var ; Nb_combi = evalin('base', 'Nb_combi'); %%% Pre-detection %%% liste_param = [num, i, j, alpha, sig^2, rayon, ok] %%% Estimation/Reconnexion %%% 1 2 3 4 5 6 7 8 %%% tab_param = [num, t, i, j, alpha, rayon, m0, ,blink] %%% tab_var = [num, t, sig_i,sig_jj, sig_alpha, sig_rayon, sig_b ,blink] %% reconnexion de la particule num part %search for particles inside search radius of trajectory ind_boule = liste_part_boule([], traj, lest, t) ; nb_part_boule = size(ind_boule, 1) ; if (nb_part_boule == 0) %% set trajectory status to BLINK part = 0 ; else %% plusieurs particule candidate %% on prend celle la plus probable %look up if other trajectory are in competition for one of the particles vec_traj_inter = liste_traj_inter(ind_boule, traj, lest, t) ; vec_traj = [traj; vec_traj_inter] ; nb_traj = size(vec_traj,1) ; %% limitation du nb de trajectoire %% en competition if (nb_traj > Nb_combi) fprintf('--> limitation combi for traj : traj %d\n', traj) ; vec_traj = limite_combi_traj_blk(vec_traj, t) ; %%vec_traj = limite_combi_traj_dst(vec_traj, t) ; nb_traj = Nb_combi ; end %if %% prise en compte des particules %% qui seraient dans les boules de recherche %% des trajectoires en competition %% "On travail ici a l'ordre 1" ind_boule_O1 = ind_boule ; for ntraj = 2:nb_traj traj_inter = vec_traj(ntraj) ; ind_boule_O1 = liste_part_boule(ind_boule_O1, traj_inter, lest, t) ; end %for nb_part_boule_O1 = size(ind_boule_O1, 1) ; %% passage a l_ordre 1 ind_boule = ind_boule_O1 ; nb_part_boule = nb_part_boule_O1 ; %% limite du nb de particules %% en competition if (nb_part_boule > Nb_combi) fprintf('--> limitation combi for part : traj %d\n', traj) ; ind_boule = limite_combi_part_dst(traj,ind_boule,lest,t) ; nb_part_boule = Nb_combi ; end %if %% recherche de la meilleur config par %% maximum de vraisemblance if nb_traj <= nb_part_boule %% pas le blink %% mais possiblilite de nouvelle particule (<) vec_part = ind_boule ; else %% nb_traj > nb_part_boule %% des particules ont blinkees vec_part = [ind_boule; zeros(nb_traj-nb_part_boule,1)] ; end %if part = best_config_reconnex(vec_traj, vec_part, t, lest, wn); end %if end %function function [indice, dist2] = N_plus_proche(ic, jc, liste_i, liste_j, N) % renvoie les indices des N point les plus proche % de C(ic,jc) % dans l'ordre d'eloignement dim_liste = size(liste_i(:),1) ; %% distances au point C sq_dist = (liste_i-ic).^2 + (liste_j-jc).^2 ; %% classement [sq_dist_classe, ind_classe] = sort(sq_dist) ; if (dim_liste > N) indice = ind_classe(1:N) ; dist2 = sq_dist_classe(1:N) ; else indice = ind_classe ; dist2 = sq_dist_classe ; end%if end%function function vec_part_out = limite_combi_part_dst(traj, vec_part_in, lest, t) % limite le nombre de part % a celle les plus proche de la ref traj % au nombre Nb_combi (global) global tab_param ; Nb_combi = evalin('base', 'Nb_combi'); ic = tab_param(traj, 7*t+3) ; jc = tab_param(traj, 7*t+4) ; tabi = lest(vec_part_in, 2) ; tabj = lest(vec_part_in, 3) ; indice = N_plus_proche(ic, jc, tabi, tabj, Nb_combi) ; vec_part_out = vec_part_in(indice) ; end%function function vec_traj_out = limite_combi_traj_blk(vec_traj_in, t) % limite le nombre de traj % a celle les plus anciennes (en blink) % au nombre Nb_combi (global) % la premiere reste : ref global tab_param ; Nb_combi = evalin('base', 'Nb_combi'); tab_blk = tab_param(vec_traj_in(2:end), 7*t+8) ; [blk,indice] = sort(tab_blk, 'descend') ; vec_traj_out = [vec_traj_in(1); vec_traj_in(indice(1:(Nb_combi-1))+1)] ; end%function function liste_traj = liste_traj_inter(liste_part, traj_ref, lest, t) % function qui renvoie les trajectoires (non reconnectees) % dont les boules (espace libre) de recherche intersecte % au moins une des particules de la liste global tab_param ; Boule_free = evalin('base', 'Boule_free'); %% init des trajectoires a tester traj_boule = zeros(size(tab_param,1), 1) ; nb_traj = size(tab_param, 1) ; boules = Boule_free * sigij_free_blink(1:nb_traj, t) ; for p = liste_part' ic = lest(p,2) ; jc = lest(p,3) ; %% fenetre de recherche des trajectoires %% boule de recherche en ecartype icm = max(ic - boules, 0) ; icM = ic + boules ; jcm = max(jc - boules, 0) ; jcM = jc + boules ; traj_boule = traj_boule | ... ((tab_param(:, 7*t+3) < icM) & (tab_param(:, 7*t+3) > icm) & ... (tab_param(:, 7*t+4) < jcM) & (tab_param(:, 7*t+4) > jcm)) ; % traj_boule = traj_boule | ... % (sqrt((tab_param(:, 7*t+3)-ic).^2+... % (tab_param(:, 7*t+4)-jc).^2)-boules) <= 0; %CPR end %for %% trajectoires a tester %% celles non encore reconnectees traj_boule = traj_boule & (tab_param(:, 7*(t+1)+8) == 0) ; %% test 22 11 07 : celles qui ne sont pas blinkee traj_boule = traj_boule & (tab_param(:, 7*t+8) > 0) ; %% on enleve la ref traj_boule(traj_ref) = 0 ; %% les trajectoires en question liste_traj = find(traj_boule) ; end %function function liste_part = liste_part_boule(liste_part_ref, traj, lest, t) %finds particles inside search radius of trajectory % si liste_par_ref == [] alors pas de ref %% evite les allocations sur des constantes global tab_param ; Boule_free = evalin('base', 'Boule_free'); % global tab_var ; nb_part = size(lest, 1) ; dim_liste = size(liste_part_ref,1) ; if (dim_liste ~= 0) %% generation d_un masque masque_part_ref = ones(nb_part, 1) ; masque_part_ref(liste_part_ref) = 0 ; end %if %last spacecoordinates for trajectory ic = tab_param(traj, 7*t+3) ; jc = tab_param(traj, 7*t+4) ; %calc search radius boule = Boule_free * sigij_free_blink(traj, t) ; icm = max(ic - boule, 0) ; % en ecart type sur i icM = ic + boule ; % en ecart type jcm = max(jc - boule, 0) ; % en ecart type sur j jcM = jc + boule ; % en ecart type % % %% liste locale a la boule (carree!!) <<<====================================!!! part_boule = ... (lest(:,2) < icM) & (lest(:,2) > icm) & ... (lest(:,3) < jcM) & (lest(:,3) > jcm) ; % part_boule = sqrt((lest(:,2)-ic).^2+(lest(:,3)-jc).^2) <= boule; %CPR %remove the ones already in ref list if (dim_liste ~= 0) part_boule = part_boule & masque_part_ref ; end %if liste_new_part = find(part_boule) ; liste_part = [liste_part_ref; liste_new_part] ; end %function function [out, flag_full_alpha] = rapport_detection(traj, t, lest, part, wn)%, T) % EN/ returns the likelihood for reconnection between % the particle num_test (in list lest) and the trajectory traj % % flag_full_alpha indicates if the particle % is ON (FULL, belongs to the Gaussian) %% evite les allocations sur des constantes global tab_param ; global tab_moy ; global tab_var ; Poids_melange_aplha = evalin('base', 'Poids_melange_aplha'); Poids_melange_diff = evalin('base', 'Poids_melange_diff'); T_off = evalin('base', 'T_off'); im_t = evalin('base', 'im_t'); N = wn*wn ;% carree %% ============================================== %% test glrt avec parametre estime pour new traj %% ============================================== %% %% glrt_1vue : le meme que dans carte_H0H1 %% mais ici calcule pour les parametres estimes %% pour les particules nouvelles if (traj<=0) %% P(x|H1) %% deja calcule lors de l'estimation 1 vue sig2_H1 = lest(part, 5 ) ; LxH1 = -N/2*log(sig2_H1) ; % -N/2 %% P(x|H0) %% probleme lors des deflations!!! Pi = round(lest(part, 2)) ; Pj = round(lest(part, 3)) ; di = (1:wn)+Pi-floor(wn/2) ; dj = (1:wn)+Pj-floor(wn/2) ; im_part = im_t(di, dj) ; sig2_H0 = var(im_part(:)) ; LxH0 = -N/2*log(sig2_H0) ; % -N/2 % glrt = -2*( LxH0 - LxH1 ) ; out = -2*( LxH0 - LxH1 ) ; return ; end%if %% ============================================== %% vraixemblance de la reconnexion traj <-> part %% ============================================== %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% proba de reapparition pendant un blink (blinch) %% gaussienne > 0 %% nb_blink if (tab_param(traj, 7*t+8) < 0) nb_blink = -tab_param(traj, 7*t+8) ; sig_blink = -T_off/3 ; Pblink = 2*inv(sqrt(2*pi)*sig_blink) * exp(-inv(2*sig_blink^2)*nb_blink^2) ; Lblink = log(Pblink) ; else % nb_blink = 0 ; Lblink = 0 ; end %if %%%%%%%%%%%%%%%%%%%%% %% intensite des pics %% P(alpha|H1) %% c'est un melange de loi uniforme et gaussienne %% on travail a tres faible nombre d'echantillons %% estimer la proportion uni/gauss est tres difficile %% ancienne version _old %% on fait plutot un test de vraisemblance uni/gauss %% on est don, soit gaussienne, soit uniforme %% nouvelle version : la loi est une combinaison %% d'une loi uniforme et gaussienne %% en effet, l'estimation conjointe des parametres %% avec melange n'est possible qu'a grand nombre d echantillons %% ici : a nombre d echantillons reduits on test si %% le comportement et plutot gaussien ou uniforme (MV) %% si uniforme, on garde les anciens parametres %% si gaussien, on met a jour moyenne et variance %% %% Attention, les para metres des lois (les stats m, var) %% sont mis a jour par la fonction mise_a_jour_tab.m %% dans les tableaux tab_moy et tab_var %% %% si modif verifer mise_a_jour_tab.m alpha = lest(part, 4 ) ; alpha_moy = real(tab_moy(traj, 7*t+5)) ; %% sur tout l'echantillon sig_alpha = tab_var(traj, 7*t+5) ; %% sur tout l'echantillon %%alpha_max = imag(tab_moy(traj, 7*t+5)) ; alpha_max = alpha_moy ; %% gaussienne (1) Palpha_gaus = inv(sqrt(2*pi)*sig_alpha) * exp(-inv(2*sig_alpha^2)*(alpha-alpha_moy)^2) ; %% uniforme (2) if (alpha < alpha_max) Palpha_univ = 1/alpha_max ; else Palpha_univ = 0.0 ; end%if poids = Poids_melange_aplha ; Lalpha = log(poids*Palpha_gaus + (1-poids)*Palpha_univ) ; if (Palpha_gaus > Palpha_univ) flag_full_alpha = 1 ; else flag_full_alpha = 0 ; end%if %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% vraisemblance de traj a intensitee full %% nb_alpha_full = mod(tab_param(traj,7*t+8), Nb_STK); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% vraisemblance position / mvt brownien (libre/confine) %% P(n0|H1) i0 = lest(part, 2) ; j0 = lest(part, 3) ; ic = tab_param(traj, 7*t+3) ; % derniere position jc = tab_param(traj, 7*t+4) ; % sig_ij_ref = tab_var(traj, 7*t+3); sig_ij_ref = sigij_blink(traj, t) ;%% avec blk sig_free_blk = sigij_free_blink(traj, t) ;%% avec blk !!! poids = Poids_melange_diff ; %% entre gaussienne ref et gaussienne libre Pn_ref = inv(2*pi*sig_ij_ref^2) * exp(- inv(2*sig_ij_ref^2) * ((i0-ic)^2 + (j0-jc)^2)) ; Pn_free = inv(2*pi*sig_free_blk^2) * exp(- inv(2*sig_free_blk^2) * ((i0-ic)^2 + (j0-jc)^2)) ; Ln0 = log(poids*Pn_ref + (1-poids)*Pn_free); %%%%%%%%%% %% P(r|H1) r = lest(part, 6) ; r_ref = tab_moy(traj, 7*t+6) ; sig_r_ref = tab_var(traj, 7*t+6) ; if (sig_r_ref ~= 0) Lr = -0.5*log(sig_r_ref) - inv(2*sig_r_ref^2) * (r-r_ref)^2; else Lr = 0 ; end%if %% vraisemblance out = Lalpha + Ln0 + Lblink + 0*Lr; end %function function sig_blk = sigij_blink(traj, t) % EN/ if blink, increase of the std global tab_param ; global tab_var ; %% offset de zone de blink nb_blink==(-offset) if (tab_param(traj, 7*t+8) < 0) offset = tab_param(traj, 7*t+8) ; else offset = 0 ; end %if %% sigi = sigj sig_blk = tab_var(traj, 7*t+3) ; %% sur i %% prise en compte du blink pour sig_i/j if (offset < 0) sig_blk = sig_blk * sqrt(1-offset) ; end %if end%function function sig_free_blk = sigij_free_blink(traj, t, sig_free) % EN/ if blink, increase of the std % traj scalar or vector of trajectories global tab_param ; sig_free = evalin('base', 'sig_free'); traj = traj(:) ; nb_traj = size(traj, 1) ; %% offset offset = tab_param(traj, 7*t+8) ; %% offset de zone de blink nb_blink==(-offset) %% offset = 0 si non_blink (>0) %% idem sinon ; nb_blink = - (offset .* (offset < 0)) ; %% sigi = sigj sig_free_blk = sig_free*ones(nb_traj, 1) ; %% prise en compte du blink pour sig_i/j sig_free_blk = sig_free_blk .* sqrt(1+nb_blink) ; end%function function part = best_config_reconnex(vec_traj, vec_part, t, lest, wn)%,T) % EN/ This function looks for the best config % according to the ML and sends back % the most probable particle (O if blinked) % The refering trace IS the first one % of the list in vect_traj % % Caution with combinatory tests beyond nb_part = 4 % Exemple de calcul de Log-vraisemblance % de reconnexion a 3 trajectoires/Particules % reprenant les notations de la figure 3 % % % - T_domain = P_domain % 3 trajectoires (a,k,b) pour 3 particules (1,2,3) % on cherche la meilleure combinaison en comparant leur vraisemblance % respective : % L(a,1) + L(k,2) + L(b,3) <> % L(a,1) + L(k,3) + L(b,2) <> % L(a,2) + L(k,1) + L(b,3) <> % etc. % % - T_domain > P_domain % 3 trajectoires (a,k,b) pour 2 particules : On en cree une 3eme OFF % (1,2,OFF). % Alors les tests deviennent : % L(a,1) + L(k,2) + L(b,OFF) <> % L(a,1) + L(k,OFF) + L(b,2) <> % L(a,2) + L(k,1) + L(b,OFF) <> % etc. % Dans ce cas, seulement 2 termes de vraisemblance sont % presents car le troisieme L(T,OFF), probabilite de disparition d'une % trajectoire, est identique pour toute trajectoires T. % % - T_domain < P_domain % 2 trajectoires (a,k) pour 3 particules (1,2,3) : On cree une nouvelle % trajectoire (a,k,NEW) % Alors les tests deviennent : % L(a,1) + L(k,2) + L(NEW,3) <> % L(a,1) + L(k,3) + L(NEW,2) <> % L(a,2) + L(k,1) + L(NEW,3) <> % etc. % La encore, dans ce cas, seulement 2 termes de vraisemblance sont % presents car le troisieme terme L(NEW,P), probabilite d'apparition % d'une nouvelle trajectoire dans l'image, est suppose constant. % Elle ne depend ni de la position, ni de l'intensite. %% permutation circulaire sur vec_part %% limite a la taille nb_traj % nb_part = size(vec_part(:), 1) ; nb_traj = size(vec_traj(:), 1) ; best_part = vec_part(1) ; vec_part_ref = vec_part(1:nb_traj) ; vrais = vrais_config_reconnex(vec_traj, vec_part_ref, t, lest, wn);%,T) tab_perms_vec_part = perms(vec_part)' ; nb_perms = size(tab_perms_vec_part, 2) ; for p=2:nb_perms vec_part_perm = tab_perms_vec_part(:,p) ; %% si plus de particules que de traj %% cas de nouvelle traj %% on test les nb_traj premiere vec_part_perm = vec_part_perm(1:nb_traj) ; vrais_tmp = vrais_config_reconnex(vec_traj, vec_part_perm, t, ... lest, wn);%, T) ; if (vrais_tmp > vrais) vrais = vrais_tmp ; best_part = vec_part_perm(1) ; end %if end %for part = best_part ; end %function function vrais = vrais_config_reconnex(vec_traj, vec_part, t, lest, wn)%,T) % function qui renvoie la vraisemblance % d'une configuration de reconnexion/blink % pour plusieurs trajectoires et particules % % les cardinaux des deux vecteurs d'entrees % sont forcement egaux % vec_part peut avoir des valeurs nulles % correspondant aux particules blinkees % la proba de blink est sans a priori % et c'est la meme pour tout traj % toute comparaison ce fera a nombre de % blink egal, donc on fait rien vrais = 0 ; nb_part = size(vec_part(:), 1) ; for p = 1:nb_part part = vec_part(p) ; traj = vec_traj(p) ; if part ~= 0 vrais_p = rapport_detection(traj, t, lest, part, wn) ; vrais = vrais + vrais_p ; end %if end %for end %function %% EXTRAS function setOptions(src, event) fig = gcbf; switch get(src,'State') case 'on' ss = get(0,'ScreenSize'); switch getappdata(fig, 'viewMode') case 'monoView' if getappdata(fig, 'isTrack') nImCh = 0; nTrackCh = 1; trackSrcFig = fig; else nImCh = 1; imCh = 1; nTrackCh = 0; srcFig = fig; end %if otherwise srcFig = getappdata(fig,'imSrcFig'); imCh = getappdata(fig,'imCh'); srcFig = srcFig(imCh); nImCh = getappdata(fig,'nImCh'); trackSrcFig = getappdata(fig,'trackSrcFig'); nTrackCh = getappdata(fig,'nTrackCh'); end %switch figOpt =... figure(... 'Units','pixels',... 'Position', [50 150 ... 202+98*(nImCh+nTrackCh) ss(4)-300],... 'Color', get(fig,'Color'),... 'Name', 'Options',... 'NumberTitle', 'off',... 'MenuBar', 'none',... 'ToolBar', 'none',... 'Resize', 'off'); %save settings profile hMenu = uicontextmenu; uimenu(hMenu, 'Label', 'save settings',... 'Callback', @saveSet); uimenu(hMenu, 'Label', 'load settings',... 'Callback', @loadSet); set(figOpt, 'UIContextMenu', hMenu) inputPosY = ss(4)-(370:30:1010); x = [176 274 372 470]; if nImCh > 0 %% localization uicontrol(... 'Tag', 'locButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(2) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Framerange:',... 'HorizontalAlignment', 'left',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'locButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(3) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Error Rate [10^]:',... 'HorizontalAlignment', 'left',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'locButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(4) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Detection Box [px]:',... 'HorizontalAlignment', 'left',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'locButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(5) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Deflation Loops:',... 'HorizontalAlignment', 'left',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'locButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(6) 161 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Intensity Thresh [cnts]:',... 'HorizontalAlignment', 'left',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'locButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(7) 161 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'use multiple cores:',... 'HorizontalAlignment', 'left',... 'BackgroundColor', get(fig,'Color'),... 'ToolTipString', sprintf(['\n'... 'If this option is checked the programm will perform \n'... 'the particle localization process using the specefied \n'... 'number of processor cores. \n'... 'The maximum of available cores will be used by default.'])); uicontrol(... 'Tag', 'locButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(8) 161 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'apply spatial correction:',... 'HorizontalAlignment', 'left',... 'BackgroundColor', get(fig,'Color'),... 'ToolTipString', sprintf(['\n'... 'If this option is checked the programm will perform \n'... 'a spatial transformation on the particle coordinates\n'... 'when the localization process is finished. \n'... 'The spatial transformation corrects for rotation and transition \n'... 'between image channels'])); uicontrol(... 'Tag', 'locButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(9) 161 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'live localization:',... 'HorizontalAlignment', 'left',... 'BackgroundColor', get(fig,'Color'),... 'ToolTipString', sprintf(['\n'... 'If this option is checked the programm will directly \n'... 'stream the localization process into a preview window.'])); uicontrol(... 'Tag', 'locButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(11) 167 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'FontWeight', 'bold',... 'String', 'Optimization Settings',... 'HorizontalAlignment', 'left',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'locButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(12) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'max. # iterations:',... 'HorizontalAlignment', 'left',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'locButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(13) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'term. tol. [10^]:',... 'HorizontalAlignment', 'left',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'locButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(14) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'r0 tolerance [%]:',... 'HorizontalAlignment', 'left',... 'BackgroundColor', get(fig,'Color'),... 'ToolTipString', sprintf(['\n'... 'If this option is checked the programm will optimize for \n'... 'the gaussian radius approximating the point spreads function std. \n'.... 'If the tolerancelevel set is exceeded the particle will be discarded.'])); uicontrol(... 'Tag', 'locButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(15) 155 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'max. pos. refinement [px]:',... 'HorizontalAlignment', 'left',... 'BackgroundColor', get(fig,'Color')); %% render uicontrol(... 'Tag', 'renderButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(2) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Framerange:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'renderButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(3) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Expansion Factor:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'renderButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [176 inputPosY(3) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(fig,'exfNew'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, fig,'exfNew'},... 'Visible', 'off'); uicontrol(... 'Tag', 'renderButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(4) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Convolution Mode:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'renderButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(5) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Int. Weight:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'renderButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(6) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Size Factor:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'renderButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(8) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'FontWeight', 'bold',... 'String', 'Movie Settings',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'renderButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(9) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Windowsize:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'renderButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(10) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Stepsize:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'renderButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [176 inputPosY(10) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(fig,'rStep'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, fig, 'rStep'},... 'Visible', 'off'); uicontrol(... 'Tag', 'renderButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(11) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'fps:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'renderButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [176 inputPosY(11) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(fig,'fps'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, fig,'fps'},... 'Visible', 'off'); uicontrol(... 'Tag', 'renderButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(12) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Compression:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'renderButton',... 'Style', 'popupmenu',... 'Units','pixels',... 'Position', [176 inputPosY(12) 84 20],... 'FontSize', 7,... 'FontUnits', 'normalized',... 'String', {'RLE' 'MSVC' 'none'},... 'Value', getappdata(fig,'movCompression'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, fig,'movCompression'},... 'Visible', 'off'); uicontrol(... 'Tag', 'renderButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(13) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'accumultative movie:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); %% filters uicontrol(... 'Tag', 'threshButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(2) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Loc.Prec. [nm]:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'threshButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(3) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Signal to Noise:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'threshButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(4) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Detection Density:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); %% scalebar uicontrol(... 'Tag', 'barButton',... 'Style', 'checkbox',... 'Units','pixels',... 'Position', [22 inputPosY(2) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Colormap [px]:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'Value', getappdata(fig,'isColormap'),... 'Callback',{@changeValue, fig,'isColormap'},... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'barButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [176 inputPosY(2) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(fig,'colormapWidth'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, fig,'colormapWidth'},... 'Visible', 'off'); uicontrol(... 'Tag', 'barButton',... 'Style', 'checkbox',... 'Units','pixels',... 'Position', [22 inputPosY(3) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Scalebar [nm]:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'Value', getappdata(fig,'isScalebar'),... 'Callback',{@changeValue, fig,'isScalebar'},... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'barButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [176 inputPosY(3) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(fig,'micronBarLength'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, fig,'micronBarLength'},... 'Visible', 'off'); uicontrol(... 'Tag', 'barButton',... 'Style', 'checkbox',... 'Units','pixels',... 'Position', [22 inputPosY(4) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Timestamp [sec]:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'Value', getappdata(fig,'isTimestamp'),... 'Callback',{@changeValue, fig,'isTimestamp'},... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'barButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [176 inputPosY(4) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(fig,'timestampInkrement'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, fig,'timestampInkrement'},... 'Visible', 'off'); uicontrol(... 'Tag', 'barButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(5) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Charactersize:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'barButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [176 inputPosY(5) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(fig,'timestampSize'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, fig,'timestampSize'},... 'Visible', 'off'); %% optics uicontrol(... 'Tag', 'opticsButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(2) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Pixel Size [µm]:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'opticsButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [176 inputPosY(2) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String',getappdata(fig,'pxSize'),... 'BackgroundColor', [1 1 1],... 'Callback', {@calcPSF, fig, 'pxSize'},... 'Visible', 'off',... 'ToolTipString', sprintf(['\n'... 'This Value is used to estimate the pixel to micron conversion factor. \n'... 'In Theory: pixel size = phys. pixel size / total magnification(objectiv*ocular)\n'... '60, 1x = 0.267µm per pixel \n 60, 1.6x = 0.167µm per pixel \n'... '150, 1x = 0.107µm per pixel \n 150, 1.6x = 0.067µm per pixel'])); uicontrol(... 'Tag', 'opticsButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(3) 156 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Emission [nm]:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'opticsButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(4) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'N.A.:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'opticsButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(5) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'PSF Scaling:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'opticsButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(6) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'PSF Std [px]:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color'),... 'ToolTipString', sprintf(['\n'... 'Standard deviation of the Gaussian modelling the \n'... 'Microscope associated Point Spread Function.'])); uicontrol(... 'Tag', 'opticsButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(8) 156 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Counts/Photon:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'opticsButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(9) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Lag Time [ms]:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'opticsButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [176 inputPosY(9) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String',getappdata(fig,'frameSize'),... 'BackgroundColor', [1 1 1],... 'Callback', {@calcPSF, fig, 'frameSize'},... 'Visible', 'off'); %% tracking uicontrol(... 'Tag', 'trackingButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(2)-20 147 40],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Max. expected Diffusion Coefficient [µm^2/s]:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'trackingButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(3)-20 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Searchexp. Factor:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'trackingButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(4)-20 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Statistics Win. [frames]:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'trackingButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(5)-20 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Max. # Competitors:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'trackingButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(6)-20 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Max. OFF-Time [frames]:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'trackingButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(7)-20 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Int. Fluc. Weight:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'trackingButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(8)-40 147 40],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Local vs. Max. expected Diffusion Weight:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); %% for ch = 1:nImCh %% channel uicontrol(... 'Style', 'text',... 'Units','pixels',... 'Position', [x(ch)+10 inputPosY(1) 84 20],... 'FontSize', 10,... 'FontWeight', 'bold',... 'FontUnits', 'normalized',... 'String', ['Channel ' num2str(imCh(ch)) ':'],... 'HorizontalAlignment', 'left',... 'BackgroundColor', get(fig,'Color')); %% localization uicontrol(... 'Tag', 'locButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(2) 42 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'locStart'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch), 'locStart'}); uicontrol(... 'Tag', 'locButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch)+43 inputPosY(2) 42 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'locEnd'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch), 'locEnd'}); uicontrol(... 'Tag', 'locButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(3) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'errorRate'),... 'BackgroundColor', [1 1 1],... 'Callback', {@changeValue, srcFig(ch), 'errorRate'},... 'ToolTipString', sprintf(['\n'... 'This Value limits the Probability for Type One Error (False H0 Rejection), \n'... 'while estimation of the generalized likelihood ratio test. \n'... 'These Ratios follow aproximated a chi^2 distribution\n'... 'with degree of freedom (3 [signal, offset, noise]-2[offset, noise]) = 1'])); uicontrol(... 'Tag', 'locButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(4) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'w2d'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch), 'w2d'},... 'ToolTipString', sprintf(['\n'... 'Size of 2 dimensional sliding box inside whom a \n'... 'generalized likelihood ratio test (H0/H1) is performed with: \n'... 'H0 = no target (offset and noise) \n'... 'H1 = presence of target (signal, offset and noise) \n'... 'followed by subpixel estimation via Gauss-Newton Approximation. \n'... 'By rule of thumb this value should be set to 6*PSFstd+1. \n'... 'Strictly avoid an even number!!!'])); uicontrol(... 'Tag', 'locButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(5) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'dfltnLoops'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch), 'dfltnLoops'},... 'ToolTipString', sprintf(['\n'... 'This Value determines how often the detection process will be iterated. \n'... 'After each Iteration the detected Particles represented by their \n'... 'gaussian Intensity Profile will be subtracted from the Image. \n'... 'In this way small peaks initially covered can be detected.'])); uicontrol(... 'Tag', 'locButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(6) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'minInt'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch), 'minInt'},... 'ToolTipString', sprintf(['\n'... 'Defines the min. Signal Intensity expressed as offset-corrected amplitude of the Gaussian.'])); uicontrol(... 'Tag', 'locButton',... 'Style', 'checkbox',... 'Units','pixels',... 'Position', [x(ch) inputPosY(7) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', '',... 'Value', getappdata(srcFig(ch),'locParallel'),... 'HorizontalAlignment', 'left',... 'Callback', {@changeValue, srcFig(ch), 'locParallel'},... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'locButton',... 'Style', 'popupmenu',... 'Units','pixels',... 'Position', [x(ch)+20 inputPosY(7) 64 20],... 'FontSize', 7,... 'FontUnits', 'normalized',... 'String', {'max' '2' '3'},... 'Value', getappdata(srcFig(ch),'nCores'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch), 'nCores'}); uicontrol(... 'Tag', 'locButton',... 'Style', 'checkbox',... 'Units','pixels',... 'Position', [x(ch) inputPosY(8) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', '',... 'Value', getappdata(srcFig(ch),'spatialCorrection'),... 'HorizontalAlignment', 'left',... 'Callback', {@setSpatialCorrPath,srcFig(ch)},... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'locButton',... 'Style', 'checkbox',... 'Units','pixels',... 'Position', [x(ch) inputPosY(9) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', '',... 'Value', getappdata(srcFig(ch),'rLive'),... 'HorizontalAlignment', 'left',... 'Callback', {@changeValue,srcFig(ch),'rLive'},... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'locButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(12) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'maxOptimIter'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch), 'maxOptimIter'}); uicontrol(... 'Tag', 'locButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(13) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'termTol'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch),'termTol'}); uicontrol(... 'Tag', 'locButton',... 'Style', 'checkbox',... 'Units','pixels',... 'Position', [x(ch) inputPosY(14) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', '',... 'Value', getappdata(srcFig(ch),'isRadiusTol'),... 'HorizontalAlignment', 'left',... 'Callback', {@changeValue, srcFig(ch),'isRadiusTol'},... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'locButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch)+20 inputPosY(14) 64 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'radiusTol'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch),'radiusTol'}); uicontrol(... 'Tag', 'locButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(15) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'posTol'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch),'posTol'}); %% rendering uicontrol(... 'Tag', 'renderButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(2) 42 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'rStart'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch), 'rStart'},... 'Visible', 'off'); uicontrol(... 'Tag', 'renderButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch)+43 inputPosY(2) 42 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'rEnd'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch), 'rEnd'},... 'Visible', 'off'); uicontrol(... 'Tag', 'renderButton',... 'Style', 'popupmenu',... 'Parent', gcf,... 'Units','pixels',... 'Position', [x(ch) inputPosY(4) 84 20],... 'FontSize', 7,... 'FontUnits', 'normalized',... 'String', {'fixed', 'dynamic', 'none'},... 'Value', getappdata(srcFig(ch),'convMode'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch), 'convMode'},... 'Visible', 'off'); uicontrol(... 'Tag', 'renderButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(5) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'intWeight'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch), 'intWeight'},... 'Visible', 'off'); uicontrol(... 'Tag', 'renderButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(6) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'sizeFac'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch), 'sizeFac'},... 'Visible', 'off'); uicontrol(... 'Tag', 'renderButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(9) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'rW'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch), 'rW'},... 'Visible', 'off'); uicontrol(... 'Tag', 'renderButton',... 'Style', 'checkbox',... 'Units','pixels',... 'Position', [x(ch) inputPosY(13) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', '',... 'Value', getappdata(srcFig(ch),'isCumsum'),... 'HorizontalAlignment', 'left',... 'Callback', {@changeValue, srcFig(ch),'isCumsum'},... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); %% filters uicontrol(... 'Tag', 'threshButton',... 'Style', 'checkbox',... 'Units','pixels',... 'Position', [x(ch) inputPosY(2) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', ':',... 'HorizontalAlignment', 'left',... 'Value', getappdata(srcFig(ch),'isThreshLocPrec'),... 'Visible', 'off',... 'Callback',{@changeValue, srcFig(ch),'isThreshLocPrec'},... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'threshButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch)+20 inputPosY(2) 32 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'minLoc'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch), 'minLoc'},... 'Visible', 'off'); uicontrol(... 'Tag', 'threshButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch)+52 inputPosY(2) 32 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'maxLoc'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch), 'maxLoc'},... 'Visible', 'off'); uicontrol(... 'Tag', 'threshButton',... 'Style', 'checkbox',... 'Units','pixels',... 'Position', [x(ch) inputPosY(3) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', '',... 'HorizontalAlignment', 'left',... 'Value', getappdata(srcFig(ch),'isThreshSNR'),... 'Visible', 'off',... 'Callback',{@changeValue, srcFig(ch),'isThreshSNR'},... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'threshButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch)+20 inputPosY(3) 32 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'minSNR'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch), 'minSNR'},... 'Visible', 'off'); uicontrol(... 'Tag', 'threshButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch)+52 inputPosY(3) 32 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'maxSNR'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch), 'maxSNR'},... 'Visible', 'off'); uicontrol(... 'Tag', 'threshButton',... 'Style', 'checkbox',... 'Units','pixels',... 'Position', [x(ch) inputPosY(4) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', '',... 'HorizontalAlignment', 'left',... 'Value', getappdata(srcFig(ch),'isThreshDensity'),... 'Visible', 'off',... 'Callback',{@changeValue, fig,'isThreshDensity'},... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'threshButton',... 'Style', 'popupmenu',... 'Units','pixels',... 'Position', [x(ch)+20 inputPosY(4) 64 20],... 'FontSize', 7,... 'FontUnits', 'normalized',... 'String', {'inclusive', 'exclusiv'},... 'Value', getappdata(srcFig(ch),'clusterMode'),... 'BackgroundColor', [1 1 1],... 'Visible', 'off',... 'Callback',{@changeValue, srcFig(ch), 'clusterMode'}); %% optics uicontrol(... 'Tag', 'opticsButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(3) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'emWvlnth'),... 'BackgroundColor', [1 1 1],... 'Callback',{@calcPSF, srcFig(ch), 'emWvlnth'},... 'Visible', 'off'); uicontrol(... 'Tag', 'opticsButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(4) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'NA'),... 'BackgroundColor', [1 1 1],... 'Callback',{@calcPSF, srcFig(ch), 'NA'},... 'Visible', 'off'); uicontrol(... 'Tag', 'opticsButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(5) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'psfScale'),... 'BackgroundColor', [1 1 1],... 'Callback', {@calcPSF, srcFig(ch), 'psfScale'},... 'Visible', 'off'); uicontrol(... 'Tag', 'opticsButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(6) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', num2str(getappdata(srcFig(ch),'psfStd'),'%.2f'),... 'Enable', 'off',... 'Visible', 'off'); uicontrol(... 'Tag', 'opticsButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [176 inputPosY(8) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'cntsPerPhoton'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch),'cntsPerPhoton'},... 'Visible', 'off'); %% tracking uicontrol(... 'Tag', 'trackingButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(2)-10 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'Dmax'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch), 'Dmax'},... 'Visible', 'off'); uicontrol(... 'Tag', 'trackingButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(3)-20 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'searchExpFac'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch), 'searchExpFac'},... 'Visible', 'off'); uicontrol(... 'Tag', 'trackingButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(4)-20 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'statWin'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch), 'statWin'},... 'Visible', 'off'); uicontrol(... 'Tag', 'trackingButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(5)-20 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'maxComp'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch), 'maxComp'},... 'Visible', 'off'); uicontrol(... 'Tag', 'trackingButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(6)-20 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'maxOffTime'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch), 'maxOffTime'},... 'Visible', 'off'); uicontrol(... 'Tag', 'trackingButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(7)-20 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'intLawWeight'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch), 'intLawWeight'},... 'Visible', 'off'); uicontrol(... 'Tag', 'trackingButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(8)-30 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(srcFig(ch),'diffLawWeight'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, srcFig(ch), 'diffLawWeight'},... 'Visible', 'off'); end end %if if nTrackCh > 0 %% uicontrol(... 'Tag', 'trackButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(2) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Framerange:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'trackButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(3) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Colorcoding:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'trackButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(4) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Track Thickness:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'trackButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(5) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Track Length:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'trackButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(7) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'FontWeight', 'bold',... 'String', 'Movie Settings',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'trackButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(8) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'Windowsize:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'trackButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(9) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'accumultative track:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'trackButton',... 'Style', 'text',... 'Units','pixels',... 'Position', [22 inputPosY(10) 147 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', 'track always visible:',... 'HorizontalAlignment', 'left',... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); %% x = x+98*nImCh; for ch = 1:nTrackCh uicontrol(... 'Style', 'text',... 'Units','pixels',... 'Position', [x(ch)+10 inputPosY(1) 84 20],... 'FontSize', 10,... 'FontWeight', 'bold',... 'FontUnits', 'normalized',... 'String', ['Track ' num2str(ch) ':'],... 'HorizontalAlignment', 'left',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'trackButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(2) 42 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(trackSrcFig(ch),'rStart'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, trackSrcFig(ch), 'rStart'},... 'Visible', 'off'); uicontrol(... 'Tag', 'trackButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch)+42 inputPosY(2) 42 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(trackSrcFig(ch),'rEnd'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeValue, trackSrcFig(ch), 'rEnd'},... 'Visible', 'off'); uicontrol(... 'Tag', 'trackButton',... 'Style', 'popupmenu',... 'Units','pixels',... 'Position', [x(ch) inputPosY(3) 64 20],... 'FontSize', 7,... 'FontUnits', 'normalized',... 'String', {'ensemble', 'individual'},... 'Value', getappdata(trackSrcFig(ch),'trackColorMode'),... 'BackgroundColor', [1 1 1],... 'Visible', 'off',... 'Callback',{@changeTrackColorcode,trackSrcFig(ch)}); color = getappdata(trackSrcFig(ch),'trackColor'); uicontrol(... 'Tag', 'trackButton',... 'Style', 'pushbutton',... 'Units','pixels',... 'Position', [x(ch)+64 inputPosY(3) 20 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'FontWeight', 'bold',... 'BackgroundColor', color{1},... 'String', '',... 'Callback',{@changeTrackColor, trackSrcFig(ch)},... 'Visible', 'off'); uicontrol(... 'Tag', 'trackButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(4) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(trackSrcFig(ch),'trackWidth'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeTrackLinewidth, trackSrcFig(ch)},... 'Visible', 'off'); uicontrol(... 'Tag', 'trackButton',... 'Style', 'checkbox',... 'Units','pixels',... 'Position', [x(ch) inputPosY(5) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', '',... 'HorizontalAlignment', 'left',... 'Value', getappdata(trackSrcFig(ch),'isTracksizeThresh'),... 'Visible', 'off',... 'Callback',{@changeValue, trackSrcFig(ch),'isTracksizeThresh'},... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'trackButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch)+20 inputPosY(5) 32 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(trackSrcFig(ch),'minTracksize'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeTracksize,trackSrcFig(ch),'minTracksize'},... 'Visible', 'off'); uicontrol(... 'Tag', 'trackButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch)+52 inputPosY(5) 32 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(trackSrcFig(ch),'maxTracksize'),... 'BackgroundColor', [1 1 1],... 'Callback',{@changeTracksize,trackSrcFig(ch),'maxTracksize'},... 'Visible', 'off'); uicontrol(... 'Tag', 'trackButton',... 'Style', 'edit',... 'Units','pixels',... 'Position', [x(ch) inputPosY(8) 84 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', getappdata(trackSrcFig(ch),'rW'),... 'BackgroundColor', [1 1 1],... 'Callback', {@changeValue, trackSrcFig(ch), 'rW'},... 'Visible', 'off'); uicontrol(... 'Tag', 'trackButton',... 'Style', 'checkbox',... 'Units','pixels',... 'Position', [x(ch) inputPosY(9) 161 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', '',... 'Value', getappdata(trackSrcFig(ch),'isCumsum'),... 'HorizontalAlignment', 'left',... 'Callback', {@changeValue, trackSrcFig(ch), 'isCumsum'},... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); uicontrol(... 'Tag', 'trackButton',... 'Style', 'checkbox',... 'Units','pixels',... 'Position', [x(ch) inputPosY(10) 161 20],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'String', '',... 'Value', getappdata(trackSrcFig(ch),'trackVisibility'),... 'HorizontalAlignment', 'left',... 'Callback', {@changeValue, trackSrcFig(ch), 'trackVisibility'},... 'Visible', 'off',... 'BackgroundColor', get(fig,'Color')); end end %if %% switch tabs uicontrol(... 'Style', 'text',... 'Units','normalized',... 'Position', [0 0.95 0.3 0.05],... 'FontSize', 19,... 'FontUnits', 'normalized',... 'String', 'Sheet:',... 'HorizontalAlignment', 'center',... 'BackgroundColor', get(fig,'Color')); hToggle =... uicontrol(... 'Style', 'popupmenu',... 'Units','normalized',... 'Position', [0.3 0.95 0.7 0.05],... 'FontSize', 15,... 'FontUnits', 'normalized',... 'HorizontalAlignment','right',... 'String', {... 'Localization',... 'Tracking',... 'Render',... 'Trajectories',... 'Acquisition',... 'Bars',... 'Filters'},... 'Value', 3,... 'BackgroundColor', get(fig,'Color'),... 'CreateFcn', @changeTab,... 'Callback', @changeTab); sliderPos = 1; uicontrol(... 'Style', 'slider',... 'Units','normalized',... 'Position', [0.942 0 0.05 0.9],... 'SliderStep', [0.01 0.01],... 'Value',sliderPos,... 'Callback', @adjustInputs); case 'off' delete(findobj(allchild(0),'Color',get(fig,'Color'),... '-and', 'Name', 'Options')) end %switch function changeTab(src, event) selection = get(src, {'String','Value'}); switch char(selection{1}(selection{2})) case 'Localization' set(findobj(figOpt,'Tag','locButton'), 'Visible', 'on') set(findobj(figOpt,'Tag','renderButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','barButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','opticsButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','threshButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','trackButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','trackingButton'), 'Visible', 'off') case 'Render' set(findobj(figOpt,'Tag','renderButton'), 'Visible', 'on') set(findobj(figOpt,'Tag','barButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','opticsButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','threshButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','locButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','trackButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','trackingButton'), 'Visible', 'off') case 'Bars' set(findobj(figOpt,'Tag','barButton'), 'Visible', 'on') set(findobj(figOpt,'Tag','opticsButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','threshButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','locButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','renderButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','trackButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','trackingButton'), 'Visible', 'off') case 'Acquisition' set(findobj(figOpt,'Tag','opticsButton'), 'Visible', 'on') set(findobj(figOpt,'Tag','threshButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','locButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','renderButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','barButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','trackButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','trackingButton'), 'Visible', 'off') case 'Filters' set(findobj(figOpt,'Tag','threshButton'), 'Visible', 'on') set(findobj(figOpt,'Tag','locButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','renderButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','barButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','opticsButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','trackButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','trackingButton'), 'Visible', 'off') case 'Trajectories' set(findobj(figOpt,'Tag','trackButton'), 'Visible', 'on') set(findobj(figOpt,'Tag','threshButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','locButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','renderButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','barButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','opticsButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','trackingButton'), 'Visible', 'off') case 'Tracking' set(findobj(figOpt,'Tag','trackingButton'), 'Visible', 'on') set(findobj(figOpt,'Tag','trackButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','threshButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','locButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','renderButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','barButton'), 'Visible', 'off') set(findobj(figOpt,'Tag','opticsButton'), 'Visible', 'off') end %switch end function changeValue(src, event, channel, fieldname) switch get(src, 'Style') case 'edit' for h = channel setappdata(h,fieldname,str2double(get(src,'String'))) end %for case 'checkbox' for h = channel setappdata(h,fieldname,get(src,'Value')) end %for case 'popupmenu' for h = channel setappdata(h,fieldname,get(src,'Value')) end %for end %switch end function calcPSF(src, event, channel, fieldname) setappdata(channel,fieldname,str2double(get(src,'String'))); psfStd = getappdata(channel,'psfScale')*0.55*... getappdata(channel,'emWvlnth')/1000/... getappdata(channel,'NA')/1.17/2/... getappdata(channel,'pxSize'); set(findobj(figOpt,'Tag','opticsButton', '-and', 'Enable', 'off'),... 'String', num2str(psfStd,'%.2f')); setappdata(channel, 'psfStd', psfStd) end function changeTrackLinewidth(src, event, fig) setappdata(fig,'trackWidth', str2double(get(src,'String'))); set(findobj(fig,'Type','Line'),'LineWidth', getappdata(fig,'trackWidth')) end function changeTrackColorcode(src,event,fig) switch get(src,'value') case 1 setappdata(fig,'trackColorMode',1) color = getappdata(fig,'trackColor'); set(findobj(fig,'Type','Line'),'Color',... color{1}); case 2 setappdata(fig,'trackColorMode',2) color = getappdata(fig,'trackColor'); set(findobj(fig,'Type','Line'),{'Color'},... mat2cell(color{2},... ones(getappdata(fig,'nTracks'),1),3)); end %switch end function changeTrackColor(src, event, fig) if getappdata(fig,'trackColorMode') == 1 color = getappdata(fig,'trackColor'); colorNew = colorui(color{1}, 'Track Color'); if numel(colorNew) > 1 color{1} = colorNew; setappdata(fig,'trackColor',color); set(src, 'BackgroundColor', colorNew); set(findobj(fig,'Type','Line'),'Color', colorNew) end %if end %if end function changeTracksize(src,event,fig,field) tracks = getappdata(fig,'tracks'); tracksize = cellfun('size',tracks,1); if strcmp(field,'minTracksize') minTracksize = str2double(get(src,'String')); setappdata(fig,field,minTracksize) maxTracksize = getappdata(fig,'maxTracksize'); else minTracksize = getappdata(fig,'minTracksize'); maxTracksize = str2double(get(src,'String')); setappdata(fig,field,maxTracksize) end %if if isinf(maxTracksize) hasSize = tracksize >= minTracksize; else hasSize = tracksize >= minTracksize &... tracksize <= maxTracksize; end %if hTracks = getappdata(fig,'hTracks'); set(hTracks,'Visible','off') set(hTracks(hasSize),'Visible','on') end function saveSet(src, event) [optName,optPath,isOK] = uiputfile(... '.mat' ,'Save Profile to', getappdata(0,'searchPath')); if isOK setappdata(0,'searchPath', optPath) hEdit = get(findobj(figOpt,'Style', 'edit'), 'String'); hCheck = get(findobj(figOpt,'Style', 'checkbox'), 'Value'); hPopup = get(findobj(figOpt,'Style', 'popupmenu'), 'Value'); save ([optPath optName], 'hEdit', 'hCheck', 'hPopup') else return end %if end function loadSet(src, event) [optName, optPath, isOK] = uigetfile(... '*.mat', 'Select Profile', getappdata(0,'searchPath')); if isOK setappdata(0,'searchPath', optPath) hEdit = []; hCheck = []; hPopup = []; load([optPath optName]) set(findobj(figOpt,'Style', 'edit'), {'String'},hEdit) set(findobj(figOpt,'Style', 'checkbox'), {'Value'},hCheck) set(findobj(figOpt,'Style', 'popupmenu'), {'Value'}, hPopup) else return end %if end function adjustInputs(src,event) if get(src,'Value') < sliderPos slideVal = [0 5 0 0]; else slideVal = [0 -5 0 0]; end %if sliderPos = get(src,'Value'); hList = findobj(figOpt,... 'Style','Edit',... '-or','Style','Text',... '-or','Style','popupmenu',... '-or','Style','checkbox'); oldPos = get(hList,'Position'); newPos = cellfun(@(x) x+slideVal, oldPos, 'Un', 0); set(hList,{'Position'},newPos) end function setSpatialCorrPath(src,event,fig) if get(src,'Value') [tMatName, tMatPath, isOK] = uigetfile(... '*.mat', 'Select spatial Transformationmatrix',... getappdata(0,'searchPath')); if isOK tMat = []; load([tMatPath tMatName]) setappdata(fig,'spatialCorrection',1) setappdata(fig,'tMat',tMat); end %if else setappdata(fig,'spatialCorrection',0) rmappdata(fig,'tMat'); end %if end end function showCredits(src, event) figure(... 'Units','normalized',... 'Position', [0.2 0.2 0.3 0.5],... 'Color', get(0,'defaultUicontrolBackgroundColor'),... 'Name', 'Credits',... 'NumberTitle', 'off',... 'MenuBar', 'none',... 'ToolBar', 'none',... 'Resize', 'off'); text(0.5,0.8,... {'{\fontsize{12} Particle Localization:}',... '\copyright A. Serge, N. Bertaux,', 'H. Rigneault & D. Marguet',... '\bf Dynamic multiple-target tracing', 'to probe spatiotemporal',... 'cartography of cell membranes', '\rm Nature Methods, Aug. 08'},... 'Units','normalized', 'HorizontalAlignment', 'center',... 'FontUnits', 'normalized'); text(0.5,0.5,... {'{\fontsize{12} Dynamic Convolution:}',... 'M. Parent, T. Gould,', 'S.T. Hess'},... 'Units','normalized', 'HorizontalAlignment', 'center',... 'FontUnits', 'normalized'); text(0.5,0.35,... {'{\fontsize{12} kd-Tree & k-NN Search:}',... 'A. Tagliasacchi'},... 'Units','normalized', 'HorizontalAlignment', 'center',... 'FontUnits', 'normalized'); text(0.5,0.1, {'{\fontsize{12} written by C.P.Richter}',... 'Division of Biophysics / Group Piehler', 'University of Osnabrueck'},... 'Units','normalized', 'HorizontalAlignment', 'center',... 'FontUnits', 'normalized'); axis off end function showChangeLog(src, event) fig =... figure(... 'Units','normalized',... 'Position', [0.2 0.2 0.5 0.5],... 'Color', get(0,'defaultUicontrolBackgroundColor'),... 'Name', 'Changelog',... 'NumberTitle', 'off',... 'MenuBar', 'none',... 'ToolBar', 'none',... 'Resize', 'off'); hList =... uicontrol(... 'Style', 'listbox',... 'Parent', fig,... 'Units','normalized',... 'Position', [0.1 0.1 0.8 0.8],... 'FontSize', 10,... 'FontUnits', 'normalized',... 'FontWeight', 'bold',... 'BackgroundColor', [1 1 1]); set(hList, 'String',... {'1.101b',... '-batch processing of stacks',... '-2D and 3D scatterplot',... '-fixed calculation of loc. Prec.',... '',... '1.012b',... '-improved trajectory integration',... '',... '1.012a',... '-support for Hess FPALM restored',... '-added spatial correction after localization',... '-added compatibility mode for older SLIMfast builds',... '-counts2photon conversion factor fixed',... '-bugfix roi+expansion factor',... '',... '1.011c',... '-adjustable multicore mode',... '-z-Projection (max. & mean Intensity)',... '',... '1.011b',... '-localization parallelized',... '',... '1.011a',... '-improved colorID (gradually shading childs)',... '-lenghtstring added to scalebar',... '',... '1.010g',... '-density threshold by data clustering',... '',... '1.010f',... '-dualView mode enabled (movie)',... '-tripleView mode enabled (movie)',... '-colormaps for polyview improved',... '-scalebar moved to north-east',... '',... '1.010e',... '-sync ROI between channels',... '-tripleView mode enabled (image)',... '',... '1.010d',... '-load/save options profile (contextmenu on window)',... '-multiple fractions to intensity fit',... '(allows constraint mean intensities)',... '-options window on/off togglebutton',... '-changelog added',... '',... '1.010c',... '-colorcode for associated windows',... '-buttons to manipulate roi (contextmenu on roi)',... '-accumulative movie option',... '-fixed convolutionkernel effected by Int.Weight and SizeFactor',... '-imagestack locking into free channel (fixed)',... '-dualView mode enabled (image)',... '',... '1.010b',... '-next/previous frame on superstack (fixed)',... '-analysis histograms relate to roi and framerange',... '-Signal to noise ratio thresholds for rendering',... '-abort localization at any time (Strg-Alt-S)',... '-ascii-export of current used options (Opt2Txt-Pushbutton)',... '-actual searchpath is set to last used directory',... '-check on loc.data name and possibility to overwrite',... '-save button if imagestack loaded (fixed)',... '-# rendered particles / total # particles added to windowtitles',... '(analysis histograms & rendered images)'}) end function [imFig trackFig] = getSelectedFigHandles varList = {... 'menuRedChannel',... 'menuGreenChannel',... 'menuBlueChannel',... 'menuGrayChannel',... 'menuTrackChannel'}; rootFig = findobj(0,'Tag','root'); imFig = nan(4,1); for ch = 1:4 hList = allchild(findobj(rootFig,'Tag',varList{ch})); isChecked = strcmp(get(hList,'Checked'),'on'); if any(isChecked) imFig(ch) = get(hList(isChecked),'UserData'); end %if end %for hList = allchild(findobj(rootFig,'Tag',varList{5})); isChecked = strcmp(get(hList,'Checked'),'on'); if any(isChecked) trackFig = get(hList(isChecked),'UserData'); if iscell(trackFig) trackFig = cell2mat(trackFig); end %if else trackFig = []; end %if end function transferVarList(targetFig,srcFig,mode) switch mode case 'render-mono' varList = {... 'isOwn',... 'isLoaded',... 'isSuperstack',... 'isTrack',... 'frame',... 'viewMode',... 'locStart',... 'locEnd',... 'errorRate',... 'w2d',... 'dfltnLoops',... 'minInt',... 'locParallel',... 'nCores',... 'spatialCorrection',... 'isRadiusTol',... 'radiusTol',... 'posTol',... 'maxOptimIter',... 'termTol',... 'isScalebar',... 'micronBarLength',... 'isColormap',... 'colormapWidth',... 'isTimestamp',... 'timestampSize',... 'timestampInkrement',... 'clusterMode',... 'exfOld',... 'exfNew',... 'rW',... 'rStep',... 'rStart',... 'rEnd',... 'rLive',... 'fps',... 'movCompression',... 'convMode',... 'intWeight',... 'sizeFac',... 'isCumsum',... 'isThreshLocPrec',... 'minLoc',... 'maxLoc',... 'isThreshSNR',... 'minSNR',... 'maxSNR',... 'isThreshDensity',... 'pxSize',... 'cntsPerPhoton',... 'emWvlnth',... 'NA',... 'psfScale',... 'psfStd',... 'imageName',... 'pathname',... 'filename',... 'width',... 'height',... 'roiX0',... 'roiY0',... 'roi',... 'hROI',... 'intensityRange',... 'ctrsN'}; for var = 1:numel(varList) setappdata(targetFig,varList{var},... getappdata(srcFig,varList{var})) end %for case 'merge' varList = {... 'pxSize',... 'isScalebar',... 'micronBarLength',... 'isColormap',... 'colormapWidth',... 'isTimestamp',... 'timestampSize',... 'timestampInkrement',... 'exfNew',... 'rStep',... 'fps',... 'movCompression'}; for var = 1:numel(varList) val = []; for ch = 1:numel(srcFig) val(ch) =... getappdata(srcFig(ch),varList{var}); end %for if isequal(val,circshift(val,[0 1])) setappdata(targetFig,varList{var},val(1)) else answer = inputdlg(... {sprintf('%s not equal between Channels',varList{var})},... 'set new Value'); setappdata(targetFig,varList{var},str2double(answer{1})) end %if end %for end %switch end function data = preprocessData(fig,returnValue,roi) varNames = {'ctrsX', 'ctrsY', 'signal', 'noise', 'offset', 'radius', 'frame',... 'photons', 'precision', 'snr', 'sbr', 'cluster'}; %define data to load loadValue = returnValue(1:7); if returnValue(3); loadValue(6) = true; end if returnValue(8); loadValue([3 6]) = true; end if returnValue(9); loadValue([3 4 6]) = true; end if returnValue(10); loadValue([3 4 6]) = true; end if returnValue(11); loadValue([3 5]) = true; end if returnValue(12) || getappdata(fig,'isThreshDensity');... loadValue([1 2 6 7]) = true; end if getappdata(fig,'isThreshSNR') || getappdata(fig,'isThreshLocPrec');... loadValue([3 4 6]) = true; end if ~isempty(getappdata(fig,'hROI')); loadValue([1 2]) = true; end %load data from disk for value = find(loadValue(1,:)) if loadValue(1,value) fid = fopen([getappdata(fig,'pathname')... getappdata(fig,'filename') '.' varNames{value}], 'r'); if isinf(getappdata(fig,'elements')) %load complete list data.(varNames{value}) = fread(fid,inf,'real*8'); else fseek(fid, getappdata(fig,'startPnt')*8, 'bof'); data.(varNames{value}) = fread(fid,getappdata(fig,'elements'),'real*8'); end %if end %if fclose(fid); end %for %remove points outside of ROI if loadValue(1) && loadValue(2) good =... data.(varNames{1}) > roi(1) &... data.(varNames{1}) < roi(1)+roi(3) &... data.(varNames{2}) > roi(2) &... data.(varNames{2}) < roi(2)+roi(4); for value = find(loadValue) data.(varNames{value}) = data.(varNames{value})(good); end %for end %if if loadValue(3) %volume [photons] data.photons = data.(varNames{3})*2*pi.*data.(varNames{6}).^2/... getappdata(fig,'cntsPerPhoton'); %[photons] %calculate loc. prec. if returnValue(9) || getappdata(fig,'isThreshLocPrec') data.precision = calcLocPrecision(... data.radius, getappdata(fig,'pxSize'),... data.photons, data.(varNames{4})/getappdata(fig,'cntsPerPhoton')); %[µm] end %if %calculate snr if returnValue(10) || getappdata(fig,'isThreshSNR') data.snr = data.signal./data.noise; end %if %calculate sbr if returnValue(11) data.sbr = data.signal./data.offset; end %if %apply loc. prec. or snr threshold if selected if getappdata(fig,'isThreshLocPrec') || getappdata(fig,'isThreshSNR') if getappdata(fig,'isThreshLocPrec') && getappdata(fig,'isThreshSNR') good = data.precision > getappdata(fig,'minLoc')/1000 &... data.precision < getappdata(fig,'maxLoc')/1000 &... data.snr > getappdata(fig,'minSNR') &... data.snr < getappdata(fig,'maxSNR'); elseif getappdata(fig,'isThreshLocPrec') && ~getappdata(fig,'isThreshSNR') good = data.precision > getappdata(fig,'minLoc')/1000 &... data.precision < getappdata(fig,'maxLoc')/1000; elseif ~getappdata(fig,'isThreshLocPrec') && getappdata(fig,'isThreshSNR') good = data.snr > getappdata(fig,'minSNR') &... data.snr < getappdata(fig,'maxSNR'); end %if for value = find([loadValue 0 0 0 0 0] | returnValue) if isfield(data,(varNames{value})) data.(varNames{value}) = data.(varNames{value})(good); end %if end end %if end %if %apply density threshold if selected if getappdata(fig,'isThreshDensity') || returnValue(12) if ~all([isappdata(fig,'clusterScore'),... isappdata(fig,'clusterRadius'),... isappdata(fig,'clusterWeights')]) [data,tree,clusterScore,... clusterRadius,clusterWeights] =... densitybasedClustering(data); kdtree_delete(tree) setappdata(fig,'clusterScore',clusterScore) setappdata(fig,'clusterRadius',clusterRadius) setappdata(fig,'clusterWeights',clusterWeights) setappdata(fig,'cluster',data.cluster) for value = find([loadValue 0 0 0 0 0] | returnValue) if getappdata(fig,'clusterMode') == 1 data.(varNames{value}) = data.(varNames{value})(data.cluster > 0); else data.(varNames{value}) = data.(varNames{value})(data.cluster == 0); end %if end %for else cluster = getappdata(fig,'cluster'); if getappdata(fig,'startPnt') == 0 startPnt = 1; else startPnt = getappdata(fig,'startPnt'); end %if if isinf(getappdata(fig,'elements')) good = startPnt:numel(cluster); else good = startPnt:startPnt+getappdata(fig,'elements')-1; end %if for value = find([loadValue 0 0 0 0 0] | returnValue) if getappdata(fig,'clusterMode') == 1 data.(varNames{value}) = data.(varNames{value})... (cluster(good) > 0); else data.(varNames{value}) = data.(varNames{value})... (cluster(good) == 0); end %if end %for end %if end %if %remove unnecessary variables for value = find(~returnValue); if isfield(data,varNames{value}) data = rmfield(data,varNames{value}); end %if end %for function precision =... calcLocPrecision(psfStd, pxSize, photons, noise) %calculates the localization uncertainty based on % psfStd, pxSize, photons, noise. (Thompson and Webb) psfStd = psfStd*pxSize; % px -> µm precision = sqrt((psfStd.^2+pxSize^2/12)./photons+... 8*pi.*psfStd.^4.*noise.^2/pxSize^2./photons.^2); %[µm] end end function exportSettings(src, event, visMode) fig = gcbf; [filename,pathname,isOK] =... uiputfile('.txt' ,'Save to', getappdata(0,'searchPath')); if isOK setappdata(0,'searchPath',pathname) fid = fopen([pathname filename], 'wt'); fprintf(fid, 'Filename: %s \n',... [getappdata(fig,'pathname') getappdata(fig,'filename') '.mat']); if getappdata(fig,'isSuperstack') for idx = 1:numel(getappdata(fig,'imageName')) imageName = getappdata(fig,'imageName'); fprintf(fid, 'Imagename: %s \n', imageName{idx}); end %for else fprintf(fid, 'Imagename: %s \n', getappdata(fig,'imageName')); end fprintf(fid, 'Created: %s \n', datestr(clock)); fprintf(fid, '\n Optics Options: \n'); fprintf(fid,'Pixelsize [µm] = %g \n', getappdata(fig,'pxSize')); fprintf(fid,'Numerical Aperture = %g \n', getappdata(fig,'NA')); fprintf(fid,'Emission Wavelength [nm] = %g \n', getappdata(fig,'emWvlnth')); fprintf(fid,'PSF Scaling Factor = %g \n', getappdata(fig,'psfScale')); fprintf(fid,'PSF [px] = %g \n', getappdata(fig,'psfStd')); fprintf(fid,'Counts/Photon = %g \n', getappdata(fig,'cntsPerPhoton')); fprintf(fid, '\n Localization Options: \n'); fprintf(fid,'Framerange = %g to %g \n', getappdata(fig,'locStart'), getappdata(fig,'locEnd')); fprintf(fid,'ErrorRate [10^] = %g \n', getappdata(fig,'errorRate')); fprintf(fid,'Detectionbox [px] = %g \n', getappdata(fig,'w2d')); fprintf(fid,'# of Deflationloops = %g \n', getappdata(fig,'dfltnLoops')); fprintf(fid,'Intensity Threshold [Photons] = %g \n', getappdata(fig,'minInt')); fprintf(fid, '\n Rendering Options: \n'); fprintf(fid,'Framerange = %g to %g \n', getappdata(fig,'rStart'), getappdata(fig,'rEnd')); fprintf(fid,'Expansion Factor = %g \n', getappdata(fig,'exfNew')); switch getappdata(fig,'convMode') case 2 fprintf(fid,'Rendering Method = dynamic convolution \n'); case 1 fprintf(fid,'Rendering Method = fixed convolution \n'); end %if fprintf(fid,'Intensity Weighting Factor = %g \n', getappdata(fig,'intWeight')); fprintf(fid,'Size Factor (times Loc. Prec.) = %g \n', getappdata(fig,'sizeFac')); switch visMode case 'Image' fprintf(fid,'Visualization Method = Image \n'); case 'Movie' fprintf(fid,'Visualization Method = Movie \n'); fprintf(fid,'Windowsize = %g \n', getappdata(fig,'rW')); fprintf(fid,'Stepsize = %g \n', getappdata(fig,'rStep')); fprintf(fid,'Frames/Second = %g \n', getappdata(fig,'fps')); switch getappdata(fig,'movCompression') case 1 fprintf(fid,'Compression Algorithm = RLE \n'); case 2 fprintf(fid,'Compression Algorithm = MSVL \n'); case 3 fprintf(fid,'Compression Algorithm = no Compression \n'); end %switch end %switch fprintf(fid, '\n Filter Options: \n'); fprintf(fid,'Localization Precision = %g \n',... getappdata(fig,'isThreshLocPrec')) fprintf(fid,'Filter Range = %g to %g \n',... getappdata(fig,'minLoc'), getappdata(fig,'maxLoc')); fprintf(fid,'Signal to Noise Ratio = %g \n',... getappdata(fig,'isThreshSNR')) fprintf(fid,'Filter Range = %g to %g \n',... getappdata(fig,'minSNR'), getappdata(fig,'maxSNR')); fclose(fid); end end function [data,tree,score,radius,sigma] = densitybasedClustering(data) fig =... figure(... 'Units','normalized',... 'Position', [0.1 0.2 0.8 0.6],... 'NumberTitle', 'off',... 'MenuBar', 'none',... 'ToolBar', 'figure',... 'Resize', 'on',... 'DockControls', 'off',... 'Name', 'Densitybased Clustering',... 'Renderer','zbuffer',... 'Color', get(0,'defaultUicontrolBackgroundColor')); %customize toolbar hToolBar = findall(fig,'Type','uitoolbar'); hToggleList = findall(hToolBar); delete(hToggleList([2 3 4 5 6 7 8 10 13 14 15 16 17 18])) ax(1) =... axes(... 'Parent', fig,... 'Units','normalized',... 'OuterPosition', [0 0 0.7 1],... 'Box','on'); ax(2) =... axes(... 'Parent', fig,... 'Units','normalized',... 'Position', [0.69 0.84 0.3 0.08]); ax(3) =... axes(... 'Parent', fig,... 'Units','normalized',... 'Position', [0.69 0.7 0.3 0.08]); ax(4) =... axes(... 'Parent', fig,... 'Units','normalized',... 'Position', [0.69 0.56 0.3 0.08]); ax(5) =... axes(... 'Parent', fig,... 'Units','normalized',... 'Position', [0.69 0.42 0.3 0.08]); % ax(4) =... % axes(... % 'Parent', fig,... % 'Units','normalized',... % 'Position', [0.7 0.41 0.29 0.15],... % 'XTickLabel','',... % 'YTickLabel',''); uicontrol(... 'Style', 'text',... 'Units','normalized',... 'Position', [0.7 0.26 0.1 0.05],... 'FontSize', 13,... 'FontUnits', 'normalized',... 'String', 'Scale(x,y,z):',... 'HorizontalAlignment', 'left'); uicontrol(... 'Style', 'edit',... 'Tag', 'DBSCAN scalex',... 'Units','normalized',... 'Position', [0.8 0.26 0.05 0.05],... 'FontSize', 15,... 'FontUnits', 'normalized',... 'String', '1',... 'BackgroundColor', [1 1 1]); uicontrol(... 'Style', 'edit',... 'Tag', 'DBSCAN scaley',... 'Units','normalized',... 'Position', [0.85 0.26 0.05 0.05],... 'FontSize', 15,... 'FontUnits', 'normalized',... 'String', '1',... 'BackgroundColor', [1 1 1]); uicontrol(... 'Style', 'edit',... 'Tag', 'DBSCAN scalez',... 'Units','normalized',... 'Position', [0.9 0.26 0.05 0.05],... 'FontSize', 15,... 'FontUnits', 'normalized',... 'String', '0.01',... 'BackgroundColor', [1 1 1]); uicontrol(... 'Style', 'togglebutton',... 'Units','normalized',... 'Position', [0.95 0.26 0.05 0.05],... 'FontSize', 15,... 'FontUnits', 'normalized',... 'String', 'lock',... 'Callback', @lockScale); uicontrol(... 'Style', 'checkbox',... 'Tag', 'DBSCAN isWeighted',... 'Units','normalized',... 'Position', [0.7 0.21 0.3 0.05],... 'FontSize', 15,... 'FontUnits', 'normalized',... 'Value', 1,... 'String', ' Set 3D-Gaussian Weights:',... 'Callback', @activateWeights); uicontrol(... 'Style', 'text',... 'Units','normalized',... 'Position', [0.7 0.16 0.15 0.05],... 'FontSize', 15,... 'FontUnits', 'normalized',... 'String', 'Sigma(x,y,z):',... 'HorizontalAlignment', 'left'); uicontrol(... 'Style', 'edit',... 'Tag', 'DBSCAN sigx',... 'Units','normalized',... 'Position', [0.85 0.16 0.05 0.05],... 'FontSize', 15,... 'FontUnits', 'normalized',... 'String', '1',... 'BackgroundColor', [1 1 1]); uicontrol(... 'Style', 'edit',... 'Tag', 'DBSCAN sigy',... 'Units','normalized',... 'Position', [0.9 0.16 0.05 0.05],... 'FontSize', 15,... 'FontUnits', 'normalized',... 'String', '1',... 'BackgroundColor', [1 1 1]); uicontrol(... 'Style', 'edit',... 'Tag', 'DBSCAN sigz',... 'Units','normalized',... 'Position', [0.95 0.16 0.05 0.05],... 'FontSize', 15,... 'FontUnits', 'normalized',... 'String', '1',... 'BackgroundColor', [1 1 1]); uicontrol(... 'Style', 'text',... 'Units','normalized',... 'Position', [0.7 0.11 0.15 0.05],... 'FontSize', 15,... 'FontUnits', 'normalized',... 'String', 'min Score:',... 'HorizontalAlignment', 'left'); uicontrol(... 'Style', 'edit',... 'Tag', 'DBSCAN score',... 'Units','normalized',... 'Position', [0.85 0.11 0.08 0.05],... 'FontSize', 15,... 'FontUnits', 'normalized',... 'String', '1',... 'BackgroundColor', [1 1 1]); uicontrol(... 'Style', 'pushbutton',... 'Units','normalized',... 'Position', [0.93 0.11 0.07 0.05],... 'FontSize', 15,... 'FontUnits', 'normalized',... 'String', 'critical',... 'Callback', @evalCriticalScore); uicontrol(... 'Style', 'text',... 'Units','normalized',... 'Position', [0.7 0.06 0.15 0.05],... 'FontSize', 15,... 'FontUnits', 'normalized',... 'String', 'Search Radius:',... 'HorizontalAlignment', 'left'); uicontrol(... 'Style', 'edit',... 'Tag', 'DBSCAN radius',... 'Units','normalized',... 'Position', [0.85 0.06 0.08 0.05],... 'FontSize', 15,... 'FontUnits', 'normalized',... 'String', '1',... 'BackgroundColor', [1 1 1],... 'Enable', 'off'); uicontrol(... 'Style', 'popupmenu',... 'Tag', 'DBSCAN units',... 'Units','normalized',... 'Position', [0.93 0.06 0.07 0.05],... 'FontSize', 15,... 'FontUnits', 'normalized',... 'String', {'px', 'nm'},... 'Value', 1,... 'BackgroundColor', [1 1 1],... 'Enable', 'off'); uicontrol(... 'Style', 'pushbutton',... 'Units','normalized',... 'Position', [0.8 0 0.1 0.06],... 'FontSize', 15,... 'FontUnits', 'normalized',... 'String', 'evaluate',... 'Callback', @evalDensity); % uicontrol(... % 'Style', 'pushbutton',... % 'Units','normalized',... % 'Position', [0.8 0 0.1 0.06],... % 'FontSize', 15,... % 'FontUnits', 'normalized',... % 'String', 'preview',... % 'Callback', @showClusterPreview); uicontrol(... 'Style', 'pushbutton',... 'Units','normalized',... 'Position', [0.9 0 0.1 0.06],... 'FontSize', 15,... 'FontUnits', 'normalized',... 'String', 'accept',... 'Callback', @accept); pnts = numel(data.ctrsX); rescaled = struct('ctrsX',[],'ctrsY',[],'frame',[]); drawnow uiwait(fig) function activateWeights(src,event) switch get(src,'Value') case 1 set(findobj(fig,'Tag','DBSCAN sigx',... '-or','Tag','DBSCAN sigy','-or','Tag','DBSCAN sigz'),... 'Enable','on') set(findobj(fig,'Tag','DBSCAN radius',... '-or','Tag','DBSCAN units'),'Enable','off') case 0 set(findobj(fig,'Tag','DBSCAN sigx',... '-or','Tag','DBSCAN sigy','-or','Tag','DBSCAN sigz'),... 'Enable','off') set(findobj(fig,'Tag','DBSCAN radius',... '-or','Tag','DBSCAN units'),'Enable','on') end %switch end function lockScale(src,event) hScaleX = findobj(fig,'Tag','DBSCAN scalex'); hScaleY = findobj(fig,'Tag','DBSCAN scaley'); hScaleZ = findobj(fig,'Tag','DBSCAN scalez'); if get(src,'Value') cla(ax(1),'reset'); set(ax(1),'UserData',[],'Box','on') hMsg =... text(0.5,0.5,... {'Please wait...',... 'this may take approximatly',... [num2str(2e-10*pnts^2.14,'%.0f') ' seconds to finish'],... '(building kd-tree)'},... 'Parent', ax(1),... 'Units', 'normalized',... 'FontSize', 25,... 'FontUnits', 'normalized',... 'HorizontalAlignment', 'center'); drawnow %rescale data dimensions rescaled.ctrsX = str2double(get(hScaleX,'String'))*data.ctrsX; rescaled.ctrsY = str2double(get(hScaleY,'String'))*data.ctrsY; rescaled.frame = str2double(get(hScaleZ,'String'))*data.frame; set([hScaleX hScaleY hScaleZ],'Enable','off') if isappdata(fig,'tree') kdtree_delete(tree) %free memory from old tree rmappdata(fig,'tree') end %if tree = kdtree_build([rescaled.ctrsX rescaled.ctrsY rescaled.frame]); setappdata(fig,'tree',tree) if get(findobj(fig,'Tag','DBSCAN isWeighted'),'Value') sigma = [str2double(get(findobj(fig,'Tag','DBSCAN sigx'),'String')),... str2double(get(findobj(fig,'Tag','DBSCAN sigy'),'String')),... str2double(get(findobj(fig,'Tag','DBSCAN sigz'),'String'))]; radius = 3*max(sigma); else sigma = []; radius = str2double(get(findobj(fig,'Tag','DBSCAN radius'),'String')); end %if delete(hMsg) else set([hScaleX hScaleY hScaleZ],'Enable','on') end %if end function evalDensity(src,event) if get(findobj(fig,'Tag','DBSCAN isWeighted'),'Value') sigma = [str2double(get(findobj(fig,'Tag','DBSCAN sigx'),'String')),... str2double(get(findobj(fig,'Tag','DBSCAN sigy'),'String')),... str2double(get(findobj(fig,'Tag','DBSCAN sigz'),'String'))]; radius = 3*max(sigma); else sigma = []; radius = str2double(get(findobj(fig,'Tag','DBSCAN radius'),'String')); end %if score = str2double(get(findobj(fig,'Tag','DBSCAN score'),'String')); %perform cluster analysis tree = getappdata(fig,'tree'); [data.cluster data.clusterClass data.densityScore] =... dbscan(tree,rescaled.ctrsX,rescaled.ctrsY,... rescaled.frame,score,radius,sigma); nBins = calcnbins(data.densityScore,'fd'); clusterSize = accumarray(data.cluster+1,1); clusterScore = accumarray(data.cluster+1,data.densityScore); meanClusterScore = clusterScore./clusterSize; cla(ax(2)) set(ax(2),'NextPlot','add') [freq bin] = hist(clusterSize(2:end),nBins); bar(ax(2),bin,freq,'hist') try fitHalfLife = fit(bin',freq','exp1'); y = feval(fitHalfLife,bin); hold on plot(ax(2),bin,y,'Color',[1 0 0],'Linewidth',2) legend(ax(2),'Cluster Size',... sprintf('Average Life Time ~ %.0f',-1/fitHalfLife.b)) catch legend(ax(2),'Cluster Size') end cla(ax(3)) [freq bin] = hist(clusterScore,nBins); bar(ax(3),bin,freq,'hist') legend(ax(3),'Cluster Score') cla(ax(4)) [freq bin] = hist(meanClusterScore,nBins); bar(ax(4),bin,freq,'hist') legend(ax(4),'Average Cluster Score') cla(ax(5)) [freq bin] = hist(data.densityScore,nBins); bar(ax(5),bin,freq,'hist') legend(ax(5),'Point Score') title(ax(1),sprintf('%d clusters (%.2f %%noise)',... max(data.cluster),clusterSize(1)/pnts*100)) %plot result if isempty(get(ax(1),'UserData')) hPatch = presentResult([]); set(ax(1),'UserData',hPatch) else presentResult(get(ax(1),'UserData')); end %if function hPatch = presentResult(hPatch) if isempty(hPatch) hScaleX = findobj(fig,'Tag','DBSCAN scalex'); hScaleY = findobj(fig,'Tag','DBSCAN scaley'); hScaleZ = findobj(fig,'Tag','DBSCAN scalez'); x = [1 0; 1 1; 1 0; 1 -1; 1 0; 1 0]*... [rescaled.ctrsX,str2double(get(hScaleX,'String'))*data.radius]'; y = [1 0; 1 0; 1 1; 1 0; 1 -1; 1 0]*... [rescaled.ctrsY,str2double(get(hScaleY,'String'))*data.radius]'; z = [1 1; 1 0; 1 0; 1 0; 1 0; 1 -1]*... [rescaled.frame,str2double(get(hScaleZ,'String'))*data.radius]'; vertices = [x(:) y(:) z(:)]; faceIdx = repmat([1 2 3; 1 3 4; 1 4 5; 1 5 2;... 6 2 3; 6 3 4; 6 4 5; 6 5 2],pnts,1); face = reshape(repmat(0:6:6*(pnts-1),24,1),[3 pnts*8]); face = faceIdx+face'; color = [[1 1 1]; rand(max(data.cluster),3)]; cIdx = reshape(repmat((data.cluster+1)',8,1),[1 8*pnts]); if 1 hPatch = patch('Faces',face(cIdx>1,:),'Vertices',vertices,... 'FaceVertexCData', color(cIdx(cIdx>1),:),... 'FaceColor', 'flat','UserData',face,'Parent',ax(1)); else hPatch = patch('Faces',face,'Vertices',vertices,... 'FaceVertexCData', color(cIdx,:),... 'FaceColor', 'flat','Parent', ax(1)); end view(ax(1),-37.5,30) axis (ax(1),'vis3d','tight') else color = [[1 1 1]; rand(max(data.cluster),3)]; cIdx = reshape(repmat((data.cluster+1)',8,1),[1 8*pnts]); if 1 face = get(hPatch,'UserData'); set(hPatch,'Faces',face(cIdx>1,:),... 'FaceVertexCData', color(cIdx(cIdx>1),:)); else set(hPatch,'FaceVertexCData', color(cIdx,:)) end %if end %if end end function accept(src, event) if isappdata(fig,'tree') kdtree_delete(tree) %free memory from tree rmappdata(fig,'tree') end %if delete(gcbf) end function evalCriticalScore(src,event) samplesize = pnts; range = [min(data.ctrsX) max(data.ctrsX)... min(data.ctrsY) max(data.ctrsY)... min(data.frame) max(data.frame)]; vals = inputdlg(... {'# Monte Carlo Simulations',... 'Significance Level (alpha)'},... 'Settings',... 1,... {'10','0.001'}); if get(findobj(fig,'Tag','DBSCAN isWeighted'),'Value') sigma = [str2double(get(findobj(fig,'Tag','DBSCAN sigx'),'String')),... str2double(get(findobj(fig,'Tag','DBSCAN sigy'),'String')),... str2double(get(findobj(fig,'Tag','DBSCAN sigz'),'String'))]; radius = 3*max(sigma); else sigma = []; radius = str2double(get(findobj(fig,'Tag','DBSCAN radius'),'String')); end %if estimateCriticalScore(... [],[],str2double(vals{2}),samplesize,... range,str2double(vals{1}),sigma,radius); function criticalScore =... estimateCriticalScore(... tree,data,alpha,samplesize,range,iter,sigma,radius) if isempty(tree) auto = 1; end %if criticalScore = nan(iter,1); for test = 1:iter testpoints = [unifrnd(range(1),range(2),[samplesize 1])... unifrnd(range(3),range(4),[samplesize 1])... round(unifrnd(range(5),range(6),[samplesize,1]))]; if auto tree = kdtree_build(testpoints); data.ctrsX = testpoints(:,1); data.ctrsY = testpoints(:,2); data.frame = testpoints(:,3); end %if if isempty(sigma) applyWeight = false; else applyWeight = true; end %if for p = 1:samplesize ref = testpoints(p,:); iNN = kdtree_ball_query(tree, ref, radius); iNN(iNN == p) = []; if applyWeight score(p) = nansum(... exp(-((data.ctrsX(iNN)-ref(1)).^2/2/sigma(1)+... (data.ctrsY(iNN)-ref(2)).^2/2/sigma(2)+... (data.frame(iNN)-ref(3)).^2/2/sigma(3)))); else score(p) = numel(iNN); end %if end %for [pScore score] = ecdf(score); criticalScore(test) = score(find(pScore >= 1-alpha, 1, 'first')); end %for criticalScore = mean(criticalScore); set(findobj(fig,'Tag','DBSCAN score'),'String', criticalScore) end end end function [clusterID pntClass pntScore] = dbscan(tree,x,y,t,criticalScore,radius,sigma) %DBSCAN (Density-Based Spatial Clustering of Applications with Noise) %is a data clustering algorithm proposed by Martin Ester, Hans-Peter Kriegel, %Jörg Sander and Xiaowei Xu in 1996. %written by C.P.Richter, 2010.10.25 if isempty(sigma) applyWeight = false; else applyWeight = true; end %if pnts = sum(isfinite(x)); clusterID = nan(pnts,1); %unclassified pntClass = zeros(pnts,1); pntScore = clusterID; cluster = 1; for idx = 1:pnts pnt = [x(idx,:) y(idx,:) t(idx,:)]; if isnan(clusterID(idx)) output = expandCluster; if output cluster = cluster+1; end %if end %if end %for pntClass(pntClass < 0 & clusterID > 0) = 0; function output = expandCluster [iNN score] = findNeighbors(pnt); pntScore(idx) = score; if score < criticalScore output = false; clusterID(idx) = 0; pntClass(idx) = -1; %noise return else output = true; clusterID(iNN) = cluster; pntClass(idx) = 1; %core point iNN(iNN == idx) = []; seeds = [x(iNN) y(iNN) t(iNN) iNN]; while ~isempty(seeds) [iNN score] = findNeighbors(seeds(1,1:3)); pntScore(seeds(1,4)) = score; if score >= criticalScore %core point pntClass(seeds(1,4)) = 1; %core point iNN(iNN == seeds(1,4)) = []; result = [x(iNN) y(iNN) t(iNN) iNN]; %check if points are already assigned to a cluster % good = isnan(clusterID(iNN)); % seeds = [seeds; result(good,:)]; % clusterID(good) = cluster; for N = 1:numel(iNN) if isnan(clusterID(iNN(N))) seeds(end+1,:) = result(N,:); clusterID(iNN(N)) = cluster; end %if end %for end %if seeds(1,:) = []; end %while end %if function [iNN score] = findNeighbors(ref) iNN = kdtree_ball_query(tree, ref, radius); if applyWeight score = nansum(... exp(-((x(iNN)-ref(1)).^2/2/sigma(1)+... (y(iNN)-ref(2)).^2/2/sigma(2)+... (t(iNN)-ref(3)).^2/2/sigma(3))))-1; else score = numel(iNN); end %if end end end function changeCheckMode(src, event) if strcmp(get(src, 'Checked'),'on') set(src, 'Checked', 'off') else hList = allchild(get(src, 'Parent')); set(hList, 'Checked', 'off') set(src, 'Checked', 'on') end %if end function psf = buildPSF(sig, xw, yw) psf = zeros(yw,xw); w = ceil(6*sig); % 99% of gaussian x = floor(xw/2-w/2); y = floor(yw/2-w/2); [X Y] = meshgrid(-w/2:w/2); psf(y:y+w,x:x+w) = 1/(2*pi*sig^2)*... exp(-(X.^2+Y.^2)/(2*sig^2)); psf = fft2(psf); %translate to frequency space end function [ax, h] = buildHistogram(ax,data,unit) [freq(:,1), ctrs] = ksdensity(data,... 'npoints',calcnbins(data,'fd'),... 'function', 'cdf'); freq(:,2) = hist(data,ctrs); [ax, h(1) h(2)] = ... plotyy(ax,ctrs,freq(:,2),ctrs,freq(:,1),'bar','plot'); set(ax,'FontSize',20) ylabel(ax(1),'Frequency') ylabel(ax(2),'Cumulative Probability') set(h(2),'color','r','linewidth', 3) legend({sprintf(['\t min = %.0f ' unit... ' \n max = %.0f ' unit... '\n mean = %.0f ' unit... ' \n std = %.0f' unit],... min(ctrs),max(ctrs),mean(ctrs),std(ctrs)),'CDF'}) axis(ax(1), [min(ctrs) max(ctrs) min(freq(:,2)) max(freq(:,2))]) axis(ax(2), [min(ctrs) max(ctrs) min(freq(:,1)) max(freq(:,1))]) end function string = pxChars(N,M,num,scaleFactor) %#ok n_ = [... 0 0;... 0 0;... 0 0;... 0 0;... 0 0] ;%#ok np = [... 0;... 0;... 0;... 0;... 1] ;%#ok n0 = [... 1 1 1;... 1 0 1;... 1 0 1;... 1 0 1;... 1 1 1] ;%#ok n1 = [... 0 1 0;... 0 1 0;... 0 1 0;... 0 1 0;... 0 1 0] ;%#ok n2= [... 1 1 1;... 0 0 1 ;... 1 1 1;... 1 0 0;... 1 1 1] ;%#ok n3= [... 1 1 1;... 0 0 1 ;... 0 1 1;... 0 0 1;... 1 1 1] ;%#ok n4= [... 1 0 1;... 1 0 1 ;... 1 1 1;... 0 0 1;... 0 0 1] ;%#ok n5 = [... 1 1 1;... 1 0 0;... 1 1 1;... 0 0 1;... 1 1 1] ;%#ok n6= [... 1 1 1;... 1 0 0 ;... 1 1 1;... 1 0 1;... 1 1 1] ;%#ok n7 = [... 1 1 1;... 0 0 1;... 0 1 0;... 0 1 0;... 0 1 0] ;%#ok n8 = [... 1 1 1;... 1 0 1;... 1 1 1;... 1 0 1;... 1 1 1] ;%#ok n9 = [... 1 1 1;... 1 0 1;... 1 1 1;... 0 0 1;... 1 1 1] ;%#ok nA = [... 0 1 1 1 0;... 1 0 0 0 1;... 1 1 1 1 1;... 1 0 0 0 1;... 1 0 0 0 1] ;%#ok nB = [... 1 1 1 1 0;... 1 0 0 0 1;... 1 1 1 1 0;... 1 0 0 0 1;... 1 1 1 1 0] ;%#ok nC = [... 1 1 1 1 1;... 1 0 0 0 0;... 1 0 0 0 0;... 1 0 0 0 0;... 1 1 1 1 1] ;%#ok nD = [... 1 1 1 1 0;... 1 0 0 0 1;... 1 0 0 0 1;... 1 0 0 0 1;... 1 1 1 1 0] ;%#ok nE = [... 1 1 1 1 1;... 1 0 0 0 0;... 1 1 1 1 1;... 1 0 0 0 0;... 1 1 1 1 1] ;%#ok nF = [... 1 1 1 1 1;... 1 0 0 0 0;... 1 1 1 1 1;... 1 0 0 0 0;... 1 0 0 0 0] ;%#ok nG = [... 1 1 1 1 1;... 1 0 0 0 0;... 1 0 1 1 1;... 1 0 0 0 1;... 1 1 1 1 1] ;%#ok nH = [... 1 0 0 0 1;... 1 0 0 0 1;... 1 1 1 1 1;... 1 0 0 0 1;... 1 0 0 0 1] ;%#ok nI = [... 0 1 1 1 0;... 0 0 1 0 0;... 0 0 1 0 0;... 0 0 1 0 0;... 0 1 1 1 0] ;%#ok nJ = [... 1 1 1 1 1;... 0 0 0 0 1;... 0 0 0 0 1;... 1 0 0 0 1;... 0 1 1 1 0] ;%#ok nK = [... 1 0 0 0 1;... 1 0 0 1 0;... 1 1 1 0 0;... 1 0 0 1 0;... 1 0 0 0 1] ;%#ok nL = [... 1 0 0 0 0;... 1 0 0 0 0;... 1 0 0 0 0;... 1 0 0 0 0;... 1 1 1 1 1] ;%#ok nM = [... 1 1 0 1 1;... 1 0 1 0 1;... 1 0 1 0 1;... 1 0 0 0 1;... 1 0 0 0 1] ;%#ok nN = [... 1 0 0 0 1;... 1 1 0 0 1;... 1 0 1 0 1;... 1 0 0 1 1;... 1 0 0 0 1] ;%#ok nO = [... 0 1 1 1 0;... 1 0 0 0 1;... 1 0 0 0 1;... 1 0 0 0 1;... 0 1 1 1 0] ;%#ok nP = [... 1 1 1 1 0;... 1 0 0 0 1;... 1 1 1 1 0;... 1 0 0 0 0;... 1 0 0 0 0] ;%#ok nQ = [... 0 1 1 1 0;... 1 0 0 0 1;... 1 0 1 0 1;... 1 0 0 1 0;... 0 1 1 0 1] ;%#ok nR = [... 1 1 1 1 0;... 1 0 0 0 1;... 1 1 1 1 0;... 1 0 0 1 0;... 1 0 0 0 1] ;%#ok nS = [... 1 1 1 1 1;... 1 0 0 0 0;... 1 1 1 1 1;... 0 0 0 0 1;... 1 1 1 1 1] ;%#ok nT = [... 1 1 1 1 1;... 0 0 1 0 0;... 0 0 1 0 0;... 0 0 1 0 0;... 0 0 1 0 0] ;%#ok nU = [... 1 0 0 0 1;... 1 0 0 0 1;... 1 0 0 0 1;... 1 0 0 0 1;... 0 1 1 1 0] ;%#ok nV = [... 1 0 0 0 1;... 1 0 0 0 1;... 1 0 0 0 1;... 0 1 0 1 0;... 0 0 1 0 0] ;%#ok nW = [... 1 0 0 0 1;... 1 0 0 0 1;... 1 0 1 0 1;... 1 0 1 0 1;... 0 1 0 1 0] ;%#ok nX = [... 1 0 0 0 1;... 0 1 0 1 0;... 0 0 1 0 0;... 0 1 0 1 0;... 1 0 0 0 1] ;%#ok nY = [... 1 0 0 0 1;... 0 1 0 1 0;... 0 0 1 0 0;... 0 0 1 0 0;... 0 0 1 0 0] ;%#ok nZ = [... 1 1 1 1 1;... 0 0 0 1 0;... 0 0 1 0 0;... 0 1 0 0 0;... 1 1 1 1 1] ;%#ok nm = [... 0 0 0 0 0;... 0 0 0 0 0;... 0 1 0 1 0;... 1 0 1 0 1;... 1 0 1 0 1] ;%#ok nn = [... 0 0 0;... 0 0 0;... 0 1 0;... 1 0 1;... 1 0 1] ;%#ok strnum = num2str(num) ; string = eval(sprintf('imresize(n%s,scaleFactor)>0.5;', strnum(1))); for c=2:size(strnum, 2) string = [string, zeros(5*scaleFactor,1),... eval(sprintf('imresize(n%s,scaleFactor)>0.5;', strnum(c)))]; end%for end%function function pos = figPos(ratio) scrSize = get(0, 'ScreenSize'); if ratio > 1 pos = [0.3 0.09... 0.65*scrSize(4)/scrSize(3) 0.65/ratio]; elseif ratio < 1 pos = [0.3 0.09... 0.65*scrSize(4)/scrSize(3)*ratio 0.65]; else pos = [0.3 0.09... 0.65*scrSize(4)/scrSize(3) 0.65]; end %if end function nbins = calcnbins(x, method, minimum, maximum) % Calculate the "ideal" number of bins to use in a histogram, using a % choice of methods. % % NBINS = CALCNBINS(X, METHOD) calculates the "ideal" number of bins to use % in a histogram, using a choice of methods. The type of return value % depends upon the method chosen. Possible values for METHOD are: % 'fd': A single integer is returned, and CALCNBINS uses the % Freedman-Diaconis method, % based upon the inter-quartile range and number of data. % See Freedman, David; Diaconis, P. (1981). "On the histogram as a density % estimator: L2 theory". Zeitschrift für Wahrscheinlichkeitstheorie und % verwandte Gebiete 57 (4): 453-476. % 'scott': A single integer is returned, and CALCNBINS uses Scott's method, % based upon the sample standard deviation and number of data. % See Scott, David W. (1979). "On optimal and data-based histograms". % Biometrika 66 (3): 605-610. % % 'sturges': A single integer is returned, and CALCNBINS uses Sturges' % method, based upon the number of data. % See Sturges, H. A. (1926). "The choice of a class interval". J. American % Statistical Association: 65-66. % % 'middle': A single integer is returned. CALCNBINS uses all three % methods, then picks the middle (median) value. % % 'all': A structure is returned with fields 'fd', 'scott' and 'sturges', % each containing the calculation from the respective method. % % NBINS = CALCNBINS(X) works as NBINS = CALCNBINS(X, 'MIDDLE'). % % NBINS = CALCNBINS(X, [], MINIMUM), where MINIMUM is a numeric scalar, % defines the smallest acceptable number of bins. % % NBINS = CALCNBINS(X, [], MAXIMUM), where MAXIMUM is a numeric scalar, % defines the largest acceptable number of bins. % % Notes: % 1. If X is complex, any imaginary components will be ignored, with a % warning. % % 2. If X is an matrix or multidimensional array, it will be coerced to a % vector, with a warning. % % 3. Partial name matching is used on the method name, so 'st' matches % sturges, etc. % % 4. This function is inspired by code from the free software package R % (http://www.r-project.org). See 'Modern Applied Statistics with S' by % Venables & Ripley (Springer, 2002, p112) for more information. % % 5. The "ideal" number of depends on what you want to show, and none of % the methods included are as good as the human eye. It is recommended % that you use this function as a starting point rather than a definitive % guide. % % 6. The wikipedia page on histograms currently gives a reasonable % description of the algorithms used. % See http://en.wikipedia.org/w/index.php?title=Histogram&oldid=232222820 % % Examples: % y = randn(10000,1); % nb = calcnbins(y, 'all') % nb = % fd: 66 % scott: 51 % sturges: 15 % calcnbins(y) % ans = % 51 % subplot(3, 1, 1); hist(y, nb.fd); % subplot(3, 1, 2); hist(y, nb.scott); % subplot(3, 1, 3); hist(y, nb.sturges); % y2 = rand(100,1); % nb2 = calcnbins(y2, 'all') % nb2 = % fd: 5 % scott: 5 % sturges: 8 % hist(y2, calcnbins(y2)) % % See also: HIST, HISTX % % $ Author: Richard Cotton $ $ Date: 2008/10/24 $ $ Version 1.5 $ % Input checking error(nargchk(1, 4, nargin)); if ~isnumeric(x) && ~islogical(x) error('calcnbins:invalidX', 'The X argument must be numeric or logical.') end if ~isreal(x) x = real(x); warning('calcnbins:complexX', 'Imaginary parts of X will be ignored.'); end % Ignore dimensions of x. if ~isvector(x) x = x(:); warning('calcnbins:nonvectorX', 'X will be coerced to a vector.'); end nanx = isnan(x); if any(nanx) x = x(~nanx); warning('calcnbins:nanX', 'Values of X equal to NaN will be ignored.'); end if nargin < 2 || isempty(method) method = 'middle'; end if ~ischar(method) error('calcnbins:invalidMethod', 'The method argument must be a char array.'); end validmethods = {'fd'; 'scott'; 'sturges'; 'all'; 'middle'}; methodmatches = strmatch(lower(method), validmethods); nmatches = length(methodmatches); if nmatches~=1 error('calnbins:unknownMethod', 'The method specified is unknown or ambiguous.'); end method = validmethods{methodmatches}; if nargin < 3 || isempty(minimum) minimum = 1; end if nargin < 4 || isempty(maximum) maximum = Inf; end % Perform the calculation switch(method) case 'fd' nbins = calcfd(x); case 'scott' nbins = calcscott(x); case 'sturges' nbins = calcsturges(x); case 'all' nbins.fd = calcfd(x); nbins.scott = calcscott(x); nbins.sturges = calcsturges(x); case 'middle' nbins = median([calcfd(x) calcscott(x) calcsturges(x)]); end % Calculation details function nbins = calcfd(x) h = diff(prctile0(x, [25; 75])); %inter-quartile range if h == 0 h = 2*median(abs(x-median(x))); %twice median absolute deviation end if h > 0 nbins = ceil((max(x)-min(x))/(2*h*length(x)^(-1/3))); else nbins = 1; end nbins = confine2range(nbins, minimum, maximum); end function nbins = calcscott(x) h = 3.5*std(x)*length(x)^(-1/3); if h > 0 nbins = ceil((max(x)-min(x))/h); else nbins = 1; end nbins = confine2range(nbins, minimum, maximum); end function nbins = calcsturges(x) nbins = ceil(log2(length(x)) + 1); nbins = confine2range(nbins, minimum, maximum); end function y = confine2range(x, lower, upper) y = ceil(max(x, lower)); y = floor(min(y, upper)); end function y = prctile0(x, prc) % Simple version of prctile that only operates on vectors, and skips % the input checking (In particluar, NaN values are now assumed to % have been removed.) lenx = length(x); if lenx == 0 y = []; return end if lenx == 1 y = x; return end function foo = makecolumnvector(foo) if size(foo, 2) > 1 foo = foo'; end end sortx = makecolumnvector(sort(x)); posn = prc.*lenx/100 + 0.5; posn = makecolumnvector(posn); posn = confine2range(posn, 1, lenx); y = interp1q((1:lenx)', sortx, posn); end end function [filenameNew, pathnameNew, flag] =... checkNameExistance(filename, pathname) if exist([pathname filename],'file') answer = questdlg(... 'Do you want to override existing File?', ... 'Warning', ... 'Yes', 'No', 'No'); switch answer case 'Yes' %data will be replaced setappdata(0, 'searchPath', pathname) delete([pathname filename '.*']) pathnameNew = pathname; filenameNew = filename; flag = 0; case 'No' %loop until unoccupied filename is selected while 1 [filename,pathname,isOK] =... uiputfile('','Save to',... [getappdata(0,'searchPath') filename]); if isOK && ~exist([pathname filename],'file') setappdata(0, 'searchPath', pathname) pathnameNew = pathname; filenameNew = filename; flag = 0; break elseif ~isOK %abort file saving flag = 1; end %if end %while end %switch else pathnameNew = pathname; filenameNew = filename; flag = 0; end %if end