diff --git a/.gitignore b/.gitignore index a110f14c6e77ce9a8f80ee9f71b36315b6edfc6e..6c8603940a54ec0ace3ed0582fc786da328c81d9 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,9 @@ bin/*.prj bin/*.txt segmentationData/ +# Ignore segmentation help function used in compiled LEVER versions. +CompiledSegHelp.m + #ignore thumbnails created by windows Thumbs.db #Ignore files build by Visual Studio @@ -58,3 +61,12 @@ src/MATLAB/*.csv src/MATLAB/filmstrip/*/* src/MATLAB/*.exe bin64/*.exe +*.ipdb +*.iobj +*.exp +*.tlog +*.idb +*.opendb +src/c/Output/TrackerMex/Debug_x64/ +src/c/Output/TrackerMex/Release_x64/ +src/c/trackerMex.mexw64 diff --git a/src/gnu gpl v3.txt b/LICENSE similarity index 100% rename from src/gnu gpl v3.txt rename to LICENSE diff --git a/bin64/LEVER_SegAndTrackFolders.exe b/bin64/LEVER_SegAndTrackFolders.exe index 1d9f15730b67a1dc6f68cc25a76dd4fc5471f4b4..59b002c7389308f269cd3415c3c5fbb0a80cf299 100644 Binary files a/bin64/LEVER_SegAndTrackFolders.exe and b/bin64/LEVER_SegAndTrackFolders.exe differ diff --git a/bin64/LEVer.exe b/bin64/LEVer.exe index fc1b01a469a5d4ec7664a39cabc50e9a44b7fd2d..e8d5b9d9561db81d894b43758ebd9937a07bce62 100644 Binary files a/bin64/LEVer.exe and b/bin64/LEVer.exe differ diff --git a/bin64/MTC.exe b/bin64/MTC.exe deleted file mode 100644 index 041116cabb278981321a8cd7f5978cd015dc6819..0000000000000000000000000000000000000000 Binary files a/bin64/MTC.exe and /dev/null differ diff --git a/bin64/Segmentor.exe b/bin64/Segmentor.exe index 6f743777da97bf502da52284a6acce4d84ea218d..a79c01b79d1a5e6138f0c41f584d167ac68e1170 100644 Binary files a/bin64/Segmentor.exe and b/bin64/Segmentor.exe differ diff --git a/src/MATLAB/+Helper/.gitignore b/src/MATLAB/+Dev/.gitignore similarity index 100% rename from src/MATLAB/+Helper/.gitignore rename to src/MATLAB/+Dev/.gitignore diff --git a/src/MATLAB/+Dev/BuildDependencyGraph.m b/src/MATLAB/+Dev/BuildDependencyGraph.m new file mode 100644 index 0000000000000000000000000000000000000000..517cc444a11fedbf72eb5dafee55511f88c9e7a0 --- /dev/null +++ b/src/MATLAB/+Dev/BuildDependencyGraph.m @@ -0,0 +1,108 @@ +function graphStruct = BuildDependencyGraph(chkPath, bRecurseExternal) + if ( ~exist('chkPath','var') || isempty(chkPath) ) + chkPath = pwd(); + end + + if ( ~exist('bRecurseExternal','var')) + bRecurseExternal = true; + end + + %% Make sure we get back to our current dir even on error. + oldDir = cd(chkPath); + cleanupObj = onCleanup(@()(cd(oldDir))); + + %% + filenames = getAllFiles(chkPath); + + %% Initialize sparse matrix assuming a fanout of about 10x + n = length(filenames); + graphStruct = struct('nodes',{filenames}, 'graph',{sparse([],[],[],n,n,10*n)}); + + graphStruct = recursiveGetDeps(chkPath, graphStruct, filenames, bRecurseExternal); + graphStruct = sortNodes(chkPath,graphStruct); +end + +function graphStruct = sortNodes(localPath, graphStruct) + bLocal = strncmp(localPath,graphStruct.nodes, length(localPath)); + localIdx = find(bLocal); + externalIdx = find(~bLocal); + + %% Sort lexicographically, but all local functions are first. + [~,localSrt] = sort(graphStruct.nodes(bLocal)); + [~,externalSrt] = sort(graphStruct.nodes(~bLocal)); + + srtIdx = [localIdx(localSrt); externalIdx(externalSrt)]; + + graphStruct.nodes = graphStruct.nodes(srtIdx); + graphStruct.graph = graphStruct.graph(srtIdx,:); + graphStruct.graph = graphStruct.graph(:,srtIdx); +end + +function graphStruct = recursiveGetDeps(localPath,graphStruct, checkNames, bRecurseExternal) + if ( isempty(checkNames) ) + return; + end + + newEntries = {}; + + matRoot = matlabroot(); + % Get single-link dependencies + for i=1:length(checkNames) + [fList,pList] = matlab.codetools.requiredFilesAndProducts(checkNames{i}, 'toponly'); + toolboxes = arrayfun(@(x)(fullfile(matRoot,'toolbox',x.Name)),pList, 'UniformOutput',false); + + selfIdx = find(strcmp(checkNames{i},fList)); + if ( isempty(selfIdx) ) + selfIdx = 1; + fList = [checkNames(i) fList]; + end + + newNodes = [fList.'; toolboxes.']; + newGraph = createCallGraph(selfIdx, newNodes); + newStruct = struct('nodes',{newNodes},'graph',{newGraph}); + + [graphStruct,addedNodes] = Dev.MergeGraphStruct(graphStruct, newStruct); + newEntries = [newEntries; addedNodes]; + end + + % Don't recurse through external dependencies + bMatlab = strncmp(matRoot,newEntries, length(matRoot)); + newEntries = newEntries(~bMatlab); + if ( ~bRecurseExternal ) + bNewLocal = strncmp(localPath,newEntries, length(localPath)); + newEntries = newEntries(bNewLocal); + end + + graphStruct = recursiveGetDeps(localPath,graphStruct, newEntries, bRecurseExternal); +end + +function callGraph = createCallGraph(callerIdx,newNodes) + jIdx = setdiff(1:length(newNodes),callerIdx); + iIdx = repmat(callerIdx,1,length(jIdx)); + + callGraph = sparse(iIdx,jIdx, ones(1,length(jIdx)), length(newNodes),length(newNodes), length(jIdx)); +end + +function fullNames = getAllFiles(dirName) + matlabFiles = what(dirName); + + funcFileNames = vertcat(matlabFiles.m); + funcFileNames = [funcFileNames; vertcat(matlabFiles.mex)]; + + fullNames = cellfun(@(x)(fullfile(dirName,x)), funcFileNames, 'UniformOutput',false); + + for i=1:length(matlabFiles.packages) + pkgFullNames = getAllFiles(fullfile(dirName, ['+' matlabFiles.packages{i}])); + fullNames = [fullNames; pkgFullNames]; + end + + for i=1:length(matlabFiles.classes) + classDir = fullfile(dirName, ['@' matlabFiles.classes{i}]); + if ( ~exist(classDir,'dir') ) + continue; + end + + classFullNames = getAllFiles(classDir); + fullNames = [fullNames; classFullNames]; + end +end diff --git a/src/MATLAB/+Dev/BuildToolboxMap.m b/src/MATLAB/+Dev/BuildToolboxMap.m new file mode 100644 index 0000000000000000000000000000000000000000..b1f67fcbe607c9174cad82fe06653a3148cdfc9d --- /dev/null +++ b/src/MATLAB/+Dev/BuildToolboxMap.m @@ -0,0 +1,27 @@ +function toolboxMap = BuildToolboxMap() + toolboxRoot = toolboxdir(''); + toolboxMap = containers.Map('keyType','char', 'valueType','any'); + + % Ignore fixPoint, because + toolboxList = dir(toolboxRoot); + + bInvalidName = arrayfun(@(x)(strcmp(x.name,'.') || strcmp(x.name,'..') || strcmp(x.name,'fixpoint')), toolboxList); + bValidDir = ~bInvalidName & (vertcat(toolboxList.isdir) > 0); + toolboxList = toolboxList(bValidDir); + + % Always add local/shared directory to matlab + toolboxMap('MATLAB') = {fullfile(toolboxRoot,'local');fullfile(toolboxRoot,'shared')}; + + for i=1:length(toolboxList) + verStruct = ver(toolboxList(i).name); + if ( isempty(verStruct) ) + continue; + end + + if ( isKey(toolboxMap,verStruct.Name) ) + toolboxMap(verStruct.Name) = [toolboxMap(verStruct.Name); {fullfile(toolboxRoot,toolboxList(i).name)}]; + else + toolboxMap(verStruct.Name) = {fullfile(toolboxRoot,toolboxList(i).name)}; + end + end +end diff --git a/src/MATLAB/+Dev/CheckMEXSynch.m b/src/MATLAB/+Dev/CheckMEXSynch.m deleted file mode 100644 index cd8c746a9a0879d5c87f0875fa987cd7c6627f81..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Dev/CheckMEXSynch.m +++ /dev/null @@ -1,22 +0,0 @@ -function CheckMEXSynch(checkGraph) - [checkOut checkIn] = mexDijkstra('debugAllEdges'); - - checkOut = sortrows(checkOut); - checkIn = sortrows(checkIn); - - if ( any(checkOut(:) ~= checkIn(:)) ) - error('In/Out MEX Edges are out of synch.'); - end - - if ( exist('checkGraph','var') ) - [rcm, ccm] = find(checkGraph > 0); - graphInd = sub2ind(size(checkGraph), rcm, ccm); - checkMAT = [rcm ccm full(checkGraph(graphInd))]; - - checkMAT = sortrows(checkMAT); - - if ( any(checkOut(:) ~= checkMAT(:)) ) - error('MEX Edges out of synch with Matlab.'); - end - end -end \ No newline at end of file diff --git a/src/MATLAB/+Dev/CompileLEVer.m b/src/MATLAB/+Dev/CompileLEVer.m index ac233f2413fec459038423cdbee6b36fab4542ab..344049255a25240e914bf86d1787cbcecda012de 100644 --- a/src/MATLAB/+Dev/CompileLEVer.m +++ b/src/MATLAB/+Dev/CompileLEVer.m @@ -2,10 +2,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by @@ -25,35 +25,18 @@ function CompileLEVer(forceVersion) totalTime = tic(); - - % Try to set up git for the build, give a warning about checking the - % fallback file if we can't find git. - bFoundGit = Dev.SetupGit(); - if ( ~bFoundGit ) - questionStr = sprintf('%s\n%s','Cannot find git you should verify the fallback file version info before building.','Are you sure you wish to continue with the build?'); - result = questdlg(questionStr,'Build Warning','Yes','No','No'); - if ( strcmpi(result,'No') ) - return; - end - end - - % Give a messagebox warning if there are uncommitted changes. - % Note: even committed changes may not have been pushed to server. - [status,result] = system('git status --porcelain'); - if ( status == 0 && (length(result) > 1) ) - questionStr = sprintf('%s\n%s','There are uncommitted changes in your working directory','Are you sure you wish to continue with the build?'); - result = questdlg(questionStr,'Build Warning','Yes','No','No'); - if ( strcmpi(result,'No') ) - return; - end - end - - if ( ~exist('forceVersion', 'var') ) - Dev.MakeVersion(); - else - Dev.MakeVersion(0, forceVersion); + + if ( ~exist('forceVersion','var') ) + forceVersion = ''; end + + %% General compiler setup: Deals with version updates and pulls external dependencies + initStruct = Dev.InitCompiler('LEVER',forceVersion); + + %% Build FrameSegmentor help information into a function for use in compiled LEVER + Dev.MakeSegHelp(); + %% Setup visual studio for MEX compilation [vsStruct comparch] = setupCompileTools(); bindir = '..\..\bin'; @@ -65,11 +48,15 @@ function CompileLEVer(forceVersion) mkdir(bindir); end + %% Compile all MEX files outputFiles = {}; newOutput = compileMEX('mexMAT', vsStruct); outputFiles = [outputFiles; {newOutput}]; + newOutput = compileMEX('Tracker', vsStruct); + outputFiles = [outputFiles; {newOutput}]; + newOutput = compileMEX('mexDijkstra', vsStruct); outputFiles = [outputFiles; {newOutput}]; @@ -82,49 +69,18 @@ function CompileLEVer(forceVersion) newOutput = compileMEX('mexHashData', vsStruct); outputFiles = [outputFiles; {newOutput}]; - - newOutput = compileEXE('MTC', vsStruct, bindir); - outputFiles = [outputFiles; {newOutput}]; - - [toolboxStruct externalStruct] = Dev.GetExternalDependencies(); - if ( ~isempty(externalStruct.deps) ) - fprintf('ERROR: Some local functions have external dependencies\n'); - for i=1:length(externalStruct.deps) - fprintf('[%d] %s\n', i, externalStruct.deps{i}); - for j=1:length(externalStruct.funcs{i}) - if ( ~isempty(externalStruct.callers{i}{j}) ) - for k=1:length(externalStruct.callers{i}{j}) - localName = Dev.GetLocalName(externalStruct.callers{i}{j}{k}); - fprintf(' %s calls: %s\n', localName, externalStruct.funcs{i}{j}); - end - end - end - fprintf('------\n'); - end - -% error('External dependencies cannot be packaged in a MATLAB executable'); - questionStr = sprintf('%s\n%s','Possible external dependencies were found in project, you should verify all these functions are local before continuing the build.','Are you sure you wish to continue?'); - result = questdlg(questionStr,'External Dependency Warning','Continue','Cancel','Cancel'); - if ( strcmpi(result,'Cancel') ) - return; - end - end - - % temporarily remove any startup scripts that would normally be run by matlabrc - enableStartupScripts(false); + %% Compile LEVER, Segmentor, and batch LEVER_SegAndTrackFolders. addImgs = {'+UI\backFrame.png'; '+UI\forwardFrame.png'; '+UI\pause.png';'+UI\play.png';'+UI\stop.png'}; - newOutput = compileMATLAB('LEVer', bindir, addImgs, toolboxStruct.deps); + newOutput = compileMATLAB('LEVer', bindir, addImgs, initStruct.toolboxList); outputFiles = [outputFiles; {newOutput}]; - newOutput = compileMATLAB('LEVER_SegAndTrackFolders', bindir, {}, toolboxStruct.deps); + newOutput = compileMATLAB('LEVER_SegAndTrackFolders', bindir, {}, initStruct.toolboxList); outputFiles = [outputFiles; {newOutput}]; - newOutput = compileMATLAB('Segmentor', bindir, {}, toolboxStruct.deps); + newOutput = compileMATLAB('Segmentor', bindir, {}, initStruct.toolboxList); outputFiles = [outputFiles; {newOutput}]; - enableStartupScripts(true); - fprintf('\n'); % mcrfile = mcrinstaller(); @@ -133,16 +89,16 @@ function CompileLEVer(forceVersion) bIsEXE = cellfun(@(x)(~isempty(x)), strfind(lower(outputFiles), '.exe')); exeOutputs = outputFiles(bIsEXE); - verSuffix = Helper.GetVersion('file'); - zip(fullfile(bindir,['LEVer' verSuffix '.zip']), [exeOutputs; {'*.bat'}], bindir); +% verSuffix = Dev.GetVersion('file'); +% zip(fullfile(bindir,['LEVer' verSuffix '.zip']), [exeOutputs; {'*.bat'}], bindir); toc(totalTime) end function [vsStruct comparch] = setupCompileTools() - vsStruct.vstoolroot = getenv('VS100COMNTOOLS'); + vsStruct.vstoolroot = getenv('VS140COMNTOOLS'); if ( isempty(vsStruct.vstoolroot) ) - error('Cannot compile MTC and mexMAT without Visual Studio 2010'); + error('Cannot compile MEX files without Visual Studio 2015'); end setenv('MATLAB_DIR', matlabroot()); @@ -152,12 +108,8 @@ function [vsStruct comparch] = setupCompileTools() vsStruct.buildbits = '64'; vsStruct.buildenv = fullfile(vsStruct.vstoolroot,'..','..','vc','bin','amd64','vcvars64.bat'); vsStruct.buildplatform = 'x64'; - elseif ( strcmpi(comparch,'win32') ) - vsStruct.buildbits = '32'; - vsStruct.buildenv = fullfile(vsStruct.vstoolroot,'..','..','vc','bin','vcvars32.bat'); - vsStruct.buildplatform = 'win32'; else - error('Only windows 32/64-bit builds are currently supported'); + error('Only windows 64-bit builds are currently supported'); end system(['"' vsStruct.buildenv '"' ]); @@ -208,8 +160,8 @@ function outputFile = compileMATLAB(projectName, bindir, extrasList, toolboxList end extrasList = vertcat({'LEVER_logo.tif'; '+Segmentation\FrameSegmentor_*.m'; - '+Helper\GetVersion.m'; - '+Helper\VersionInfo.m'}, extrasList); + '+Dev\GetVersion.m'; + '+Dev\VersionInfo.m'}, extrasList); extraCommand = ''; if ( ~isempty(extrasList) ) @@ -237,45 +189,3 @@ function outputFile = compileMATLAB(projectName, bindir, extrasList, toolboxList fprintf('Done (%f sec)\n', toc(compileTime)); end - -function enableStartupScripts(bEnable) - searchPrefix = ''; - renamePrefix = 'disabled_'; - if ( bEnable ) - searchPrefix = 'disabled_'; - renamePrefix = ''; - end - - searchName = [searchPrefix 'startup.m']; - newName = [renamePrefix 'startup.m']; - - startupScripts = findFilesInPath(searchName, userpath); - for i=1:length(startupScripts) - scriptPath = fileparts(startupScripts{i}); - movefile(startupScripts{i}, fullfile(scriptPath,newName)); - end -end - -function fullNames = findFilesInPath(filename, searchPaths) - fullNames = {}; - - chkPaths = []; - while ( ~isempty(searchPaths) ) - [newPath remainder] = strtok(searchPaths, pathsep); - if ( isempty(newPath) ) - searchPaths = remainder; - continue; - end - - chkPaths = [chkPaths; {newPath}]; - searchPaths = remainder; - end - - for i=1:length(chkPaths) - chkFullPath = fullfile(chkPaths{i}, filename); - if ( exist(chkFullPath, 'file') ) - fullNames = [fullNames; {chkFullPath}]; - end - end -end - diff --git a/src/MATLAB/+Dev/DataHash.m b/src/MATLAB/+Dev/DataHash.m deleted file mode 100644 index 31a2986956a96398d1bd91678b18a318819eb11b..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Dev/DataHash.m +++ /dev/null @@ -1,408 +0,0 @@ -function Hash = DataHash(Data, Opt) -% DATAHASH - Checksum for Matlab array of any type -% This function creates a hash value for an input of any type. The type and -% dimensions of the input are considered as default, such that UINT8([0,0]) and -% UINT16(0) have different hash values. Nested STRUCTs and CELLs are parsed -% recursively. -% -% Hash = DataHash(Data, Opt) -% INPUT: -% Data: Array of these built-in types: -% (U)INT8/16/32/64, SINGLE, DOUBLE, (real or complex) -% CHAR, LOGICAL, CELL (nested), STRUCT (scalar or array, nested), -% function_handle. -% Opt: Struct to specify the hashing algorithm and the output format. -% Opt and all its fields are optional. -% Opt.Method: String, known methods for Java 1.6 (Matlab 2009a): -% 'SHA-1', 'SHA-256', 'SHA-384', 'SHA-512', 'MD2', 'MD5'. -% Known methods for Java 1.3 (Matlab 6.5): -% 'MD5', 'SHA-1'. -% Default: 'MD5'. -% Opt.Format: String specifying the output format: -% 'hex', 'HEX': Lower/uppercase hexadecimal string. -% 'double', 'uint8': Numerical vector. -% 'base64': Base64 encoded string, only printable -% ASCII characters, 33% shorter than 'hex'. -% Default: 'hex'. -% Opt.Input: Type of the input as string, not case-sensitive: -% 'array': The contents, type and size of the input [Data] are -% considered for the creation of the hash. Nested CELLs -% and STRUCT arrays are parsed recursively. Empty arrays of -% different type reply different hashs. -% 'file': [Data] is treated as file name and the hash is calculated -% for the files contents. -% 'bin': [Data] is a numerical, LOGICAL or CHAR array. Only the -% binary contents of the array is considered, such that -% e.g. empty arrays of different type reply the same hash. -% Default: 'array'. -% -% OUTPUT: -% Hash: String, DOUBLE or UINT8 vector. The length depends on the hashing -% method. -% -% EXAMPLES: -% % Default: MD5, hex: -% DataHash([]) % 7de5637fd217d0e44e0082f4d79b3e73 -% % MD5, Base64: -% Opt.Format = 'base64'; -% Opt.Method = 'MD5'; -% DataHash(int32(1:10), Opt) % bKdecqzUpOrL4oxzk+cfyg -% % SHA-1, Base64: -% S.a = uint8([]); -% S.b = {{1:10}, struct('q', uint64(415))}; -% Opt.Method = 'SHA-1'; -% DataHash(S, Opt) % ZMe4eUAp0G9TDrvSW0/Qc0gQ9/A -% % SHA-1 of binary values: -% Opt.Method = 'SHA-1'; -% Opt.Input = 'bin'; -% DataHash(1:8, Opt) % 826cf9d3a5d74bbe415e97d4cecf03f445f69225 -% -% NOTE: -% Function handles and user-defined objects cannot be converted uniquely: -% - The subfunction ConvertFuncHandle uses the built-in function FUNCTIONS, -% but the replied struct can depend on the Matlab version. -% - It is tried to convert objects to UINT8 streams in the subfunction -% ConvertObject. A conversion by STRUCT() might be more appropriate. -% Adjust these subfunctions on demand. -% -% MATLAB CHARs have 16 bits! In consequence the string 'hello' is treated as -% UINT16('hello') for the binary input method. -% -% DataHash uses James Tursa's smart and fast TYPECASTX, if it is installed: -% http://www.mathworks.com/matlabcentral/fileexchange/17476 -% As fallback the built-in TYPECAST is used automatically, but for large -% inputs this can be more than 10 times slower. -% For Matlab 6.5 installing typecastx is obligatory to run DataHash. -% -% Tested: Matlab 6.5, 7.7, 7.8, WinXP, Java: 1.3.1_01, 1.6.0_04. -% Author: Jan Simon, Heidelberg, (C) 2011 matlab.THISYEAR(a)nMINUSsimon.de -% -% See also: TYPECAST, CAST. -% FEX: -% Michael Kleder, "Compute Hash", no structs and cells: -% http://www.mathworks.com/matlabcentral/fileexchange/8944 -% Tim, "Serialize/Deserialize", converts structs and cells to a byte stream: -% http://www.mathworks.com/matlabcentral/fileexchange/29457 -% Jan Simon, "CalcMD5", MD5 only, faster C-mex, no structs and cells: -% http://www.mathworks.com/matlabcentral/fileexchange/25921 - -% $JRev: R-j V:010 Sum:q3tnsDSkI19o Date:09-Sep-2011 13:32:19 $ -% $License: BSD (use/copy/change/redistribute on own risk, mention the author) $ -% $File: Tools\GLFile\DataHash.m $ -% History: -% 001: 01-May-2011 21:52, First version. -% 007: 10-Jun-2011 10:38, [Opt.Input], binary data, complex values considered. - -% Main function: =============================================================== -% Java is needed: -if ~usejava('jvm') - error(['JSimon:', mfilename, ':NoJava'], ... - '*** %s: Java is required.', mfilename); -end - -% typecastx creates a shared data copy instead of the deep copy as Matlab's -% TYPECAST - for a [1000x1000] DOUBLE array this is 100 times faster! -persistent usetypecastx -if isempty(usetypecastx) - usetypecastx = ~isempty(which('typecastx')); % Run the slow WHICH once only -end - -% Default options: ------------------------------------------------------------- -Method = 'MD5'; -OutFormat = 'hex'; -isFile = false; -isBin = false; - -% Check number and type of inputs: --------------------------------------------- -nArg = nargin; -if nArg == 2 - if isa(Opt, 'struct') == 0 % Bad type of 2nd input: - error(['JSimon:', mfilename, ':BadInput2'], ... - '*** %s: 2nd input [Opt] must be a struct.', mfilename); - end - - % Specify hash algorithm: - if isfield(Opt, 'Method') - Method = upper(Opt.Method); - end - - % Specify output format: - if isfield(Opt, 'Format') - OutFormat = Opt.Format; - end - - % Check if the Input type is specified - default: 'array': - if isfield(Opt, 'Input') - if strcmpi(Opt.Input, 'File') - isFile = true; - if ischar(Data) == 0 - error(['JSimon:', mfilename, ':CannotOpen'], ... - '*** %s: 1st input is not a file name', mfilename); - end - - if exist(Data, 'file') ~= 2 - error(['JSimon:', mfilename, ':FileNotFound'], ... - '*** %s: File not found: %s.', mfilename, Data); - end - - elseif strncmpi(Opt.Input, 'bin', 3) % Accept 'binary' - isBin = true; - if (isnumeric(Data) || ischar(Data) || islogical(Data)) == 0 - error(['JSimon:', mfilename, ':BadDataType'], ... - '*** %s: 1st input is not numeric, CHAR or LOGICAL.', mfilename); - end - end - end - -elseif nArg ~= 1 % Bad number of arguments: - error(['JSimon:', mfilename, ':BadNInput'], ... - '*** %s: 1 or 2 inputs required.', mfilename); -end - -% Create the engine: ----------------------------------------------------------- -try - Engine = java.security.MessageDigest.getInstance(Method); -catch - error(['JSimon:', mfilename, ':BadInput2'], ... - '*** %s: Invalid algorithm: [%s].', mfilename, Method); -end - -% Create the hash value: ------------------------------------------------------- -if isFile - % Read the file and calculate the hash: - FID = fopen(Data, 'r'); - if FID < 0 - error(['JSimon:', mfilename, ':CannotOpen'], ... - '*** %s: Cannot open file: %s.', mfilename, Data); - end - Data = fread(FID, Inf, '*uint8'); - fclose(FID); - - Engine.update(Data); - if usetypecastx - Hash = typecastx(Engine.digest, 'uint8'); - else - Hash = typecast(Engine.digest, 'uint8'); - end - -elseif isBin % Contents of an elementary array: - if usetypecastx % Faster typecastx: - if isreal(Data) - Engine.update(typecastx(Data(:), 'uint8')); - else - Engine.update(typecastx(real(Data(:)), 'uint8')); - Engine.update(typecastx(imag(Data(:)), 'uint8')); - end - Hash = typecastx(Engine.digest, 'uint8'); - - else % Matlab's TYPECAST is less elegant: - if isnumeric(Data) - if isreal(Data) - Engine.update(typecast(Data(:), 'uint8')); - else - Engine.update(typecast(real(Data(:)), 'uint8')); - Engine.update(typecast(imag(Data(:)), 'uint8')); - end - elseif islogical(Data) % TYPECAST cannot handle LOGICAL - Engine.update(typecast(uint8(Data(:)), 'uint8')); - elseif ischar(Data) % TYPECAST cannot handle CHAR - Engine.update(typecast(uint16(Data(:)), 'uint8')); - Engine.update(typecast(Data(:), 'uint8')); - end - Hash = typecast(Engine.digest, 'uint8'); - end - -elseif usetypecastx % Faster typecastx: - Engine = CoreHash_(Data, Engine); - Hash = typecastx(Engine.digest, 'uint8'); - -else % Slower built-in TYPECAST: - Engine = CoreHash(Data, Engine); - Hash = typecast(Engine.digest, 'uint8'); -end - -% Convert hash specific output format: ----------------------------------------- -switch OutFormat - case 'hex' - Hash = sprintf('%.2x', double(Hash)); - case 'HEX' - Hash = sprintf('%.2X', double(Hash)); - case 'double' - Hash = double(reshape(Hash, 1, [])); - case 'uint8' - Hash = reshape(Hash, 1, []); - case 'base64' - Hash = fBase64_enc(double(Hash)); - otherwise - error(['JSimon:', mfilename, ':BadOutFormat'], ... - '*** %s: [Opt.Format] must be: HEX, hex, uint8, double, base64.', ... - mfilename); -end - -% return; - -% ****************************************************************************** -function Engine = CoreHash_(Data, Engine) -% This mothod uses the faster typecastx version. - -% Consider the type and dimensions of the array to distinguish arrays with the -% same data, but different shape: [0 x 0] and [0 x 1], [1,2] and [1;2], -% DOUBLE(0) and SINGLE([0,0]): -Engine.update([uint8(class(Data)), typecastx(size(Data), 'uint8')]); - -if isstruct(Data) % Hash for all array elements and fields: - F = sort(fieldnames(Data)); % Ignore order of fields - Engine = CoreHash_(F, Engine); % Catch the fieldnames - - for iS = 1:numel(Data) % Loop over elements of struct array - for iField = 1:length(F) % Loop over fields - Engine = CoreHash_(Data(iS).(F{iField}), Engine); - end - end - -elseif iscell(Data) % Get hash for all cell elements: - for iS = 1:numel(Data) - Engine = CoreHash_(Data{iS}, Engine); - end - -elseif isnumeric(Data) || islogical(Data) || ischar(Data) - if isempty(Data) == 0 - if isreal(Data) % TRUE for LOGICAL and CHAR also: - Engine.update(typecastx(Data(:), 'uint8')); - else % typecastx accepts complex input: - Engine.update(typecastx(real(Data(:)), 'uint8')); - Engine.update(typecastx(imag(Data(:)), 'uint8')); - end - end - -elseif isa(Data, 'function_handle') - Engine = CoreHash(ConvertFuncHandle(Data), Engine); - -else % Most likely this is a user-defined object: - try - Engine = CoreHash(ConvertObject(Data), Engine); - catch - warning(['JSimon:', mfilename, ':BadDataType'], ... - ['Type of variable not considered: ', class(Data)]); - end -end - -% return; - -% ****************************************************************************** -function Engine = CoreHash(Data, Engine) -% This methods uses the slower TYPECAST of Matlab -% See CoreHash_ for comments. - -Engine.update([uint8(class(Data)), typecast(size(Data), 'uint8')]); - -if isstruct(Data) % Hash for all array elements and fields: - F = sort(fieldnames(Data)); % Ignore order of fields - Engine = CoreHash(F, Engine); % Catch the fieldnames - for iS = 1:numel(Data) % Loop over elements of struct array - for iField = 1:length(F) % Loop over fields - Engine = CoreHash(Data(iS).(F{iField}), Engine); - end - end -elseif iscell(Data) % Get hash for all cell elements: - for iS = 1:numel(Data) - Engine = CoreHash(Data{iS}, Engine); - end -elseif isempty(Data) -elseif isnumeric(Data) - if ( issparse(Data) ) - chkIdx = find(Data); - if ( isempty(chkIdx) ) - return; - end - Engine.update(typecast(chkIdx, 'uint8')); - if isreal(Data) - Engine.update(typecast(full(Data(chkIdx)), 'uint8')); - else - Engine.update(typecast(full(real(Data(chkIdx))), 'uint8')); - Engine.update(typecast(full(imag(Data(chkIdx))), 'uint8')); - end - - else - if isreal(Data) - Engine.update(typecast(Data(:), 'uint8')); - else - Engine.update(typecast(real(Data(:)), 'uint8')); - Engine.update(typecast(imag(Data(:)), 'uint8')); - end - end -elseif islogical(Data) % TYPECAST cannot handle LOGICAL - Engine.update(typecast(uint8(Data(:)), 'uint8')); -elseif ischar(Data) % TYPECAST cannot handle CHAR - Engine.update(typecast(uint16(Data(:)), 'uint8')); -elseif isa(Data, 'function_handle') - Engine = CoreHash(ConvertFuncHandle(Data), Engine); -else % Most likely a user-defined object: - try - Engine = CoreHash(ConvertObject(Data), Engine); - catch - warning(['JSimon:', mfilename, ':BadDataType'], ... - ['Type of variable not considered: ', class(Data)]); - end -end - -% return; - -% ****************************************************************************** -function FuncKey = ConvertFuncHandle(FuncH) -% The subfunction ConvertFuncHandle converts function_handles to a struct -% using the Matlab function FUNCTIONS. The output of this function changes -% with the Matlab version, such that DataHash(@sin) replies different hashes -% under Matlab 6.5 and 2009a. -% An alternative is using the function name and name of the file for -% function_handles, but this is not unique for nested or anonymous functions. -% If the MATLABROOT is removed from the file's path, at least the hash of -% Matlab's toolbox functions is (usually!) not influenced by the version. -% Finally I'm in doubt if there is a unique method to hash function handles. -% Please adjust the subfunction ConvertFuncHandles to your needs. - -% The Matlab version influences the conversion by FUNCTIONS: -% 1. The format of the struct replied FUNCTIONS is not fixed, -% 2. The full paths of toolbox function e.g. for @mean differ. -FuncKey = functions(FuncH); - -% ALTERNATIVE: Use name and path. The <matlabroot> part of the toolbox functions -% is replaced such that the hash for @mean does not depend on the Matlab -% version. -% Drawbacks: Anonymous functions, nested functions... -% funcStruct = functions(FuncH); -% funcfile = strrep(funcStruct.file, matlabroot, '<MATLAB>'); -% FuncKey = uint8([funcStruct.function, ' ', funcfile]); - -% Finally I'm afraid there is no unique method to get a hash for a function -% handle. Please adjust this conversion to your needs. - -% return; - -% ****************************************************************************** -function DataBin = ConvertObject(DataObj) -% Convert a user-defined object to a binary stream. There cannot be a unique -% solution, so this part is left for the user... - -% Perhaps a direct conversion is implemented: -DataBin = uint8(DataObj); - -% Or perhaps this is better: -% DataBin = struct(DataObj); - -% return; - -% ****************************************************************************** -function Out = fBase64_enc(In) -% Encode numeric vector of UINT8 values to base64 string. - -Pool = [65:90, 97:122, 48:57, 43, 47]; % [0:9, a:z, A:Z, +, /] -v8 = [128; 64; 32; 16; 8; 4; 2; 1]; -v6 = [32, 16, 8, 4, 2, 1]; - -In = reshape(In, 1, []); -X = rem(floor(In(ones(8, 1), :) ./ v8(:, ones(length(In), 1))), 2); -Y = reshape([X(:); zeros(6 - rem(numel(X), 6), 1)], 6, []); -Out = char(Pool(1 + v6 * Y)); - -% return; diff --git a/src/MATLAB/+Dev/FrameSegHelp.m b/src/MATLAB/+Dev/FrameSegHelp.m new file mode 100644 index 0000000000000000000000000000000000000000..a81a70cef27a2978c46691347c2bfc58a9908724 --- /dev/null +++ b/src/MATLAB/+Dev/FrameSegHelp.m @@ -0,0 +1,95 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function helpStruct = FrameSegHelp(funcName) + helpStruct = []; + + SupportedTypes = Load.GetSupportedCellTypes(); + segInfo = [SupportedTypes.segRoutine]; + + segFuncs = arrayfun(@(x)(char(x.func)), segInfo, 'UniformOutput',false); + funcIdx = find(strcmp(segFuncs, funcName)); + if ( isempty(funcIdx) ) + return; + end + + if ( isdeployed() ) + helpStruct = Dev.CompiledSegHelp(funcName); + return; + end + + chkInfo = segInfo(funcIdx); + chkName = char(chkInfo.func); + + helpStruct.func = chkName; + helpStruct.summary = ''; + helpStruct.paramHelp = cell(length(chkInfo.params),1); + + helpString = help(chkName); + if ( isempty(helpString) ) + helpString = chkName; + end + + %% Get a segmentation summary from function help. + tokMatch = regexp(helpString,'^\s*FrameSegmentor_*\w*\s*-\s*(.+?)^\s*$', 'once','tokens','lineanchors'); + if ( isempty(tokMatch) ) + helpLines = strsplit(helpString,'\n'); + funcSummary = escapeString(strtrim(helpLines{1})); + else + funcSummary = escapeString(tokMatch{1}); + end + + %% Get parameter help if available in function documentation. + helpStruct.summary = funcSummary; + for i=1:length(chkInfo.params) + paramName = chkInfo.params(i).name; + + helpStruct.paramHelp{i} = ''; + tokMatch = regexp(helpString,['^\s*(' paramName '.+?)^\s*$'], 'once','tokens','lineanchors'); + if ( ~isempty(tokMatch) ) + helpStruct.paramHelp{i} = escapeString(tokMatch{1}); + end + end +end + +% Escape inStr so that safeStr will reproduce inStr when passed as a format string to sprintf() +function safeStr = escapeString(inStr) + escStr = {'%%','\\','\a','\b','\f','\n','\r','\t','\v'}; + escChars = num2cell(sprintf([escStr{:}])); + + escStr = [{''''''},escStr]; + escChars = [{''''},escChars]; + + escMap = containers.Map(escChars,escStr); + + safeStr = ''; + for i=1:length(inStr) + nextChar = inStr(i); + if ( isKey(escMap,nextChar) ) + nextChar = escMap(nextChar); + end + + safeStr = [safeStr nextChar]; + end +end diff --git a/src/MATLAB/+Dev/GetCommitInfo.m b/src/MATLAB/+Dev/GetCommitInfo.m new file mode 100644 index 0000000000000000000000000000000000000000..cdfc4bbf7e354d40848a01ca698b25ccc50636f3 --- /dev/null +++ b/src/MATLAB/+Dev/GetCommitInfo.m @@ -0,0 +1,15 @@ +% [repoName,commitHash] = GetCommitInfo(inPath) +% + +function [repoName,commitHash] = GetCommitInfo(inPath) + remoteUrl = Dev.GitRemote(inPath,'origin'); + + repoName = ''; + + tokMatch = regexp(remoteUrl,'\w+@[\w\-.]+:[\w\-.]+/([\w\-]+\.git)', 'tokens','once'); + if ( ~isempty(tokMatch) ) + repoName = tokMatch{1}; + end + + commitHash = Dev.GitCommitHash(inPath); +end diff --git a/src/MATLAB/+Dev/GetCoreHashList.m b/src/MATLAB/+Dev/GetCoreHashList.m index bfc98cfaa3023fd414fb229d90635c0f7a1caaf5..7e9d004c41cadc20c9f611fcafb3318cb9fc6d33 100644 --- a/src/MATLAB/+Dev/GetCoreHashList.m +++ b/src/MATLAB/+Dev/GetCoreHashList.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function hashList = GetCoreHashList() global CellHulls CellTracks CellFamilies HashedCells CellPhenotypes Costs GraphEdits diff --git a/src/MATLAB/+Dev/GetExternalDependencies.m b/src/MATLAB/+Dev/GetExternalDependencies.m deleted file mode 100644 index 96bc7bcd55af3e3641c38e332bbe68c7bc265f1d..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Dev/GetExternalDependencies.m +++ /dev/null @@ -1,283 +0,0 @@ -function [toolboxStruct externalStruct calledNames callGraph] = GetExternalDependencies(chkPath) - if ( ~exist('chkPath', 'var') ) - chkPath = pwd(); - end - - [localNames localFileNames] = getLocalNames(chkPath); - [fullNames calledFrom] = recursiveGetDeps(localFileNames); - - bIsLocal = cellfun(@(x)(~isempty(strfind(x,chkPath))), fullNames); - localNodeList = find(bIsLocal); - - [toolboxes toolboxMap] = getMatlabToolboxes(fullNames); - toolboxFuncs = transpose(arrayfun(@(x)(fullNames(toolboxMap == x)), 1:length(toolboxes), 'UniformOutput',0)); - - bIsMatlab = (toolboxMap > 0); - [externalDeps externalMap] = getOtherDeps(fullNames, bIsMatlab, bIsLocal); - externalFuncs = transpose(arrayfun(@(x)(fullNames(externalMap == x)), 1:length(externalDeps), 'UniformOutput',0)); - - fullGraph = createCallGraph(calledFrom); - bIsCalled = findCalledNodes(localNodeList, fullGraph); - - toolboxCallers = getToolboxCallers(localNodeList, toolboxes, toolboxMap, fullGraph, fullNames); - externalCallers = getToolboxCallers(localNodeList, externalDeps, externalMap, fullGraph, fullNames); - -% calledNames = fullNames(bIsCalled); -% callGraph = fullGraph(bIsCalled,bIsCalled); - callToolboxMap = toolboxMap(bIsCalled); - callExternalMap = externalMap(bIsCalled); - -% [squashNames squashGraph squashMap] = squashToolboxNodes(calledNames, callGraph, toolboxes, callToolboxMap); - -% usedToolboxes = unique(callToolboxMap(callToolboxMap>0)); -% toolboxes = toolboxes(usedToolboxes); -% toolboxFuncs = toolboxFuncs(usedToolboxes); -% toolboxCallers = toolboxCallers(usedToolboxes); - - usedExternal = unique(callExternalMap(callExternalMap>0)); - externalDeps = externalDeps(usedExternal); - externalFuncs = externalFuncs(usedExternal); - externalCallers = externalCallers(usedExternal); - - toolboxStruct = struct('deps', {toolboxes}, 'funcs', {toolboxFuncs}, 'callers',{toolboxCallers}); - externalStruct = struct('deps', {externalDeps}, 'funcs', {externalFuncs}, 'callers',{externalCallers}); -end - -function [toolboxes toolboxMap] = getMatlabToolboxes(funcNames) - bIsMatlab = strncmpi(matlabroot, funcNames, length(matlabroot)); - matlabIdx = find(bIsMatlab); - matlabNames = funcNames(bIsMatlab); - - % Add default matlab dependencies first, these will always be used - toolboxes = {'matlab';'local';'shared'}; - toolboxMap = zeros(length(funcNames),1); - for i=1:length(matlabNames) - toolboxPattern = '(?<=^.+[\\/]toolbox[\\/])[^\\/]+'; - matchToolbox = regexp(matlabNames{i}, toolboxPattern, 'match', 'once'); - if ( isempty(matchToolbox) ) - continue; - end - - if ( any(strcmpi(matchToolbox,toolboxes)) ) - toolboxMap(matlabIdx(i)) = find(strcmpi(matchToolbox,toolboxes)); - continue; - end - - toolboxes = [toolboxes; {matchToolbox}]; - toolboxMap(matlabIdx(i)) = length(toolboxes); - end -end - -function [externalDeps externalMap] = getOtherDeps(funcNames, bIsMatlab, bIsLocal) - externalMap = zeros(length(funcNames),1); - externalDeps = {}; - - bExternal = (~bIsMatlab & ~bIsLocal); - externalFuncs = funcNames(bExternal); - - tokenRemains = externalFuncs; - tokenDelims = filesep; - - pred = []; - bLeaves = false(0,0); - - pathNodes = {}; - nodeMap = ((1:length(externalFuncs)).'); - sharedPred = zeros(length(externalFuncs),1); - - depth = 1; - nextPred = zeros(length(externalFuncs),1); - bEmpty = false; - while ( ~all(bEmpty) ) - [tokenNodes tokenRemains] = strtok(tokenRemains, tokenDelims); - - bEmpty = cellfun(@(x)(isempty(x)), tokenNodes); - - tokenNodes = tokenNodes(~bEmpty); - tokenRemains = tokenRemains(~bEmpty); - - nextPred = nextPred(~bEmpty); - nodeMap = nodeMap(~bEmpty); - - [newNodes ia ic] = unique(tokenNodes); - - bEmptyLeaf = cellfun(@(x)(isempty(x)), tokenRemains); - bNewLeaves = bEmptyLeaf(ia); - - pred = [pred; nextPred(ia)]; - - % As soon as we hit a leaf node, update shared predecessor for all - % nodes. This will be condsidered the toolbox path. - leafPreds = unique(nextPred(ia(bNewLeaves))); - [bShared setPred] = ismember(nextPred, leafPreds); - - bUpdateShared = (sharedPred(nodeMap) == 0) & bShared; - sharedPred(nodeMap(bUpdateShared)) = leafPreds(setPred(bUpdateShared)); - - nextPred = ic + length(pathNodes); - - bLeaves = [bLeaves; bNewLeaves]; - pathNodes = [pathNodes; newNodes]; - - depth = depth + 1; - end - - [sharedPath ia ic] = unique(sharedPred); - externalDeps = cell(length(sharedPath),1); - for i=1:length(sharedPath) - curIdx = sharedPath(i); - while ( curIdx ~= 0 ) - externalDeps{i} = fullfile(pathNodes{curIdx}, externalDeps{i}); - curIdx = pred(curIdx); - end - end - - externalMap(bExternal) = ic; -end - -function toolboxCallers = getToolboxCallers(localNodes, toolboxes, toolboxMap, fullGraph, fullNames) - toolboxCallers = cell(length(toolboxes),1); - for i=1:length(toolboxes) - bInToolbox = (toolboxMap == i); - [callerIdx funcIdx] = find(fullGraph(:,bInToolbox)); - toolboxCallers{i} = cell(max(funcIdx),1); - for j=1:length(funcIdx) - if ( ~ismember(callerIdx(j),localNodes) ) - continue; - end - - toolboxCallers{i}{funcIdx(j)} = [toolboxCallers{i}{funcIdx(j)}; fullNames(callerIdx(j))]; - end - end -end - -function callGraph = createCallGraph(calledFrom) - numEdges = cellfun(@(x)(length(x)), calledFrom); - calledIdx = arrayfun(@(x,y)(y*ones(1,x)), numEdges, ((1:length(calledFrom)).'), 'UniformOutput',0); - - jIdx = ([calledIdx{:}]); - iIdx = ([calledFrom{:}]); - - callGraph = sparse(iIdx,jIdx, ones(1,sum(numEdges)), length(calledFrom),length(calledFrom), sum(numEdges)); -end - -function bIsCalled = findCalledNodes(localFuncIdx, callGraph) - bIsCalled = false(size(callGraph,1),1); - bIsCalled(localFuncIdx) = 1; - - for i=1:length(localFuncIdx) - [d pred] = matlab_bgl.dijkstra_sp(callGraph, localFuncIdx(i)); - - bHasPath = ~isinf(d); - bIsCalled = (bIsCalled | bHasPath); - end -end - -function [squashNames squashGraph squashMap] = squashToolboxNodes(funcNames, callGraph, toolboxes, toolboxMap) - squashNames = funcNames; - squashMap = toolboxMap; - squashGraph = callGraph; - - for i=1:length(toolboxes) - bInToolbox = (squashMap == i); - - tempRows = any(squashGraph(bInToolbox,:),1); - squashRows = [tempRows(~bInToolbox) any(tempRows(bInToolbox))]; - - tempCols = any(squashGraph(:,bInToolbox),2); - squashCols = tempCols(~bInToolbox); - - squashGraph = [squashGraph(~bInToolbox,~bInToolbox) squashCols; squashRows]; - - squashNames = [squashNames(~bInToolbox); toolboxes(i)]; - squashMap = [squashMap(~bInToolbox); i]; - end -end - -function [deplist calledFrom] = recursiveGetDeps(checkNames, bFollowToolboxes, deplist, calledFrom) - if ( ~exist('calledFrom','var') ) - calledFrom = {}; - end - - if ( ~exist('deplist','var') ) - deplist = {}; - end - - if ( ~exist('bFollowToolboxes','var') ) - bFollowToolboxes = 0; - end - - if ( isempty(checkNames) ) - return; - end - - % Get single-link dependencies - try - [newdeps, builtins, classes, prob_files, prob_sym, eval_strings, newCalledFrom, java_classes] = depfun(checkNames, '-toponly', '-quiet'); - catch excp - newdeps = cell(0,1); - newCalledFrom = cell(0,1); - end - [deplist calledFrom newEntries] = mergeLists(deplist, calledFrom, newdeps, newCalledFrom); - - % Remove any matlab toolbox entries from being recursively followed - if ( ~bFollowToolboxes ) - bIsToolbox = strncmpi(matlabroot, newEntries, length(matlabroot)); - newEntries = newEntries(~bIsToolbox); - end - - [deplist calledFrom] = recursiveGetDeps(newEntries, bFollowToolboxes, deplist, calledFrom); - -end - -function [deplist calledFrom newEntries] = mergeLists(deplist, calledFrom, newdeps, newCalledFrom) - oldIdx = cellfun(@(x)(find(strcmpi(x,deplist))), newdeps, 'UniformOutput',0); - bNew = cellfun(@(x)(isempty(x)), oldIdx); - - newEntries = newdeps(bNew); - - idxMap = zeros(1,length(newdeps)); - idxMap(~bNew) = [oldIdx{~bNew}]; - idxMap(bNew) = (1:length(newEntries)) + length(deplist); - - deplist = [deplist; newEntries]; - calledFrom = [calledFrom; cell(length(newEntries),1)]; - - calledFrom(idxMap) = cellfun(@(x,y)(unique([x idxMap(y)])), calledFrom(idxMap), newCalledFrom, 'UniformOutput',0); -end - -function [checkNames fullNames] = getLocalNames(dirName, packageString) - if ( ~exist('packageString','var') ) - packageString = ''; - end - - matlabFiles = what(dirName); - - funcFileNames = vertcat(matlabFiles.m); - funcFileNames = [funcFileNames; vertcat(matlabFiles.mex)]; - - checkNames = cellfun(@splitFName, funcFileNames, 'UniformOutput',0); - checkNames = cellfun(@(x)([packageString x]), checkNames, 'UniformOutput',0); - fullNames = cellfun(@(x)(fullfile(dirName,x)), funcFileNames, 'UniformOutput',0); - - for i=1:length(matlabFiles.packages) - nextPackageString = makePackageString(packageString, matlabFiles.packages{i}); - [pckgCheckNames pckgFullNames] = getLocalNames(fullfile(dirName, ['+' matlabFiles.packages{i}]), nextPackageString); - - checkNames = [checkNames; pckgCheckNames]; - fullNames = [fullNames; pckgFullNames]; - end -end - -function packageString = makePackageString(packageString, nextPackage) - if ( isempty(packageString) ) - packageString = [nextPackage '.']; - return; - end - - packageString = [packageString nextPackage '.']; -end - -function name = splitFName(fileName) - [path, name] = fileparts(fileName); -end diff --git a/src/MATLAB/+Dev/GetLocalName.m b/src/MATLAB/+Dev/GetLocalName.m deleted file mode 100644 index edb1e31b4bc720b1f7b71bc26345adc632a246d8..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Dev/GetLocalName.m +++ /dev/null @@ -1,17 +0,0 @@ -function localName = GetLocalName(fullName, chkPath) - if ( ~exist('chkPath', 'var') ) - chkPath = pwd(); - end - - localName = []; - partialPath = fullName; - while ( ~isempty(partialPath) && ~strcmpi(chkPath,partialPath) ) - [partialPath callPart] = fileparts(partialPath); - - if ( callPart(1) == '+' ) - localName = [callPart(2:end) '.' localName]; - else - localName = fullfile(callPart, localName); - end - end -end \ No newline at end of file diff --git a/src/MATLAB/+Dev/GetVersion.m b/src/MATLAB/+Dev/GetVersion.m new file mode 100644 index 0000000000000000000000000000000000000000..e563019b7f900a6f58297480871853d1d86796fd --- /dev/null +++ b/src/MATLAB/+Dev/GetVersion.m @@ -0,0 +1,59 @@ +% version = GetVersion(command) +% Get a version string or number depending on the command argument. This +% m-file serves as a single repository for all version-related information. +% +% Note: Uses autogenerated version information in +Dev\VersionInfo.m + +function versionStr = GetVersion(command) + versionStr = []; + + verInfo = Dev.LoadVersion(); + + if ( ~exist('command','var') ) + command = 'string'; + end + + % Get rid of slashes in branch names + cleanBranch = strrep(verInfo.branchName, '/', '_'); + cleanBranch = strrep(cleanBranch, '\', '_'); + + primaryHash = ''; + matchTok = regexp(verInfo.commitHash{1},'.*:\s*(\w+)','tokens','once'); + if ( ~isempty(matchTok) ) + primaryHash = matchTok{1}; + end + + if ( strcmpi(command, 'string') || strcmpi(command, 'versionString') ) + versionStr = [num2str(verInfo.majorVersion) '.' num2str(verInfo.minorVersion) ' ' cleanBranch]; + return; + end + + if ( strcmpi(command, 'buildString') ) + versionStr = [verInfo.buildNumber '/' verInfo.buildMachine]; + return; + end + + if ( strcmpi(command, 'primaryHash') ) + versionStr = primaryHash; + return + end + + if ( strcmpi(command, 'buildHashes') ) + versionStr = verInfo.commitHash; + return + end + + if ( strcmpi(command, 'fullString') ) + versionStr = [verInfo.name ' v' num2str(verInfo.majorVersion) '.' num2str(verInfo.minorVersion) ' ' verInfo.buildNumber '/' verInfo.buildMachine ' ' cleanBranch ' ' primaryHash]; + return; + end + + if ( strcmpi(command, 'file') ) + minorStr = num2str(verInfo.minorVersion); + minorStr = strrep(minorStr, '.', '_'); + versionStr = [num2str(verInfo.majorVersion) minorStr '_' cleanBranch]; + return; + end + +end + diff --git a/src/MATLAB/+Dev/GitCommitHash.m b/src/MATLAB/+Dev/GitCommitHash.m new file mode 100644 index 0000000000000000000000000000000000000000..3548ce2344b3b9837be6440a1db0a9e64ac45246 --- /dev/null +++ b/src/MATLAB/+Dev/GitCommitHash.m @@ -0,0 +1,16 @@ +function commitHash = GitCommitHash(inPath) + bGit = Dev.SetupGit(); + if ( ~bGit ) + return; + end + + oldDir = cd(inPath); + cleanupObj = onCleanup(@()(cd(oldDir))); + + [status,hashOut] = system('git rev-parse HEAD'); + if ( status ~= 0 ) + return; + end + + commitHash = strtrim(hashOut); +end diff --git a/src/MATLAB/+Dev/GitRemote.m b/src/MATLAB/+Dev/GitRemote.m new file mode 100644 index 0000000000000000000000000000000000000000..fae8a87be8ac2859aceb2d211cfba370d7573a6a --- /dev/null +++ b/src/MATLAB/+Dev/GitRemote.m @@ -0,0 +1,18 @@ +function remoteURL = GitRemote(inPath,remoteName) + remoteURL = ''; + + bGit = Dev.SetupGit(); + if ( ~bGit ) + return; + end + + oldDir = cd(inPath); + cleanupObj = onCleanup(@()(cd(oldDir))); + + [status,urlOut] = system(['git remote get-url ' remoteName]); + if ( status ~= 0 ) + return; + end + + remoteURL = strtrim(urlOut); +end diff --git a/src/MATLAB/+Dev/GitStatus.m b/src/MATLAB/+Dev/GitStatus.m new file mode 100644 index 0000000000000000000000000000000000000000..90f0693283146a3e3a542455480a64b3d7be004f --- /dev/null +++ b/src/MATLAB/+Dev/GitStatus.m @@ -0,0 +1,67 @@ +function changeLines = GitStatus(chkPath,chkFiles) + changeLines = {}; + + if ( ~exist('chkFiles','var') ) + chkFiles = {}; + end + + bGit = Dev.SetupGit(); + if ( ~bGit ) + return; + end + + oldDir = cd(chkPath); + cleanupObj = onCleanup(@()(cd(oldDir))); + + [status,res] = system('git status -uall --porcelain'); + if ( status ~= 0 ) + return; + end + + statusLines = strsplit(res,'\n').'; + + bValid = cellfun(@(x)(~isempty(x)),statusLines); + statusLines = statusLines(bValid); + + changeTypes = cellfun(@(x)(8*changeMap(x(1)) + changeMap(x(2))), statusLines); + changeFiles = cellfun(@(x)(x(4:end)), statusLines, 'UniformOutput',false); + + if ( isempty(chkFiles) ) + changeLines = changeFiles(changeTypes > 0); + return; + end + + changeLines = {}; + + regexpFiles = regexptranslate('escape', strrep(chkFiles, '\','/')); + for i=1:length(changeFiles) + matchStarts = regexp(changeFiles{i},regexpFiles, 'start','once'); + bMatched = cellfun(@(x)(~isempty(x)), matchStarts); + + if ( any(bMatched) ) + changeLines = [changeLines; changeFiles(i)]; + end + end + + extCell = arrayfun(@(x)([ '.\' x.ext '|']), mexext('all'), 'UniformOutput',false); + extStr = [extCell{:}]; + bMexFiles = cellfun(@(x)(~isempty(x)), regexp(chkFiles,extStr(1:end-1),'once')); + if ( any(bMexFiles) ) + matchStarts = regexp(changeFiles,'^src/c/', 'start','once'); + bMatched = cellfun(@(x)(~isempty(x)), matchStarts); + + cFiles = changeFiles(bMatched); + for i=1:length(cFiles) + changeLines = [changeLines; {'Possible MEX dependency - ' cFiles{i}}]; + end + end +end + +function change = changeMap(c) + changeList = ['?','M','A','D']; + + change = find(c == changeList); + if ( isempty(change) ) + change = 0; + end +end diff --git a/src/MATLAB/+Dev/InitCompiler.m b/src/MATLAB/+Dev/InitCompiler.m new file mode 100644 index 0000000000000000000000000000000000000000..2a96f76da37295dd174aa6e37fd1775539051bf9 --- /dev/null +++ b/src/MATLAB/+Dev/InitCompiler.m @@ -0,0 +1,134 @@ +function initStruct = InitCompiler(productName,forceVersion) + if ( ~exist('forceVersion','var') ) + forceVersion = ''; + end + + rootDir = pwd(); + + initStruct = []; + + %% Build dependency graph for current directory + depGraph = Dev.BuildDependencyGraph(rootDir,true); + + %% Get list of matlab toolbox dependencies + toolboxRoot = toolboxdir(''); + bMatlab = strncmp(toolboxRoot,depGraph.nodes, length(toolboxRoot)); + + toolboxNodes = depGraph.nodes(bMatlab); + toolboxList = Dev.LoadToolboxes(toolboxNodes); + + %% Remove matlab paths/dependencies + depGraph.nodes = depGraph.nodes(~bMatlab); + depGraph.graph = depGraph.graph(~bMatlab,~bMatlab); + + %% Get rootPaths and local subdirectories for dependencies + [rootPaths,rootNames,localPaths] = Dev.SplitDependencyNames(depGraph.nodes); + + %% Verify no uncommited changes on dependencies + changeString = {}; + [chkPaths,ia,ic] = unique(rootPaths); + chkNames = rootNames(ia); + for i=1:length(chkPaths) + bInPath = (ic == i); + changeLines = Dev.GitStatus(chkPaths{i},localPaths(bInPath)); + + if ( ~isempty(changeLines) ) + changeString = [changeString; {[chkNames{i} ' (' chkPaths{i} '):']}]; + for j=1:length(changeLines) + changeString = [changeString; {[' ' changeLines{j}]}]; + end + end + end + + if ( ~isempty(changeString) ) + message = sprintf('The following dependencies have uncommitted changes, are you sure you wish to continue?\n\n'); + for i=1:length(changeString) + message = [message sprintf('%s\n',changeString{i})]; + end + + answer = questdlg(message, 'Uncommitted changes!', 'Continue','Cancel', 'Cancel'); + if ( strcmpi(answer,'Cancel') ) + initStruct = []; + return; + end + end + + %% Make full version string and fallback version file + Dev.MakeVersion(productName,forceVersion,chkPaths); + + %% Copy the external dependencies to local paths + bExternal = ~strncmp(rootDir,rootPaths,length(rootDir)); + externalPaths = rootPaths(bExternal); + externalDeps = localPaths(bExternal); + + copyPaths = {}; + for i=1:length(externalPaths) + localDir = fileparts(externalDeps{i}); + if ( ~exist(fullfile(rootDir,localDir),'dir') ) + mkdir(fullfile(rootDir,localDir)); + end + + copyPaths = [copyPaths; fullfile(rootDir,externalDeps{i})]; + copyfile(fullfile(externalPaths{i},externalDeps{i}), fullfile(rootDir,externalDeps{i})); + end + + initStruct.toolboxList = toolboxList; + initStruct.cleanupObj = onCleanup(@()(compilerCleanup(copyPaths))); + + % temporarily remove any startup scripts that would normally be run by matlabrc + enableStartupScripts(false); +end + +function compilerCleanup(copyPaths) + % Remove all copied dependencies + for i=1:length(copyPaths) + if ( exist(copyPaths{i},'file') ) + delete(copyPaths{i}); + end + end + + % Re-enable any disabled startup scripts + enableStartupScripts(true); +end + +function enableStartupScripts(bEnable) + searchPrefix = ''; + renamePrefix = 'disabled_'; + if ( bEnable ) + searchPrefix = 'disabled_'; + renamePrefix = ''; + end + + searchName = [searchPrefix 'startup.m']; + newName = [renamePrefix 'startup.m']; + + startupScripts = findFilesInPath(searchName, userpath); + for i=1:length(startupScripts) + scriptPath = fileparts(startupScripts{i}); + movefile(startupScripts{i}, fullfile(scriptPath,newName)); + end +end + +function fullNames = findFilesInPath(filename, searchPaths) + fullNames = {}; + + chkPaths = []; + while ( ~isempty(searchPaths) ) + [newPath remainder] = strtok(searchPaths, pathsep); + if ( isempty(newPath) ) + searchPaths = remainder; + continue; + end + + chkPaths = [chkPaths; {newPath}]; + searchPaths = remainder; + end + + for i=1:length(chkPaths) + chkFullPath = fullfile(chkPaths{i}, filename); + if ( exist(chkFullPath, 'file') ) + fullNames = [fullNames; {chkFullPath}]; + end + end +end + diff --git a/src/MATLAB/+Dev/LoadToolboxes.m b/src/MATLAB/+Dev/LoadToolboxes.m new file mode 100644 index 0000000000000000000000000000000000000000..5f93c35aff9dfce6dfde80b07b7da5f306709a32 --- /dev/null +++ b/src/MATLAB/+Dev/LoadToolboxes.m @@ -0,0 +1,15 @@ +function toolboxPaths = LoadToolboxes(toolboxNodes) + toolboxMap = Dev.BuildToolboxMap(); + + toolboxRoot = toolboxdir(''); + toolboxNames = cellfun(@(x)(x(length(toolboxRoot)+2:end)), toolboxNodes, 'UniformOutput',false); + + toolboxPaths = {}; + for i=1:length(toolboxNames) + if ( ~isKey(toolboxMap,toolboxNames{i}) ) + continue; + end + + toolboxPaths = [toolboxPaths; toolboxMap(toolboxNames{i})]; + end +end diff --git a/src/MATLAB/+Dev/LoadVersion.m b/src/MATLAB/+Dev/LoadVersion.m new file mode 100644 index 0000000000000000000000000000000000000000..e9a39d08dd39d0c0665ebcfa7d7695c924ef481f --- /dev/null +++ b/src/MATLAB/+Dev/LoadVersion.m @@ -0,0 +1,82 @@ +function verInfo = LoadVersion() + %% Use compiled VersionInfo function when deployed + if ( isdeployed ) + verInfo = Dev.VersionInfo(); + return; + end + + %% Try to load version tag and branch using git + bFoundGit = Dev.SetupGit(); + verInfo = []; + if ( bFoundGit ) + chkVerInfo = gitVersionInfo(); + end + + %% Use fallback file for name (set by Dev.MakeVersion) + fallbackFile = 'version.json'; + + fallbackVerInfo = loadFallbackInfo(fallbackFile); + if ( isempty(fallbackVerInfo) ) + fprintf('WARNING: Invalid fallback file, unable to load version information.\n'); + return; + end + + if ( isempty(chkVerInfo) ) + fprintf('WARNING: Could not find git directory, using fallback %s\n', fallbackFile); + chkVerInfo = fallbackVerInfo; + end + + % Always use the name from fallback file + chkVerInfo.name = fallbackVerInfo.name; + + verInfo = chkVerInfo; +end + +%% Read fallback json version file +function verInfo = loadFallbackInfo(fallbackFile) + verInfo = []; + + fid = fopen(fallbackFile); + if ( fid <= 0 ) + return; + end + + jsonVer = fread(fid, '*char').'; + fclose(fid); + + verInfo = Utils.ParseJSON(jsonVer); +end + +%% Use git tags to get version information +function verInfo = gitVersionInfo() + verInfo = []; + + [verStatus,verString] = system('git describe --tags --match v[0-9]*.[0-9]* --abbrev=0'); + [branchStatus,branchString] = system('git rev-parse --abbrev-ref HEAD'); + + [majorVer,minorVer] = Dev.ParseVerTag(verString); + + if ( verStatus ~= 0 || isempty(majorVer) || isempty(minorVer) ) + fprintf('WARNING: There was an error retrieving tag from git:\n %s\n', verString); + return; + end + + branchName = strtrim(branchString); + if ( branchStatus ~= 0 ) + fprintf('WARNING: There was an error retrieving branch name from git:\n %s\n', branchName); + return; + end + + [repoName,commitHash] = Dev.GetCommitInfo(pwd()); + commitString = [repoName ' : ' commitHash]; + + %% VersionInfo default structure + verInfo = struct(... + 'name',{repoName},... + 'majorVersion',{majorVer},... + 'minorVersion',{minorVer+1},... + 'branchName',{branchName},... + 'buildNumber',{'UNKNOWN'},... + 'buildMachine',{'UNKNOWN'},... + 'commitHash',{{commitString}}); +end diff --git a/src/MATLAB/+Dev/MakeSegHelp.m b/src/MATLAB/+Dev/MakeSegHelp.m new file mode 100644 index 0000000000000000000000000000000000000000..a79fae0e572645236de0545d60063046f5501f54 --- /dev/null +++ b/src/MATLAB/+Dev/MakeSegHelp.m @@ -0,0 +1,89 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function MakeSegHelp() + funcPrefix = { + '% helpStruct = CompiledSegHelp(funcName)' + '% Return a cached segmentation function help string.' + '%' + '% Note: This file is autogenerated by build script DO NOT MODIFY!!' + '' + 'function helpStruct = CompiledSegHelp(funcName)' + ' helpStruct = [];' + ' funcStructs = struct(''func'',{}, ''summary'',{}, ''paramHelp'',{});'}; + + helpTemplate = struct(... + 'func', {' funcStructs(%d).func = ''%s'';'},... + 'summary',{' funcStructs(%d).summary = ''%s'';'},... + 'param',{' funcStructs(%d).paramHelp = {%s};'}); + + funcPostfix = { + ' segFuncs = {funcStructs.func};' + ' funcIdx = find(strcmp(segFuncs,funcName));' + ' if ( isempty(funcIdx) )' + ' return;' + ' end' + ' ' + ' helpStruct = funcStructs(funcIdx);' + 'end'}; + + SupportedTypes = Load.GetSupportedCellTypes(); + segInfo = [SupportedTypes.segRoutine]; + segFuncs = arrayfun(@(x)(char(x.func)), segInfo, 'UniformOutput',false); + + helpStruct = []; + for i=1:length(segFuncs) + newStruct = Dev.FrameSegHelp(segFuncs{i}); + if ( isempty(newStruct) ) + error('Unrecognized segmentation algorithm!'); + end + + helpStruct = [helpStruct; newStruct]; + end + + fid = fopen(fullfile('+Dev','CompiledSegHelp.m'),'w'); + %% + for i=1:length(funcPrefix) + fprintf(fid, '%s\n', funcPrefix{i}); + end + fprintf(fid, '\n'); + + %% + for i=1:length(helpStruct) + paramString = ''; + for j=1:length(helpStruct(i).paramHelp) + paramString = [paramString sprintf('\n ''%s'';', helpStruct(i).paramHelp{j})]; + end + + fprintf(fid, [helpTemplate.func '\n'], i, helpStruct(i).func); + fprintf(fid, [helpTemplate.summary '\n'], i, helpStruct(i).summary); + fprintf(fid, [helpTemplate.param '\n\n'], i, paramString); + end + + %% + for i=1:length(funcPostfix) + fprintf(fid, '%s\n', funcPostfix{i}); + end + fclose(fid); +end diff --git a/src/MATLAB/+Dev/MakeVersion.m b/src/MATLAB/+Dev/MakeVersion.m index af3171388c0fc6b0665654e8f765f31f17a1b25b..4c91fd3699249b5c4a8ba7d88fa671ac331a8a11 100644 --- a/src/MATLAB/+Dev/MakeVersion.m +++ b/src/MATLAB/+Dev/MakeVersion.m @@ -1,7 +1,8 @@ -function verInfo = MakeVersion(bTransientUpdate, forceVersion) +function verInfo = MakeVersion(productName, forceVersion, dependencyPaths) + %% Template for the Dev.VersionInfo command funcString = { '%% versionInfo = VersionInfo()' '%% Return the version info structure' @@ -9,76 +10,48 @@ function verInfo = MakeVersion(bTransientUpdate, forceVersion) '%% Note: This file is autogenerated by build script DO NOT MODIFY!!' '' 'function versionInfo = VersionInfo()' - ' versionInfo = struct(...' - ' ''majorVersion'',{%d},...' - ' ''minorVersion'',{%d},...' - ' ''branchName'',{''%s''},...' - ' ''buildNumber'',{''%s''},...' - ' ''buildMachine'',{''%s''},...' - ' ''commitHash'',{''%s''});' - ' end'}; - - if ( ~exist('bTransientUpdate', 'var') ) - bTransientUpdate = 0; - end + ' jsonVer = ''%s'';' + ' ' + ' versionInfo = Utils.ParseJSON(jsonVer);' + 'end'}; if ( ~exist('forceVersion', 'var') ) - forceVersion = []; - end - - verInfo = struct(... - 'majorVersion',{0},... - 'minorVersion',{0},... - 'branchName',{'UNKNOWN'},... - 'buildNumber',{'UNKNOWN'},... - 'buildMachine',{'UNKNOWN'},... - 'commitHash',{''}); - - - fallbackFile = 'version.txt'; - - bFoundGit = Dev.SetupGit(); - if ( ~bFoundGit ) - fprintf('WARNING: Could not find git directory, falling back to %s\n', fallbackFile); + forceVersion = ''; end - [verTag branchName] = gitVersionAndBranch(bFoundGit, fallbackFile); - - if ( ~isempty(forceVersion) && ischar(forceVersion) ) - verTag = ['v' forceVersion]; + if ( ~exist('dependencyPaths', 'var') ) + dependencyPaths = {}; end - % Get version info from git tag - if ( ~isempty(verTag) ) - verTag = strtrim(verTag); - numTok = regexp(verTag, '[Vv](\d+)\.(\d+(?:\.\d+)?).*', 'tokens', 'once'); - if ( length(numTok) >= 2 ) - verInfo.majorVersion = str2double(numTok{1}); - verInfo.minorVersion = str2double(numTok{2}); - end - end + fallbackFile = 'version.json'; - % Increment version if we're getting it from tag/fallback - if ( isempty(forceVersion) ) - verInfo.minorVersion = verInfo.minorVersion + 1; + %% Load version info from git tags + verInfo = Dev.LoadVersion(); + if ( isempty(verInfo) ) + error('Unable to load git version information'); end - % Try to get a branch name - [status,branchName] = system('git rev-parse --abbrev-ref HEAD'); - if ( ~isempty(branchName) ) - verInfo.branchName = strtrim(branchName); - end + % Force name to be the passed in product name + verInfo.name = productName; - [status commitHash] = system('git rev-parse HEAD'); - if ( ~isempty(commitHash) ) - verInfo.commitHash = strtrim(commitHash); + %% If we are forcing a specific version number + if ( ~isempty(forceVersion) ) + verString = ['v' forceVersion]; + + [majorVer,minorVer] = Dev.ParseVerTag(verString); + if ( isempty(majorVer) ) + error('Invalid version string %s', verString); + end + + verInfo.majorVersion = majorVer; + verInfo.minorVersion = minorVer; end - % Get a timestamp build-number + %% Get a timestamp build-number c = clock(); verInfo.buildNumber = sprintf('%d.%02d.%02d.%02d', c(1), c(2), c(3), c(4)); - % Get machine ID + %% Get machine ID [status,buildMachine] = system('hostname'); if ( status ~= 0 ) fprintf('WARNING: There was an error retrieving hostname:\n %s\n', buildMachine); @@ -86,82 +59,49 @@ function verInfo = MakeVersion(bTransientUpdate, forceVersion) verInfo.buildMachine = strtrim(buildMachine); end - if ( ~bTransientUpdate ) - if ( ~bFoundGit ) - error('Unable to use git to build version string for build.'); - end - - % Concatenate the template function lines into one giant string - templateString = []; - for i=1:length(funcString) - templateString = [templateString funcString{i} '\n']; - end - - % Now insert all our arguments into the template and write to a file. - fid = fopen('+Helper\VersionInfo.m', 'wt'); - if ( fid <= 0 ) - error('Unable to open +Helper\VersionInfo.m for writing'); - end - - fprintf(fid, templateString, verInfo.majorVersion, verInfo.minorVersion, verInfo.branchName, verInfo.buildNumber, verInfo.buildMachine, verInfo.commitHash); - - fclose(fid); - - % Update fallback file if we used git to retrieve version info. - fid = fopen(fallbackFile, 'wt'); - if ( fid < 0 ) - return; - end - - fprintf(fid, '%s\n', verTag); - fprintf(fid, '%s\n', branchName); - - fclose(fid); - end -end - -function [verTag branchName commitHash] = gitVersionAndBranch(bUseGit, fallbackFile) - verTag = ''; - branchName = ''; - commitHash = ''; + %% Make sure local path is not in the list + localPath = pwd(); + bHasLocal = strcmp(localPath,dependencyPaths); + dependencyPaths = dependencyPaths(~bHasLocal); - if ( bUseGit ) - [verStatus,verTag] = system('git describe --tags --match v[0-9]*.[0-9]* --abbrev=0'); - [branchStatus,branchName] = system('git rev-parse --abbrev-ref HEAD'); - [hashStatus,commitHash] = system('git rev-parse HEAD'); - - if ( verStatus ~= 0 ) - fprintf('WARNING: There was an error retrieving tag from git:\n %s\n', verTag); - verTag = ''; - end - - if ( branchStatus ~= 0 ) - fprintf('WARNING: There was an error retrieving branch name from git:\n %s\n', branchName); - branchName = ''; - end - - if ( hashStatus ~= 0 ) - fprintf('WARNING: There was an error retrieving commit hash from git:\n %s\n', commitHash); - commitHash = ''; - end - - return; + %% Add all other dependent commit hashes to list + hashStrings = cell(length(dependencyPaths),1); + for i=1:length(dependencyPaths) + [repoName,commitHash] = Dev.GetCommitInfo(dependencyPaths{i}); + hashStrings{i} = [repoName ' : ' commitHash]; end - if ( ~exist(fallbackFile, 'file') ) - fprintf('ERROR: There is no fallback version.txt file!\n'); - return; - end + verInfo.commitHash = [verInfo.commitHash; hashStrings]; - fid = fopen(fallbackFile, 'rt'); + %% Create +Dev/VersionInfo.m for use in compiled files + % Concatenate the template function lines into one giant string + templateString = []; + for i=1:length(funcString) + templateString = [templateString funcString{i} '\n']; + end + + % Now insert all our arguments into the template and write to a file. + if ( ~exist('+Dev','dir') ) + mkdir('+Dev'); + end - if ( fid < 0 ) + fid = fopen(fullfile('+Dev','VersionInfo.m'), 'wt'); + if ( fid <= 0 ) + error('Unable to open +Dev/VersionInfo.m for writing'); + end + + jsonVer = Utils.CreateJSON(verInfo,false); + fprintf(fid, templateString, jsonVer); + + fclose(fid); + + %% Update fallback file if we used git to retrieve version info. + jsonStr = Utils.CreateJSON(verInfo); + fid = fopen(fallbackFile, 'wt'); + if ( fid <= 0 ) return; end - - verTag = fgetl(fid); - branchName = fgetl(fid); - commitHash = fgetl(fid); - + + fprintf(fid, '%s\n', jsonStr); fclose(fid); end diff --git a/src/MATLAB/+Dev/MergeGraphStruct.m b/src/MATLAB/+Dev/MergeGraphStruct.m new file mode 100644 index 0000000000000000000000000000000000000000..c8dcab1c81d9c9dea391115a403cf66f7cca8c30 --- /dev/null +++ b/src/MATLAB/+Dev/MergeGraphStruct.m @@ -0,0 +1,18 @@ +function [graphStruct,newNodes] = MergeGraphStruct(graphStruct, newStruct) + oldIdx = cellfun(@(x)(find(strcmp(x,graphStruct.nodes),1,'first')), newStruct.nodes, 'UniformOutput',0); + bNew = cellfun(@(x)(isempty(x)), oldIdx); + + newNodes = newStruct.nodes(bNew); + + p = length(newNodes); + [m,n] = size(graphStruct.graph); + + idxMap = zeros(1,length(newStruct.nodes)); + idxMap(~bNew) = [oldIdx{~bNew}]; + idxMap(bNew) = (1:p) + n; + + graphStruct.nodes = [graphStruct.nodes; newNodes]; + graphStruct.graph = [graphStruct.graph zeros(n,p); zeros(p,n+p)]; + + graphStruct.graph(idxMap,idxMap) = (graphStruct.graph(idxMap,idxMap) | newStruct.graph); +end \ No newline at end of file diff --git a/src/MATLAB/+Dev/ParseVerTag.m b/src/MATLAB/+Dev/ParseVerTag.m new file mode 100644 index 0000000000000000000000000000000000000000..278ecaa61b879af28761ec7d4c6b4c2fd95031d0 --- /dev/null +++ b/src/MATLAB/+Dev/ParseVerTag.m @@ -0,0 +1,15 @@ +% [majorVer,minorVer] = ParseVerTag(verString) +% + +function [majorVer,minorVer] = ParseVerTag(verString) + majorVer = []; + minorVer = []; + + verString = strtrim(verString); + + numTok = regexp(verString, '[Vv](\d+)\.(\d+(?:\.\d+)?).*', 'tokens', 'once'); + if ( length(numTok) >= 2 ) + majorVer = str2double(numTok{1}); + minorVer = str2double(numTok{2}); + end +end diff --git a/src/MATLAB/+Dev/PrintIntegrityErrors.m b/src/MATLAB/+Dev/PrintIntegrityErrors.m index f511f62f3bcbbe6c52a7046676a25be5b7b0c3b8..1580608e2d7207e3b1d9979ec3aebe9e6080b946 100644 --- a/src/MATLAB/+Dev/PrintIntegrityErrors.m +++ b/src/MATLAB/+Dev/PrintIntegrityErrors.m @@ -1,6 +1,30 @@ % PrintIntegrityErrors(errs, filename) % Prints integrity errors to filename (or stdout if no name specified) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function PrintIntegrityErrors(errs, fid) if ( isempty(errs) ) diff --git a/src/MATLAB/+Dev/ReplayActionsFile.m b/src/MATLAB/+Dev/ReplayActionsFile.m index 6df25993fde817a4e3e775a5c0efbcb63d29ee73..11d2b4861ac265db4e6e4a4b6dc71d9e142bb07d 100644 --- a/src/MATLAB/+Dev/ReplayActionsFile.m +++ b/src/MATLAB/+Dev/ReplayActionsFile.m @@ -1,5 +1,29 @@ % ReplayActionsFile(filename) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function ReplayActionsFile(filename) loadStruct = load(filename, 'ReplayEditActions'); diff --git a/src/MATLAB/+Dev/ReplayEditAction.m b/src/MATLAB/+Dev/ReplayEditAction.m index ff62a9222e017bd31c1b5f1f293189b29846f004..deab54970cbaeebb4f8b63e0ddc233987779cd9a 100644 --- a/src/MATLAB/+Dev/ReplayEditAction.m +++ b/src/MATLAB/+Dev/ReplayEditAction.m @@ -2,6 +2,30 @@ % % ReplayEditAction attempts to replay an action from an editaction list. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [bErr chkHash varargout] = ReplayEditAction(actPtr, varargin) varargout = cell(1,max(0,nargout-2)); diff --git a/src/MATLAB/+Dev/SetupGit.m b/src/MATLAB/+Dev/SetupGit.m index 86d9a197e937a810d5dcd3c3453c0100488e9974..aece550b17f59bdfd74b87a7b3614ed789303da7 100644 --- a/src/MATLAB/+Dev/SetupGit.m +++ b/src/MATLAB/+Dev/SetupGit.m @@ -30,9 +30,10 @@ function gitPath = findGitPath() gitPath = ''; comparch = computer('arch'); - progFilesPath = 'C:\Program Files (x86)'; + progFilesPath64 = 'C:\Program Files'; if ( strcmpi(comparch,'win64') ) progFilesPath = getenv('ProgramFiles(x86)'); + progFilesPath64 = getenv('ProgramFiles'); elseif ( strcmpi(comparch,'win32') ) progFilesPath = getenv('ProgramFiles'); else @@ -40,7 +41,9 @@ function gitPath = findGitPath() end tryPaths = {fullfile(progFilesPath, 'Git'); + fullfile(progFilesPath64, 'Git'); fullfile(progFilesPath, 'msysgit'); + fullfile(progFilesPath64, 'msysgit'); 'C:\Git'; 'C:\msysgit'}; diff --git a/src/MATLAB/+Dev/SplitDependencyNames.m b/src/MATLAB/+Dev/SplitDependencyNames.m new file mode 100644 index 0000000000000000000000000000000000000000..6cf65d26a984843f085c59872b023989e11b83e6 --- /dev/null +++ b/src/MATLAB/+Dev/SplitDependencyNames.m @@ -0,0 +1,61 @@ +function [rootPath,rootName,localPath] = SplitDependencyNames(depList) + rootPath = cell(length(depList),1); + rootName = cell(length(depList),1); + localPath = cell(length(depList),1); + + dropPostfix = {'src/MATLAB'}; + localMatches = '^private$|^\+.+$|^@.+$|^.+\.(m|mexw64|mexw32|fig)$'; + + for i=1:length(depList) + qualPath = splitQualifiedPath(depList{i}); + + bLocalPath = cellfun(@(x)(~isempty(x)),regexp(qualPath,localMatches, 'start','once')); + endRoot = find(diff(bLocalPath),1,'last'); + if ( isempty(endRoot) ) + % This shouldn't happen if matlab toolboxes are handled first. + continue; + end + + chkPath = qualPath(1:endRoot); + for j=1:size(dropPostfix,1) + chkPostfix = strsplit(dropPostfix{j},'/'); + cmpIdx = length(chkPath)-length(chkPostfix) + 1; + bDropMatch = strcmp(chkPostfix,chkPath(cmpIdx:end)); + + if ( all(bDropMatch) ) + chkPath = chkPath(1:(cmpIdx-1)); + break; + end + end + + rootName{i} = chkPath{end}; + rootPath{i} = fullfile(qualPath{1:endRoot}); + localPath{i} = fullfile(qualPath{(endRoot+1):end}); + end +end + +function qualPath = splitQualifiedPath(inPath) + chkPath = strrep(inPath, '\','/'); + + qualPath = {}; + splitRoot = regexp(chkPath,'^(/{1,2}.+?|.+?:)/(.*?)$','tokens','once'); + if ( ~isempty(splitRoot) ) + qualPath = splitRoot(1); + chkPath = splitRoot{2}; + end + + splitPath = strsplit(chkPath,'/'); + while ( ~isempty(splitPath) ) + popPath = splitPath{1}; + splitPath = splitPath(2:end); + + if ( strcmp('.',popPath) ) + continue; + elseif ( strcmp('..',popPath) ) + qualPath = qualPath(1:end-1); + continue; + end + + qualPath = [qualPath {popPath}]; + end +end diff --git a/src/MATLAB/+Dev/UnitTestMexDijkstra.m b/src/MATLAB/+Dev/UnitTestMexDijkstra.m deleted file mode 100644 index 9891d1c90b44a11ba1cf5a266d8581331db01f85..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Dev/UnitTestMexDijkstra.m +++ /dev/null @@ -1,54 +0,0 @@ -function UnitTestMexDijkstra(costGraph, numIters) - - UI.Progressbar(0); - % Test single edge removal - mexDijkstra('initGraph', costGraph); - numIters = min(numIters, nnz(costGraph)); - testCostGraph = costGraph; - for i=1:numIters - [rcm, ccm] = find(testCostGraph > 0); -% graphInd = sub2ind(size(testCostGraph), rcm, ccm); - - rndidx = randi(length(rcm),1); - testCostGraph(rcm(rndidx),ccm(rndidx)) = 0; - - mexDijkstra('removeEdges', rcm(rndidx),ccm(rndidx)); - UI.Progressbar((i/numIters) / 3); - end - Dev.CheckMEXSynch(testCostGraph); - - % Test out edge removal - mexDijkstra('initGraph', costGraph); - testCostGraph = costGraph; - for i=1:numIters - [rcm, ccm] = find(testCostGraph > 0); -% graphInd = sub2ind(size(testCostGraph), rcm, ccm); - - if ( isempty(rcm) ) - break; - end - - rndidx = randi(length(rcm),1); - testCostGraph(rcm(rndidx),:) = 0; - - mexDijkstra('removeEdges', rcm(rndidx),[]); - UI.Progressbar((i/numIters) / 3 + 1/3); - end - Dev.CheckMEXSynch(testCostGraph); - - % Test in edge removal - mexDijkstra('initGraph', costGraph); - testCostGraph = costGraph; - for i=1:numIters - [rcm, ccm] = find(testCostGraph > 0); -% graphInd = sub2ind(size(testCostGraph), rcm, ccm); - - rndidx = randi(length(rcm),1); - testCostGraph(:,ccm(rndidx)) = 0; - - mexDijkstra('removeEdges', [],ccm(rndidx)); - UI.Progressbar((i/numIters) / 3 + 2/3); - end - Dev.CheckMEXSynch(testCostGraph); - UI.Progressbar(1); -end \ No newline at end of file diff --git a/src/MATLAB/+Dev/VerifyCachedCostMatrix.m b/src/MATLAB/+Dev/VerifyCachedCostMatrix.m deleted file mode 100644 index e5bf68d65123c7e5b264043db16446906ad17414..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Dev/VerifyCachedCostMatrix.m +++ /dev/null @@ -1,51 +0,0 @@ -% err = VerifyCachedCostMatrix() -% Compares CachedCostMatrix to what would be generated by old GetCostMatrix -% code. - -function err = VerifyCachedCostMatrix() - global Costs GraphEdits CellHulls CachedCostMatrix - err = []; - - costMatrix = Costs; - % bRemovedEdges = (GraphEdits < 0); - % costMatrix(bRemovedEdges) = 0; - % - % bSetEdges = (GraphEdits > 0); - % bSetRows = any(bSetEdges, 2); - % bSetCols = any(bSetEdges, 1); - % - % costMatrix(bSetRows,:) = 0; - % costMatrix(:,bSetCols) = 0; - % costMatrix(bSetEdges) = GraphEdits(bSetEdges)*eps; - - % Vectorized/binary indexed implementation of this code is commented - % out above because we cannot use more than 46K square elements in a - % matrix in 32-bit matlab. - [r,c] = find(GraphEdits < 0); - for i=1:length(r) - costMatrix(r(i),c(i)) = 0; - end - - % Remove all edges to/from deleted hulls - % This may end up being super slow, however it stops other graph code - % from always having to check for deleted hulls (in general) by making - % them unreachable. - r = find([CellHulls.deleted]); - for i=1:length(r) - costMatrix(r(i),:) = 0; - costMatrix(:,r(i)) = 0; - end - - [r,c] = find(GraphEdits > 0); - for i=1:length(r) - costMatrix(r(i),:) = 0; - costMatrix(:,c(i)) = 0; - end - for i=1:length(r) - costMatrix(r(i),c(i)) = GraphEdits(r(i),c(i))*eps; - end - - [r,c] = find(costMatrix ~= CachedCostMatrix); - - err = [r c]; -end diff --git a/src/MATLAB/+Dev/WriteFrozenErrorCounts.m b/src/MATLAB/+Dev/WriteFrozenErrorCounts.m index 6e31a72de847b92f178d0e37a74f46dea81b8272..5251dd6de9c015d806d00a6f60ae8f29928b6c8d 100644 --- a/src/MATLAB/+Dev/WriteFrozenErrorCounts.m +++ b/src/MATLAB/+Dev/WriteFrozenErrorCounts.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function WriteFrozenErrorCounts(rootDir) flist = dir(fullfile(rootDir,'*.mat')); @@ -41,7 +65,7 @@ function [datasetName, frozenTrees, hullCount, trackCount, missingCount, userSeg return; end - datasetName = CONSTANTS.datasetName; + datasetName = Metadata.GetDatasetName(); for i=1:length(frozenTrees) [hullIDs missingHulls] = Families.GetAllHulls(frozenTrees(i)); diff --git a/src/MATLAB/+Dev/WriteGraphDOT.m b/src/MATLAB/+Dev/WriteGraphDOT.m deleted file mode 100644 index f6364ca82cd2d780d7a02b59ee2d3f34a95f19df..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Dev/WriteGraphDOT.m +++ /dev/null @@ -1,69 +0,0 @@ -function WriteGraphDOT(callGraph, fullFuncList) - fullNames = cellfun(@(x)(strrep(x, '\', '\\')), fullFuncList, 'UniformOutput',0); - -% toolboxes = {}; -% toolboxMap = zeros(1,length(fullFuncList)); -% for i=1:length(fullFuncList) -% toolboxPattern = '(?<=^.+[\\/]toolbox[\\/])[^\\/]+'; -% matchToolbox = regexp(fullFuncList{i}, toolboxPattern, 'match', 'once'); -% if ( isempty(matchToolbox) ) -% continue; -% end -% -% if ( any(strcmpi(matchToolbox,toolboxes)) ) -% toolboxMap(i) = find(strcmpi(matchToolbox,toolboxes)); -% continue; -% end -% -% toolboxMap(i) = length(toolboxes) + 1; -% toolboxes = [toolboxes; {matchToolbox}]; -% end - - % Write a DOT file representing call graph - fid = fopen('adjmat.dot','w'); - % fprintf(fid,'digraph G {\ncenter = 1;\nsize="10,10";\n'); - fprintf(fid, 'digraph G \n{\n'); - fprintf(fid, 'rankdir=LR\n'); - fprintf(fid, 'node [shape=box]\n'); - - bUsedNodes = false(1,length(fullFuncList)); -% for i=1:length(toolboxes) -% bInToolbox = (toolboxMap == i); -% tbGraph = callGraph(bInToolbox,bInToolbox); -% subNodes = find(bInToolbox); -% -% fprintf(fid, 'subgraph ["%s"]\n{\n', toolboxes{i}); -% -% for j=1:length(subNodes) -% [funcPath shortName] = fileparts(fullFuncList{subNodes(j)}); -% fprintf(fid, '%d[label="%s"]; ', subNodes(j), shortName); -% end -% -% fprintf(fid, '\n'); -% -% [r c] = find(tbGraph); -% for j=1:length(r) -% fprintf(fid, '%d -> %d; ', subNodes(r(j)), subNodes(c(j))); -% end -% -% fprintf(fid, '\n}\n'); -% -% bUsedNodes(bInToolbox) = 1; -% callGraph(bInToolbox,bInToolbox) = 0; -% end - - remainingNodes = find(~bUsedNodes); - for i=1:length(remainingNodes) - [funcPath shortName] = fileparts(fullFuncList{remainingNodes(i)}); - fprintf(fid, '%d[label="%s"]; ', remainingNodes(i), shortName); - end - - fprintf(fid, '\n'); - [r c] = find(callGraph); - for i=1:length(r) - fprintf(fid, '%d -> %d; ', r(i), c(i)); - end - - fprintf(fid, '\n}'); - fclose(fid); -end \ No newline at end of file diff --git a/src/MATLAB/+Dev/hemetoSegTesting.m b/src/MATLAB/+Dev/hemetoSegTesting.m deleted file mode 100644 index 247d61e062e0bda91d3e360e9951b2a2036a8669..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Dev/hemetoSegTesting.m +++ /dev/null @@ -1,103 +0,0 @@ -orgImg = imread('C:\Users\Eric\Pictures\Pos18\Pos18\Doc_0008_2_Position18.tif_Files_cropped\120608ML_p018_t00637_w0.tif'); -gry = mat2gray(orgImg); -thGry = graythresh(gry); -bwGry = im2bw(gry,thGry); -se=strel('disk',2); -gd=imdilate(gry,se); -ge=imerode(gry,se); -ig=gd-ge; - -thIg = graythresh(ig); -bwig=im2bw(ig,thIg); - -% gry_ig=bwGry-bwig; -% gry_ig(:)=max(gry_ig(:),0); -% ds = bwdist(bwig); - -bw = bwGry &~ bwig; -bw2 = +bwGry; -bw2 = bw2-ig; - -bw3 = imfill(bw,'holes'); -% bw3 = imopen(bw3,se); - -[bwR bwC] = find(bwGry); -imagesc(gry);colormap gray, hold on -plot(bwC,bwR,'sb'); - -CC = bwconncomp(bw3,8); -stats = regionprops(CC, 'Area', 'Centroid', 'Eccentricity','MinorAxisLength'); -idx = find([stats.Area] > 100); -for i=1:length(idx) - id = sprintf('%d',idx(i)); - text(stats(idx(i)).Centroid(1),stats(idx(i)).Centroid(2),id); -end - -cell = 166; -pixels = CC.PixelIdxList{cell}; -[r c] = ind2sub(size(orgImg), pixels); -points = []; -for i=1:length(pixels) -% for j=1:stats(cell).MinorAxisLength*bw2(pixels(i)) -% z = ceil(j/2); -% if (mod(j,2)) -% z = -z; -% end - points = [points;[r(i) c(i) i]]; -% end -end - -[B I]=unique(points,'rows'); - -clstr = 4; -opt = statset('MaxIter',400); -obj = gmdistribution.fit([points(:,1) points(:,2)],clstr,'Options',opt,'Replicates',15); -kIdx = cluster(obj, [points(:,1) points(:,2)]); - -[kIdxK m] = kmeans([points(:,1) points(:,2)],clstr,'Replicates',15); - -hulls = []; -for i=1:clstr - hulls(i).pixels = []; -end - -for i=1:length(I) - hulls(kIdx(I(i))).pixels = [hulls(kIdx(I(i))).pixels; points(I(i),:)]; -end - -hullsK = []; -for i=1:clstr - hullsK(i).pixels = []; -end - -for i=1:length(I) - hullsK(kIdxK(I(i))).pixels = [hullsK(kIdxK(I(i))).pixels; points(I(i),:)]; -end - -% for i=1:4 -% hulls(i).pixels = [r(kIdx==i) c(kIdx==i)]; -% end - -%imagesc(gry); colormap gray, hold on - -plot(hulls(1).pixels(:,2),hulls(1).pixels(:,1),'.r'); -plot(hulls(2).pixels(:,2),hulls(2).pixels(:,1),'.g'); -plot(hulls(3).pixels(:,2),hulls(3).pixels(:,1),'.b'); -plot(hulls(4).pixels(:,2),hulls(4).pixels(:,1),'.c'); -plot(hulls(5).pixels(:,2),hulls(5).pixels(:,1),'om'); -plot(hulls(6).pixels(:,2),hulls(6).pixels(:,1),'.y'); -plot(hulls(7).pixels(:,2),hulls(7).pixels(:,1),'.k'); - -plot(hullsK(1).pixels(:,2),hullsK(1).pixels(:,1),'.r'); -plot(hullsK(2).pixels(:,2),hullsK(2).pixels(:,1),'.g'); -plot(hullsK(3).pixels(:,2),hullsK(3).pixels(:,1),'.b'); -plot(hullsK(4).pixels(:,2),hullsK(4).pixels(:,1),'.c'); -plot(hullsK(5).pixels(:,2),hullsK(5).pixels(:,1),'.m'); -plot(hullsK(6).pixels(:,2),hullsK(6).pixels(:,1),'.y'); -plot(hullsK(7).pixels(:,2),hullsK(7).pixels(:,1),'.k'); - -plot(m(1,2),m(1,1),'sk','MarkerFaceColor','k'); -plot(m(2,2),m(2,1),'sk','MarkerFaceColor','k'); -plot(m(3,2),m(3,1),'sk','MarkerFaceColor','k'); -plot(m(4,2),m(4,1),'sk','MarkerFaceColor','k'); -plot(m(5,2),m(5,1),'sk','MarkerFaceColor','k'); diff --git a/src/MATLAB/+Dev/testMexDijkstra.m b/src/MATLAB/+Dev/testMexDijkstra.m deleted file mode 100644 index 1163126ebf2dabbe7c2f4f19d67a2c00e374dfca..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Dev/testMexDijkstra.m +++ /dev/null @@ -1,143 +0,0 @@ -function testMexDijkstra() - global CellHulls - - clear mex - - tic; - costMatrix = Tracker.GetCostMatrix(); - mexDijkstra('initGraph', costMatrix); - - maxFrameExt = 19; - - UI.Progressbar(0); - for i=1:length(CellHulls) -% [pathExt pathCost] = dijkstraSearch(i, costMatrix, @checkExtension, maxFrameExt); - [testPaths testCosts] = mexDijkstra('checkExtension', i, maxFrameExt+1); - -% [pathCost srtidx] = sort(pathCost); -% pathExt = pathExt(srtidx); -% -% [testCosts srtidx] = sort(testCosts); -% testPaths = testPaths(srtidx); -% -% if ( length(pathExt) ~= length(testPaths) ) -% error(['Unequal paths at i=' num2str(i) ' (lengths mismatched)']); -% end -% -% for j=1:length(pathExt) -% if ( testCosts(j) ~= pathCost(j) ) -% error(['Unequal paths at i=' num2str(i) ' (' num2str(j) '-th cost mismatced)']); -% end -% end -% -% for j=1:length(pathExt) -% if ( testPaths{j}(end) ~= pathExt{j}(end) ) -% error(['Unequal paths at i=' num2str(i) ' (' num2str(j) '-th endHull mismatced)']); -% end -% end - - UI.Progressbar(i / length(CellHulls)); - end - - toc - - disp('SWEETNESS!'); -end - -function bGoodExt = checkExtension(startHull, endHull, path) - global CellTracks CellHulls - - bGoodExt = false; - - trackID = Hulls.GetTrackID(endHull); - bGoodTime = (CellTracks(trackID).startTime == CellHulls(endHull).time); - if ( ~bGoodTime ) - return; - end - - parentID = CellTracks(trackID).parentTrack; - if ( ~isempty(parentID) ) - nzParent = CellTracks(parentID).hulls(find(CellTracks(parentID).hulls,1,'last')); - [costMatrix bPathHulls bNextHulls] = Tracker.GetCostSubmatrix(nzParent, 1:length(CellHulls)); - nxtHulls = find(bNextHulls); - [dump minidx] = min(costMatrix); - if ( nxtHulls(minidx) == endHull ) - return; - end - end - - bGoodExt = true; -end - -function [paths pathCosts] = dijkstraSearch(startHull, costGraph, acceptFunc, maxExt) - paths = {}; - pathCosts = []; - - bestCosts = sparse([],[],[],1,size(costGraph,1),round(0.01*size(costGraph,1))); - bestPaths = cell(1,size(costGraph,1)); - - bestPaths{startHull} = startHull; - - termHulls = []; - - trvList = []; - trvHull = startHull; - while ( true ) - - nextHulls = find(costGraph(trvHull,:)); - nextPathCosts = costGraph(trvHull,nextHulls) + bestCosts(trvHull); - -% % Don't even bother putting paths that are higher cost in the list -% bestChk = bestCosts(nextHulls); -% bestChk(bestChk == 0) = Inf; -% bKeepNext = (min([nextPathCosts;bestChk],[],1) == nextPathCosts); -% nextHulls = nextHulls(bKeepNext); -% nextPathCosts = nextPathCosts(bKeepNext); - - trvList = [trvList; nextPathCosts' trvHull*ones(length(nextHulls),1) nextHulls']; - bestChk = full(bestCosts(trvList(:,3))); - bestChk(bestChk == 0) = Inf; - bKeepNext = (min([trvList(:,1)';bestChk],[],1) == trvList(:,1)'); - trvList = trvList(bKeepNext,:); - -% trvList = sortrows([trvList; nextPathCosts' trvHull*ones(length(nextHulls),1) nextHulls'],1); - trvList = sortrows(trvList,1); - - while ( size(trvList,1) > 0 ) - if ( length(bestPaths{trvList(1,2)}) > maxExt ) - trvList = trvList(2:end,:); - continue; - end - - if ( (bestCosts(trvList(1,3))==0) ) - bestCosts(trvList(1,3)) = trvList(1,1); - bestPaths{trvList(1,3)} = [bestPaths{trvList(1,2)} trvList(1,3)]; - elseif ( (bestCosts(trvList(1,3)) > trvList(1,1)) ) - error('This should never happen!'); - end - - % Is the next traversal a terminal node? - if ( acceptFunc(startHull, trvList(1,3),[bestPaths{trvList(1,2)} trvList(1,3)]) ) - termHulls = union(termHulls,trvList(1,3)); - trvList = trvList(2:end,:); - continue; - end - - break; - end - - if ( isempty(trvList) ) - break; - end - - trvHull = trvList(1,3); - trvList = trvList(2:end,:); - end - - paths = cell(1,length(termHulls)); - pathCosts = zeros(1,length(termHulls)); - for i=1:length(termHulls) - paths{i} = bestPaths{termHulls(i)}; - pathCosts(i) = bestCosts(termHulls(i)); - end -end \ No newline at end of file diff --git a/src/MATLAB/+Editor/AddHull.m b/src/MATLAB/+Editor/AddHull.m index 958a536ae0f606e8a588cf149f4d16a69a68ecbb..7105b241fca11b970a195274a3c55db8014553c5 100644 --- a/src/MATLAB/+Editor/AddHull.m +++ b/src/MATLAB/+Editor/AddHull.m @@ -3,10 +3,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Editor/AddMitosisAction.m b/src/MATLAB/+Editor/AddMitosisAction.m index af3a288b1479a3ac6534e6bae86f8de9d5bae39d..cafe0a38ae53454e2c3d8ab8505030358b25e70f 100644 --- a/src/MATLAB/+Editor/AddMitosisAction.m +++ b/src/MATLAB/+Editor/AddMitosisAction.m @@ -5,6 +5,30 @@ % leftChild is non-empty also change its label to the parent track before % adding the mitosis. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function historyAction = AddMitosisAction(parentTrack, leftChild, siblingTrack, time) global CellTracks diff --git a/src/MATLAB/+Editor/AddNewCell.m b/src/MATLAB/+Editor/AddNewCell.m index 44304e7a10b856dca570e41992841d7df46af579..8784ff6bc3ad01f69b81bc46a5d7b8a80e892176 100644 --- a/src/MATLAB/+Editor/AddNewCell.m +++ b/src/MATLAB/+Editor/AddNewCell.m @@ -5,6 +5,30 @@ % find a segmentation result, add a singple point segmentation at % clickPoint +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [historyAction newTrack] = AddNewCell(clickPoint, time) newTrack = Segmentation.AddNewSegmentHull(clickPoint, time); diff --git a/src/MATLAB/+Editor/AddPhenotype.m b/src/MATLAB/+Editor/AddPhenotype.m index eceeb6de346a8c60ab707a350e2ef7df0f2814ef..c8b8d1643e91dd0fa9fef5d5134635eecfb25672 100644 --- a/src/MATLAB/+Editor/AddPhenotype.m +++ b/src/MATLAB/+Editor/AddPhenotype.m @@ -5,6 +5,30 @@ % NOTE: this is one of the few edit actions that does not directly affect % undo stack it will always be followed by a ContextSetPhenotype action. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [historyAction phenoID] = AddPhenotype(description) global CellPhenotypes Colors diff --git a/src/MATLAB/+Editor/ChangeLabelAction.m b/src/MATLAB/+Editor/ChangeLabelAction.m index 74dc6879f6d111288ff20b6919f72bf6cf930f56..21aed091fb444cb8e7d808fa4c3fc9f87cdf0ef1 100644 --- a/src/MATLAB/+Editor/ChangeLabelAction.m +++ b/src/MATLAB/+Editor/ChangeLabelAction.m @@ -3,6 +3,30 @@ % % Changes trackID to newTrackID beginning at time. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function historyAction = ChangeLabelAction(trackID, newTrackID, time) %TODO: This edit graph update may need to more complicated to truly %capture user edit intentions. diff --git a/src/MATLAB/+Editor/ChangeParent.m b/src/MATLAB/+Editor/ChangeParent.m index 546d7a57ad10be6d7298475ef52abc25eea8775c..a6a59029226e1c1ef9bcc403613a018bce74939d 100644 --- a/src/MATLAB/+Editor/ChangeParent.m +++ b/src/MATLAB/+Editor/ChangeParent.m @@ -5,6 +5,30 @@ % Context Swap Labels % Toggle lock on family ID % Maria Enokian + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function historyAction = ChangeParent(familyID,trackID,newTrackID, time) % Initialized variables global CellFamilies CellTracks Figures diff --git a/src/MATLAB/+Editor/ContextAddAllToExtendedFamily.m b/src/MATLAB/+Editor/ContextAddAllToExtendedFamily.m new file mode 100755 index 0000000000000000000000000000000000000000..80180899a68ca25a4d3a0c33ba3b2091a95e0a69 --- /dev/null +++ b/src/MATLAB/+Editor/ContextAddAllToExtendedFamily.m @@ -0,0 +1,34 @@ +% ContextAddAllToExtendedFamily.m - Context menu callback function for adding +% all tracks on a frame to an extended family + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function ContextAddAllToExtendedFamily(time) + global Figures + + Families.MultiTreeAllTracks(time); + + UI.DrawTree(Figures.tree.familyID); + UI.DrawCells(); +end diff --git a/src/MATLAB/+Editor/ContextAddMitosis.m b/src/MATLAB/+Editor/ContextAddMitosis.m index d0279d3b3bcb8c807e348af1cbe91b39205d9b93..a299ef5318ea6ff97720b16421c45211609dad38 100644 --- a/src/MATLAB/+Editor/ContextAddMitosis.m +++ b/src/MATLAB/+Editor/ContextAddMitosis.m @@ -1,5 +1,29 @@ % ContextAddMitosis(trackID, siblingTrack, time) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + % ChangeLog: % EW 6/8/12 created function ContextAddMitosis(trackID, siblingTrack, time, localLabels, revLocalLabels) diff --git a/src/MATLAB/+Editor/ContextAddToExtendedFamily.m b/src/MATLAB/+Editor/ContextAddToExtendedFamily.m index 6900ff7dc674e7a25ac71846fe02eb8e64a24bc9..7427628621981964e7820e658262bb48604f16fd 100755 --- a/src/MATLAB/+Editor/ContextAddToExtendedFamily.m +++ b/src/MATLAB/+Editor/ContextAddToExtendedFamily.m @@ -3,10 +3,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by @@ -24,22 +24,26 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -function ContextAddToExtendedFamily(trackID) +function ContextAddToExtendedFamily(hullIDs) global CellFamilies CellTracks Figures - familyID = CellTracks(trackID).familyID; - - if ~isempty(CellFamilies(familyID).extFamily) - xfam = CellFamilies(familyID).extFamily; - if length(xfam) > 1 - warn = sprintf('Track %d is already in an extended family', trackID); - warndlg(warn); - return; + trackIDs = Hulls.GetTrackID(hullIDs); + familyIDs = [CellTracks(trackIDs).familyID]; + + for i=1:length(familyIDs) + familyID = familyIDs(i); + if ~isempty(CellFamilies(familyID).extFamily) + xfam = CellFamilies(familyID).extFamily; + if length(xfam) > 1 + warn = sprintf('Track %d is already in an extended family', trackID); + warndlg(warn); + return; + end end end [localLabels, revLocalLabels] = UI.GetLocalTreeLabels(Figures.tree.familyID); - answer = inputdlg('Enter cell label of family to join','Join Family',1,{UI.TrackToLocal(localLabels, trackID)}); + answer = inputdlg('Enter cell label of family to join','Join Family',1,{num2str(CellFamilies(Figures.tree.familyID).tracks(1))}); if(isempty(answer)),return,end; newTrackIDLocal = answer{1}; @@ -57,14 +61,14 @@ function ContextAddToExtendedFamily(trackID) return end - if ( newTrackID == trackID ) - warn = sprintf('Track %s is the current track.', newTrackIDLocal); + if ( ismember(newTrackID, trackIDs) ) + warn = sprintf('Track %s is one of the selected track(s).', newTrackIDLocal); warndlg(warn); return; end newFamilyID = CellTracks(newTrackID).familyID; - newExtFamily = union(CellFamilies(newFamilyID).extFamily, [familyID newFamilyID]); + newExtFamily = union(CellFamilies(newFamilyID).extFamily, [familyIDs newFamilyID]); [CellFamilies(newExtFamily).extFamily] = deal(newExtFamily); UI.DrawTree(Figures.tree.familyID); diff --git a/src/MATLAB/+Editor/ContextChangeLabel.m b/src/MATLAB/+Editor/ContextChangeLabel.m index bee4e4c8fb28e1d0323440089a95e3fc56047115..89d142130f72d16a781b4b644f1b1cdef5c8bc08 100644 --- a/src/MATLAB/+Editor/ContextChangeLabel.m +++ b/src/MATLAB/+Editor/ContextChangeLabel.m @@ -5,10 +5,10 @@ % EW 6/8/12 reviewed %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Editor/ContextChangeParent.m b/src/MATLAB/+Editor/ContextChangeParent.m index a94023a08d0cbb50c548c4e2ca4b8ae3e994d59f..14b2d26f18e9fd2af88dc5fd8fefdb3ac7a8ea85 100644 --- a/src/MATLAB/+Editor/ContextChangeParent.m +++ b/src/MATLAB/+Editor/ContextChangeParent.m @@ -1,6 +1,30 @@ % ContextChangeParent.m - Allows user to correct the parents during the % mitosis stage, and fix the tree. % Maria Enokian + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function ContextChangeParent(familyID,time,trackID) global CellTracks global Figures diff --git a/src/MATLAB/+Editor/ContextProperties.m b/src/MATLAB/+Editor/ContextProperties.m index 954f0eea7c67fd3695189208e05e9a47a46f355a..c171da84e1512c1133b31960ce495d7e81ba3dc8 100644 --- a/src/MATLAB/+Editor/ContextProperties.m +++ b/src/MATLAB/+Editor/ContextProperties.m @@ -3,10 +3,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Editor/ContextRemoveAllFromExtendedFamily.m b/src/MATLAB/+Editor/ContextRemoveAllFromExtendedFamily.m new file mode 100755 index 0000000000000000000000000000000000000000..e2adbcba68309c51c74be1e8de162b065f0ce5b5 --- /dev/null +++ b/src/MATLAB/+Editor/ContextRemoveAllFromExtendedFamily.m @@ -0,0 +1,34 @@ +% ContextAddAllToExtendedFamily.m - Context menu callback function for adding +% all tracks on a frame to an extended family + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function ContextRemoveAllFromExtendedFamily() + global Figures CellFamilies + + [CellFamilies(:).extFamily] = deal([]); + + UI.DrawTree(Figures.tree.familyID); + UI.DrawCells(); +end diff --git a/src/MATLAB/+Editor/ContextRemoveFromExtendedFamily.m b/src/MATLAB/+Editor/ContextRemoveFromExtendedFamily.m index 862a765e3b5d3d79b412fa2af23df7cc951b3a3e..c5f25fca2c43b4fc5b54519f35a38995ae5bbf88 100755 --- a/src/MATLAB/+Editor/ContextRemoveFromExtendedFamily.m +++ b/src/MATLAB/+Editor/ContextRemoveFromExtendedFamily.m @@ -3,10 +3,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Editor/ContextRemoveFromTree.m b/src/MATLAB/+Editor/ContextRemoveFromTree.m index 05374a0323cdb30b680e8b255d7d81975d3c82f4..cbae7dc4638694c3984b9cc34178fd83e65129a0 100644 --- a/src/MATLAB/+Editor/ContextRemoveFromTree.m +++ b/src/MATLAB/+Editor/ContextRemoveFromTree.m @@ -5,10 +5,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Editor/ContextSetPhenotype.m b/src/MATLAB/+Editor/ContextSetPhenotype.m index a291f7b8a1705807bdeb72ec85f058956d09607a..e72f1d5aaee3db6574d4c9bf326c2b6016993d15 100644 --- a/src/MATLAB/+Editor/ContextSetPhenotype.m +++ b/src/MATLAB/+Editor/ContextSetPhenotype.m @@ -4,6 +4,30 @@ % Sets or clears the phenotype specified for the given hull. If the % phenotype is "dead" there is also some special handling to drop children. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function historyAction = ContextSetPhenotype(hullID, phenotype, bActive) global CellPhenotypes diff --git a/src/MATLAB/+Editor/ContextSwapLabels.m b/src/MATLAB/+Editor/ContextSwapLabels.m index 08a8fa41afce8969f15b7323bc418ae8184d38f0..bf20fb9faeaa120a3f4293cade8a48d286a04af0 100644 --- a/src/MATLAB/+Editor/ContextSwapLabels.m +++ b/src/MATLAB/+Editor/ContextSwapLabels.m @@ -3,6 +3,30 @@ % % Swap tracking for tracks A and B beginning at specified time. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function historyAction = ContextSwapLabels(trackA, trackB, time) Tracker.GraphEditSetEdge(trackA, trackB, time); diff --git a/src/MATLAB/+Editor/CreateMitosisAction.m b/src/MATLAB/+Editor/CreateMitosisAction.m index e1efde9d25a604ba0373f8165a6eeee19372def9..7de7a66d85c3790ef1e2d555dea75ded522fc9ab 100644 --- a/src/MATLAB/+Editor/CreateMitosisAction.m +++ b/src/MATLAB/+Editor/CreateMitosisAction.m @@ -3,6 +3,30 @@ % % Create user identified mitosis events and add to current tree. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function historyAction = CreateMitosisAction(trackID, dirFlag, time, linePoints) global CellTracks @@ -49,11 +73,11 @@ function historyAction = CreateMitosisAction(trackID, dirFlag, time, linePoints) end function newPoints = clipToImage(linePoints) - global CONSTANTS - newPoints = linePoints; - newPoints(:,1) = min(newPoints(:,1), repmat(CONSTANTS.imageSize(2),size(linePoints,1),1)); - newPoints(:,2) = min(newPoints(:,2), repmat(CONSTANTS.imageSize(1),size(linePoints,1),1)); + + xyImageDims = Metadata.GetDimensions('xy'); + newPoints(:,1) = min(newPoints(:,1), repmat(xyImageDims(1),size(linePoints,1),1)); + newPoints(:,2) = min(newPoints(:,2), repmat(xyImageDims(2),size(linePoints,1),1)); newPoints(:,1) = max(newPoints(:,1), repmat(1,size(linePoints,1),1)); newPoints(:,2) = max(newPoints(:,2), repmat(1,size(linePoints,1),1)); diff --git a/src/MATLAB/+Editor/DeleteCells.m b/src/MATLAB/+Editor/DeleteCells.m index a6a9275d2b227e32ea79a610937e2ce6e89f8192..579d05258151904f080f36109623c0f27ad35d26 100644 --- a/src/MATLAB/+Editor/DeleteCells.m +++ b/src/MATLAB/+Editor/DeleteCells.m @@ -4,10 +4,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Editor/DropReplayableSubtask.m b/src/MATLAB/+Editor/DropReplayableSubtask.m index 64f677f3302f74ba0e08fc50c73c74003c699be1..53611b454be04e48e1e8b17a94f1979ea9eab387 100644 --- a/src/MATLAB/+Editor/DropReplayableSubtask.m +++ b/src/MATLAB/+Editor/DropReplayableSubtask.m @@ -9,6 +9,30 @@ % The tasklabel should match the task that was added, the labels are only % an error checking device. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function historyAction = DropReplayableSubtask(taskLabel) global TaskStack diff --git a/src/MATLAB/+Editor/History.m b/src/MATLAB/+Editor/History.m index f3d16bdf55f4632a9f2ed27451bfd2ff38057bd1..0ff96b9ef6acd1acdf4d96f1b2522c6efc66d660 100644 --- a/src/MATLAB/+Editor/History.m +++ b/src/MATLAB/+Editor/History.m @@ -15,23 +15,23 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -% +% http://n2t.net/ark:/87918/d9rp4t for details +% % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation, either version 3 of the License, or % (at your option) any later version. -% +% % LEVer is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. -% +% % You should have received a copy of the GNU General Public License -% along with LEVer in file "gnu gpl v3.txt". If not, see +% along with LEVer in file "gnu gpl v3.txt". If not, see % <http://www.gnu.org/licenses/>. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -160,16 +160,17 @@ function setMenus() end if (isfield(Figures.cells,'menuHandles') && isfield(Figures.cells.menuHandles,'saveMenu')) + datasetName = Metadata.GetDatasetName(); if ( Editor.StackedHistory.IsSaved() ) set(Figures.cells.menuHandles.saveMenu,'Enable','off'); set(Figures.tree.menuHandles.saveMenu,'Enable','off'); - set(Figures.cells.handle,'Name',[CONSTANTS.datasetName ' Image Data']); - set(Figures.tree.handle,'Name',[CONSTANTS.datasetName ' Image Data']); + set(Figures.cells.handle,'Name',[datasetName ' Image Data']); + set(Figures.tree.handle,'Name',[datasetName ' Lineage Data']); else set(Figures.cells.menuHandles.saveMenu,'Enable','on'); set(Figures.tree.menuHandles.saveMenu,'Enable','on'); - set(Figures.cells.handle,'Name',[CONSTANTS.datasetName ' Image Data *']); - set(Figures.tree.handle,'Name',[CONSTANTS.datasetName ' Image Data *']); + set(Figures.cells.handle,'Name',[datasetName ' Image Data *']); + set(Figures.tree.handle,'Name',[datasetName ' Lineage Data *']); end end end %setMenu diff --git a/src/MATLAB/+Editor/InitHistory.m b/src/MATLAB/+Editor/InitHistory.m index fb70431b29b7ca4b560a7eb3c517eb3ac9804cec..366760f75384e726906649e4c56975273161d212 100644 --- a/src/MATLAB/+Editor/InitHistory.m +++ b/src/MATLAB/+Editor/InitHistory.m @@ -3,6 +3,30 @@ % % Tells the replay code that history has been reinitialized (on open). +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function historyAction = InitHistory() historyAction = 'Init'; end diff --git a/src/MATLAB/+Editor/LearnFromEdits.m b/src/MATLAB/+Editor/LearnFromEdits.m index 5c14f529d87bc04c265494df2bd67dffac995260..390d3573edff874c0fa665fd4b9d72f9c2114e9f 100644 --- a/src/MATLAB/+Editor/LearnFromEdits.m +++ b/src/MATLAB/+Editor/LearnFromEdits.m @@ -3,6 +3,30 @@ % % Propagate segmentation edits forward. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function historyAction = LearnFromEdits() global SegmentationEdits diff --git a/src/MATLAB/+Editor/LockedAddMitosisAction.m b/src/MATLAB/+Editor/LockedAddMitosisAction.m index 11951ac5b6e88727442a5278675882cc547f28dc..6c5e097e221e6256911e32f2b52229a4cb30af38 100644 --- a/src/MATLAB/+Editor/LockedAddMitosisAction.m +++ b/src/MATLAB/+Editor/LockedAddMitosisAction.m @@ -5,6 +5,30 @@ % leftChild is non-empty also change its label to the parent track before % adding the mitosis. Try to minimize locked tree structure changes +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function historyAction = LockedAddMitosisAction(parentTrack, leftChildTrack, siblingTrack, time) global CellTracks diff --git a/src/MATLAB/+Editor/LockedChangeLabelAction.m b/src/MATLAB/+Editor/LockedChangeLabelAction.m index 10c6378733f96d737ad4da9ab646a86d5bb78401..3e9b6efa57d6de05b5d4d09d92ad1e49a76d3855 100644 --- a/src/MATLAB/+Editor/LockedChangeLabelAction.m +++ b/src/MATLAB/+Editor/LockedChangeLabelAction.m @@ -4,6 +4,30 @@ % Changes hull at time from trackID to newTrackID. Tries to preserve tree % structure. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function historyAction = LockedChangeLabelAction(trackID, newTrackID, time) Tracker.GraphEditSetEdge(newTrackID,trackID,time,false); Tracks.LockedChangeLabel(trackID,newTrackID,time); diff --git a/src/MATLAB/+Editor/LogEdit.m b/src/MATLAB/+Editor/LogEdit.m index aa48e935e8b380589abccc422e847d3d7a2ec2f1..852f7fe861f22ebd84e45af316197238a6addb97 100644 --- a/src/MATLAB/+Editor/LogEdit.m +++ b/src/MATLAB/+Editor/LogEdit.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function LogEdit(actionStr, inputIDs, outputIDs, bUserEdit) global EditList diff --git a/src/MATLAB/+Editor/MergeCellsAction.m b/src/MATLAB/+Editor/MergeCellsAction.m index f12cf60a768f602c2c988cb4cabd36317dd66669..911ec921eed0198562a958af5ad02994f33d9ad5 100644 --- a/src/MATLAB/+Editor/MergeCellsAction.m +++ b/src/MATLAB/+Editor/MergeCellsAction.m @@ -3,6 +3,30 @@ % % Attempt to merge oversegmented cells. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [historyAction deletedCells replaceCell] = MergeCellsAction(selectedHulls, selectedTree) global SegmentationEdits diff --git a/src/MATLAB/+Editor/MitosisEditInitializeAction.m b/src/MATLAB/+Editor/MitosisEditInitializeAction.m index c139554d0132b4fdd339a4d965ad4cd7d7ff876a..c51d5dc117a574eb0aeba3273e0c91c345de775e 100644 --- a/src/MATLAB/+Editor/MitosisEditInitializeAction.m +++ b/src/MATLAB/+Editor/MitosisEditInitializeAction.m @@ -3,6 +3,30 @@ % % Initialize mitosis editing state +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function historyAction = MitosisEditInitializeAction(treeID, endTime) global CellFamilies diff --git a/src/MATLAB/+Editor/MitosisHullPhenotypeAction.m b/src/MATLAB/+Editor/MitosisHullPhenotypeAction.m index 8aea85b38b6bf6a7c4b51d3c9904c3fdc1070113..9ee53c05e329607c384f09193a7b68a0328d9a5a 100644 --- a/src/MATLAB/+Editor/MitosisHullPhenotypeAction.m +++ b/src/MATLAB/+Editor/MitosisHullPhenotypeAction.m @@ -1,6 +1,30 @@ % [historyAction newTrack] = MitosisHullPhenotypeAction() % Edit Action: +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [historyAction hullID] = MitosisHullPhenotypeAction(clickPoint, time, trackID) hullID = Hulls.FindHull(time, clickPoint); diff --git a/src/MATLAB/+Editor/OriginAction.m b/src/MATLAB/+Editor/OriginAction.m index 645f560339bdf02aaf5c1547c8e93d5f4241b20e..eeaa2bac75c3980656c24886a812479647e0e9a0 100644 --- a/src/MATLAB/+Editor/OriginAction.m +++ b/src/MATLAB/+Editor/OriginAction.m @@ -4,6 +4,30 @@ % This initial action creates a hash of several core data structures to % allow verification that a run of edits starts from the correct data. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [historyAction coreHash bInitialSeg] = OriginAction(bInitialSeg) historyAction = ''; coreHash = Dev.GetCoreHashList(); diff --git a/src/MATLAB/+Editor/Redo.m b/src/MATLAB/+Editor/Redo.m index 86e0c73153057b0b9c88bf5fb3fb27e27776b286..53d5e7a845449fdc374100295a144aac09afbbf9 100644 --- a/src/MATLAB/+Editor/Redo.m +++ b/src/MATLAB/+Editor/Redo.m @@ -4,6 +4,30 @@ % This is purely a placeholder to tell the replay action code that a redo % was performed. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function historyAction = Redo() historyAction = 'Redo'; end diff --git a/src/MATLAB/+Editor/RemoveTrackHulls.m b/src/MATLAB/+Editor/RemoveTrackHulls.m index e398ad51387a9b8069ad65c0c7fd91741b752f2f..8cbc373cd63c1381f54695a165368e605a1e87c3 100644 --- a/src/MATLAB/+Editor/RemoveTrackHulls.m +++ b/src/MATLAB/+Editor/RemoveTrackHulls.m @@ -5,10 +5,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Editor/ReplayableEditAction.m b/src/MATLAB/+Editor/ReplayableEditAction.m index b092f75f086de5932091b2f16cc2660113d8b3c5..bcfeeb0511dc3d5eaab2a46a75f6fe61bd7fab47 100644 --- a/src/MATLAB/+Editor/ReplayableEditAction.m +++ b/src/MATLAB/+Editor/ReplayableEditAction.m @@ -14,6 +14,30 @@ % Regardless of success, the action and all arguments are added to the end % of the replay list. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [bErr varargout] = ReplayableEditAction(actPtr, varargin) global ReplayEditActions diff --git a/src/MATLAB/+Editor/ResegBackAction.m b/src/MATLAB/+Editor/ResegBackAction.m index da567bc54b29669d711f1ddc162d6d101acf0481..60d41b45d3c0be4a2850cfc378fac3d2192be950 100644 --- a/src/MATLAB/+Editor/ResegBackAction.m +++ b/src/MATLAB/+Editor/ResegBackAction.m @@ -4,6 +4,30 @@ % Back up a single frame, undoing whatever reseg actions were taken in the % current frame +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function historyAction = ResegBackAction() historyAction.action = 'Undo'; historyAction.arg = 'Jump'; diff --git a/src/MATLAB/+Editor/ResegFinishAction.m b/src/MATLAB/+Editor/ResegFinishAction.m index ed51778daaf5ad910caf134f4f5854e45528c88b..89d53a6c59cb1ffd4437002a9458d5809aa6969f 100644 --- a/src/MATLAB/+Editor/ResegFinishAction.m +++ b/src/MATLAB/+Editor/ResegFinishAction.m @@ -3,6 +3,30 @@ % % Finish resegmentation action, (push history) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [historyAction finishTime finalResegState] = ResegFinishAction() global ResegState bResegPaused diff --git a/src/MATLAB/+Editor/ResegForwardAction.m b/src/MATLAB/+Editor/ResegForwardAction.m index e5484d00f5e5858ce4307a02ce49f956a626c2ca..186381e4e89d8bf2ca9006dec5019a248d05f7be 100644 --- a/src/MATLAB/+Editor/ResegForwardAction.m +++ b/src/MATLAB/+Editor/ResegForwardAction.m @@ -3,6 +3,30 @@ % % Single forward reseg (from pause) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function historyAction = ResegForwardAction() global bResegPaused diff --git a/src/MATLAB/+Editor/ResegFrameAction.m b/src/MATLAB/+Editor/ResegFrameAction.m index 426bea92ef3334f63a283f1b1f6a72b6729dd339..dcda0de520d2519e46da83dc22ef5aeddee1abec 100644 --- a/src/MATLAB/+Editor/ResegFrameAction.m +++ b/src/MATLAB/+Editor/ResegFrameAction.m @@ -3,6 +3,30 @@ % % Resegment a single frame +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [historyAction bFinished] = ResegFrameAction(t, tMax, viewLims) global ResegState CellFamilies diff --git a/src/MATLAB/+Editor/ResegInitializeAction.m b/src/MATLAB/+Editor/ResegInitializeAction.m index 93bf1ffa38987db23eed3fcfcf94001e3e528571..d916703c902965272592923a7ce1facfff515403 100644 --- a/src/MATLAB/+Editor/ResegInitializeAction.m +++ b/src/MATLAB/+Editor/ResegInitializeAction.m @@ -3,6 +3,30 @@ % % Initialize resegmentation state +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function historyAction = ResegInitializeAction(preserveFamilies, tStart) global ResegState bResegPaused diff --git a/src/MATLAB/+Editor/ResegPauseAction.m b/src/MATLAB/+Editor/ResegPauseAction.m index 413a85d75b5b98df861ad9843552d95f2b687f84..8b17536ba20b90c080b13d0009e19be86ded86ff 100644 --- a/src/MATLAB/+Editor/ResegPauseAction.m +++ b/src/MATLAB/+Editor/ResegPauseAction.m @@ -3,6 +3,30 @@ % % Pause resegmentation +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function historyAction = ResegPauseAction() global ResegState bResegPaused diff --git a/src/MATLAB/+Editor/ResegPlayAction.m b/src/MATLAB/+Editor/ResegPlayAction.m index e2d97ce254c7ed9d9d781c4786a7e7453c9a0914..62b5d103dd42821a8306ed37c1a6a915e050c367 100644 --- a/src/MATLAB/+Editor/ResegPlayAction.m +++ b/src/MATLAB/+Editor/ResegPlayAction.m @@ -3,6 +3,30 @@ % % Begin resegmenting (from pause) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function historyAction = ResegPlayAction(tStart) global bResegPaused diff --git a/src/MATLAB/+Editor/SafeExecuteAction.m b/src/MATLAB/+Editor/SafeExecuteAction.m index ce8a3a826ec8471a2072fe6d4c743ce5b764b4e4..c65edcc915f9467a64c02973549d370e88f99a59 100644 --- a/src/MATLAB/+Editor/SafeExecuteAction.m +++ b/src/MATLAB/+Editor/SafeExecuteAction.m @@ -5,6 +5,30 @@ % an exception is caught during execution of the function an error is logged % and the edit is undone. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [bErr historyAction varargout] = SafeExecuteAction(actPtr, varargin) varargout = cell(1,max(0,nargout-2)); diff --git a/src/MATLAB/+Editor/SliceAtFrameAction.m b/src/MATLAB/+Editor/SliceAtFrameAction.m index 3a59d54b444f7246a384c1ea579de740ca279b1b..93c7497e60a1e1370d4ef561aff092cdc6108d79 100644 --- a/src/MATLAB/+Editor/SliceAtFrameAction.m +++ b/src/MATLAB/+Editor/SliceAtFrameAction.m @@ -3,6 +3,30 @@ % % Call RemoveFromTree() on all tracks on family at time. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function historyAction = SliceAtFrameAction(rootTrackID, time) global CellFamilies CellTracks diff --git a/src/MATLAB/+Editor/SplitCell.m b/src/MATLAB/+Editor/SplitCell.m index c46a1587230e7894304c1c42fba357acf1f0a5f7..a8d49c321fdc475567e4065e3d47bbbde19a8969 100644 --- a/src/MATLAB/+Editor/SplitCell.m +++ b/src/MATLAB/+Editor/SplitCell.m @@ -3,6 +3,30 @@ % % Attempt to split specified hull into k pieces. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [historyAction newTracks] = SplitCell(hullID, k) oldTrackID = Hulls.GetTrackID(hullID); diff --git a/src/MATLAB/+Editor/StackedHistory.m b/src/MATLAB/+Editor/StackedHistory.m deleted file mode 100644 index bfb08e8f775f9950c01f73c16afa7634eccd2a4b..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Editor/StackedHistory.m +++ /dev/null @@ -1,6 +0,0 @@ - -function StackedHistory(action) - switch action - - end -end diff --git a/src/MATLAB/+Editor/StartReplayableSubtask.m b/src/MATLAB/+Editor/StartReplayableSubtask.m index 7f82f0a1b0e362ac65df096ade034c998d6172a3..5e80259615ea069070194efa82f3d9ec9ccc1c7c 100644 --- a/src/MATLAB/+Editor/StartReplayableSubtask.m +++ b/src/MATLAB/+Editor/StartReplayableSubtask.m @@ -3,6 +3,30 @@ % Begin a new subtask, this creates a new history stack to be used for the % task. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function historyAction = StartReplayableSubtask(taskLabel) global TaskStack diff --git a/src/MATLAB/+Editor/StopReplayableSubtask.m b/src/MATLAB/+Editor/StopReplayableSubtask.m index 4bdfadfc8a3bd5e5021552468afbee45650d4595..54bac71bd1ee18b15ff0c17a86c448653c9d3d10 100644 --- a/src/MATLAB/+Editor/StopReplayableSubtask.m +++ b/src/MATLAB/+Editor/StopReplayableSubtask.m @@ -3,6 +3,30 @@ % Stop a subtask, the tasklabel should match the task which was added, the % labels are only an error checking device. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function historyAction = StopReplayableSubtask(time, taskLabel) global TaskStack diff --git a/src/MATLAB/+Editor/Top.m b/src/MATLAB/+Editor/Top.m index bc5832dec91404e557ecbd0c6c4488afe8da6732..8a6fd7ca9d97f651e754869517cef370e2bf23fb 100644 --- a/src/MATLAB/+Editor/Top.m +++ b/src/MATLAB/+Editor/Top.m @@ -4,6 +4,30 @@ % This is purely a placeholder to tell the replay action code that a top % was performed. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function historyAction = Top() historyAction = 'Top'; end \ No newline at end of file diff --git a/src/MATLAB/+Editor/TreeFreezeAction.m b/src/MATLAB/+Editor/TreeFreezeAction.m index 286d43b145eed577e2b3a3738723af2b8f99f065..0cd84c3822ec65e236b0a2ef6d97a33cc9d2ffa4 100644 --- a/src/MATLAB/+Editor/TreeFreezeAction.m +++ b/src/MATLAB/+Editor/TreeFreezeAction.m @@ -3,6 +3,30 @@ % % Toggles frozen property of familyID +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function historyAction = TreeFreezeAction(familyID) global CellFamilies diff --git a/src/MATLAB/+Editor/TreeInference.m b/src/MATLAB/+Editor/TreeInference.m index e306c76233301750fda01f1d4391fdf2c2a1f871..c101af0b02c628e5faa1fdd4f3d308a8fb338518 100644 --- a/src/MATLAB/+Editor/TreeInference.m +++ b/src/MATLAB/+Editor/TreeInference.m @@ -3,6 +3,30 @@ % % Applies inference to attempt to improve tree structure. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function historyAction = TreeInference(families, stopTime) [iters totalTime] = Families.LinkTrees(families, stopTime); diff --git a/src/MATLAB/+Editor/TreeLockAction.m b/src/MATLAB/+Editor/TreeLockAction.m index 19187739d4e707d410adb4c0f4e8c11310508a87..91770f2dcba22171b1fd8065d2559ec4a3921b82 100644 --- a/src/MATLAB/+Editor/TreeLockAction.m +++ b/src/MATLAB/+Editor/TreeLockAction.m @@ -3,6 +3,30 @@ % % Toggles lock on familyID +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function historyAction = TreeLockAction(familyID) global CellFamilies diff --git a/src/MATLAB/+Editor/Undo.m b/src/MATLAB/+Editor/Undo.m index 068a52a484943f8d6b83ed713806f9d7089be0dc..b5c35b1cd68423ba0d91aec9ca5198de14bf4c98 100644 --- a/src/MATLAB/+Editor/Undo.m +++ b/src/MATLAB/+Editor/Undo.m @@ -4,6 +4,30 @@ % This is purely a placeholder to tell the replay action code that an undo % was performed. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function historyAction = Undo() historyAction = 'Undo'; end diff --git a/src/MATLAB/+Error/ErrorHandling.m b/src/MATLAB/+Error/ErrorHandling.m index 5b12f65ff98a214e28ba263ba6f47b1443c7242b..bc0a996c5971834e9670a1e7baf1c3677fee4352 100644 --- a/src/MATLAB/+Error/ErrorHandling.m +++ b/src/MATLAB/+Error/ErrorHandling.m @@ -6,10 +6,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Error/LogAction.m b/src/MATLAB/+Error/LogAction.m index cfb6aff1cef84ae0f26f6b77b994d74ab3676c1f..83c3a131665e9588cadd903b0c1908f73e8602f7 100644 --- a/src/MATLAB/+Error/LogAction.m +++ b/src/MATLAB/+Error/LogAction.m @@ -6,10 +6,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by @@ -35,13 +35,13 @@ time = clock;%[year month day hour minute seconds] settings = Load.ReadSettings(); if ( ~isempty(settings.matFilePath) ) logPath = settings.matFilePath; - logFile = fullfile(logPath, [CONSTANTS.datasetName '_log.csv']); + logFile = fullfile(logPath, [Metadata.GetDatasetName() '_log.csv']); elseif ( isfield(CONSTANTS,'matFullFile') && ~isempty(CONSTANTS.matFullFile) ) logPath = fileparts(CONSTANTS.matFullFile); - logFile = fullfile(logPath, [CONSTANTS.datasetName '_log.csv']); + logFile = fullfile(logPath, [Metadata.GetDatasetName() '_log.csv']); else logPath = '.\'; - logFile = fullfile(logPath, [CONSTANTS.datasetName '_log.csv']); + logFile = fullfile(logPath, [Metadata.GetDatasetName() '_log.csv']); end [x usr] = system('whoami'); @@ -106,7 +106,7 @@ while(file<2) answer = questdlg('Please close the log.','Log Opened','Use new log name','Try Again','Try Again'); switch answer case 'Use new log name' - file = fopen(fullfile(logPath,[CONSTANTS.datasetName '_log2.csv']),'a'); + file = fopen(fullfile(logPath,[Metadata.GetDatasetName() '_log2.csv']),'a'); case 'Try Again' file = fopen(logFile,'a'); end diff --git a/src/MATLAB/+Error/OutputDebugErrorFile.m b/src/MATLAB/+Error/OutputDebugErrorFile.m index 622b1094e9ad4b06b7cd28c10ffccdd481640000..a014af2d0cb454ad57fa80a73934ac8ca09a70ea 100644 --- a/src/MATLAB/+Error/OutputDebugErrorFile.m +++ b/src/MATLAB/+Error/OutputDebugErrorFile.m @@ -2,10 +2,34 @@ % Outputs ReplayEditActions to a file, this should allow for a complete % reconstruction of an edit set from the original data. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function OutputDebugErrorFile() - global CONSTANTS Log ReplayEditActions + global Log ReplayEditActions - errfile = [CONSTANTS.datasetName '_DBGEDITS_' num2str(length(Log)) '.mat']; + errfile = [Metadata.GetDatasetName() '_DBGEDITS_' num2str(length(Log)) '.mat']; save(errfile, 'ReplayEditActions'); end diff --git a/src/MATLAB/+Error/PrintException.m b/src/MATLAB/+Error/PrintException.m index a8f54571c09be09edebc5e3c6eaf9b8f1f78d7ae..b7726c637ffb359715d88544ea8b8ff0fbdd8f97 100644 --- a/src/MATLAB/+Error/PrintException.m +++ b/src/MATLAB/+Error/PrintException.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function excpString = PrintException(excp, prefixstr) if ( ~exist('prefixstr','var') ) prefixstr = ' '; diff --git a/src/MATLAB/+Families/AddMitosis.m b/src/MATLAB/+Families/AddMitosis.m index e2af4ea73affd67f6e76e044ebe5ad302bca396c..02529ba14898b0b96021698b9bcd66e726cfebdf 100644 --- a/src/MATLAB/+Families/AddMitosis.m +++ b/src/MATLAB/+Families/AddMitosis.m @@ -1,5 +1,29 @@ % droppedTracks = AddMitosis(addTrack, ontoTrack, time) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + % ChangeLog: % EW 6/7/12 created function droppedTracks = AddMitosis(addTrack, ontoTrack, time) diff --git a/src/MATLAB/+Families/AddToTree.m b/src/MATLAB/+Families/AddToTree.m index 909d7301b0251017990b09aa98e5513cf9b0ac65..6fdb7c20990b0f371750feee8a4e3ab776e2fa48 100644 --- a/src/MATLAB/+Families/AddToTree.m +++ b/src/MATLAB/+Families/AddToTree.m @@ -4,6 +4,30 @@ % addTrack.startTime < ontoTrack.startTime % addTrack.startTime > ontoTrack.endTime +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + % ChangLog % EW 6/7/12 Created function droppedTracks = AddToTree(addTrack, ontoTrack) diff --git a/src/MATLAB/+Families/ChangeTrackAndChildrensFamily.m b/src/MATLAB/+Families/ChangeTrackAndChildrensFamily.m index a079811e0462867ed654bc4db5f2f20505f63e00..b16b5de24cd0fda991d96f0148c938fe56a12554 100644 --- a/src/MATLAB/+Families/ChangeTrackAndChildrensFamily.m +++ b/src/MATLAB/+Families/ChangeTrackAndChildrensFamily.m @@ -8,10 +8,10 @@ % ECW 6/6/12 rewrite %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Families/CheckLockedAddMitosis.m b/src/MATLAB/+Families/CheckLockedAddMitosis.m index 4d46a3a50e14dc9fe8c520c14fe1050f2c868f54..cd61d9f8c50eb114d0d98903bb7414faacf66017 100644 --- a/src/MATLAB/+Families/CheckLockedAddMitosis.m +++ b/src/MATLAB/+Families/CheckLockedAddMitosis.m @@ -3,6 +3,30 @@ % This function will check to verify if a "tree-preserving" add mitosis is % possible. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [bLockedParent bLockedChildren bCanAdd] = CheckLockedAddMitosis(parentTrack, leftChildTrack, siblingTrack, time) global CellTracks diff --git a/src/MATLAB/+Families/ComputeTrackHeights.m b/src/MATLAB/+Families/ComputeTrackHeights.m index c59d14ed8cc98ce9970c881fdc4df73aabedfade..fcafa59427b7708ed9c13bd3513632619a57e167 100644 --- a/src/MATLAB/+Families/ComputeTrackHeights.m +++ b/src/MATLAB/+Families/ComputeTrackHeights.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function trackHeights = ComputeTrackHeights(rootTrackID) trackHeights = containers.Map('KeyType', 'uint32', 'ValueType', 'uint32'); diff --git a/src/MATLAB/+Families/CreateEmptyFamily.m b/src/MATLAB/+Families/CreateEmptyFamily.m index d31c5b60084f443ddf5abac5a827e058c2e1974d..ffceb2db0bbce81caaa46ca984850dc1e3a9a5e5 100644 --- a/src/MATLAB/+Families/CreateEmptyFamily.m +++ b/src/MATLAB/+Families/CreateEmptyFamily.m @@ -2,6 +2,30 @@ % Creates an empty family with each of the fields set to [] and returns the % new family id. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function familyID = CreateEmptyFamily() global CellFamilies familyID = length(CellFamilies) +1; diff --git a/src/MATLAB/+Families/FindLargestTree.m b/src/MATLAB/+Families/FindLargestTree.m index 023cfbb0a21fd0268352ccc982ec4a664185d982..3e7389fc34a896581372e6253cd413d54bb550e5 100644 --- a/src/MATLAB/+Families/FindLargestTree.m +++ b/src/MATLAB/+Families/FindLargestTree.m @@ -2,10 +2,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Families/GetAllHulls.m b/src/MATLAB/+Families/GetAllHulls.m index 781ecbd6287fcc4cb7276edaddb72dd08e398beb..a5ebebd1c4fc2b6bd34f687102d8d74729aa655e 100644 --- a/src/MATLAB/+Families/GetAllHulls.m +++ b/src/MATLAB/+Families/GetAllHulls.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function [hullIDs missingHulls] = GetAllHulls(familyID) global CellFamilies CellTracks diff --git a/src/MATLAB/+Families/GetFamilyRoots.m b/src/MATLAB/+Families/GetFamilyRoots.m index 108344b2854f474d237049abaa98a9a3fecabfd0..f422403a47b89f6a3e78fee954bb1c88a5c92e57 100644 --- a/src/MATLAB/+Families/GetFamilyRoots.m +++ b/src/MATLAB/+Families/GetFamilyRoots.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function roots = GetFamilyRoots(rootTrackID) global CellFamilies CellTracks diff --git a/src/MATLAB/+Families/LinkFirstFrameTrees.m b/src/MATLAB/+Families/LinkFirstFrameTrees.m deleted file mode 100644 index 30d80941d8f485f6643c97dddc4ba8ae48da5f8f..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Families/LinkFirstFrameTrees.m +++ /dev/null @@ -1,22 +0,0 @@ -function [iterations totalTime] = LinkFirstFrameTrees() - global HashedCells - - iterations = 0; - - % Try to Push/reseg - totalTime = 0; - maxPushCount = 10; - for i=1:maxPushCount - [assignExt findTime extTime] = Families.LinkTreesForward([HashedCells{1}.trackID]); -% LogAction(['Tree inference step ' num2str(i)],[assignExt findTime extTime],[]); - totalTime = totalTime + findTime + extTime; - - iterations = i; - - if ( assignExt == 0 ) - break; - end - end - -% LogAction('Completed Tree Inference', [i totalTime],[]); -end \ No newline at end of file diff --git a/src/MATLAB/+Families/LinkTrees.m b/src/MATLAB/+Families/LinkTrees.m index 06233112498933d0fd4ed0b101ab24499184dd61..734eb34b378b8dcf901e8b65a90c720bff414f4e 100644 --- a/src/MATLAB/+Families/LinkTrees.m +++ b/src/MATLAB/+Families/LinkTrees.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function [iterations totalTime] = LinkTrees(families, stopTime) global CellFamilies CellTracks diff --git a/src/MATLAB/+Families/LinkTreesForward.m b/src/MATLAB/+Families/LinkTreesForward.m index 977e9191ecd25e0f800023fc34bb2057e08344ac..65c11b18122d5a4c1206d194316d12541812c939 100644 --- a/src/MATLAB/+Families/LinkTreesForward.m +++ b/src/MATLAB/+Families/LinkTreesForward.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function [assignedExtensions findTime extTime] = LinkTreesForward(rootTracks, stopTime) global CellHulls CellTracks HashedCells Costs diff --git a/src/MATLAB/+Families/MultiTreeAllTracks.m b/src/MATLAB/+Families/MultiTreeAllTracks.m new file mode 100644 index 0000000000000000000000000000000000000000..7d21535584209941ccbea5eb9dd8da5a363493fd --- /dev/null +++ b/src/MATLAB/+Families/MultiTreeAllTracks.m @@ -0,0 +1,33 @@ +% MultiTreeAllTracks.m - Add all tracks on a frame to the same extended +% family + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function MultiTreeAllTracks(t) + global HashedCells CellTracks CellFamilies + + trackIDs = [HashedCells{t}.trackID]; + familyIDs = [CellTracks(trackIDs).familyID]; + [CellFamilies(familyIDs).extFamily] = deal(familyIDs); +end diff --git a/src/MATLAB/+Families/NewCellFamily.m b/src/MATLAB/+Families/NewCellFamily.m index 7418cce2f9c3f0af3a23354cc680b97c61e13025..0014b9b9a242140fb4e61555a4b511799dedd44b 100644 --- a/src/MATLAB/+Families/NewCellFamily.m +++ b/src/MATLAB/+Families/NewCellFamily.m @@ -5,10 +5,10 @@ % EW 6/6/12 t is no longer a requirement %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Families/ProcessNewborns.m b/src/MATLAB/+Families/ProcessNewborns.m index 291ce733fa019e4470100f7e0f7607c04b9e4927..f7fb1d7324ed52e28df1595931bb034b9de15faf 100644 --- a/src/MATLAB/+Families/ProcessNewborns.m +++ b/src/MATLAB/+Families/ProcessNewborns.m @@ -4,10 +4,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Families/ReconnectParentWithChildren.m b/src/MATLAB/+Families/ReconnectParentWithChildren.m index 3b9dd65291fba75b2154a624c3603652ba74c1b8..150f577e3362dbe5ba791508d6b6c4da899fc4c5 100644 --- a/src/MATLAB/+Families/ReconnectParentWithChildren.m +++ b/src/MATLAB/+Families/ReconnectParentWithChildren.m @@ -7,6 +7,30 @@ % children have parents % parent has children +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + % ChangeLog % EW 6/7/12 created function ReconnectParentWithChildren(parentTrack,children) diff --git a/src/MATLAB/+Families/RemoveFromTree.m b/src/MATLAB/+Families/RemoveFromTree.m index 52ee34746525985cff3ab1dd96dc988891f6a39d..fdac66293bc742dcdbffc6e16e7cf3edcc381d8c 100644 --- a/src/MATLAB/+Families/RemoveFromTree.m +++ b/src/MATLAB/+Families/RemoveFromTree.m @@ -3,6 +3,30 @@ % Is similar to RemoveFromTreePrune but keeps the other child. This will % straighten out the parent track with the sibling of the given track +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + % ChangeLog: % EW 6/7/12 created function droppedTracks = RemoveFromTree(removeTrackID,time) diff --git a/src/MATLAB/+Families/RemoveFromTreePrune.m b/src/MATLAB/+Families/RemoveFromTreePrune.m index e9e2f7aa5f470990ff527553797a5417789d1d0d..bb24243a2834cbd9087cbd208809d1b38bc09756 100644 --- a/src/MATLAB/+Families/RemoveFromTreePrune.m +++ b/src/MATLAB/+Families/RemoveFromTreePrune.m @@ -10,10 +10,10 @@ % EW 6/6/12 rewriten %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Families/RemoveTrackFromFamily.m b/src/MATLAB/+Families/RemoveTrackFromFamily.m index 349f409a2ce761528692fb2792778fd59d632e65..1b2d64037a4fcaf5942f5e82ce7f2ae3319821d8 100644 --- a/src/MATLAB/+Families/RemoveTrackFromFamily.m +++ b/src/MATLAB/+Families/RemoveTrackFromFamily.m @@ -8,10 +8,10 @@ % EW 6/6/12 rewrite %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Families/UpdateFamilyTimes.m b/src/MATLAB/+Families/UpdateFamilyTimes.m index 68663b5d31e5d2328915525bd751ee311afad77d..727ec42cce0f4f49c31bf4c3709443a0a86a5e09 100644 --- a/src/MATLAB/+Families/UpdateFamilyTimes.m +++ b/src/MATLAB/+Families/UpdateFamilyTimes.m @@ -1,4 +1,28 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + % UpdateLog: % EW 6/6/12 Created function UpdateFamilyTimes( familyID ) diff --git a/src/MATLAB/+Helper/CalcConnectedDistance.m b/src/MATLAB/+Helper/CalcConnectedDistance.m index 1343924af66328a9c6cd392f3850faa689c5e897..e97b3d55d8e9caca49ff4aebe1e52bed80cfc7e3 100644 --- a/src/MATLAB/+Helper/CalcConnectedDistance.m +++ b/src/MATLAB/+Helper/CalcConnectedDistance.m @@ -1,10 +1,10 @@ -% dist = CalcConnectedDistance(startHull,nextHull, imageSize, perimMap, cellHulls) +% dist = CalcConnectedDistance(startHull,nextHull, rcImageDims, perimMap, cellHulls) % Calculate the connected-component distance from startHull to nextHull. % % startHull,nextHull - must be valid indices into the cellHulls structure. % -% imageSize - indicates the dimensions of the image or volume the hulls -% were segmented from (for use in converting cellHulls.indexPixels. +% rcImageDims - indicates the dimensions (row,column,height) of the image or volume +% the hulls were segmented from (for use in converting cellHulls.indexPixels. % % perimMap = containers.Map('KeyType', 'uint32', 'ValueType', 'any'), must % be a map handle passed by the calling routine. This shares perimeter @@ -14,7 +14,31 @@ % % See Tracker.BuildConnectedDistance() for calling examples. -function dist = CalcConnectedDistance(startHull,nextHull, imageSize, perimMap, cellHulls) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +function dist = CalcConnectedDistance(startHull,nextHull, rcImageDims, perimMap, cellHulls) isect = intersect(cellHulls(startHull).indexPixels, cellHulls(nextHull).indexPixels); if ( ~isempty(isect) ) isectDist = 1 - (length(isect) / min(length(cellHulls(startHull).indexPixels), length(cellHulls(nextHull).indexPixels))); @@ -22,20 +46,20 @@ function dist = CalcConnectedDistance(startHull,nextHull, imageSize, perimMap, c return; end - addPerim(startHull, imageSize,perimMap,cellHulls); - addPerim(nextHull, imageSize,perimMap,cellHulls); + addPerim(startHull, rcImageDims,perimMap,cellHulls); + addPerim(nextHull, rcImageDims,perimMap,cellHulls); D = pdist2(perimMap(startHull), perimMap(nextHull)); dist = min(D(:)); end -function addPerim(hullID, imageSize, perimMap, cellHulls) +function addPerim(hullID, rcImageDims, perimMap, cellHulls) if ( isKey(perimMap, hullID) ) return end; - pxCell = cell(1,length(imageSize)); - [pxCell{:}] = ind2sub(imageSize, cellHulls(hullID).indexPixels); + pxCell = cell(1,length(rcImageDims)); + [pxCell{:}] = ind2sub(rcImageDims, cellHulls(hullID).indexPixels); pixelCoords = cell2mat(pxCell); minCoord = min(pixelCoords,[],1); @@ -49,10 +73,10 @@ function addPerim(hullID, imageSize, perimMap, cellHulls) end bwIm = false(locMax); - locCell = mat2cell(locCoord, size(locCoord,1), ones(1,length(imageSize))); + locCell = mat2cell(locCoord, size(locCoord,1), ones(1,length(rcImageDims))); locInd = sub2ind(locMax, locCell{:}); - perimCell = cell(1,length(imageSize)); + perimCell = cell(1,length(rcImageDims)); bwIm(locInd) = true; perimIm = bwperim(bwIm); diff --git a/src/MATLAB/+Helper/CheckInTracks.m b/src/MATLAB/+Helper/CheckInTracks.m index b9c4fe1d4b8c8fe77151b00352de18cab0169576..13f30789d974463b18d8bd3806340dc8c57cda4b 100644 --- a/src/MATLAB/+Helper/CheckInTracks.m +++ b/src/MATLAB/+Helper/CheckInTracks.m @@ -2,6 +2,30 @@ % % Check (for reseg or mitosis editing) if time t is within tracks. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function bInTrack = CheckInTracks(t, tracks, bIncludeStart, bIncludeEnd) global CellTracks diff --git a/src/MATLAB/+Helper/CheckTreeFrozen.m b/src/MATLAB/+Helper/CheckTreeFrozen.m index 691e4f13db2e19a37b9e7296b5c076548a874556..721fa4653feba92026380aee75e08f56da35a918 100644 --- a/src/MATLAB/+Helper/CheckTreeFrozen.m +++ b/src/MATLAB/+Helper/CheckTreeFrozen.m @@ -3,6 +3,30 @@ % Check if tracks are on frozen families, return list bFrozen with boolean % indicator per track. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function bFrozen = CheckTreeFrozen(tracks) global CellTracks CellFamilies diff --git a/src/MATLAB/+Helper/CheckTreeLocked.m b/src/MATLAB/+Helper/CheckTreeLocked.m index 75e2b065a19ce8c1945b8f874ffc4bda964a069a..0d745b2871a5bc2a9c7139d0d1a3d171275c7384 100644 --- a/src/MATLAB/+Helper/CheckTreeLocked.m +++ b/src/MATLAB/+Helper/CheckTreeLocked.m @@ -3,6 +3,30 @@ % Check if tracks are on locked families, return list bLocked with boolean % indicator per track. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function bLocked = CheckTreeLocked(tracks) global CellTracks CellFamilies diff --git a/src/MATLAB/+Helper/Clamp.m b/src/MATLAB/+Helper/Clamp.m deleted file mode 100644 index c57bd813f66afe806584cffab16c4a35c2840fd8..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Helper/Clamp.m +++ /dev/null @@ -1,4 +0,0 @@ -function x_clamped = Clamp(x, minval, maxval) - x_clamped = max(cat(3,x,minval*ones(size(x))),[],3); - x_clamped = min(cat(3,x_clamped,maxval*ones(size(x))),[],3); -end \ No newline at end of file diff --git a/src/MATLAB/+Helper/ClearAllGlobals.m b/src/MATLAB/+Helper/ClearAllGlobals.m index 73b5f007180c76b2fd270a7d0f441a96482b3f64..72d27ba54d5b96581806f58a97bc774813f94d13 100644 --- a/src/MATLAB/+Helper/ClearAllGlobals.m +++ b/src/MATLAB/+Helper/ClearAllGlobals.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function ClearAllGlobals() global CellFamilies CellTracks HashedCells CONSTANTS CellHulls Costs GraphEdits global CachedCostMatrix ConnectedDist CellPhenotypes SegmentationEdits ReplayEditActions diff --git a/src/MATLAB/+Helper/ConvexHull.m b/src/MATLAB/+Helper/ConvexHull.m index 8ff566c1ba55085d345fb864bdad4950b90a6600..cef576de1c7ca9205836c72a4e9173a3131e76c2 100644 --- a/src/MATLAB/+Helper/ConvexHull.m +++ b/src/MATLAB/+Helper/ConvexHull.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function chIdx = ConvexHull(x,y) chIdx = []; diff --git a/src/MATLAB/+Helper/CoordToIndex.m b/src/MATLAB/+Helper/CoordToIndex.m deleted file mode 100644 index 1c8960267e8ad45c3bc777cfa4d251dbcd1dabfe..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Helper/CoordToIndex.m +++ /dev/null @@ -1,4 +0,0 @@ -function arrayIdx = CoordToIndex(arraySize, coords) - linSize = [1 cumprod(arraySize(1:end-1))]; - arrayIdx = sum((coords-1) .* repmat(linSize, size(coords,1),1), 2) + 1; -end diff --git a/src/MATLAB/+Helper/CountResegEdits.m b/src/MATLAB/+Helper/CountResegEdits.m deleted file mode 100644 index 471152531fd6aa1845f5af33ea9f0cb4baa5ea0a..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Helper/CountResegEdits.m +++ /dev/null @@ -1,160 +0,0 @@ - -function [userEditCount resegEditCount userEditList resegEditList] = CountResegEdits(trackID) - global ReplayEditActions CellHulls CellTracks CellFamilies - - userEditCount = 0; - resegEditCount = 0; - - userEditList = {}; - resegEditList = {}; - - %blockTypes = {'extra', 'reseg', 'user'}; - - % Pretty much simulates the undo stacks, but with just edit counts - typeStack = 1; - stackEnds = 0; - editStack = {{}}; - - totalReseg = 0; - - bInReseg = 0; - for i=1:length(ReplayEditActions) - - if ( strcmpi(ReplayEditActions(i).funcName,'Editor.ResegInitializeAction') ) - bInReseg = 1; - continue; - end - - % TODO: Get reseg edits out here: - if ( strcmpi(ReplayEditActions(i).funcName,'Editor.ResegFinishAction') ) - bInReseg = 0; - - if ( isempty(ReplayEditActions(i).ret) ) - continue; - end - - numEdits = length(ReplayEditActions(i).ret{2}.SegEdits); - - totalReseg = totalReseg + numEdits; - - newEdit = struct('count',{numEdits}, 'type',{typeStack(end)}, 'editFunc',{'ResegEdits'}); - editStack{end} = [editStack{end}(1:stackEnds(end)); {newEdit}]; - - stackEnds(end) = stackEnds(end) + 1; - continue; - end - - % TODO: This is unfortunate, and I need it to really just not happen - if ( bInReseg && strcmpi(ReplayEditActions(i).funcName,'Editor.InitHistory') ) - warning('RESEG:NoFinish', 'The current file was closed without finishing resegmentation process, edit counts may be inaccurate'); -% return; - end - -% % Increase stack level and pick an edit type if a new subtask is started -% if ( strcmpi(ReplayEditActions(i).funcName,'Editor.StartReplayableSubtask') ) -% typeStack = [typeStack 1]; -% stackEnds = [stackEnds 0]; -% editStack = [editStack; {{}}]; -% -% if ( strcmpi(ReplayEditActions(i).args{1},'PauseResegTask') ) -% typeStack(end) = 3; -% elseif ( strcmpi(ReplayEditActions(i).args{1},'InteractiveResegTask') ) -% typeStack(end) = 2; -% end -% continue; -% end -% -% % Reduce stack level and add new edit block to level below (if not empty) -% if ( strcmpi(ReplayEditActions(i).funcName,'Editor.StopReplayableSubtask') ) -% topStack = editStack{end}; -% topEnd = stackEnds(end); -% -% stackEnds = stackEnds(1:(end-1)); -% typeStack = typeStack(1:(end-1)); -% editStack = editStack(1:(end-1)); -% -% if ( topEnd > 0 ) -% popEntry = topStack(1:topEnd,:); -% editStack{end} = [editStack{end}(1:stackEnds(end)); {popEntry}]; -% stackEnds(end) = stackEnds(end) + 1; -% end -% continue; -% end -% -% % Just drop stack level by one -% if ( strcmpi(ReplayEditActions(i).funcName,'Editor.DropReplayableSubtask') ) -% -% stackEnds = stackEnds(1:(end-1)); -% typeStack = typeStack(1:(end-1)); -% editStack = editStack(1:(end-1)); -% -% if ( strcmpi(ReplayEditActions(i).args{1},'PauseResegTask') ) -% bInPause = 0; -% end -% continue; -% end -% -% % Ignore these actions as they have no direct edit significance -% if ( strcmpi(ReplayEditActions(i).funcName,'Editor.ResegPlayAction') || strcmpi(ReplayEditActions(i).funcName,'Editor.ResegPauseAction') ... -% || strcmpi(ReplayEditActions(i).funcName,'Editor.ResegBackAction') || strcmpi(ReplayEditActions(i).funcName,'Editor.ResegPauseAction') ... -% || strcmpi(ReplayEditActions(i).funcName,'Editor.Top') ) -% continue; -% end -% -% % Undo reduces current edit end by one -% if ( strcmpi(ReplayEditActions(i).funcName,'Editor.Undo') ) -% if ( stackEnds(end) > 0 ) -% stackEnds(end) = stackEnds(end) - 1; -% end -% -% continue; -% end -% -% % Redo increases current edit end by one -% if ( strcmpi(ReplayEditActions(i).funcName,'Editor.Redo') ) -% if ( stackEnds(end) < size(editStack{end},1) ) -% stackEnds(end) = stackEnds(end) + 1; -% end -% -% continue; -% end -% -% newEdit = struct('count',{1}, 'type',{typeStack(end)}, 'editFunc',{ReplayEditActions(i).funcName}); -% editStack{end} = [editStack{end}(1:stackEnds(end)); {newEdit}]; -% -% stackEnds(end) = stackEnds(end) + 1; - end - -% [resegEditCount resegEditList] = countAllEdits(editStack{1}, 2); -% [userEditCount userEditList] = countAllEdits(editStack{1}, 3); - - famID = CellTracks(trackID).familyID; - trackHulls = [CellTracks(CellFamilies(famID).tracks).hulls]; - nzHulls = trackHulls(trackHulls ~= 0); - - bUserEdited = [CellHulls(nzHulls).userEdited]; - - userEditCount = nnz(bUserEdited); - resegEditCount = totalReseg; -end - -function [editCount editList] = countAllEdits(editStack, editType) - editCount = 0; - editList = {}; - - if ( isstruct(editStack) ) - if ( editType == editStack.type ) - editCount = editStack.count; - editList = {editStack.editFunc}; - end - - return; - end - - for i=1:length(editStack) - [curCount curList] = countAllEdits(editStack{i}, editType); - - editCount = editCount + curCount; - editList = [editList; curList]; - end -end diff --git a/src/MATLAB/+Helper/DropSubtree.m b/src/MATLAB/+Helper/DropSubtree.m index cd5d23929f881a2523a4cd88b1fe728a46169570..2fcb74cb87ff8ddc03b73786a8537e0dd1b2e7a9 100644 --- a/src/MATLAB/+Helper/DropSubtree.m +++ b/src/MATLAB/+Helper/DropSubtree.m @@ -1,4 +1,28 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function DropSubtree(trackID) global CellTracks diff --git a/src/MATLAB/+Helper/GetCellHullTemplate.m b/src/MATLAB/+Helper/GetCellHullTemplate.m index 4f25b3073c415c667318a7c876ec577486029404..4dc81975cf2e7143d9ad379c903ae54a33969fc4 100644 --- a/src/MATLAB/+Helper/GetCellHullTemplate.m +++ b/src/MATLAB/+Helper/GetCellHullTemplate.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function cellHullsTemplate = GetCellHullTemplate() cellHullsTemplate = struct('time',{0},... 'points',{[]},... diff --git a/src/MATLAB/+Helper/GetFamilySegEditCount.m b/src/MATLAB/+Helper/GetFamilySegEditCount.m index 6a7a06855c50ad4cd6894dd74c154eb7bff21436..a1b9546774f09bf42b74cc4b92dc2ef82ddfa105 100644 --- a/src/MATLAB/+Helper/GetFamilySegEditCount.m +++ b/src/MATLAB/+Helper/GetFamilySegEditCount.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function segEditCount = GetFamilySegEditCount(familyID, bIncludeUser, bIncludeAuto) global EditList diff --git a/src/MATLAB/+Helper/GetFamilyTrackEditCount.m b/src/MATLAB/+Helper/GetFamilyTrackEditCount.m index 365a375feca95af1d27d1243557cf7d880fd307e..7d46cca09cc6b4b0badcce53b663f163d774c0c3 100644 --- a/src/MATLAB/+Helper/GetFamilyTrackEditCount.m +++ b/src/MATLAB/+Helper/GetFamilyTrackEditCount.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function edgeEditCount = GetFamilyTrackEditCount(familyID, bIncludeUser, bIncludeAuto) global EditList diff --git a/src/MATLAB/+Helper/GetFullImagePath.m b/src/MATLAB/+Helper/GetFullImagePath.m deleted file mode 100644 index 6f33d07c06dff597eb8330a1b3b06ea506669b75..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Helper/GetFullImagePath.m +++ /dev/null @@ -1,8 +0,0 @@ -function pathString = GetFullImagePath(chan, frame) -global CONSTANTS - -imageName = Helper.GetImageName(chan, frame); - -pathString = fullfile(CONSTANTS.rootImageFolder,imageName); -end - diff --git a/src/MATLAB/+Helper/GetImListInfo.m b/src/MATLAB/+Helper/GetImListInfo.m deleted file mode 100644 index 087d8f9fe72f86b58d219ab16eba47e6c2eac92a..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Helper/GetImListInfo.m +++ /dev/null @@ -1,53 +0,0 @@ -% [channelList, frameList] = GetImListInfo(rootFolder, namePattern) -% -% Use image namePattern to return a list of all unique image frames and channels -% based on image files in existing under rootFolder. -% -% The lists are returned in sorted order. - -function [channelList, frameList] = GetImListInfo(rootFolder, namePattern) - channelList = []; - frameList = []; - - % Generate a directory list glob from namePattern as well as a - % tokenized set for creating a regexp to match channel and frame numbers - [prefixString, paramTokens, postfixString] = Helper.SplitNamePattern(namePattern); - if ( isempty(prefixString) ) - return; - end - - paramGlobs = cellfun(@(x)(['_' x{1} '*']),paramTokens, 'UniformOutput',0); - dirPattern = [prefixString paramGlobs{:} postfixString]; - - flist = dir(fullfile(rootFolder,dirPattern)); - if ( isempty(flist) ) - return; - end - - matchPrefix = regexptranslate('escape', prefixString); - matchPostfix = regexptranslate('escape', postfixString); - paramPatterns = cellfun(@(x)(['_' x{1} '(\d{' x{2} '})']),paramTokens, 'UniformOutput',0); - - matchPattern = [matchPrefix paramPatterns{:} matchPostfix]; - - fileNames = {flist.name}; - matchTok = regexpi(fileNames, matchPattern, 'tokens','once'); - - paramOrder = cellfun(@(x)(x{1}),paramTokens, 'UniformOutput',0); - assumedParams = {'c' 't' 'z'}; - [bHasParam,paramIdx] = ismember(assumedParams, paramOrder); - - channelList = 1; - frameList = 1; - zList = 1; - - if ( bHasParam(1) ) - chans = cellfun(@(x)(str2double(x{paramIdx(1)})), matchTok); - channelList = unique(chans); - end - - if ( bHasParam(2) ) - times = cellfun(@(x)(str2double(x{paramIdx(2)})), matchTok); - frameList = unique(times); - end -end diff --git a/src/MATLAB/+Helper/GetImageName.m b/src/MATLAB/+Helper/GetImageName.m deleted file mode 100644 index ac429d27037514c599cc5087275269b9b64bbf42..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Helper/GetImageName.m +++ /dev/null @@ -1,21 +0,0 @@ -function imageName = GetImageName(chan, frame) -global CONSTANTS - -valueNames = {'c' 't'}; -paramValues = {chan frame}; - -paramTokens = Helper.GetNamePatternParams(CONSTANTS.imageNamePattern); -paramOrder = cellfun(@(x)(x{1}),paramTokens, 'UniformOutput',0); - -[bHasParam,valueIdx] = ismember(paramOrder, valueNames); -if ( ~all(bHasParam) ) - imageName = ''; - - missingValues = cellfun(@(x)([' ' x]), paramOrder(bHasParam)); - fprintf('Unspecified value(s) needed to generate image string:%s\n', missingValues); - return; -end - -imageName = sprintf(CONSTANTS.imageNamePattern, paramValues{valueIdx}); -end - diff --git a/src/MATLAB/+Helper/GetNamePatternParams.m b/src/MATLAB/+Helper/GetNamePatternParams.m deleted file mode 100644 index 2acbebb74f9340822bc74458ae11fe5b7437fa39..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Helper/GetNamePatternParams.m +++ /dev/null @@ -1,3 +0,0 @@ -function paramTokens = GetNamePatternParams(namePattern) - paramTokens = regexp(namePattern, '_([a-zA-Z]{1,2})%0(\d+)d', 'tokens'); -end \ No newline at end of file diff --git a/src/MATLAB/+Helper/GetNearestTrackHull.m b/src/MATLAB/+Helper/GetNearestTrackHull.m index 9dbc6aa642b9fba27e45af0b4ef279ec1f064318..f27a07a3484f3586e12f78ce1cbd826a0c45f599 100644 --- a/src/MATLAB/+Helper/GetNearestTrackHull.m +++ b/src/MATLAB/+Helper/GetNearestTrackHull.m @@ -6,6 +6,30 @@ % (searchDir == 0) -> search exact time only. % returns hull=0 if search fails. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [hull hullTime] = GetNearestTrackHull(trackID, time, searchDir) global CellTracks CellHulls diff --git a/src/MATLAB/+Helper/GetRandomState.m b/src/MATLAB/+Helper/GetRandomState.m index edfeff50a174c8b946e8f0393047e1213e722b3e..e6a5d80620cbf9cd6606c6547587f067aefded65 100644 --- a/src/MATLAB/+Helper/GetRandomState.m +++ b/src/MATLAB/+Helper/GetRandomState.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function randState = GetRandomState() globStream = RandStream.getGlobalStream(); randState = globStream.State; diff --git a/src/MATLAB/+Helper/GetVersion.m b/src/MATLAB/+Helper/GetVersion.m deleted file mode 100644 index d0f9153699cfb474578712b804e2838a009d7b85..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Helper/GetVersion.m +++ /dev/null @@ -1,61 +0,0 @@ -% version = GetVersion(command) -% Get a version string or number depending on the command argument. This -% m-file serves as a single repository for all version-related information. -% -% Note: Uses autogenerated version information in +Helper\VersionInfo.m - -function version = GetVersion(command) - version = []; - - if ( isdeployed ) - verInfo = Helper.VersionInfo(); - else - verInfo = Dev.MakeVersion(1); - end - - if ( ~exist('command','var') ) - command = 'string'; - end - - cleanBranch = strrep(verInfo.branchName, '/', '_'); - cleanBranch = strrep(cleanBranch, '\', '_'); - - if ( strcmpi(command, 'string') || strcmpi(command, 'versionString') ) - version = [num2str(verInfo.majorVersion) '.' num2str(verInfo.minorVersion) ' ' cleanBranch]; - return; - end - - if ( strcmpi(command, 'buildString') ) - version = [verInfo.buildNumber '/' verInfo.buildMachine]; - return; - end - - if ( strcmpi(command, 'buildHash') ) - version = verInfo.commitHash; - return - end - - if ( strcmpi(command, 'fullString') ) - version = ['LEVER v' num2str(verInfo.majorVersion) '.' num2str(verInfo.minorVersion) ' ' verInfo.buildNumber '/' verInfo.buildMachine ' ' cleanBranch ' ' verInfo.commitHash]; - return; - end - - if ( strcmpi(command, 'major') ) - version = verInfo.majorVersion; - return - end - - if ( strcmpi(command, 'minor') ) - version = verInfo.minorVersion; - return; - end - - if ( strcmpi(command, 'file') ) - minorStr = num2str(verInfo.minorVersion); - minorStr = strrep(minorStr, '.', '_'); - version = [num2str(verInfo.majorVersion) minorStr '_' cleanBranch]; - return; - end - -end - diff --git a/src/MATLAB/+Helper/ImageFileDialog.m b/src/MATLAB/+Helper/ImageFileDialog.m index 32494cbbea39ad9156a1d7c0bca417781c68d130..384f6c0b4b0265729d6bed525c6ffa2d9ce53137 100644 --- a/src/MATLAB/+Helper/ImageFileDialog.m +++ b/src/MATLAB/+Helper/ImageFileDialog.m @@ -1,48 +1,49 @@ -function bOpened = ImageFileDialog() -global CONSTANTS -settings = Load.ReadSettings(); +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -if ~isfield(settings,'imagePathFl') - settings.imagePathFl = settings.imagePath; -end - -%find the first image -imageFilter = [settings.imagePath '*.TIF']; +function bOpened = ImageFileDialog() +settings = Load.ReadSettings(); bOpened = 0; -while ( ~bOpened ) - dataSetString = ''; - if ( isfield(CONSTANTS,'datasetName') ) - dataSetString = CONSTANTS.datasetName; - end - - [settings.imageFile,settings.imagePath,filterIndexImage] = uigetfile(imageFilter,['Open First Image in Dataset (' dataSetString '): ' ]); - if (filterIndexImage==0) - return - end - - [imageDataset namePattern] = Helper.ParseImageName(settings.imageFile); - if ( isempty(imageDataset) ) - error('File name pattern is not supported: %s', settings.imageFile); +while ( ~bOpened ) + metadataPath = Load.ImageLoadDialog(settings.imagePath,['Open Dataset Metadata or Image (' Metadata.GetDatasetName() '): ']); + if ( isempty(metadataPath) ) + return; end - Load.AddConstant('imageNamePattern', namePattern, 1); - if ( ~isfield(CONSTANTS,'datasetName') ) - Load.AddConstant('datasetName', imageDataset, 1); + [imageData, settings.imagePath] = MicroscopeData.ReadMetadataFile(metadataPath); + if ( isempty(imageData) ) + return; end - if ( strcmp(imageDataset, [CONSTANTS.datasetName '_']) ) - Load.AddConstant('datasetName', [CONSTANTS.datasetName '_'], 1); - bOpened = 1; - elseif ( ~strcmp(imageDataset, CONSTANTS.datasetName) ) + if ( ~isempty(Metadata.GetDatasetName()) && ~strcmp(Metadata.GetDatasetName(),imageData.DatasetName) ) answer = questdlg('Image does not match dataset would you like to choose another?','Image Selection','Yes','No','Close LEVer','Yes'); switch answer case 'Yes' continue; case 'No' - Load.AddConstant('imageNamePattern', '', 1); bOpened = 1; case 'Close LEVer' return @@ -51,52 +52,11 @@ while ( ~bOpened ) end end + Metadata.SetMetadata(imageData); + Load.AddConstant('rootImageFolder', settings.imagePath, 1); Load.AddConstant('matFullFile', [settings.matFilePath settings.matFile], 1); - [channelList, frameList] = Helper.GetImListInfo(settings.imagePath, namePattern); - - % Verify that channel and time are 1-based. - remapChan = 1 - channelList(1); - remapFrame = 1 - frameList(1); - if ( remapChan ~= 0 || remapFrame ~= 0 ) - queryStr = sprintf('LEVER requires that image channel and frame numbers begin at 1.\nWould you like to automatically rename the images in the selected folder?'); - respStr = questdlg(queryStr,'Image Name Unsupported','Ok','Cancel','Ok'); - if ( strcmpi(respStr,'Cancel') ) - return; - end - - for c=channelList(1):channelList(end) - for t=frameList(1):frameList(end) - oldName = Helper.GetImageName(c,t); - tempName = ['tmp_' Helper.GetImageName(c+remapChan, t+remapFrame)]; - if ( ~exist(fullfile(settings.imagePath,oldName), 'file') ) - continue; - end - - movefile(fullfile(settings.imagePath,oldName), fullfile(settings.imagePath,tempName)); - end - end - - for c=channelList(1):channelList(end) - for t=frameList(1):frameList(end) - tempName = ['tmp_' Helper.GetImageName(c+remapChan, t+remapFrame)]; - newName = Helper.GetImageName(c+remapChan, t+remapFrame); - if ( ~exist(fullfile(settings.imagePath,tempName), 'file') ) - continue; - end - - movefile(fullfile(settings.imagePath,tempName), fullfile(settings.imagePath,newName)); - end - end - - channelList = channelList + remapChan; - frameList = frameList + remapFrame; - end - - Load.AddConstant('numFrames', frameList(end), 1); - Load.AddConstant('numChannels', channelList(end), 1); - bOpened = 1; end diff --git a/src/MATLAB/+Helper/IndexToCoord.m b/src/MATLAB/+Helper/IndexToCoord.m deleted file mode 100644 index 30129941d10595f1673a8a8168f7c4f67cfbb23b..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Helper/IndexToCoord.m +++ /dev/null @@ -1,13 +0,0 @@ -function coord = IndexToCoord(arraySize, arrayIdx) - coord = zeros(length(arrayIdx),length(arraySize)); - - linSize = [1 cumprod(arraySize)]; - partialIdx = arrayIdx; - for i = length(arraySize):-1:1 - r = rem(partialIdx-1, linSize(i)) + 1; - q = floor((partialIdx-r) / linSize(i)) + 1; - - coord(:,i) = q; - partialIdx = r; - end -end diff --git a/src/MATLAB/+Helper/IsDebug.m b/src/MATLAB/+Helper/IsDebug.m index fa0d7dbd7d204eb2e6762944487972f69b2b828c..603d936a8049bbe011da0865d10e231d098b6cdc 100644 --- a/src/MATLAB/+Helper/IsDebug.m +++ b/src/MATLAB/+Helper/IsDebug.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function bDebug = IsDebug() global bDebugMode diff --git a/src/MATLAB/+Helper/LoadChannelIntensityImage.m b/src/MATLAB/+Helper/LoadChannelIntensityImage.m deleted file mode 100644 index a0d26120f7e4d2f1bdb2e042fdcfc9211ef82ec3..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Helper/LoadChannelIntensityImage.m +++ /dev/null @@ -1,15 +0,0 @@ -function im = LoadChannelIntensityImage(frame, chanIdx) - global CONSTANTS - - im = zeros(0,0); - if (chanIdx > CONSTANTS.numChannels) - return; - end - - imFilename = Helper.GetFullImagePath(chanIdx, frame); - if ( ~exist(imFilename,'file') ) - return; - end - - im = Helper.LoadIntensityImage(imFilename); -end diff --git a/src/MATLAB/+Helper/LoadIntensityImage.m b/src/MATLAB/+Helper/LoadIntensityImage.m index bc080cf17c3f5c2187930e7d6824dba36af54d25..0a6578ac09ac5c24ef214c08389f2d2d67fa2a09 100644 --- a/src/MATLAB/+Helper/LoadIntensityImage.m +++ b/src/MATLAB/+Helper/LoadIntensityImage.m @@ -1,15 +1,38 @@ -% imgray = LoadIntensityImage(filename) +% imgray = LoadIntensityImage(frame, chan) % Loads image and calculates "intensity" if it is an rgb image, % then uses mat2gray to convert to grayscale values on [0,1]. -function imgray = LoadIntensityImage(filename) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +function imgray = LoadIntensityImage(frame, chan) global CONSTANTS bitrates = [8 12 16]; - [im map]=imread(filename); - + im = MicroscopeData.Reader('imageData',Metadata.GetImageInfo(), 'chanList',chan, 'timeRange',[frame frame], 'prompt',false); if ( ndims(im) > 3 ) - error('LEVER tool only supports grayscale images, please select single channel tiff images.'); + error('LEVER tool only supports grayscale images!'); end if ( ~isfield(CONSTANTS,'bitrate') ) @@ -33,9 +56,8 @@ function imgray = LoadIntensityImage(filename) imgray = mat2gray(im); end - % Handle "color" images by averaging the color channels to get - % intensity (should all be the same for all channels) + % Handle "color" or 3D images by max intensity projection of the color channels to get intensity if ( ndims(imgray) == 3 ) - imgray = mean(imgray,3); + imgray = max(imgray,[],3); end end diff --git a/src/MATLAB/+Helper/LoadIntensityImageSet.m b/src/MATLAB/+Helper/LoadIntensityImageSet.m index 7ad6f66135896a6171c996978d9c0c43bb482fb1..25aed55b30a9e2840e32b8dc984ada60642b5b61 100644 --- a/src/MATLAB/+Helper/LoadIntensityImageSet.m +++ b/src/MATLAB/+Helper/LoadIntensityImageSet.m @@ -1,17 +1,39 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function chanImSet = LoadIntensityImageSet(frame) - global CONSTANTS - - chanImSet = cell(1,CONSTANTS.numChannels); + chanImSet = cell(1, Metadata.GetNumberOfChannels()); bAllMissing = true; - for c = 1:CONSTANTS.numChannels - imFilename = Helper.GetFullImagePath(c, frame); - if ( ~exist(imFilename,'file') ) + for c = 1:Metadata.GetNumberOfChannels() + im = Helper.LoadIntensityImage(frame, c); + if ( isempty(im) ) continue; end bAllMissing = false; - chanImSet{c} = Helper.LoadIntensityImage(imFilename); + chanImSet{c} = im; end if ( bAllMissing ) diff --git a/src/MATLAB/+Helper/LoadPrimaryIntensityImage.m b/src/MATLAB/+Helper/LoadPrimaryIntensityImage.m deleted file mode 100644 index c6e0143b2f407fe5240654464c8fa0aec6b844f8..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Helper/LoadPrimaryIntensityImage.m +++ /dev/null @@ -1,13 +0,0 @@ -function im = LoadPrimaryIntensityImage(frame) - global CONSTANTS - primaryChan = CONSTANTS.primaryChannel; - - im = zeros(0,0); - - imFilename = Helper.GetFullImagePath(primaryChan, frame); - if ( ~exist(imFilename,'file') ) - return; - end - - im = Helper.LoadIntensityImage(imFilename); -end diff --git a/src/MATLAB/+Helper/MakeEmptyStruct.m b/src/MATLAB/+Helper/MakeEmptyStruct.m index 23faf17c1f0078bd53a5af85f169c8654d2ea0e8..5f8653ccbf8ae0d442a192a7532d35882fd476ab 100644 --- a/src/MATLAB/+Helper/MakeEmptyStruct.m +++ b/src/MATLAB/+Helper/MakeEmptyStruct.m @@ -1,6 +1,30 @@ % newStruct = MakeEmptyStruct(inStruct) % Returns an empty struct based on the fields of inStruct +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function newStruct = MakeEmptyStruct(inStruct) outFields = fieldnames(inStruct); newStruct = struct(); diff --git a/src/MATLAB/+Helper/MakeExpandedCVHull.m b/src/MATLAB/+Helper/MakeExpandedCVHull.m index 4db01269a9bbdf69f6c6db2268586761e18b26cc..fd755eeafe304ea12e61bd9bd2e57f75e9336b89 100644 --- a/src/MATLAB/+Helper/MakeExpandedCVHull.m +++ b/src/MATLAB/+Helper/MakeExpandedCVHull.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function expandPoints = MakeExpandedCVHull(hullPoints, expandRadius) expandPoints = []; if ( size(hullPoints,1) <= 1 ) diff --git a/src/MATLAB/+Helper/MakeInitStruct.m b/src/MATLAB/+Helper/MakeInitStruct.m index cf2242a51719b17306c911b05f36bf2503b91edd..ee07bd8d1a93fba7f54be9767d7f8ad83e4aa4ff 100644 --- a/src/MATLAB/+Helper/MakeInitStruct.m +++ b/src/MATLAB/+Helper/MakeInitStruct.m @@ -1,5 +1,29 @@ % newStruct = MakeInitStruct(outStruct, inStruct) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + % Output a structure entry with fields same as outStruct and any fields % with the same name copied from inStruct (all others empty) @@ -26,7 +50,8 @@ function newStruct = MakeInitStruct(templateStruct, initStruct) end else if ( isfield(initStruct,outFields(i)) ) - [newStruct.(outFields{i})] = deal(forceLogical(initStruct.(outFields{i}))); + logicalData = arrayfun(@(x)(forceLogical(x.(outFields{i}))), initStruct, 'UniformOutput',false); + [newStruct.(outFields{i})] = deal(logicalData{:}); else [newStruct.(outFields{i})] = deal(false); end diff --git a/src/MATLAB/+Helper/NonEmptyField.m b/src/MATLAB/+Helper/NonEmptyField.m index 4e5d676744defc670f17d887a26979451936713e..b15d81658a29098b731e2910301088c6ebc401fc 100644 --- a/src/MATLAB/+Helper/NonEmptyField.m +++ b/src/MATLAB/+Helper/NonEmptyField.m @@ -1,4 +1,28 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function bHasNonempty = NonEmptyField(S, fieldname) bHasNonempty = (isfield(S,fieldname) && ~isempty(S.(fieldname))); end \ No newline at end of file diff --git a/src/MATLAB/+Helper/ParseImageName.m b/src/MATLAB/+Helper/ParseImageName.m deleted file mode 100644 index 4b83dbbccb39fc8442e127bb1edd245cf117e1d8..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Helper/ParseImageName.m +++ /dev/null @@ -1,32 +0,0 @@ -% [datasetName namePattern] = ParseImageName(imageName) - -function [datasetName namePattern] = ParseImageName(imageName) - datasetName = ''; - namePattern = ''; - - supportedPatterns = {%'^(.+)_(c\d+)_(t\d+)_(z\d+)(.*)$'; - '^(.+)_(c\d+)_(t\d+)(.*)$'; - '^(.+)_(t\d+)(.*)$'}; - - [filePath fileName fileExt] = fileparts(imageName); - for i=1:length(supportedPatterns) - matchTok = regexpi(fileName, supportedPatterns{i}, 'tokens', 'once'); - if ( isempty(matchTok) ) - continue; - end - - paramPatternSet = ''; - for j=2:length(matchTok)-1 - numDigits = length(matchTok{j})-1; - paramPattern = ['_' matchTok{j}(1) '%0' num2str(numDigits) 'd']; - - paramPatternSet = [paramPatternSet paramPattern]; - end - - patternPostfix = [matchTok{end} fileExt]; - - datasetName = [matchTok{1} '_']; - namePattern = [matchTok{1} paramPatternSet patternPostfix]; - break; - end -end diff --git a/src/MATLAB/+Helper/PushTrackToFrame.m b/src/MATLAB/+Helper/PushTrackToFrame.m deleted file mode 100644 index f6ee1214272f576d68e82f82d6e7da85e5b26b70..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Helper/PushTrackToFrame.m +++ /dev/null @@ -1,45 +0,0 @@ - -function PushTrackToFrame(trackID, frameTime) - global CellFamilies CellTracks CellHulls HashedCells - - bLockedHulls = false(1,length(CellHulls)); - - bLockedFamilies = arrayfun(@(x)(x.bLocked > 0),CellFamilies); - lockedTracks = [CellFamilies(bLockedFamilies).tracks]; - lockTrackHulls = [CellTracks(lockedTracks).hulls]; - nzHulls = lockTrackHulls(lockTrackHulls > 0); - bLockedHulls(nzHulls) = 1; - - costMatrix = Tracker.GetCostMatrix(); - - startHull = CellTracks(trackID).hulls(1); - termHulls = [HashedCells{frameTime}.hullID]; - bLockedTerms = bLockedHulls(termHulls); - - d = matlab_bgl.dijkstra_sp(costMatrix, startHull); - - dTerms = d(termHulls); - [sortDist srtIdx] = sort(dTerms); - - bValid = ~isinf(sortDist); - checkIdx = srtIdx(bValid); - if ( isempty(checkIdx) ) - % Try to add a hull somewhere - error('No hulls available to add'); - return; - end - - bUnlocked = ~bLockedTerms(checkIdx); - unlockedHulls = termHulls(checkIdx(bUnlocked)); - if ( isempty(unlockedHulls) ) - % Find locked hull to split? - error('Should probably split a hull here'); - return; - end - - endHull = unlockedHulls(1); - - time = CellHulls(endHull).time; - oldTrackID = Hulls.GetTrackID(endHull); - Tracks.ChangeLabel(oldTrackID, trackID, time); -end \ No newline at end of file diff --git a/src/MATLAB/+Helper/SaveLEVerState.m b/src/MATLAB/+Helper/SaveLEVerState.m index 0c538d578b3c6a8d28395f173c593cb85f06a670..b4eb790251bdb41949c8d25865b27b8782717bd7 100644 --- a/src/MATLAB/+Helper/SaveLEVerState.m +++ b/src/MATLAB/+Helper/SaveLEVerState.m @@ -2,10 +2,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Helper/SetDebug.m b/src/MATLAB/+Helper/SetDebug.m index f2719f66ee69d1eea053482617af9bb35e84e638..bac7fc82200dca3dd066fb55d2b4d25e3224844a 100644 --- a/src/MATLAB/+Helper/SetDebug.m +++ b/src/MATLAB/+Helper/SetDebug.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function SetDebug(bEnable) global bDebugMode diff --git a/src/MATLAB/+Helper/SetRandomState.m b/src/MATLAB/+Helper/SetRandomState.m index 3beb9faee8e213afb40aa9a698ea0359df8e698b..a5cbb49b6f482bdab1ab246637d9cafe3b8f6d04 100644 --- a/src/MATLAB/+Helper/SetRandomState.m +++ b/src/MATLAB/+Helper/SetRandomState.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function SetRandomState(randState) globStream = RandStream.getGlobalStream(); globStream.State = randState; diff --git a/src/MATLAB/+Helper/SetTreeFrozen.m b/src/MATLAB/+Helper/SetTreeFrozen.m index 7caf9ced6a2648cface8aef9ff43c3650c6808c5..f5391bf502bafdc4b9c3a8114bf7e8cb4d62f219 100644 --- a/src/MATLAB/+Helper/SetTreeFrozen.m +++ b/src/MATLAB/+Helper/SetTreeFrozen.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function SetTreeFrozen(treeID, bFrozen) global CellFamilies diff --git a/src/MATLAB/+Helper/SetTreeLocked.m b/src/MATLAB/+Helper/SetTreeLocked.m index 0fcda66e3a6779b53145420fce7e8ada3c797a95..8213c6011a1a7c4a41c669860ae3dd9552e1076b 100644 --- a/src/MATLAB/+Helper/SetTreeLocked.m +++ b/src/MATLAB/+Helper/SetTreeLocked.m @@ -1,4 +1,28 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function SetTreeLocked(treeID, bLocked) global CellFamilies diff --git a/src/MATLAB/+Helper/SplitNamePattern.m b/src/MATLAB/+Helper/SplitNamePattern.m deleted file mode 100644 index 3604b9dcd733ae75ddbbb6bbdf52f5e4b0774d7e..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Helper/SplitNamePattern.m +++ /dev/null @@ -1,21 +0,0 @@ -function [prefixString paramTokens postfixString] = SplitNamePattern(namePattern) - prefixString = ''; - postfixString = ''; - - paramTokens = Helper.GetNamePatternParams(namePattern); - if ( isempty(paramTokens) ) - return; - end - - paramStrings = cellfun(@(x)(['_' x{1} '%0' x{2} 'd']),paramTokens, 'UniformOutput',0); - - matchExpr = ['^(.+)' paramStrings{:} '(.*)$']; - matchTok = regexp(namePattern, matchExpr, 'tokens','once'); - if ( isempty(matchTok) ) - paramTokens = {}; - return; - end - - prefixString = matchTok{1}; - postfixString = matchTok{2}; -end diff --git a/src/MATLAB/+Helper/SweepDeleted.m b/src/MATLAB/+Helper/SweepDeleted.m index ee752ea11cbbb595fc45b90b6cb1b6987ba19883..eed0439e1c347b58a9e21e6690ae2b517a9f6cc7 100644 --- a/src/MATLAB/+Helper/SweepDeleted.m +++ b/src/MATLAB/+Helper/SweepDeleted.m @@ -1,5 +1,29 @@ % This is a LEVer garbage collection routine to clean up deleted % tracks and families while keeping all data consistent. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function SweepDeleted() global CellHulls HashedCells CellTracks CellFamilies Costs ConnectedDist SegmentationEdits diff --git a/src/MATLAB/+Helper/UpdateFrozenCosts.m b/src/MATLAB/+Helper/UpdateFrozenCosts.m index 709dab16c5ca694e1b0b39e11da3b5023446af8f..d135edce7c771f78c5365578ac070510d69418ea 100644 --- a/src/MATLAB/+Helper/UpdateFrozenCosts.m +++ b/src/MATLAB/+Helper/UpdateFrozenCosts.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function UpdateFrozenCosts(treeID, bFrozen) global CellFamilies CellTracks CachedCostMatrix diff --git a/src/MATLAB/+Helper/ValidUIHandle.m b/src/MATLAB/+Helper/ValidUIHandle.m index 76bf7141d1000c60d300c3849744a8b223a0d35a..abb617389c35e4a0cf89f625cabb697bc63c9259 100644 --- a/src/MATLAB/+Helper/ValidUIHandle.m +++ b/src/MATLAB/+Helper/ValidUIHandle.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function bValid = ValidUIHandle(hCheck) if ( isempty(hCheck) ) bValid = false; diff --git a/src/MATLAB/+Helper/WasDropped.m b/src/MATLAB/+Helper/WasDropped.m index 4ddbd7fbb5814d2f35ace81e5fa90603e35a3144..6eecbe6f8ee787a95669d0958cc5aa082ec6aac1 100644 --- a/src/MATLAB/+Helper/WasDropped.m +++ b/src/MATLAB/+Helper/WasDropped.m @@ -1,6 +1,30 @@ % bool = WasDropped(track, list) % Returns 1 or 0 depending if the track is in the given list +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + % ChangeLog: % EW 6/8/12 created function bool = WasDropped(track, list) diff --git a/src/MATLAB/+Helper/fitGMM.m b/src/MATLAB/+Helper/fitGMM.m index 07e690e85ece7c8622058ee0a1e63342ca3d97aa..cbfc4ca11212b463af8c73a1489325333f9f6b87 100644 --- a/src/MATLAB/+Helper/fitGMM.m +++ b/src/MATLAB/+Helper/fitGMM.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function gmmObj = fitGMM(X,k,varargin) if ( verLessThan('matlab', '8.4.0') ) gmmObj = gmdistribution.fit(X,k, varargin{:}); diff --git a/src/MATLAB/+Hulls/AddHashedCell.m b/src/MATLAB/+Hulls/AddHashedCell.m index 6367ecc43e17d0fb6c00c92b89b8b5039d4c1560..801a8998eb588d509570cc4e7cc5a0eed0a994ef 100644 --- a/src/MATLAB/+Hulls/AddHashedCell.m +++ b/src/MATLAB/+Hulls/AddHashedCell.m @@ -4,10 +4,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Hulls/CheckHullsContainsPoint.m b/src/MATLAB/+Hulls/CheckHullsContainsPoint.m index 6771d819c7b5a4b36e866edf835974e5c3c677b8..6436970132bf9330281fc3ecf094fb22c81c7ace 100644 --- a/src/MATLAB/+Hulls/CheckHullsContainsPoint.m +++ b/src/MATLAB/+Hulls/CheckHullsContainsPoint.m @@ -3,10 +3,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Hulls/ClearHull.m b/src/MATLAB/+Hulls/ClearHull.m index d708ac0ad7fcaee935e11bed201dc85fd712d449..c0f768b63e62e7b53221a1d1fb4a2d25d6caf6f5 100644 --- a/src/MATLAB/+Hulls/ClearHull.m +++ b/src/MATLAB/+Hulls/ClearHull.m @@ -1,6 +1,30 @@ % ClearHull( hullID ) % Clears the hull and marks it deleted +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + % ChangeLog: % EW 6/8/12 created function ClearHull( hullID ) diff --git a/src/MATLAB/+Hulls/CreateHull.m b/src/MATLAB/+Hulls/CreateHull.m index 33a778811f4e6b35188b6ed82066cc547e0f6001..87db8b0fd552bc91a360bab1f349270530f0cd1b 100644 --- a/src/MATLAB/+Hulls/CreateHull.m +++ b/src/MATLAB/+Hulls/CreateHull.m @@ -1,4 +1,28 @@ -function newHull = CreateHull(imageSize, indexPixels, time, userEdited, tag) + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function newHull = CreateHull(rcImageDims, indexPixels, time, userEdited, tag) global CellHulls if ( ~exist('time','var') ) @@ -18,8 +42,8 @@ function newHull = CreateHull(imageSize, indexPixels, time, userEdited, tag) newHull = Helper.MakeEmptyStruct(CellHulls); end - rcCoords = Helper.IndexToCoord(imageSize, indexPixels); - xyCoords = Helper.SwapXY_RC(rcCoords); + rcCoords = Utils.IndToCoord(rcImageDims, indexPixels); + xyCoords = Utils.SwapXY_RC(rcCoords); newHull.indexPixels = indexPixels; newHull.centerOfMass = mean(rcCoords,1); @@ -30,7 +54,7 @@ function newHull = CreateHull(imageSize, indexPixels, time, userEdited, tag) return; end - newHull.points = xyCoords(chIdx,:); + newHull.points = xyCoords(chIdx,1:2); newHull.time = time; newHull.userEdited = (userEdited > 0); diff --git a/src/MATLAB/+Hulls/ExpandedHullContains.m b/src/MATLAB/+Hulls/ExpandedHullContains.m index 839cef2262a8c8b3328dfb954650f29a79bc3a7f..c615e7244c159fa26ba0f1f61a1762776f556245 100644 --- a/src/MATLAB/+Hulls/ExpandedHullContains.m +++ b/src/MATLAB/+Hulls/ExpandedHullContains.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function bInside = ExpandedHullContains(cvHull, expandRadius, pointList) numPoints = size(pointList,1); diff --git a/src/MATLAB/+Hulls/FindHull.m b/src/MATLAB/+Hulls/FindHull.m index 8546fcae32d4e7ffbd742a496c4ed42574069d49..ef2265f57b3634b9e05ca33e29719ee497058f52 100644 --- a/src/MATLAB/+Hulls/FindHull.m +++ b/src/MATLAB/+Hulls/FindHull.m @@ -4,10 +4,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Hulls/GetTrackID.m b/src/MATLAB/+Hulls/GetTrackID.m index 25c6d6e64a01c5c82b0e93ffbe31336c85ab87d0..86cdd359381f2c5c7669d9421cfd905a2034a9fa 100644 --- a/src/MATLAB/+Hulls/GetTrackID.m +++ b/src/MATLAB/+Hulls/GetTrackID.m @@ -2,10 +2,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Hulls/RadiusContains.m b/src/MATLAB/+Hulls/RadiusContains.m index 42e98f2ae46a305e0e68bb7d1fb53b6a9178aa9a..f9c7304dc5b2ccbc4c28edcab778c745789f17fc 100644 --- a/src/MATLAB/+Hulls/RadiusContains.m +++ b/src/MATLAB/+Hulls/RadiusContains.m @@ -1,4 +1,28 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function bMayOverlap = RadiusContains(hullIDs, expandRadius, point) global CellHulls diff --git a/src/MATLAB/+Hulls/RemoveHull.m b/src/MATLAB/+Hulls/RemoveHull.m index a0e68155f7cdbd64b8692cd76e93ea6b6fa8b9c8..73d92a2f308f6e3627207d70b26694519080578e 100644 --- a/src/MATLAB/+Hulls/RemoveHull.m +++ b/src/MATLAB/+Hulls/RemoveHull.m @@ -7,10 +7,10 @@ % EW 6/6/12 rewrite %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Hulls/SetCellHullEntries.m b/src/MATLAB/+Hulls/SetCellHullEntries.m index 388617ca36343a5d0c46d7c705320f61df6e00fc..8f012dbddaa5e96a5c84954d79411ba36db4b1f1 100644 --- a/src/MATLAB/+Hulls/SetCellHullEntries.m +++ b/src/MATLAB/+Hulls/SetCellHullEntries.m @@ -5,6 +5,30 @@ % % NOTE: This does not automatically update tracking information for hulls +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [newHulls newFamilies] = SetCellHullEntries(setHullIDs, setObjs) global CellHulls Costs GraphEdits ResegLinks CachedCostMatrix diff --git a/src/MATLAB/+ImUtils/ConvertType.m b/src/MATLAB/+ImUtils/ConvertType.m new file mode 100644 index 0000000000000000000000000000000000000000..01756425f863f3ede570b0939b441431438f33d2 --- /dev/null +++ b/src/MATLAB/+ImUtils/ConvertType.m @@ -0,0 +1,117 @@ +% [ imageOut ] = ConvertType(IMAGEIN, OUTCLASS, NORMALIZE) +% ConvertType converts image from current type into the specified type +% OUTCLASS +% If normalize==true then each channel/frame will be set between [0,1] prior +% to conversion, meaning that normalization happens on a frame by frame as +% well as a channel by channel bases. +% Assumes a 5D image of (rows,col,z,channels,time). Non-existent dimensions +% should be singleton. + +function [ imageOut ] = ConvertType(imageIn, typ, normalize) + +if (~exist('normalize','var') || isempty(normalize)) + normalize = 0; +end + +if (~strcmpi(typ,'logical')) + imageOut = zeros(size(imageIn),typ); +else + imageOut = false(size(imageIn)); +end + +if (normalize) + for t=1:size(imageIn,5) + for c=1:size(imageIn,4) + inType = class(imageIn); + if (strcmpi(inType,'double') || strcmpi(inType,'uint64') || strcmpi(inType,'int64')) + imTemp = double(imageIn(:,:,:,c,t)); + else + imTemp = single(imageIn(:,:,:,c,t)); + end + imTemp = imTemp-min(imTemp(:)); + imTemp = imTemp./max(imTemp(:)); + + switch typ + case 'uint8' + imageOut(:,:,:,c,t) = im2uint8(imTemp); + case 'uint16' + imageOut(:,:,:,c,t) = im2uint16(imTemp); + case 'int16' + imageOut(:,:,:,c,t) = im2int16(imTemp); + case 'uint32' + imageOut(:,:,:,c,t) = im2uint32(imTemp); + case 'int32' + imageOut(:,:,:,c,t) = im2int32(imTemp); + case 'single' + imageOut(:,:,:,c,t) = im2single(imTemp); + case 'double' + imageOut(:,:,:,c,t) = imTemp; + case 'logical' + imageOut(:,:,:,c,t) = imTemp>min(imTemp(:)); + otherwise + error('Unkown type of image to convert to!'); + end + end + end +else + w = whos('imageIn'); + switch w.class + case 'single' + imageIn = convertToMaxOfOne(imageIn,w.class); + case 'double' + imageIn = convertToMaxOfOne(imageIn,w.class); + end + if (strcmpi(w.class,typ)) + imageOut = imageIn; + else + switch typ + case 'uint8' + imageOut = im2uint8(imageIn); + case 'uint16' + imageOut = im2uint16(imageIn); + case 'int16' + imageOut = im2int16(imageIn); + case 'uint32' + imageOut = im2uint32(imageIn); + case 'int32' + imageOut = im2int32(imageIn); + case 'single' + imageOut = im2single(imageIn); + case 'double' + imageOut = im2double(imageIn); + case 'logical' + imageOut = imageIn>min(imageIn(:)); + otherwise + error('Unkown type of image to convert to!'); + end + end +end +end + +function im = convertToMaxOfOne(im,outTyp) +switch outTyp + case 'uint8' + im = im./2^8; + case 'uint16' + if (max(im(:))<2^12+1) + im = im./2^12; + else + im = im./2^16; + end + case 'int16' + im = im./2^15-1; + case 'uint32' + im = im./2^32; + case 'int32' + im = im./2^32-1; + case 'single' + im = im./max(im(:)); + case 'double' + im = im./max(im(:)); + case 'logical' + % im = im; + otherwise + error('Unkown type of image to convert to!'); +end +end + diff --git a/src/MATLAB/+Load/AddConstant.m b/src/MATLAB/+Load/AddConstant.m index c3688d4c80d0a105d34e7edcc8a283e1105c8ed3..9112c6031a1f5ca5606e31e63cb6ac7379083fe4 100644 --- a/src/MATLAB/+Load/AddConstant.m +++ b/src/MATLAB/+Load/AddConstant.m @@ -6,10 +6,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Load/AddFamilyEditFields.m b/src/MATLAB/+Load/AddFamilyEditFields.m index cfc2d78dcfbb58e1fe733238d4d115870b8e9846..313a9eb1032cfd2dce6c93b97b110686a04c7e40 100644 --- a/src/MATLAB/+Load/AddFamilyEditFields.m +++ b/src/MATLAB/+Load/AddFamilyEditFields.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function bNeedsUpdate = AddFamilyEditFields() global CellFamilies diff --git a/src/MATLAB/+Load/AddUserEditedField.m b/src/MATLAB/+Load/AddUserEditedField.m index 1aa3d8a148b4442618a788a4c5a8141885b513bc..a7a746bbcfb887826418f75702bc079bb89614d1 100644 --- a/src/MATLAB/+Load/AddUserEditedField.m +++ b/src/MATLAB/+Load/AddUserEditedField.m @@ -3,10 +3,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Load/BuildRenameStruct.m b/src/MATLAB/+Load/BuildRenameStruct.m new file mode 100644 index 0000000000000000000000000000000000000000..1e4336e782cf5bb8ec6851d3a0d23a1c8dd7ec48 --- /dev/null +++ b/src/MATLAB/+Load/BuildRenameStruct.m @@ -0,0 +1,80 @@ +% [renameStruct,bNeedRename] = BuildRenameStruct(imageName) + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +function renameStruct = BuildRenameStruct(imageName) + renameStruct = []; + + paramSet = {'c';'t';'z'}; + paramSize = {2;4;4}; + requireParam = [false,true,false]; + + paramPattern = cellfun(@(x)(['_(' x ')\d+']), paramSet, 'UniformOutput',false); + + [~,fileName,fileExt] = fileparts(imageName); + [startMatch,tokMatch] = regexpi(fileName, paramPattern, 'start','tokens'); + + % If there are multiple matches to the parameter type, take only the one that's furthest in the name. + bFoundParams = cellfun(@(x)(~isempty(x)),startMatch); + validStarts = cellfun(@(x)(x(end)), startMatch(bFoundParams)); + validParams = cellfun(@(x)(x{end}{1}), tokMatch(bFoundParams), 'UniformOutput',false); + + if ( isempty(validStarts) ) + return; + end + + [~,validParamOrder] = sort(validStarts); + + tokPattern = cellfun(@(x)(['_' x '(\d+)']), validParams(validParamOrder), 'UniformOutput',false); + buildPattern = ['^(.+)' tokPattern{:} '(.*?)$']; + + tokMatch = regexp(fileName, buildPattern, 'tokens','once'); + if ( isempty(tokMatch) ) + return; + end + + paramOrder = zeros(1,length(paramSet)); + paramOrder(bFoundParams) = validParamOrder; + if ( ~all(paramOrder(requireParam)>0) ) + return; + end + + prefixStr = regexptranslate('escape',tokMatch{1}); + postfixStr = regexptranslate('escape',tokMatch{end}); + + % Escape some possible file name issues + datasetName = tokMatch{1}; + prefixName = strrep(tokMatch{1},'"','\"'); + prefixName = strrep(prefixName,'''','\'''); + prefixName = strrep(prefixName,'%','%%'); + + dirBlob = [datasetName '*' fileExt]; + loadPattern = [prefixStr tokPattern{:} postfixStr '\' fileExt]; + + outParams = cellfun(@(x,y)(['_' x '%0' num2str(y) 'd']), paramSet,paramSize, 'UniformOutput',false); + outPattern = [prefixName outParams{:} '.tif']; + + renameStruct = struct('datasetName',{datasetName}, 'dirBlob',{dirBlob}, 'loadPattern',{loadPattern}, 'outPattern',{outPattern}, 'paramOrder',{paramOrder}); +end diff --git a/src/MATLAB/+Load/CheckExportImages.m b/src/MATLAB/+Load/CheckExportImages.m new file mode 100644 index 0000000000000000000000000000000000000000..d09a71e76827a126dc91052351e14419a60a2da2 --- /dev/null +++ b/src/MATLAB/+Load/CheckExportImages.m @@ -0,0 +1,61 @@ +% [bNeedsExport,bInplaceUpdate] = CheckExportImages(rootDir,fileName) +% +% Check if these specified image file needs to be exported for LEVER use or +% or if only an inplace rename and json generation is required. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +function [bNeedsExport,bWriteable,renameStruct] = CheckExportImages(rootDir,fileName) + bNeedsExport = false; + bWriteable = false; + renameStruct = []; + + [~,chkName,chkExt] = fileparts(fileName); + if ( any(strcmpi(chkExt,{'.tif','.tiff'})) ) + jsonList = dir(fullfile(rootDir,[chkName '*.json'])); + if ( ~isempty(jsonList) ) + return; + end + + renameStruct = Load.BuildRenameStruct(fileName); + end + + bWriteable = ~isempty(renameStruct) && checkWriteable(rootDir); + bNeedsExport = true; +end + +function bCanWrite = checkWriteable(rootDir) + bCanWrite = false; + + fid = fopen(fullfile(rootDir,'testWriteFile'),'w'); + if ( fid < 0 ) + return; + end + fclose(fid); + + delete(fullfile(rootDir,'testWriteFile')); + + bCanWrite = true; +end \ No newline at end of file diff --git a/src/MATLAB/+Load/CheckFolderExport.m b/src/MATLAB/+Load/CheckFolderExport.m new file mode 100644 index 0000000000000000000000000000000000000000..eb1cd280429438599b961ced1383d1165d502929 --- /dev/null +++ b/src/MATLAB/+Load/CheckFolderExport.m @@ -0,0 +1,100 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function [subPaths,needsExport,renamable] = CheckFolderExport(rootDir) + [subPaths,needsExport,renamable] = recursiveCheckExport(rootDir,''); +end + +function [subPaths,needsExport,renamable] = recursiveCheckExport(rootDir,subDir) + subPaths = {}; + needsExport = false(0); + renamable = false(0); + + dirList = dir(fullfile(rootDir,subDir)); + + bInvalidName = arrayfun(@(x)(strncmpi(x.name,'.',1) || strncmpi(x.name,'..',2)), dirList); + bValidDir = ~bInvalidName & (vertcat(dirList.isdir) > 0); + bValidFile = ~bInvalidName & (vertcat(dirList.isdir) == 0); + + fileList = dirList(bValidFile); + pathList = dirList(bValidDir); + + filenames = {fileList.name}.'; + + %% Get a list of valid JSON files + jsonMatch = regexpi(filenames, '(\.json$)','once'); + bJSON = cellfun(@(x)(~isempty(x)),jsonMatch); + + jsonNames = filenames(bJSON); + if ( ~isempty(jsonNames) ) + bValid = cellfun(@(x)(~isempty(MicroscopeData.ReadMetadataFile(fullfile(rootDir,subDir,x)))),jsonNames); + + % Remove files that have the same prefix (datasetName) as .json from the list + datasetNames = cellfun(@(x)(x(1:end-5)),jsonNames(bValid),'UniformOutput',false); + matchDatasets = cellfun(@(x)(strncmp(x,filenames.',length(x))),datasetNames,'UniformOutput',false); + bMatched = any(vertcat(matchDatasets{:}),1); + filenames = filenames(~bMatched); + + subPaths = cellfun(@(x)(fullfile(subDir,x)),jsonNames(bValid),'UniformOutput',false); + needsExport = false(nnz(bValid),1); + renamable = false(nnz(bValid),1); + end + + %% Handle folders of TIFs that don't require export or are renamable stacks + tifMatch = regexpi(filenames, '(\.tif$)|(\.tiff$)','once'); + bTIF = cellfun(@(x)(~isempty(x)),tifMatch); + + tifNames = filenames(bTIF); + if ( ~isempty(tifNames) ) + % If these appear to be renameable tifs don't bother with subdirectories + [bNeedsExport,bWriteable,renameStruct] = Load.CheckExportImages(fullfile(rootDir,subDir),tifNames{1}); + if ( ~isempty(renameStruct) ) + subPaths = {fullfile(subDir,tifNames{1})}; + needsExport = bNeedsExport; + renamable = bWriteable; + + return; + end + end + + %% Check any other files to see if they are supported and need export + if ( ~isempty(filenames) ) + bCanExport = MicroscopeData.Original.CanExportFormat(filenames); + exportNames = filenames(bCanExport); + + subPaths = [subPaths; cellfun(@(x)(fullfile(subDir,x)),exportNames,'UniformOutput',false)]; + needsExport = [needsExport; true(length(exportNames),1)]; + renamable = [renamable; false(length(exportNames),1)]; + end + + %% Deal with further subdirectories + for i=1:length(pathList) + nextSubDir = fullfile(subDir,pathList(i).name); + [newPaths,chkExport,chkRename] = recursiveCheckExport(rootDir,nextSubDir); + + subPaths = [subPaths; newPaths]; + needsExport = [needsExport; chkExport]; + renamable = [renamable; chkRename]; + end +end diff --git a/src/MATLAB/+Load/CreateColors.m b/src/MATLAB/+Load/CreateColors.m index 9b66c6172504832ed8a2a255d8ecaf803c70ac5a..c951a26057e091a13105a2deba837f0fbd6fb7fa 100644 --- a/src/MATLAB/+Load/CreateColors.m +++ b/src/MATLAB/+Load/CreateColors.m @@ -5,10 +5,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Load/ExportImages.m b/src/MATLAB/+Load/ExportImages.m new file mode 100644 index 0000000000000000000000000000000000000000..f2ac3b773a15a893dbbf518c2d2017a818a28ce5 --- /dev/null +++ b/src/MATLAB/+Load/ExportImages.m @@ -0,0 +1,34 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function jsonPath = ExportImages(exportDir, inRoot,inFilename) + [~,imD] = MicroscopeData.Original.Convert2Tiffs(inRoot,inFilename, exportDir, true, false); + if ( length(imD) > 1 ) + [~,imName] = fileparts(inFilename); + exportDir = fullfile(exportDir,imName); + end + + [~,chkIdx] = max(cellfun(@(x)((x.NumberOfFrames)),imD)); + jsonPath = fullfile(exportDir,imD{chkIdx}.DatasetName,[imD{chkIdx}.DatasetName '.json']); +end diff --git a/src/MATLAB/+Load/ExportLocationDialog.m b/src/MATLAB/+Load/ExportLocationDialog.m new file mode 100644 index 0000000000000000000000000000000000000000..fa1ad480445c1ec7a7e299c6058fac225dd5df64 --- /dev/null +++ b/src/MATLAB/+Load/ExportLocationDialog.m @@ -0,0 +1,60 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function exportLocation = ExportLocationDialog(rootDir,bInplace) + exportLocation = ''; + + % Offer to update the image names/json in place if possible. + if ( bInplace ) + selAns = questdlg({'Selected images must be updated to conform to LEVER naming and metadata guidelines:',... + 'Image name format: <DatasetName>_c%02d_t%04d_z%04d.tif',... + ' ',... + 'The images can be updated in place or exported to a new directory.'},... + 'Image Export Required', 'Update','Export','Update'); + + if ( isempty(selAns) ) + return; + end + + if ( strcmpi(selAns,'Update') ) + exportLocation = rootDir; + return; + end + end + + while ( true ) + chkDir = uigetdir(rootDir, 'Image Export Directory'); + if ( ~chkDir ) + return; + end + + if ( strcmp(chkDir,rootDir) ) + h = warndlg('Please select or create a different directory to export into.','Export Required'); + uiwait(h); + else + exportLocation = chkDir; + return; + end + end +end diff --git a/src/MATLAB/+Load/FileVersionGreaterOrEqual.m b/src/MATLAB/+Load/FileVersionGreaterOrEqual.m index e1b0818d960cb9a6f8bd07065a890b9faa23c5d3..62deed0eeb6ad5f7aab2e8ba9b9d35dd370affb3 100644 --- a/src/MATLAB/+Load/FileVersionGreaterOrEqual.m +++ b/src/MATLAB/+Load/FileVersionGreaterOrEqual.m @@ -3,10 +3,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Load/FixDefaultPhenotypes.m b/src/MATLAB/+Load/FixDefaultPhenotypes.m index ace98fd56a83452c7d666f85d06cb9bfe4f30808..4046c5937ebb669c7b0f75ad5aace1ab1e0668ee 100644 --- a/src/MATLAB/+Load/FixDefaultPhenotypes.m +++ b/src/MATLAB/+Load/FixDefaultPhenotypes.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function bNeedsUpdate = FixDefaultPhenotypes() % Merge together any duplicate phenotypes (based on description) bNeedsUpdate = mergeDuplicateIDs(); diff --git a/src/MATLAB/+Load/FixMetadata.m b/src/MATLAB/+Load/FixMetadata.m new file mode 100644 index 0000000000000000000000000000000000000000..23314303598fabfc1acd6aa22dec415625721a00 --- /dev/null +++ b/src/MATLAB/+Load/FixMetadata.m @@ -0,0 +1,43 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function bNeedsUpdate = FixMetadata() + global CONSTANTS + + oldFields = {'datasetName' + 'numChannels' + 'numFrames' + 'imageNamePattern' + 'imageSize' + 'imageSignificantDigits'}; + + bNeedsUpdate = false; + + for i=1:length(oldFields) + if ( isfield(CONSTANTS,oldFields{i}) ) + CONSTANTS = rmfield(CONSTANTS,oldFields{i}); + bNeedsUpdate = true; + end + end +end \ No newline at end of file diff --git a/src/MATLAB/+Load/FixOldFileVersions.m b/src/MATLAB/+Load/FixOldFileVersions.m index 29ed9dcb4b0c8e6c11fff42937b0bb72190939ce..8bd241e0e3ecf4ee51a19160f5274d19502351f6 100644 --- a/src/MATLAB/+Load/FixOldFileVersions.m +++ b/src/MATLAB/+Load/FixOldFileVersions.m @@ -3,10 +3,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by @@ -131,6 +131,11 @@ function bNeedsUpdate = FixOldFileVersions() bNeedsUpdate = true; end + % Properly include image metadata, remove old superfluous fields + if ( Load.FixMetadata() ) + bNeedsUpdate = true; + end + % % Adds the special origin action, to indicate that this is initial % % segmentation data from which edit actions are built. % if ( isempty(ReplayEditActions) || bNeedsUpdate ) diff --git a/src/MATLAB/+Load/FolderExport.m b/src/MATLAB/+Load/FolderExport.m new file mode 100644 index 0000000000000000000000000000000000000000..c93c912ab9bf37eee01b545de26f9208237ab7fe --- /dev/null +++ b/src/MATLAB/+Load/FolderExport.m @@ -0,0 +1,82 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function exportRoot = FolderExport(rootDir) + exportRoot = rootDir; + + [subPaths,needsExport,renamable] = Load.CheckFolderExport(rootDir); + if ( isempty(subPaths) ) + return; + end + + bExport = any(needsExport); + if ( ~bExport ) + return; + end + + % Allow an inplace update if all exports are renamable + exportRenames = renamable(needsExport); + exportPaths = subPaths(needsExport); + + bInplace = all(exportRenames); + exportRoot = Load.ExportLocationDialog(rootDir, bInplace); + if ( isempty(exportRoot) ) + return; + end + + %% Copy all entries that don't need an export if we aren't doing inplace + copyPaths = {}; + if ( ~strcmp(exportRoot,rootDir) ) + copyPaths = subPaths(~needsExport); + end + + %% Copy all valid lever data to export directory + for i=1:length(copyPaths) + [subDir,filename] = fileparts(exportPaths{i}); + + exportDir = fullfile(exportRoot,subDir); + importDir = fullfile(rootDir,subDir); + if ( ~exist(exportDir,'dir') ) + mkdir(exportDir); + end + + copyfile(fullfile(importDir,[filename '*']),exportDir); + end + + %% Export or rename/copy + for i=1:length(exportPaths) + [subDir,filename,fext] = fileparts(exportPaths{i}); + + inputName = [filename fext]; + exportDir = fullfile(exportRoot,subDir); + importDir = fullfile(rootDir,subDir); + + if ( ~exportRenames(i) ) + Load.ExportImages(exportDir, importDir,inputName); + else + renameStruct = Load.BuildRenameStruct(inputName); + Load.RenameImages(exportDir, importDir,renameStruct,false); + end + end +end diff --git a/src/MATLAB/+Load/GetCellTypeStructure.m b/src/MATLAB/+Load/GetCellTypeStructure.m index e1f234a3faa4b5a55565fc9862a97f54bfdb8f31..3698078aee64dbcb7c690f9efe226b298ee1aa72 100644 --- a/src/MATLAB/+Load/GetCellTypeStructure.m +++ b/src/MATLAB/+Load/GetCellTypeStructure.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function typeParams = GetCellTypeStructure(cellType) cellTypes = Load.GetSupportedCellTypes(); diff --git a/src/MATLAB/+Load/GetSupportedCellTypes.m b/src/MATLAB/+Load/GetSupportedCellTypes.m index fbbbcf0f2cebda4029a948a86cd67cffd78b3265..4dd7b8017876b62a89fc05091055f96b951a1197 100644 --- a/src/MATLAB/+Load/GetSupportedCellTypes.m +++ b/src/MATLAB/+Load/GetSupportedCellTypes.m @@ -10,10 +10,36 @@ % % See also Segmentation.FrameSegmentor % + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function SupportedTypes = GetSupportedCellTypes() SupportedTypes = []; %% Adult neural progenitor cell segmentation algorithm + % the embryonic cell type has default settings for all parameters. override + % in custom segmentation as needed only. SupportedTypes = addCellType(SupportedTypes, 'Adult',... 'segRoutine',setAlgorithm(@Segmentation.FrameSegmentor_Adult, setParamValue('imageAlpha', 1.5)),... 'resegRoutine',setAlgorithm(@Segmentation.FrameSegmentor_Adult, setParamRange('imageAlpha', 1.0,0.5,5)),... @@ -30,7 +56,11 @@ function SupportedTypes = GetSupportedCellTypes() 'trackParams',struct('dMaxCenterOfMass',{80}, 'dMaxConnectComponentTracker',{40}),... 'leverParams',struct('timeResolution',{5}, 'maxPixelDistance',{80}, 'maxCenterOfMassDistance',{80}, 'dMaxConnectComponent',{40}),... 'channelParams',struct('primaryChannel',{1}, 'channelColor',{[1 1 1]}, 'channelFluor',{[false]})); - + %% Three level segmentation + SupportedTypes = addCellType(SupportedTypes, 'MultiThreshDark',... + 'segRoutine',setAlgorithm(@Segmentation.FrameSegmentor_MDK, setParamValue('imageAlpha', 1)),... + 'resegRoutine',setAlgorithm(@Segmentation.FrameSegmentor_MDK, setParamRange('imageAlpha', 1.0,.95,5)),... + 'splitParams',struct('useGMM',true)); % TODO: Move channel params and some lever params into metadata structure and parse directly from microscope data. end diff --git a/src/MATLAB/+Load/ImageExportDialog.m b/src/MATLAB/+Load/ImageExportDialog.m new file mode 100644 index 0000000000000000000000000000000000000000..3c4b5eba2a65dd98aa106915b5bef9b9d7c7d107 --- /dev/null +++ b/src/MATLAB/+Load/ImageExportDialog.m @@ -0,0 +1,44 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function jsonPath = ImageExportDialog(rootDir,filename) + [bNeedsExport,bWriteable,renameStruct] = Load.CheckExportImages(rootDir,filename); + if ( ~bNeedsExport ) + [~,chkName] = fileparts(filename); + jsonList = dir(fullfile(rootDir,[chkName '*.json'])); + jsonPath = fullfile(rootDir,jsonList(1).name); + return; + end + + exportDir = Load.ExportLocationDialog(rootDir, bWriteable); + if ( isempty(exportDir) ) + return; + end + + if ( isempty(renameStruct) ) + jsonPath = Load.ExportImages(exportDir, rootDir,filename); + else + jsonPath = Load.RenameImages(exportDir, rootDir, renameStruct); + end +end diff --git a/src/MATLAB/+Load/ImageLoadDialog.m b/src/MATLAB/+Load/ImageLoadDialog.m new file mode 100644 index 0000000000000000000000000000000000000000..c4669ca1a61439fd655f06530464bb2d1c8ce6b0 --- /dev/null +++ b/src/MATLAB/+Load/ImageLoadDialog.m @@ -0,0 +1,51 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function jsonPath = ImageLoadDialog(initialPath,promptTitle) + filterSpecs = {'*.json','LEVER Metadata (*.json)'; + '*.lif;*.lei','Leica LAS (*.lif,*.lei)'; + '*.czi;*.lsm;*.zvi','Zeiss (*.czi,*.lsm,*.zvi)'; + '*.tif;*.tiff','TIFF Images (*.tif,*.tiff)'; + '*.*','All Files (*.*)'}; + + jsonPath = ''; + + [fileName,rootDir,filterIndex] = uigetfile(filterSpecs,promptTitle,initialPath); + if (filterIndex==0) + return + end + + if ( filterIndex == 1 ) + jsonPath = fullfile(rootDir,fileName); + return + end + + [~,~,chkExt] = fileparts(fileName); + if ( filterIndex == length(filterSpecs) && strcmpi(chkExt,'.json') ) + jsonPath = fullfile(rootDir,fileName); + return; + end + + jsonPath = Load.ImageExportDialog(rootDir,fileName); +end diff --git a/src/MATLAB/+Load/InitializeCachedCosts.m b/src/MATLAB/+Load/InitializeCachedCosts.m index 8b524ada1c48257e8befd211c6fb1dc3fa1946f5..1f5f1687be6c084ff89be49b3150f2b786f89a95 100644 --- a/src/MATLAB/+Load/InitializeCachedCosts.m +++ b/src/MATLAB/+Load/InitializeCachedCosts.m @@ -1,6 +1,30 @@ % InitializeCachedCosts() % Initialize CachedCostMatrix from current Costs and GraphEdits +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function InitializeCachedCosts(bForceInitialize) global Costs GraphEdits CellHulls CachedCostMatrix CellFamilies diff --git a/src/MATLAB/+Load/InitializeConstants.m b/src/MATLAB/+Load/InitializeConstants.m index b574ff16991a760a87f7ffde9e908df90134d216..45d7927653ca2297cb5f287203997dd0c9c7b28a 100644 --- a/src/MATLAB/+Load/InitializeConstants.m +++ b/src/MATLAB/+Load/InitializeConstants.m @@ -3,10 +3,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by @@ -28,9 +28,6 @@ function InitializeConstants() %% Set all constants here global CONSTANTS - -Load.SetImageInfo(); - if (~isfield(CONSTANTS,'cellType') || isempty(CONSTANTS.cellType)) cellType = Load.QueryCellType(); Load.AddConstant('cellType',cellType,1); @@ -63,13 +60,13 @@ primaryChannel = typeParams.channelParams.primaryChannel; channelColor = typeParams.channelParams.channelColor; channelFluor = typeParams.channelParams.channelFluor; -numMissingChan = CONSTANTS.numChannels - length(channelFluor); +numMissingChan = Metadata.GetNumberOfChannels() - length(channelFluor); if ( numMissingChan > 0 ) channelColor = [channelColor; hsv(numMissingChan+2)]; channelFluor = [channelFluor false(1,numMissingChan)]; elseif ( numMissingChan < 0 ) - channelColor = channelColor(1:CONSTANTS.numChannels,:); - channelFluor = channelFluor(1:CONSTANTS.numChannels); + channelColor = channelColor(1:Metadata.GetNumberOfChannels(),:); + channelFluor = channelFluor(1:Metadata.GetNumberOfChannels()); end Load.AddConstant('primaryChannel', primaryChannel); diff --git a/src/MATLAB/+Load/OpenData.m b/src/MATLAB/+Load/OpenData.m index d1a9d1b91c9c1dfb458357ea77239eb1925e3f89..28fb9ac5365435d82c490caaa4f0677e50573363 100644 --- a/src/MATLAB/+Load/OpenData.m +++ b/src/MATLAB/+Load/OpenData.m @@ -7,10 +7,10 @@ % EW - Rewrite %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by @@ -31,9 +31,9 @@ function opened = OpenData() global Figures Colors CONSTANTS -softwareVersion = Helper.GetVersion(); +softwareVersion = Dev.GetVersion(); if(isempty(Figures)) - fprintf('LEVer ver %s\n***DO NOT DISTRIBUTE***\n\n', softwareVersion); + fprintf('%s\n***DO NOT DISTRIBUTE***\n\n', softwareVersion); end if(exist('ColorScheme.mat','file')) @@ -128,26 +128,43 @@ switch answer end Load.SaveSettings(settings); - Load.AddConstant('matFullFile', [settings.matFilePath settings.matFile], 1); - bQueryImageDir = false; - if ( ~isfield(CONSTANTS,'imageNamePattern') ) - bQueryImageDir = true; - elseif ( ~isfield(CONSTANTS,'primaryChannel') ) - [channelList, frameList] = Helper.GetImListInfo(CONSTANTS.rootImageFolder,CONSTANTS.imageNamePattern); - bQueryImageDir = isempty(frameList); - else - bQueryImageDir = isempty(Helper.LoadPrimaryIntensityImage(1)); + % Update imageData.DatasetName early enough to check for + % image/data match. + if ( isfield(CONSTANTS,'datasetName') ) + oldName = CONSTANTS.datasetName; + if ( oldName(end) == '_' ) + oldName = oldName(1:end-1); + end + + Load.AddConstant('imageData.DatasetName',oldName,true); end - if ( bQueryImageDir ) - if (~Helper.ImageFileDialog()) + imageData = MicroscopeData.ReadMetadataFile(fullfile(CONSTANTS.rootImageFolder, [Metadata.GetDatasetName() '.json'])); + if ( isempty(imageData) ) + tifList = dir(fullfile(CONSTANTS.rootImageFolder,'*.tif')); + if ( exist(CONSTANTS.rootImageFolder,'dir') && ~isempty(tifList) ) + % Try to export or rename old lever image data + metadataPath = Load.ImageExportDialog(CONSTANTS.rootImageFolder,tifList(1).name); + if ( isempty(metadataPath) ) + CONSTANTS = oldCONSTANTS; + return; + end + + imageData = MicroscopeData.ReadMetadataFile(metadataPath); + Metadata.SetMetadata(imageData); + + imageFolder = fileparts(metadataPath); + Load.AddConstant('rootImageFolder', imageFolder, 1); + elseif (~Helper.ImageFileDialog()) CONSTANTS = oldCONSTANTS; return end + else + Metadata.SetMetadata(imageData); end - + if(exist('objHulls','var')) errordlg('Data too old to run with this version of LEVer'); CONSTANTS = oldCONSTANTS; @@ -168,17 +185,20 @@ switch answer ovwAns = questdlg('Old file format detected! Update required. Would you like to save the updated file to a new location?', ... 'Verision Update', ... 'Save As...','Overwrite','Overwrite'); - + + bValidAns = false; % Handle response switch ovwAns case 'Save As...' - if ( ~UI.SaveDataAs(true) ) - warning(['File format must updated. Overwriting file: ' CONSTANTS.matFullFile]); - Helper.SaveLEVerState(CONSTANTS.matFullFile); - end + bValidAns = UI.SaveDataAs(true); case 'Overwrite' + bValidAns = true; Helper.SaveLEVerState(CONSTANTS.matFullFile); - end + end + + if ( ~bValidAns ) + warning('Proceeding without updating file, be sure to save before exiting LEVer!'); + end end UI.InitializeFigures(); diff --git a/src/MATLAB/+Load/QueryCellType.m b/src/MATLAB/+Load/QueryCellType.m index 04756feb80ff39ef331d23749e6d95a410085a1d..eef2e870c2234bf2fd615418185042b2a6c4e692 100644 --- a/src/MATLAB/+Load/QueryCellType.m +++ b/src/MATLAB/+Load/QueryCellType.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function cellType = QueryCellType() SupportedTypes = Load.GetSupportedCellTypes(); diff --git a/src/MATLAB/+Load/ReadSettings.m b/src/MATLAB/+Load/ReadSettings.m index 3246096c8340cb78e7231e6c69615c2d8395e928..0dc5e82482b05a0ec2a6b89a492fb9f35e369913 100644 --- a/src/MATLAB/+Load/ReadSettings.m +++ b/src/MATLAB/+Load/ReadSettings.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function settings = ReadSettings() settingsPath = 'LEVerSettings.mat'; if ( isdeployed() ) diff --git a/src/MATLAB/+Load/RemoveImagePixelsField.m b/src/MATLAB/+Load/RemoveImagePixelsField.m index 9fb0fed1d3bc5aa0d3826bb550e14324e2470533..b2019cc45491b3e9372c3508bbff1c6ff3631b2a 100644 --- a/src/MATLAB/+Load/RemoveImagePixelsField.m +++ b/src/MATLAB/+Load/RemoveImagePixelsField.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function RemoveImagePixelsField() global CellHulls diff --git a/src/MATLAB/+Load/RenameImages.m b/src/MATLAB/+Load/RenameImages.m new file mode 100644 index 0000000000000000000000000000000000000000..37fc2c922ce95d3e9e0be8b28abc30f3a779a6ca --- /dev/null +++ b/src/MATLAB/+Load/RenameImages.m @@ -0,0 +1,78 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function jsonPath = RenameImages(exportDir,inRoot, renameStruct, bCreateDatasetDir) + if ( ~exist('bCreateDatasetDir','var') ) + bCreateDatasetDir = true; + end + + fileOp = @(src,dst)(movefile(src,dst,'f')); + if ( ~strcmp(exportDir,inRoot) ) + fileOp = @(src,dst)(copyfile(src,dst,'f')); + + if ( bCreateDatasetDir ) + exportDir = fullfile(exportDir,renameStruct.datasetName); + end + end + % fileOp = @(src,dst)(fprintf('%s -> %s\n', src,dst)); + + if ( ~exist(exportDir,'dir') ) + mkdir(exportDir); + end + + flist = dir(fullfile(inRoot,renameStruct.dirBlob)); + nameList = {flist.name}.'; + + loadTok = regexp(nameList, renameStruct.loadPattern, 'tokens','once'); + + bValidParams = (renameStruct.paramOrder > 0); + paramIdx = find(bValidParams); + validOrder = paramIdx(renameStruct.paramOrder(bValidParams)); + + bValidNames = cellfun(@(x)(length(x)==nnz(bValidParams)), loadTok); + paramTok = vertcat(loadTok{bValidNames}); + + paramVals = ones(size(paramTok,1),length(renameStruct.paramOrder)); + paramVals(:,validOrder) = cellfun(@(x)(str2double(x)), paramTok); + + paramMin = min(paramVals,[],1); + paramOffset = 1 - paramMin; + + validNames = nameList(bValidNames); + for i=1:length(validNames) + paramCell = num2cell(paramVals(i,:)+paramOffset); + outName = sprintf(renameStruct.outPattern,paramCell{:}); + + if ( strcmp(outName,validNames{i}) ) + continue; + end + + fileOp(fullfile(inRoot,validNames{i}),fullfile(exportDir,outName)); + end + + imageData = MicroscopeData.MakeMetadataFromFolder(exportDir,renameStruct.datasetName); + MicroscopeData.CreateMetadata(exportDir,imageData,true); + + jsonPath = fullfile(exportDir,[renameStruct.datasetName '.json']); +end diff --git a/src/MATLAB/+Load/ReplaceConstant.m b/src/MATLAB/+Load/ReplaceConstant.m index f4222f30f003a95dab4985ec2944225ac5a37215..ce39111bd91d2ea8418bff4f00536991a70f3e91 100644 --- a/src/MATLAB/+Load/ReplaceConstant.m +++ b/src/MATLAB/+Load/ReplaceConstant.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function ReplaceConstant(curField, newField,newValue) global CONSTANTS @@ -8,6 +32,13 @@ function ReplaceConstant(curField, newField,newValue) constFields = fieldnames(CONSTANTS); curFieldIdx = find(strcmp(curField,constFields)); + newFieldIdx = find(strcmp(newField,constFields)); + if ( ~isempty(newFieldIdx) ) + warning(['CONSTANTS.' newField ' already exists, removing ''' curField '']); + CONSTANTS = rmfield(CONSTANTS, curField); + return; + end + newFieldIdx = find(strcmp(newField,constFields)); if ( ~isempty(newFieldIdx) ) constFields = constFields(setdiff(1:length(constFields),newFieldIdx)); diff --git a/src/MATLAB/+Load/SaveSettings.m b/src/MATLAB/+Load/SaveSettings.m index 215696ce5950630d0b8181a52851acad0eddf4bf..f2020a1dcb81f926abeb1085627677c1d61e934b 100644 --- a/src/MATLAB/+Load/SaveSettings.m +++ b/src/MATLAB/+Load/SaveSettings.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function SaveSettings(settings) save(settings.settingsPath, 'settings'); end diff --git a/src/MATLAB/+Load/SetImageInfo.m b/src/MATLAB/+Load/SetImageInfo.m index 1f78449da571393d998f859b9db36e2e55520235..392136c37c3adf129bc6b4e18d5c75565f2bb1a7 100644 --- a/src/MATLAB/+Load/SetImageInfo.m +++ b/src/MATLAB/+Load/SetImageInfo.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function SetImageInfo() global CONSTANTS [channelList, frameList] = Helper.GetImListInfo(CONSTANTS.rootImageFolder, CONSTANTS.imageNamePattern); diff --git a/src/MATLAB/+Load/SetWorkingDir.m b/src/MATLAB/+Load/SetWorkingDir.m index adc766c1145dfa37c48dd1864778b90e2b39997e..706ae5747e194b2f63e7c95808f3ced8beb8b471 100644 --- a/src/MATLAB/+Load/SetWorkingDir.m +++ b/src/MATLAB/+Load/SetWorkingDir.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function SetWorkingDir() userDir = getenv('USERPROFILE'); if ( isempty(userDir) ) diff --git a/src/MATLAB/+Load/UpdatePhenotypeInfo.m b/src/MATLAB/+Load/UpdatePhenotypeInfo.m index 0256ed7f06a1ecae4af49ca7984209aeb34711bd..794528441c0af1008599465e7cc22b62b690ac2e 100644 --- a/src/MATLAB/+Load/UpdatePhenotypeInfo.m +++ b/src/MATLAB/+Load/UpdatePhenotypeInfo.m @@ -3,10 +3,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Families/FindFamiliesAfter.m b/src/MATLAB/+Metadata/GetDatasetName.m similarity index 65% rename from src/MATLAB/+Families/FindFamiliesAfter.m rename to src/MATLAB/+Metadata/GetDatasetName.m index 807c8ba9bf08ce0798e99448782415ecd60e146d..5626abdd4835083d0ca5daf5e5b7d4454af8d5de 100644 --- a/src/MATLAB/+Families/FindFamiliesAfter.m +++ b/src/MATLAB/+Metadata/GetDatasetName.m @@ -1,12 +1,10 @@ -% families = FindFamiliesAfter(trackID) -% Find the set of families which start after the beginning of this track %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by @@ -24,10 +22,13 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -function families = FindFamiliesAfter(trackID) - global CellTracks CellFamilies +function datasetName = GetDatasetName() + global CONSTANTS - nefam = find(arrayfun(@(x)(~isempty(x.startTime)), CellFamilies)); + datasetName = ''; + if ( ~isfield(CONSTANTS,'imageData') ) + return; + end - families = nefam([CellFamilies(nefam).startTime] > CellTracks(trackID).startTime); -end \ No newline at end of file + datasetName = CONSTANTS.imageData.DatasetName; +end diff --git a/src/MATLAB/+Metadata/GetDimensions.m b/src/MATLAB/+Metadata/GetDimensions.m new file mode 100644 index 0000000000000000000000000000000000000000..19583804d2778422c2d4c03874861612957bd82d --- /dev/null +++ b/src/MATLAB/+Metadata/GetDimensions.m @@ -0,0 +1,48 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function dims = GetDimensions(dimOrder) + global CONSTANTS + + if ( ~exist('dimOrder','var') ) + dimOrder = 'xy'; + end + + dims = []; + if ( ~isfield(CONSTANTS,'imageData') ) + return; + end + + numDims = 3; + if ( CONSTANTS.imageData.Dimensions(3) == 1 ) + numDims = 2; + end + + selectedDims = 1:numDims; + if ( strcmpi(dimOrder,'rc') ) + selectedDims = Utils.SwapXY_RC(selectedDims); + end + + dims = CONSTANTS.imageData.Dimensions(selectedDims); +end diff --git a/src/MATLAB/+Metadata/GetImageInfo.m b/src/MATLAB/+Metadata/GetImageInfo.m new file mode 100644 index 0000000000000000000000000000000000000000..81275132878fc89a6cfba81905e3b0fa07d54eff --- /dev/null +++ b/src/MATLAB/+Metadata/GetImageInfo.m @@ -0,0 +1,34 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function imageData = GetImageInfo() + global CONSTANTS + + imageData = []; + if ( ~isfield(CONSTANTS,'imageData') ) + return; + end + + imageData = CONSTANTS.imageData; +end diff --git a/src/MATLAB/+Metadata/GetNumberOfChannels.m b/src/MATLAB/+Metadata/GetNumberOfChannels.m new file mode 100644 index 0000000000000000000000000000000000000000..f331fa0007f4a729537348e3ee34da2387448758 --- /dev/null +++ b/src/MATLAB/+Metadata/GetNumberOfChannels.m @@ -0,0 +1,34 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function numChannels = GetNumberOfChannels() + global CONSTANTS + + numChannels = 0; + if ( ~isfield(CONSTANTS,'imageData') ) + return; + end + + numChannels = CONSTANTS.imageData.NumberOfChannels; +end diff --git a/src/MATLAB/+Metadata/GetNumberOfFrames.m b/src/MATLAB/+Metadata/GetNumberOfFrames.m new file mode 100644 index 0000000000000000000000000000000000000000..f57e11e55868836522fcba9aff946bd00d7c0478 --- /dev/null +++ b/src/MATLAB/+Metadata/GetNumberOfFrames.m @@ -0,0 +1,34 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function numFrames = GetNumberOfFrames() + global CONSTANTS + + numFrames = 0; + if ( ~isfield(CONSTANTS,'imageData') ) + return; + end + + numFrames = CONSTANTS.imageData.NumberOfFrames; +end diff --git a/src/MATLAB/+Metadata/GetPixelSize.m b/src/MATLAB/+Metadata/GetPixelSize.m new file mode 100644 index 0000000000000000000000000000000000000000..b677f9024fe2b2b08b9da2e1381ceac2beb3e101 --- /dev/null +++ b/src/MATLAB/+Metadata/GetPixelSize.m @@ -0,0 +1,34 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function pixelSize = GetPixelSize() + global CONSTANTS + + pixelSize = 0; + if ( ~isfield(CONSTANTS,'imageData') ) + return; + end + + pixelSize = CONSTANTS.imageData.PixelPhysicalSize; +end diff --git a/src/MATLAB/+Metadata/SetMetadata.m b/src/MATLAB/+Metadata/SetMetadata.m new file mode 100644 index 0000000000000000000000000000000000000000..1d2d38c70df5eb5c12da03a3f896f24d2d69cb4f --- /dev/null +++ b/src/MATLAB/+Metadata/SetMetadata.m @@ -0,0 +1,29 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function SetMetadata(imageData) + global CONSTANTS + + CONSTANTS.imageData = imageData; +end \ No newline at end of file diff --git a/src/MATLAB/+MicroscopeData/+Helper/CreateUniqueWordedPath.m b/src/MATLAB/+MicroscopeData/+Helper/CreateUniqueWordedPath.m new file mode 100644 index 0000000000000000000000000000000000000000..80c66aa3ba2f292c38e7c5f95da703710b5387f8 --- /dev/null +++ b/src/MATLAB/+MicroscopeData/+Helper/CreateUniqueWordedPath.m @@ -0,0 +1,64 @@ +function newFilePath = CreateUniqueWordedPath(fPath) +%newFilePath = CreateUniqueWordedPath(fPath) +% Pass in a path with at least two directories with '\' seperating the +% direcories, and a new path will be generated that removes the words that +% are repeated. This forces the unique words closer to the file name or +% most deep directory. + +driveIdx = find(fPath==':',1,'first'); +if (~isempty(driveIdx)) + tmpPath = strtrim(MicroscopeData.Helper.SanitizeString(fPath(driveIdx+1:end))); + fPath = [fPath(1:driveIdx),tmpPath]; +else + fPath = strtrim(MicroscopeData.Helper.SanitizeString(fPath)); +end + +dirs = strsplit(fPath,'\'); + +newDirs = {}; +for i=1:length(dirs) + if (strcmp(dirs{i},'.')) + continue + end + if (strcmp(dirs{i},'..')) + newDirs = newDirs(1:end-1); + continue + end + if (isempty(newDirs)) + newDirs = dirs(i); + else + newDirs{end+1} = dirs{i}; + end +end + +dirs = newDirs; + +wordList = strsplit(dirs{end},' '); + +newFilePath = dirs{end}; + +for i=length(dirs)-1:-1:1 + curDir = dirs{i}; + curWords = strsplit(curDir,' '); + keepWords = true(1,length(curWords)); + for j=1:length(curWords) + if (any(strcmpi(curWords{j},wordList))) + keepWords(j) = false; + else + wordList{end+1} = curWords{j}; + end + end + + newDir = ''; + for j=1:length(keepWords) + if (keepWords(j)) + if (isempty(newDir)) + newDir = strtrim(curWords{j}); + else + newDir = sprintf('%s %s',newDir,strtrim(curWords{j})); + end + end + end + newFilePath = fullfile(newDir,newFilePath); +end +end diff --git a/src/MATLAB/+MicroscopeData/+Helper/GetPixelTypeTIF.m b/src/MATLAB/+MicroscopeData/+Helper/GetPixelTypeTIF.m new file mode 100644 index 0000000000000000000000000000000000000000..25247b9e1d4018aa97238dfa3930e8fe61a2fabf --- /dev/null +++ b/src/MATLAB/+MicroscopeData/+Helper/GetPixelTypeTIF.m @@ -0,0 +1,37 @@ +% [pixelType,dataTypeLookup] = GetPixelTypeTIF(tifFile) + +function [pixelType,imInfo] = GetPixelTypeTIF(tifFile) + pixelType = []; + + dataTypeLookup = {'uint8';'uint16';'uint32';'uint64'; + 'int8';'int16';'int32';'int64'; + 'single';'double'; + 'logical'}; + + dataTypeSize = [1;2;4;8; + 1;2;4;8; + 4;8; + 1]; + + dataTypeFormat = {'Unsigned integer';'Unsigned integer';'Unsigned integer';'Unsigned integer'; + 'Integer';'Integer';'Integer';'Integer'; + 'IEEE floating point';'IEEE floating point'; + 'Unsigned Integer'}; + + imInfo = imfinfo(tifFile,'tif'); + sampleFormat = 'Unsigned integer'; + if ( isfield(imInfo,'SampleFormat') ) + sampleFormat = imInfo.SampleFormat; + end + bitDepth = imInfo.BitDepth; + + bSizeMatch = (dataTypeSize == floor(bitDepth/8)); + bSampleMatch = strcmpi(sampleFormat,dataTypeFormat); + + formatIdx = find(bSizeMatch & bSampleMatch); + if ( isempty(formatIdx) ) + return; + end + + pixelType = dataTypeLookup{formatIdx}; +end diff --git a/src/MATLAB/+MicroscopeData/+Helper/ParseReaderInputs.m b/src/MATLAB/+MicroscopeData/+Helper/ParseReaderInputs.m new file mode 100644 index 0000000000000000000000000000000000000000..3e70080448e0f95ba717fd9cd8148fa7ab9b1eb8 --- /dev/null +++ b/src/MATLAB/+MicroscopeData/+Helper/ParseReaderInputs.m @@ -0,0 +1,43 @@ +function argStruct = ParseReaderInputs(varargin) + dataTypeLookup = {'uint8';'uint16';'uint32';'uint64'; + 'int8';'int16';'int32';'int64'; + 'single';'double'; + 'logical'}; + + dataTypeSize = [1;2;4;8; + 1;2;4;8; + 4;8; + 1]; + + p = inputParser(); + p.StructExpand = false; + + % This is ridiculous, but we assume that the optional path is specified if + % length(varargin) is odd + if ( mod(length(varargin),2) == 1 ) + addOptional(p,'path','', @ischar); + else + addParameter(p,'path','', @ischar); + end + + addParameter(p,'imageData',[], @(x)(validOrEmpty(@isstruct,x))); + + addParameter(p,'chanList',[], @(x)(validOrEmpty(@isvector,x))); + addParameter(p,'timeRange',[], @(x)(validOrEmpty(@(y)(numel(y)==2),x))); + addParameter(p,'roi_xyz',[], @(x)(validOrEmpty(@(y)(all(size(y)==[2,3])),x))); + + addParameter(p,'outType',[], @(x)(validOrEmpty(@(y)(any(strcmp(y,dataTypeLookup))),x))); + addParameter(p,'normalize',false,@islogical); + + addParameter(p,'verbose',false, @islogical); + addParameter(p,'prompt',[], @(x)(validOrEmpty(@islogical,x))); + addParameter(p,'promptTitle','', @ischar); + + parse(p,varargin{:}); + argStruct = p.Results; +end + +% Inputs are valid if they are empty or if they satisfy their validity function +function bValid = validOrEmpty(validFunc,x) + bValid = (isempty(x) || validFunc(x)); +end diff --git a/src/MATLAB/+MicroscopeData/+Helper/SanitizeString.m b/src/MATLAB/+MicroscopeData/+Helper/SanitizeString.m new file mode 100644 index 0000000000000000000000000000000000000000..43140f0e05b44030b01a2b61922b48b60c6ff507 --- /dev/null +++ b/src/MATLAB/+MicroscopeData/+Helper/SanitizeString.m @@ -0,0 +1,24 @@ +function [ str ] = SanitizeString( str ) +%SANITIZESTRING Summary of this function goes here +% Detailed explanation goes here +str = strrep(str, '!', ''); +str = strrep(str, '*', ''); +str = strrep(str, '''', ''); +str = strrep(str, '(', ''); +str = strrep(str, ')', ''); +str = strrep(str, ';', ''); +str = strrep(str, ':', ''); +str = strrep(str, '@', ''); +str = strrep(str, '&', ''); +str = strrep(str, '=', ''); +str = strrep(str, '+', ''); +str = strrep(str, '$', ''); +str = strrep(str, ',', ''); +str = strrep(str, '/', ''); +str = strrep(str, '?', ''); +str = strrep(str, '#', ''); +str = strrep(str, '[', ''); +str = strrep(str, ']', ''); + +str = strtrim(str); +end diff --git a/src/MATLAB/+MicroscopeData/+Original/+BioFormats/CheckJarPath.m b/src/MATLAB/+MicroscopeData/+Original/+BioFormats/CheckJarPath.m new file mode 100644 index 0000000000000000000000000000000000000000..42ae0e4ee556b23c135446e4ecbc4693ab8ad5d8 --- /dev/null +++ b/src/MATLAB/+MicroscopeData/+Original/+BioFormats/CheckJarPath.m @@ -0,0 +1,24 @@ +function CheckJarPath() +%CHECKJARPATH Summary of this function goes here +% Detailed explanation goes here + +%% ensure that the bioformats jar file is on the path +dynamicPaths = javaclasspath('-dynamic'); +bfIsLoaded = false; +if (~isempty(dynamicPaths)) + for i=1:length(dynamicPaths) + [~,name,~] = fileparts(dynamicPaths{i}); + if (strcmpi('bioformats_package',name)) + bfIsLoaded = true; + break + end + end +end + +if (~bfIsLoaded) + curPath = mfilename('fullpath'); + [pathstr,~,~] = fileparts(curPath); + javaaddpath(fullfile(pathstr,'bioformats_package.jar'),'-end'); +end +end + diff --git a/src/MATLAB/+MicroscopeData/+Original/+BioFormats/CheckJavaMemory.m b/src/MATLAB/+MicroscopeData/+Original/+BioFormats/CheckJavaMemory.m new file mode 100644 index 0000000000000000000000000000000000000000..92a2223060a7723abedfcaf22a295809a3ecb124 --- /dev/null +++ b/src/MATLAB/+MicroscopeData/+Original/+BioFormats/CheckJavaMemory.m @@ -0,0 +1,54 @@ +function [] = bfCheckJavaMemory(varargin) +% bfCheckJavaMemory warn if too little memory is allocated to Java +% +% SYNOPSIS bfCheckJavaMemory() +% +% Input +% +% minMemory - (Optional) The minimum suggested memory setting in MB. +% Default: 512 +% +% Output +% +% A warning message is printed if too little memory is allocated. + +% OME Bio-Formats package for reading and converting biological file formats. +% +% Copyright (C) 2014 Open Microscopy Environment: +% - Board of Regents of the University of Wisconsin-Madison +% - Glencoe Software, Inc. +% - University of Dundee +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as +% published by the Free Software Foundation, either version 2 of the +% License, or (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License along +% with this program; if not, write to the Free Software Foundation, Inc., +% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +runtime = java.lang.Runtime.getRuntime(); +maxMemory = runtime.maxMemory() / (1024 * 1024); + +ip = inputParser; +ip.addOptional('minMemory', 512, @isscalar); +ip.parse(varargin{:}); +minMemory = ip.Results.minMemory; + +warningID = 'BF:lowJavaMemory'; + +if maxMemory < minMemory - 64 + warning_msg = [... + '*** Insufficient memory detected. ***\n'... + '*** %dm found ***\n'... + '*** %dm or greater is recommended ***\n'... + '*** See http://www.mathworks.com/matlabcentral/answers/92813 ***\n'... + '*** for instructions on increasing memory allocation. ***\n']; + warning(warningID, warning_msg, round(maxMemory), minMemory); +end diff --git a/src/MATLAB/+MicroscopeData/+Original/+BioFormats/GetImages.m b/src/MATLAB/+MicroscopeData/+Original/+BioFormats/GetImages.m new file mode 100644 index 0000000000000000000000000000000000000000..4ab4ffa76d764824df513dd1e15d88472cff579d --- /dev/null +++ b/src/MATLAB/+MicroscopeData/+Original/+BioFormats/GetImages.m @@ -0,0 +1,117 @@ +function [ seriesImages ] = GetImages( bfReader, seriesNum ) +%GETIMAGES Summary of this function goes here +% Detailed explanation goes here + +numSeries = bfReader.getSeriesCount(); + +omeMetadata = bfReader.getMetadataStore(); +prgs = Utils.CmdlnProgress(1,true); + +if (exist('seriesNum','var') && ~isempty(seriesNum) && numSeries>=seriesNum) + seriesImages = readSeriesImage(bfReader, seriesNum-1, omeMetadata, true, prgs); +else + if (bfReader.getSeriesCount()>1) + prgs.SetMaxIterations(bfReader.getSeriesCount()); + + onlyOneSeries = false; + else + prgs.SetMaxIterations(numSeries); + onlyOneSeries = true; + end + + for series=0:numSeries-1; + im = readSeriesImage(bfReader, series, omeMetadata, onlyOneSeries, prgs); + + seriesImages{series+1} = im; + + prgs.PrintProgress(series+1); + end +end + +prgs.ClearProgress(); +end + +function im = readSeriesImage(bfReader, series, omeMetadata, onlyOneSeries, prgs) + bfReader.setSeries(series); + + imageData = []; + + imageData.Dimensions = [safeGetValue(omeMetadata.getPixelsSizeX(series));... + safeGetValue(omeMetadata.getPixelsSizeY(series));... + safeGetValue(omeMetadata.getPixelsSizeZ(series))]; + + imageData.NumberOfChannels = omeMetadata.getChannelCount(series); + imageData.NumberOfFrames = safeGetValue(omeMetadata.getPixelsSizeT(series)); + + clss = char(omeMetadata.getPixelsType(series)); + if (strcmpi(clss,'float')) + clss = 'single'; + end + im = zeros([Utils.SwapXY_RC(imageData.Dimensions'),imageData.NumberOfChannels,imageData.NumberOfFrames],clss); + + order = char(omeMetadata.getPixelsDimensionOrder(series)); + + if (onlyOneSeries) + prgs.SetMaxIterations(imageData.NumberOfFrames*imageData.NumberOfChannels*imageData.Dimensions(3)); + i = 1; + end + + for t=1:imageData.NumberOfFrames + for z=1:imageData.Dimensions(3) + for c=1:imageData.NumberOfChannels + ind = calcPlaneInd(order,z,c,t,imageData); + im(:,:,z,c,t) = MicroscopeData.Original.BioFormats.GetPlane(bfReader,ind); + + if (onlyOneSeries) + prgs.PrintProgress(i); + i = i+1; + end + end + end + end +end + +function ind = calcPlaneInd(order,z,c,t,imageData) +switch order(3) + case 'Z' + ind = z-1; + mul = imageData.Dimensions(3); + case 'C' + ind = c-1; + mul = imageData.NumberOfChannels; + case 'T' + ind = t-1; + mul = imageData.NumberOfFrames; +end + +switch order(4) + case 'Z' + ind = ind + (z-1)*mul; + mul = imageData.Dimensions(3)*mul; + case 'C' + ind = ind + (c-1)*mul; + mul = imageData.NumberOfChannels*mul; + case 'T' + ind = ind + (t-1)*mul; + mul = imageData.NumberOfFrames*mul; +end + +switch order(5) + case 'Z' + ind = ind + (z-1)*mul; + case 'C' + ind = ind + (c-1)*mul; + case 'T' + ind = ind + (t-1)*mul; +end + +ind = ind +1; +end + +function val = safeGetValue(varIn) +if (isempty(varIn)) + val = 0; + return +end +val = varIn.getValue(); +end diff --git a/src/MATLAB/+MicroscopeData/+Original/+BioFormats/GetMetadata.m b/src/MATLAB/+MicroscopeData/+Original/+BioFormats/GetMetadata.m new file mode 100644 index 0000000000000000000000000000000000000000..decc62a844aa6268d813654caf1ad3b0808abf02 --- /dev/null +++ b/src/MATLAB/+MicroscopeData/+Original/+BioFormats/GetMetadata.m @@ -0,0 +1,171 @@ +function [seriesMetadata, varargout] = GetMetadata( bfReader, datasetExt ) +%GETMETADATA Summary of this function goes here +% Detailed explanation goes here + +seriesMetadata = {}; + +if (~exist('datasetExt','var') || isempty(datasetExt)) + datasetExt = ''; +end + +orgMetadata = bfReader.getSeriesMetadata(); +omeMetadata = bfReader.getMetadataStore(); + +onlyOneSeries = true; +if (bfReader.getSeriesCount()>1) + prgs = Utils.CmdlnProgress(bfReader.getSeriesCount(),true); + onlyOneSeries = false; +end + +for series=0:bfReader.getSeriesCount()-1; + bfReader.setSeries(series); + + imageData = []; + + [~,imageData.DatasetName,~] = fileparts(char(omeMetadata.getImageName(series))); + + imageData.Dimensions = [safeGetValue(omeMetadata.getPixelsSizeX(series)),... + safeGetValue(omeMetadata.getPixelsSizeY(series)),... + safeGetValue(omeMetadata.getPixelsSizeZ(series))]; + + imageData.NumberOfChannels = omeMetadata.getChannelCount(series); + imageData.NumberOfFrames = safeGetValue(omeMetadata.getPixelsSizeT(series)); + + xPixelPhysicalSize = safeGetValue(omeMetadata.getPixelsPhysicalSizeX(series)); + if xPixelPhysicalSize==0 + xPixelPhysicalSize = 1; + end + + yPixelPhysicalSize = safeGetValue(omeMetadata.getPixelsPhysicalSizeY(series)); + if yPixelPhysicalSize==0 + yPixelPhysicalSize = 1; + end + + zPixelPhysicalSize = safeGetValue(omeMetadata.getPixelsPhysicalSizeZ(series)); + if zPixelPhysicalSize==0 + zPixelPhysicalSize = 1; + end + + imageData.PixelPhysicalSize = [xPixelPhysicalSize, yPixelPhysicalSize, zPixelPhysicalSize]; + + if (strcmp(datasetExt,'.czi')) + imageData.Position = [orgMetadata.get('Global Information|Image|S|Scene|Position|X #1'),... + orgMetadata.get('Global Information|Image|S|Scene|Position|Y #1'),... + orgMetadata.get('Global Information|Image|S|Scene|Position|Z #1')]; + elseif (omeMetadata.getPlaneCount(series)>0) + imageData.Position = [double(omeMetadata.getPlanePositionX(series,0)),... + double(omeMetadata.getPlanePositionY(series,0)),... + double(omeMetadata.getPlanePositionZ(series,0))]; + end + + imageData.ChannelNames = cell(imageData.NumberOfChannels,1); + for c=1:imageData.NumberOfChannels + colr = char(omeMetadata.getChannelName(series,c-1)); + + if (isempty(colr)) + colr = sprintf('Channel:%d',c); + end + + imageData.ChannelNames{c} = colr; + end + + imageData.StartCaptureDate = safeGetValue(omeMetadata.getImageAcquisitionDate(series)); + ind = strfind(imageData.StartCaptureDate,'T'); + if (~isempty(ind)) + imageData.StartCaptureDate(ind) = ' '; + end + + imageData.TimeStampDelta = 0; + + order = char(omeMetadata.getPixelsDimensionOrder(series)); + + if (onlyOneSeries) + prgs = Utils.CmdlnProgress(imageData.NumberOfFrames*imageData.NumberOfChannels*imageData.Dimensions(3),true); + i = 1; + end + + for t=1:imageData.NumberOfFrames + for z=1:imageData.Dimensions(3) + for c=1:imageData.NumberOfChannels + ind = calcPlaneInd(order,z,c,t,imageData); + try + delta = omeMetadata.getPlaneDeltaT(series,ind-1); + catch er + delta = []; + end + if (~isempty(delta)) + imageData.TimeStampDelta(z,c,t) = delta.floatValue; + end + if (onlyOneSeries) + prgs.PrintProgress(i); + i = i+1; + end + end + end + end + + if (size(imageData.TimeStampDelta,1)~=imageData.Dimensions(3) ||... + size(imageData.TimeStampDelta,2)~=imageData.NumberOfChannels || ... + size(imageData.TimeStampDelta,3)~=imageData.NumberOfFrames) + imageData = rmfield(imageData,'TimeStampDelta'); + end + + seriesMetadata{series+1} = imageData; + + prgs.PrintProgress(series+1); +end + +prgs.ClearProgress(); + +if (nargout>1) + varargout{1} = omeMetadata; +end +if (nargout>2) + varargout{2} = orgMetadata; +end +end + +function ind = calcPlaneInd(order,z,c,t,imageData) +switch order(3) + case 'Z' + ind = z-1; + mul = imageData.Dimensions(3); + case 'C' + ind = c-1; + mul = imageData.NumberOfChannels; + case 'T' + ind = t-1; + mul = imageData.NumberOfFrames; +end + +switch order(4) + case 'Z' + ind = ind + (z-1)*mul; + mul = imageData.Dimensions(3)*mul; + case 'C' + ind = ind + (c-1)*mul; + mul = imageData.NumberOfChannels*mul; + case 'T' + ind = ind + (t-1)*mul; + mul = imageData.NumberOfFrames*mul; +end + +switch order(5) + case 'Z' + ind = ind + (z-1)*mul; + case 'C' + ind = ind + (c-1)*mul; + case 'T' + ind = ind + (t-1)*mul; +end + +ind = ind +1; +end + +function val = safeGetValue(varIn) +if (isempty(varIn)) + val = 0; + return +end +val = varIn.getValue(); +end diff --git a/src/MATLAB/+MicroscopeData/+Original/+BioFormats/GetPlane.m b/src/MATLAB/+MicroscopeData/+Original/+BioFormats/GetPlane.m new file mode 100644 index 0000000000000000000000000000000000000000..8794cc475b4a03b382b45c0a2dbbeb966be96e0e --- /dev/null +++ b/src/MATLAB/+MicroscopeData/+Original/+BioFormats/GetPlane.m @@ -0,0 +1,110 @@ +function I = GetPlane(r, iPlane, varargin) +% BFGETPLANE Retrieve the plane data from a reader using Bio-Formats +% +% I = bfGetPlane(r, iPlane) returns a specified plane from the input +% format reader. The index specifying the plane to retrieve should be +% contained between 1 and the number of planes for the series. +% +% I = bfGetPlane(r, iPlane, x, y, width, height) only returns the tile +% which origin is specified by (x, y) and dimensions are specified by +% (width, height). +% +% Examples +% +% I = bfGetPlane(r, 1) % First plane of the series +% I = bfGetPlane(r, r.getImageCount()) % Last plane of the series +% I = bfGetPlane(r, 1, 1, 1, 20, 20) % 20x20 tile originated at (0, 0) +% +% See also: BFGETREADER + +% OME Bio-Formats package for reading and converting biological file formats. +% +% Copyright (C) 2012 - 2014 Open Microscopy Environment: +% - Board of Regents of the University of Wisconsin-Madison +% - Glencoe Software, Inc. +% - University of Dundee +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as +% published by the Free Software Foundation, either version 2 of the +% License, or (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License along +% with this program; if not, write to the Free Software Foundation, Inc., +% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +% Input check +ip = inputParser; +ip.addRequired('r', @(x) isa(x, 'loci.formats.IFormatReader') && ... + ~isempty(x.getCurrentFile())); +ip.parse(r); + +% Plane check +isValidPlane = @(x) isscalar(x) && ismember(x, 1 : r.getImageCount()); +ip.addRequired('iPlane', isValidPlane); + +% Optional tile arguments check +isValidX = @(x) isscalar(x) && ismember(x, 1 : r.getSizeX()); +isValidY = @(x) isscalar(x) && ismember(x, 1 : r.getSizeY()); +ip.addOptional('x', 1, isValidX); +ip.addOptional('y', 1, isValidY); +ip.addOptional('width', r.getSizeX(), isValidX); +ip.addOptional('height', r.getSizeY(), isValidY); +ip.parse(r, iPlane, varargin{:}); + +% Additional check for tile size +assert(ip.Results.x - 1 + ip.Results.width <= r.getSizeX(),... + 'MATLAB:InputParser:ArgumentFailedValidation',... + 'Invalid tile size'); +assert(ip.Results.y - 1 + ip.Results.height <= r.getSizeY(),... + 'MATLAB:InputParser:ArgumentFailedValidation',... + 'Invalid tile size'); + +% Get pixel type +pixelType = r.getPixelType(); +bpp = loci.formats.FormatTools.getBytesPerPixel(pixelType); +fp = loci.formats.FormatTools.isFloatingPoint(pixelType); +sgn = loci.formats.FormatTools.isSigned(pixelType); +little = r.isLittleEndian(); + +plane = r.openBytes(iPlane - 1, ip.Results.x - 1, ip.Results.y - 1, ... + ip.Results.width, ip.Results.height); + +% convert byte array to MATLAB image +if sgn + % can get the data directly to a matrix + I = loci.common.DataTools.makeDataArray2D(plane, ... + bpp, fp, little, ip.Results.height); +else + % get the data as a vector, either because makeDataArray2D + % is not available, or we need a vector for typecast + I = loci.common.DataTools.makeDataArray(plane, ... + bpp, fp, little); +end + +% Java does not have explicitly unsigned data types; +% hence, we must inform MATLAB when the data is unsigned +if ~sgn + % NB: arr will always be a vector here + switch class(I) + case 'int8' + I = typecast(I, 'uint8'); + case 'int16' + I = typecast(I, 'uint16'); + case 'int32' + I = typecast(I, 'uint32'); + case 'int64' + I = typecast(I, 'uint64'); + end +end + +if isvector(I) + % convert results from vector to matrix + shape = [ip.Results.width ip.Results.height]; + I = reshape(I, shape)'; +end diff --git a/src/MATLAB/+MicroscopeData/+Original/+BioFormats/GetReader.m b/src/MATLAB/+MicroscopeData/+Original/+BioFormats/GetReader.m new file mode 100644 index 0000000000000000000000000000000000000000..80d105a429965219a77bda69109675aa5b95a359 --- /dev/null +++ b/src/MATLAB/+MicroscopeData/+Original/+BioFormats/GetReader.m @@ -0,0 +1,22 @@ +function [ bfReader ] = GetReader( fullPath ) +%GETSERIESDATA Summary of this function goes here +% Detailed explanation goes here + +%% read data using bioformats +MicroscopeData.Original.BioFormats.CheckJavaMemory(); +loci.common.DebugTools.enableLogging('INFO'); + +bfReader = loci.formats.ChannelFiller(); +bfReader = loci.formats.ChannelSeparator(bfReader); +OMEXMLService = loci.formats.services.OMEXMLServiceImpl(); +bfReader.setMetadataStore(OMEXMLService.createOMEXMLMetadata()); + +try + bfReader.setId(fullPath); +catch err + warning(err.message); + bfReader = []; +end + +end + diff --git a/src/MATLAB/+MicroscopeData/+Original/CanExportFormat.m b/src/MATLAB/+MicroscopeData/+Original/CanExportFormat.m new file mode 100644 index 0000000000000000000000000000000000000000..6ad68667b7a1b8a6012d8322de3dc7b913dc4fb8 --- /dev/null +++ b/src/MATLAB/+MicroscopeData/+Original/CanExportFormat.m @@ -0,0 +1,31 @@ +% [bCanExport,guessType] = CanExportFormat(filenames) +% +% bCanExport - True for all filenames that match a bioformats supported extension +% guessType - Cell arry of strings representing a guess at the associated file type + +function [bCanExport,guessType] = CanExportFormat(filenames) + exportFormats = MicroscopeData.Original.GetSupportedFormats(); + formatIdx = arrayfun(@(x,y)(repmat(y,length(x{1}),1)),exportFormats(:,2),(1:size(exportFormats,1)).', 'UniformOutput',false); + + allExt = vertcat(exportFormats{:,2}); + allIdx = vertcat(formatIdx{:}); + + [chkExt,idxExt] = unique(allExt); + chkIdx = allIdx(idxExt); + + % Can use strncmpi to quickly check extension matches on reversed filenames + revExt = cellfun(@(x)(x(end:-1:1)),chkExt, 'UniformOutput',false); + revNames = cellfun(@(x)(x(end:-1:1)),filenames, 'UniformOutput',false); + + bCanExport = false(length(filenames),1); + guessType = cell(length(filenames),1); + + matchExt = cellfun(@(x)(find(strncmpi(revNames,x,length(x)))),revExt,'UniformOutput',false); + matchFormatIdx = arrayfun(@(x,y)(repmat(y,length(x{1}),1)),matchExt,chkIdx,'UniformOutput',false); + + matchedIdx = vertcat(matchExt{:}); + matchedFormats = vertcat(matchFormatIdx{:}); + + bCanExport(matchedIdx) = true; + guessType(matchedIdx) = exportFormats(matchedFormats,1); +end diff --git a/src/MATLAB/+MicroscopeData/+Original/Convert2Tiffs.m b/src/MATLAB/+MicroscopeData/+Original/Convert2Tiffs.m new file mode 100644 index 0000000000000000000000000000000000000000..b3863dfb33c7f16166d2e484f03195b4f515ddd2 --- /dev/null +++ b/src/MATLAB/+MicroscopeData/+Original/Convert2Tiffs.m @@ -0,0 +1,75 @@ +function [ im, imD ] = Convert2Tiffs( imDir, imName, outDir, overwrite, quiet, cleanName) +%[ im, imD ] = Convert2Tiffs( imDir, imName, outDir, overwrite, quiet, cleanName) + +im = []; +imD = []; + +if (~exist('overwrite','var') || isempty(overwrite)) + overwrite = false; +end +if (~exist('quiet','var') || isempty(quiet)) + quiet = false; +end + +if (~exist('imDir','var') || isempty(imDir)) + imDir = '.'; +end + +if (~exist('imName','var') || isempty(imName)) + [imName,imDir,~] = uigetfile('*.*','Choose a Microscope File to Convert'); + if (imName==0) + warning('Nothing read'); + return + end +end + +if (~exist('outDir','var') || isempty(outDir)) + outDir = uigetdir('.','Choose a folder to output to'); + if (outDir==0) + warning('No where to write!'); + return + end +end + +if (~exist('cleanName','var') || isempty(cleanName)) + cleanName = false; +end + +if (cleanName) + outDir = MicroscopeData.Helper.CreateUniqueWordedPath(outDir); +end + +[~,name,~] = fileparts(imName); + +if (~exist(fullfile(outDir,name),'dir') || overwrite) + + imD = MicroscopeData.Original.ReadMetadata(imDir,imName); + if ( isempty(imD) ) + return; + end + + if (length(imD)>1) + [~,datasetName,~] = fileparts(imName); + if (cleanName) + datasetName = MicroscopeData.Helper.SanitizeString(datasetName); + end + outDir = fullfile(outDir,datasetName); + end + + % Don't overwrite images that already exist + if (exist(fullfile(outDir,imD{1}.DatasetName),'dir') && ~overwrite) + return; + end + + im = MicroscopeData.Original.ReadImages(imDir,imName); + for i=1:length(imD) + if (cleanName) + imD{i}.DatasetName = MicroscopeData.Helper.SanitizeString(imD{i}.DatasetName); + end + if (~exist(fullfile(outDir,imD{i}.DatasetName),'dir') || overwrite) + MicroscopeData.Writer(im{i},fullfile(outDir,imD{i}.DatasetName),imD{i},[],[],[],quiet); + end + end +end +end + diff --git a/src/MATLAB/+MicroscopeData/+Original/GetSupportedFormats.m b/src/MATLAB/+MicroscopeData/+Original/GetSupportedFormats.m new file mode 100644 index 0000000000000000000000000000000000000000..aef1a75495a2ff02f6f7858499b0c87a6923fa47 --- /dev/null +++ b/src/MATLAB/+MicroscopeData/+Original/GetSupportedFormats.m @@ -0,0 +1,294 @@ +% This is just a big list of names and associated extensions supported by bioformats; based on their website: +% https://www.openmicroscopy.org/site/support/bio-formats5.1/supported-formats.html. + +function formats = GetSupportedFormats() + extensions = {{'.gif'}; + {'.jpg'}; + {'.jp2'}; + {'.png'}; + {'.txt'}; + {'.tif';'.tiff'}; + {'.bmp'}; + + {'.sld'}; + {'.tif'}; + {'.aim'}; + {'.al3d'}; + {'.gel'}; + {'.am';'.amiramesh';'.grey';'.hx';'.labels'}; + {'.cif'}; + {'.img';'.hdr'}; + {'.png'}; + {'.afi';'.svs'}; + {'.svs'}; + {'.htd';'.pnl'}; + {'.avi'}; + {'.arf'}; + {'.exp';'.tif'}; + {'.sdt'}; + {'.1sc'}; + {'.pic';'.raw';'.xml'}; + {'.scn'}; + {'.ims'}; + { }; + {'.img'}; + {'.cr2';'.crw'}; + {'.ch5'}; + {'.c01';'.dib'}; + {'.vsi'}; + {'.xml';'.tif'}; + {'.dv';'.r3d'}; + {'.dcm';'.dicom'}; + {'.v'}; + {'.eps';'.epsi';'.ps'}; + {'.flex';'.mea';'.res'}; + {'.img'}; + {'.tiff'}; + {'.fits'}; + {'.dm3';'.dm4'}; + {'.dm2'}; + {'.naf'}; + {'.his'}; + {'.ndpi';'.ndpis'}; + {'.vms'}; + {'.txt';'.tif';'.bmp';'.jpg'}; + {'.i2i'}; + {'.ics';'.ids'}; + {'.fff'}; + {'.seq'}; + {'.ipw'}; + {'.hed';'.img'}; + {'.mod'}; + {'.liff'}; + {'.raw'}; + {'.tif'}; + {'.obf';'.msr'}; + {'.xdce';'.tif'}; + {'.frm'}; + {'.inr'}; + {'.hdr'}; + {'.ipl'}; + {'.ipm'}; + {'.dat';'.img';'.par'}; + {'.jpk'}; + {'.jpx'}; + {'.xv'}; + {'.bip'}; + {'.fli'}; + {'.msr'}; + {'.lei';'.tif'}; + {'.lif'}; + {'.scn'}; + {'.sxm'}; + {'.l2d';'.tif';'.scn'}; + {'.lim'}; + {'.tiff'}; + {'.stk';'.nd'}; + {'.tif'}; + {'.tif';'.txt';'.xml'}; + {'.mnc'}; + {'.mrw'}; + {'.mng'}; + {'.stp'}; + {'.mrc'}; + {'.nef';'.tif'}; + {'.img';'.hdr'}; + {'.tiff'}; + {'.tiff'}; + {'.nd2'}; + {'.nrrd';'.nhdr';'.raw';'.txt'}; + {'.apl';'.mtb';'.tnb';'.tif';'.obsep'}; + {'.oib';'.oif'}; + {'.tif'}; + {'.xml';'.dat';'.tif'}; + {'.tiff'}; + {'.ome.tiff'}; + {'.ome';'.ome.xml'}; + {'.top'}; + {'.pcoraw';'.rec'}; + {'.pcx'}; + {'.pds'}; + {'.im3'}; + {'.tiff';'.xml'}; + {'.tif';'.2';'.3';'.4'}; + {'.pbm';'.pgm';'.ppm'}; + {'.psd'}; + {'.tif';'.tiff'}; + {'.bin'}; + {'.pict'}; + {'.tif';'.xml';'.cfg'}; + {'.afm'}; + {'.mov'}; + {'.sm2';'.sm3'}; + { }; + {'.xqd';'.xqf'}; + {'.cxd'}; + {'.tiff'}; + { }; + {'.spi';'.stk'}; + {'.tga'}; + {'.vws'}; + {'.tfr';'.ffr';'.zfr';'.zfp';'.2fl'}; + {'.tif';'.sld';'.jpg'}; + {'.pr3'}; + {'.dat';'.hdr'}; + {'.fdf'}; + {'.hdf'}; + {'.dti'}; + {'.xys';'.html'}; + {'.mvd2'}; + {'.acff'}; + {'.wat'}; + {'.wlz'}; + {'.lms'}; + {'.xml';'.tiff'}; + {'.zvi'}; + {'.czi'}; + {'.lsm';'.mdb'}}; + + names = {'GIF (Graphics Interchange Format)'; + 'JPEG'; + 'JPEG 2000'; + 'PNG (Portable Network Graphics)'; + 'Text'; + 'TIFF (Tagged Image File Format)'; + 'Windows Bitmap'; + + '3i SlideBook'; + 'Andor Bio-Imaging Division (ABD) TIFF'; + 'AIM'; + 'Alicona 3D'; + 'Amersham Biosciences Gel'; + 'Amira Mesh'; + 'Amnis FlowSight'; + 'Analyze 7.5'; + 'Animated PNG'; + 'Aperio AFI'; + 'Aperio SVS TIFF'; + 'Applied Precision CellWorX'; + 'AVI (Audio Video Interleave)'; + 'Axon Raw Format'; + 'BD Pathway'; + 'Becker & Hickl SPCImage'; + 'Bio-Rad Gel'; + 'Bio-Rad PIC'; + 'Bio-Rad SCN'; + 'Bitplane Imaris'; + 'Bruker MRI'; + 'Burleigh'; + 'Canon DNG'; + 'CellH5'; + 'Cellomics'; + 'cellSens VSI'; + 'CellVoyager'; + 'DeltaVision'; + 'DICOM'; + 'ECAT7'; + 'EPS (Encapsulated PostScript)'; + 'Evotec/PerkinElmer Opera Flex'; + 'FEI'; + 'FEI TIFF'; + 'FITS (Flexible Image Transport System)'; + 'Gatan Digital Micrograph'; + 'Gatan Digital Micrograph 2'; + 'Hamamatsu Aquacosmos NAF'; + 'Hamamatsu HIS'; + 'Hamamatsu ndpi'; + 'Hamamatsu VMS'; + 'Hitachi S-4800'; + 'I2I'; + 'ICS (Image Cytometry Standard)'; + 'Imacon'; + 'ImagePro Sequence'; + 'ImagePro Workspace'; + 'IMAGIC'; + 'IMOD'; + 'Improvision Openlab LIFF'; + 'Improvision Openlab Raw'; + 'Improvision TIFF'; + 'Imspector OBF'; + 'InCell 1000/2000'; + 'InCell 3000'; + 'INR'; + 'Inveon'; + 'IPLab'; + 'IVision'; + 'JEOL'; + 'JPK'; + 'JPX'; + 'Khoros VIFF (Visualization Image File Format) Bitmap'; + 'Kodak BIP'; + 'Lambert Instruments FLIM'; + 'LaVision Imspector'; + 'Leica LCS LEI'; + 'Leica LAS AF LIF (Leica Image File Format)'; + 'Leica SCN'; + 'LEO'; + 'Li-Cor L2D'; + 'LIM (Laboratory Imaging/Nikon)'; + 'MetaMorph 7.5 TIFF'; + 'MetaMorph Stack (STK)'; + 'MIAS (Maia Scientific)'; + 'Micro-Manager'; + 'MINC MRI'; + 'Minolta MRW'; + 'MNG (Multiple-image Network Graphics)'; + 'Molecular Imaging'; + 'MRC (Medical Research Council)'; + 'NEF (Nikon Electronic Format)'; + 'NIfTI'; + 'Nikon Elements TIFF'; + 'Nikon EZ-C1 TIFF'; + 'Nikon NIS-Elements ND2'; + 'NRRD (Nearly Raw Raster Data)'; + 'Olympus CellR/APL'; + 'Olympus FluoView FV1000'; + 'Olympus FluoView TIFF'; + 'Olympus ScanR'; + 'Olympus SIS TIFF'; + 'OME-TIFF'; + 'OME-XML'; + 'Oxford Instruments'; + 'PCORAW'; + 'PCX (PC Paintbrush)'; + 'Perkin Elmer Densitometer'; + 'PerkinElmer Nuance'; + 'PerkinElmer Operetta'; + 'PerkinElmer UltraVIEW'; + 'Portable Any Map'; + 'Adobe Photoshop PSD'; + 'Photoshop TIFF'; + 'PicoQuant Bin'; + 'PICT (Macintosh Picture)'; + 'Prairie Technologies TIFF'; + 'Quesant'; + 'QuickTime Movie'; + 'RHK'; + 'SBIG'; + 'Seiko'; + 'SimplePCI & HCImage'; + 'SimplePCI & HCImage TIFF'; + 'SM Camera'; + 'SPIDER'; + 'Targa'; + 'TillPhotonics TillVision'; + 'Topometrix'; + 'Trestle'; + 'UBM'; + 'Unisoku'; + 'Varian FDF'; + 'Veeco AFM'; + 'VG SAM'; + 'VisiTech XYS'; + 'Volocity'; + 'Volocity Library Clipping'; + 'WA-TOP'; + 'Woolz'; + 'Zeiss Axio CSM'; + 'Zeiss AxioVision TIFF'; + 'Zeiss AxioVision ZVI (Zeiss Vision Image)'; + 'Zeiss CZI'; + 'Zeiss LSM (Laser Scanning Microscope) 510/710'}; + + formats = [names extensions]; +end diff --git a/src/MATLAB/+MicroscopeData/+Original/ReadImages.m b/src/MATLAB/+MicroscopeData/+Original/ReadImages.m new file mode 100644 index 0000000000000000000000000000000000000000..70732a9ceafa2e4164e09e56fce0c206bc236db1 --- /dev/null +++ b/src/MATLAB/+MicroscopeData/+Original/ReadImages.m @@ -0,0 +1,37 @@ +function [ seriesImages ] = ReadImages( dirIn, fileNameIn, seriesNum ) +%READIMAGES [seriesImages] = ReadImages(dirIn, fileNameIn) +%This function will read in data generated by a microscope and return the +%image data along with the metadata associated with each of the images. +% dirIn and fileNameIn are both optional arguments where if either are +% empty, a get file dialog will appear. +% +% Microscope data may contain more than one set of images thus the output +% of this function will each be cells. Each cell will contain the image +% data for each microscope run. There are more than one "series" typically +% when there are multiple stage positions that are being captured over an +% experiment. + +%% get file and properties +if (~exist('dirIn','var') || ~exist('fileNameIn','var') || isempty(dirIn) || isempty(fileNameIn)) + [fileNameIn,dirIn,~] = uigetfile('*.*','Select Microscope Data'); + if (fileNameIn==0) + warning('No images read'); + return + end +end + +if (~exist('seriesNum','var')) + seriesNum = []; +end + +[datasetPath,datasetName,datasetExt] = fileparts(fullfile(dirIn,fileNameIn)); + +MicroscopeData.Original.BioFormats.CheckJarPath(); + +bfReader = MicroscopeData.Original.BioFormats.GetReader(fullfile(datasetPath,[datasetName,datasetExt])); + +seriesImages = MicroscopeData.Original.BioFormats.GetImages(bfReader,seriesNum); + +bfReader.close(); +end + diff --git a/src/MATLAB/+MicroscopeData/+Original/ReadMetadata.m b/src/MATLAB/+MicroscopeData/+Original/ReadMetadata.m new file mode 100644 index 0000000000000000000000000000000000000000..bebfdb2e1b8aeb0f05acef01b3975c05b26036ce --- /dev/null +++ b/src/MATLAB/+MicroscopeData/+Original/ReadMetadata.m @@ -0,0 +1,46 @@ +function [ seriesMetaData, varargout ] = ReadMetadata( dirIn, fileNameIn ) +%READMETADATA [seriesMetadata] = ReadData(dirIn, fileNameIn) +%This function will read in data generated by a microscope and return the +%image data along with the metadata associated with each of the images. +% dirIn and fileNameIn are both optional arguments where if either are +% empty, a get file dialog will appear. +% +% Microscope data may contain more than one set of images thus the output +% of this function will each be cells. Each cell will contain the associated +% metadata for each microscope run. There are more than one "series" +% typically when there are multiple stage positions that are being captured +% over an experiment. + +%% get file and properties +if (~exist('dirIn','var') || ~exist('fileNameIn','var') || isempty(dirIn) || isempty(fileNameIn)) + [fileNameIn,dirIn,~] = uigetfile('*.*','Select Microscope Data'); + if (fileNameIn==0) + warning('No images read'); + return + end +end + +[datasetPath,datasetName,datasetExt] = fileparts(fullfile(dirIn,fileNameIn)); + +MicroscopeData.Original.BioFormats.CheckJarPath(); + +bfReader = MicroscopeData.Original.BioFormats.GetReader(fullfile(datasetPath,[datasetName,datasetExt])); + +if (~isempty(bfReader)) + [seriesMetaData, omeMetaData, orgMetaData] = MicroscopeData.Original.BioFormats.GetMetadata(bfReader,datasetExt); + bfReader.close(); +else + seriesMetaData = []; + omeMetaData = []; + orgMetaData = []; +end + +if (nargout>1) + varargout{1} = omeMetaData; +end +if (nargout>2) + varargout{2} = orgMetaData; +end + +end + diff --git a/src/MATLAB/+MicroscopeData/CreateMetadata.m b/src/MATLAB/+MicroscopeData/CreateMetadata.m new file mode 100644 index 0000000000000000000000000000000000000000..d163e93a166e0052a4085b7a0b95734930d9c240 --- /dev/null +++ b/src/MATLAB/+MicroscopeData/CreateMetadata.m @@ -0,0 +1,43 @@ +function CreateMetadata(root,imageData,quiet) + +if (isempty(root)) + if (isfield(imageData,'imageDir')) + openDir = imageData.imageDir; + else + openDir = []; + end + root = uigetdir(openDir,'Directory to Place Metadata'); + if (root==0) + return + end +end + +if (~exist(root,'dir')) + mkdir(root); +end + +if (~exist('quiet','var') || isempty(quiet)) + quiet = 0; +end + +fileName = fullfile(root,[imageData.DatasetName '.json']); + +if (~quiet) + fprintf('Creating Metadata %s...',fileName); +end + +if (isfield(imageData,'imageDir')) + imageData = rmfield(imageData,'imageDir'); +end + +jsonMetadata = Utils.CreateJSON(imageData); +fileHandle = fopen(fileName,'wt'); + +fwrite(fileHandle, jsonMetadata, 'char'); + +fclose(fileHandle); + +if (~quiet) + fprintf('Done\n'); +end +end \ No newline at end of file diff --git a/src/MATLAB/+MicroscopeData/GetEmptyMetadata.m b/src/MATLAB/+MicroscopeData/GetEmptyMetadata.m new file mode 100644 index 0000000000000000000000000000000000000000..5431d4e2aa83307b2f50041d123431f479bbe18c --- /dev/null +++ b/src/MATLAB/+MicroscopeData/GetEmptyMetadata.m @@ -0,0 +1,21 @@ +function imageData = GetEmptyMetadata() +imageData = struct('DatasetName',{''},... + 'Dimensions',{[0,0,0]},... + 'NumberOfChannels',{0},... + 'NumberOfFrames',{0},... + 'PixelPhysicalSize',{[1,1,1]},... + 'ChannelNames',{''},... + 'StartCaptureDate',{},... + 'ChannelColors',{[]},... + 'PixelFormat',{''}); + +imageData(1).DatasetName = ''; +imageData.Dimensions = [0,0,0]; +imageData.NumberOfChannels = 0; +imageData.NumberOfFrames = 0; +imageData.PixelPhysicalSize = [0,0,0]; +imageData.ChannelNames = ''; +imageData.StartCaptureDate = ''; +imageData.ChannelColors = []; +imageData.PixelFormat = 'none'; +end \ No newline at end of file diff --git a/src/MATLAB/+MicroscopeData/MakeMetadataFromFolder.m b/src/MATLAB/+MicroscopeData/MakeMetadataFromFolder.m new file mode 100644 index 0000000000000000000000000000000000000000..5bff00d2817e5fb6e9fd82e664ca101adfa98999 --- /dev/null +++ b/src/MATLAB/+MicroscopeData/MakeMetadataFromFolder.m @@ -0,0 +1,42 @@ +function imageData = MakeMetadataFromFolder(rootDir,datasetName) + imageData = MicroscopeData.GetEmptyMetadata(); + + tifList = dir(fullfile(rootDir,[datasetName '*.tif'])); + nameList = {tifList.name}.'; + + prefixStr = regexptranslate('escape',datasetName); + + tokMatch = regexp(nameList, [prefixStr '_c(\d+)_t(\d+)_z(\d+)\.tif'], 'tokens','once'); + + bValidTok = cellfun(@(x)(length(x)==3), tokMatch); + chkTok = vertcat(tokMatch{bValidTok}); + + ctzVals = cellfun(@(x)(str2double(x)), chkTok); + + ctzMax = max(ctzVals,[],1); + + chkFilename = sprintf('%s_c%02d_t%04d_z%04d.tif', datasetName,1,1,1); + imInfo = imfinfo(fullfile(rootDir,chkFilename)); + + imageData.DatasetName = datasetName; + imageData.Dimensions = [imInfo.Width, imInfo.Height, ctzMax(3)]; + imageData.NumberOfChannels = ctzMax(1); + imageData.NumberOfFrames = ctzMax(2); + imageData.PixelPhysicalSize = [1,1,1]; + + colors = [1,0,0;... + 0,1,0;... + 0,0,1;... + 0,1,1;... + 1,0,1;... + 1,1,0]; + + for c=1:imageData.NumberOfChannels + imageData.ChannelNames = [imageData.ChannelNames; {sprintf('Channel %d',c)}]; + colidx = mod(c,size(colors,1)); + imageData.ChannelColors = vertcat(imageData.ChannelColors,colors(colidx,:)); + end + + imageData.StartCaptureDate = datestr(now,'yyyy-mm-dd HH:MM:SS'); + imageData.PixelFormat = MicroscopeData.Helper.GetPixelTypeTIF(fullfile(rootDir,chkFilename)); +end diff --git a/src/MATLAB/+MicroscopeData/ReadMetadata.m b/src/MATLAB/+MicroscopeData/ReadMetadata.m new file mode 100644 index 0000000000000000000000000000000000000000..708499193262c55613445264ce5c89a3e23bfdfa --- /dev/null +++ b/src/MATLAB/+MicroscopeData/ReadMetadata.m @@ -0,0 +1,46 @@ +function [imageData,jsonDir,jsonFile] = ReadMetadata(root,forcePrompt,promptTitle) + +imageData = []; +jsonDir = []; +jsonFile = []; + +if ( ~exist('promptTitle','var') ) + promptTitle = []; +end + +if (~exist('forcePrompt','var')) + forcePrompt = []; +end + +if (~exist('root','var') || isempty(root)) + root = ''; +end + +if (~isempty(root) && ~any(strcmp(root(end),{'\','/'})) && exist(root,'dir')) + root = fullfile(root, filesep); +end + +% This is to help when the filename might have '.' whithin them +% TODO rework this logic %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +if (exist([root,'.json'],'file')) + root = [root,'.json']; +end +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +bAlwaysPrompt = (~isempty(forcePrompt) && forcePrompt); +if ( ~bAlwaysPrompt ) + [imageData,jsonDir,jsonFile] = MicroscopeData.ReadMetadataFile(root); +end + +bNeedData = (isempty(forcePrompt) && isempty(imageData)); +if ( bAlwaysPrompt || bNeedData ) + [fileName,rootDir,filterIndex] = uigetfile({'*.json','Metadata files (*.json)';'*.*','All Files (*.*)'},promptTitle,root); + if (filterIndex==0) + return + end + + root = fullfile(rootDir,fileName); + [imageData,jsonDir,jsonFile] = MicroscopeData.ReadMetadataFile(root); +end + +end diff --git a/src/MATLAB/+MicroscopeData/ReadMetadataFile.m b/src/MATLAB/+MicroscopeData/ReadMetadataFile.m new file mode 100644 index 0000000000000000000000000000000000000000..19c3b5fc2358b368d6b5f668fc683fa3de098479 --- /dev/null +++ b/src/MATLAB/+MicroscopeData/ReadMetadataFile.m @@ -0,0 +1,64 @@ +function [imageData,jsonDir,jsonFile] = ReadMetadataFile(metadataPath) + imageData = []; + jsonDir = []; + jsonFile = []; + + if ( isempty(metadataPath) ) + metadataPath = ''; + end + + chkPath = findValidJSON(metadataPath); + if ( isempty(chkPath) ) + return; + end + + fileHandle = fopen(chkPath); + + jsonData = fread(fileHandle,'*char').'; + imageData = Utils.ParseJSON(jsonData); + + fclose(fileHandle); + + [rootDir,fileName] = fileparts(chkPath); + + jsonDir = rootDir; + jsonFile = [fileName '.json']; + + imageData.imageDir = jsonDir; +end + +function jsonPath = findValidJSON(chkPath) + jsonPath = []; + + [rootDir,fileName,ext] = fileparts(chkPath); + if ( ~isempty(ext) ) + if ( ~strcmpi(ext,'.json') ) + return; + end + chkPath = fullfile(rootDir,[fileName,'.json']); + elseif (~isempty(fileName)) + % case root has a file name + if (~exist(fullfile(rootDir,[fileName,'.json']),'file')) + return; + end + chkPath = fullfile(rootDir,[fileName,'.json']); + elseif (~isempty(rootDir)) + % case root is a path (e.g. \ terminated) + jsonList = dir(fullfile(rootDir,'*.json')); + if (isempty(jsonList)) + return; + end + chkPath = fullfile(rootDir,jsonList(1).name); + end + + [~,~,ext] = fileparts(chkPath); + if ( ~strcmpi(ext,'.json') ) + return; + end + + if (~exist(chkPath,'file')) + return + end + + jsonPath = chkPath; +end diff --git a/src/MATLAB/+MicroscopeData/Reader.m b/src/MATLAB/+MicroscopeData/Reader.m new file mode 100644 index 0000000000000000000000000000000000000000..abafe06ba52e612c88a0e13efd75e934c17b3476 --- /dev/null +++ b/src/MATLAB/+MicroscopeData/Reader.m @@ -0,0 +1,62 @@ +% [IM, IMAGEDATA] = MicroscopeData.Reader([path], varargin) +% +% Optional Parameters (Key,Value pairs): +% +% imageData - Input metadata, if specified, the optional path argument is ignored +% chanList - List of channels to read +% timeRange - Range min and max times to read +% roi_xyz - x,y,z min and max roi to read +% outType - Desired output type, conversion is applied if different from image +% normalize - Normalize images on [0,1] per frame before conersion to output type +% verbose - Display verbose output and timing information +% prompt - False to completely disable prompts, true to force prompt, leave unspecified or empty for default prompt behavior +% promptTitle - Open dialog title in the case that prompting is required + +function [im, imD] = Reader(varargin) +im = []; +imD = []; + +dataTypeLookup = {'uint8';'uint16';'uint32';'uint64'; + 'int8';'int16';'int32';'int64'; + 'single';'double'; + 'logical'}; + +args = MicroscopeData.Helper.ParseReaderInputs(varargin{:}); + +loadPath = ''; +if ( ~isempty(args.imageData) ) + loadPath = args.imageData.imageDir; +elseif ( ~isempty(args.path) ) + loadPath = args.path; +end + +if ( args.prompt ) + imD = MicroscopeData.ReadMetadata(loadPath,args.prompt,args.promptTitle); +elseif ( isempty(args.imageData) ) + imD = MicroscopeData.ReadMetadata(loadPath,args.prompt,args.promptTitle); +else + imD = args.imageData; +end + +if (isempty(imD)) + warning('No image read!'); + return +end + +imPath = imD.imageDir; +hdf5File = fullfile(imPath,[imD.DatasetName '.h5']); +if ( exist(hdf5File,'file') ) + [im,imD] = MicroscopeData.ReaderH5('imageData',imD, 'chanList',args.chanList, 'timeRange',args.timeRange, 'roi_xyz',args.roi_xyz,... + 'outType',args.outType, 'normalize',args.normalize, 'verbose',args.verbose, 'prompt',false); + return; +end + +tifFile = fullfile(imPath,sprintf('%s_c%02d_t%04d_z%04d.tif',imD.DatasetName,1,1,1)); +if ( exist(tifFile,'file') ) + [im,imD] = MicroscopeData.ReaderTIF('imageData',imD, 'chanList',args.chanList, 'timeRange',args.timeRange, 'roi_xyz',args.roi_xyz,... + 'outType',args.outType, 'normalize',args.normalize, 'verbose',args.verbose, 'prompt',false); + return; +end + +warning('No supported image type found!'); +end diff --git a/src/MATLAB/+MicroscopeData/ReaderH5.m b/src/MATLAB/+MicroscopeData/ReaderH5.m new file mode 100644 index 0000000000000000000000000000000000000000..54a6227016c043339967af3c17cbae517867db57 --- /dev/null +++ b/src/MATLAB/+MicroscopeData/ReaderH5.m @@ -0,0 +1,141 @@ +% [IM, IMAGEDATA] = MicroscopeData.Sandbox.ReaderH5([path], varargin) +% +% Optional Parameters (Key,Value pairs): +% +% imageData - Input metadata, if specified, the optional path argument is ignored +% chanList - List of channels to read +% timeRange - Range min and max times to read +% roi_xyz - x,y,z min and max roi to read +% outType - Desired output type, conversion is applied if different from image +% normalize - Normalize images on [0,1] per frame before conersion to output type +% verbose - Display verbose output and timing information +% prompt - False to completely disable prompts, true to force prompt, leave unspecified or empty for default prompt behavior +% promptTitle - Open dialog title in the case that prompting is required + +function [im, imD] = ReaderH5(varargin) +im = []; + +dataTypeLookup = {'uint8';'uint16';'uint32';'uint64'; + 'int8';'int16';'int32';'int64'; + 'single';'double'; + 'logical'}; + +dataTypeSize = [1;2;4;8; + 1;2;4;8; + 4;8; + 1]; + +args = MicroscopeData.Helper.ParseReaderInputs(varargin{:}); + +loadPath = ''; +if ( ~isempty(args.imageData) ) + loadPath = args.imageData.imageDir; +elseif ( ~isempty(args.path) ) + loadPath = args.path; +end + +if ( args.prompt ) + imD = MicroscopeData.ReadMetadata(loadPath,args.prompt,args.promptTitle); +elseif ( isempty(args.imageData) ) + imD = MicroscopeData.ReadMetadata(loadPath,args.prompt,args.promptTitle); +else + imD = args.imageData; +end + +imPath = imD.imageDir; + +if (isempty(args.chanList)) + args.chanList = 1:imD.NumberOfChannels; +end + +if (isempty(args.timeRange)) + args.timeRange = [1 imD.NumberOfFrames]; +end + +if (isempty(args.roi_xyz)) + args.roi_xyz = [1 1 1; imD.Dimensions]; +end + +if (~exist(fullfile(imPath,[imD.DatasetName '.h5']),'file')) + warning('No image to read!'); + return +end + +inType = class(h5read(fullfile(imPath,[imD.DatasetName '.h5']),'/Data',[1 1 1 1 1],[1 1 1 1 1])); +inIdx = find(strcmp(inType,dataTypeLookup)); +if ( ~isempty(inIdx) ) + inBytes = dataTypeSize(inIdx); +else + error('Unsupported image type!'); +end + +if (~isfield(imD,'PixelFormat')) + imD.PixelFormat = inType; +end + +if ( isempty(args.outType) ) + if (strcmp(imD.PixelFormat,'logical')) + args.outType = 'logical'; + else + args.outType = inType; + end +elseif ( ~any(strcmp(args.outType,dataTypeLookup)) ) + error('Unsupported output type!'); +end + +outIdx = find(strcmp(args.outType,dataTypeLookup)); +if ( ~isempty(outIdx) ) + outBytes = dataTypeSize(outIdx); +end + +convert = ~strcmpi(inType,args.outType) || args.normalize; +imSize = [diff(Utils.SwapXY_RC(args.roi_xyz),1)+1,length(args.chanList),(args.timeRange(2)-args.timeRange(1)+1)]; +if (~strcmpi(args.outType,'logical')) + im = zeros(imSize, args.outType); +else + im = false(imSize); +end + +if ( args.verbose ) + orgSize = [imD.Dimensions(1),imD.Dimensions(2),imD.Dimensions(3),imD.NumberOfChannels,imD.NumberOfFrames]; + fprintf('Reading (%d,%d,%d,%d,%d) %s %5.2fMB --> Into (%d,%d,%d,%d,%d) %s %5.2fMB,',... + orgSize(2),orgSize(1),orgSize(3),orgSize(4),orgSize(5),inType,... + (prod(orgSize)*inBytes)/(1024*1024),... + imSize(1),imSize(2),imSize(3),imSize(4),imSize(5),args.outType,... + (prod(imSize)*outBytes)/(1024*1024)); +end + +tic +if ( convert ) + for c=1:length(args.chanList) + for t=1:imSize(5) + tempIm = h5read(fullfile(imPath,[imD.DatasetName '.h5']),'/Data', [Utils.SwapXY_RC(args.roi_xyz(1,:)) args.chanList(c) t+args.timeRange(1)-1], [imSize(1:3) 1 1]); + im(:,:,:,c,t) = ImUtils.ConvertType(tempIm,args.outType,args.normalize); + end + end + + clear tempIm; +else + for c=1:length(args.chanList) + im(:,:,:,c,:) = h5read(fullfile(imPath,[imD.DatasetName '.h5']),'/Data', [Utils.SwapXY_RC(args.roi_xyz(1,:)) args.chanList(c) args.timeRange(1)], [imSize(1:3) 1 imSize(5)]); + end +end +if (args.verbose) + fprintf(' took:%s\n',Utils.PrintTime(toc)); +end + +imD.Dimensions = Utils.SwapXY_RC(imSize(1:3)); +imD.NumberOfChannels = size(im,4); +imD.NumberOfFrames = size(im,5); + +if (isfield(imD,'ChannelNames') && ~isempty(imD.ChannelNames)) + imD.ChannelNames = imD.ChannelNames(args.chanList)'; +else + imD.ChannelNames = {}; +end +if (isfield(imD,'ChannelColors') && ~isempty(imD.ChannelColors)) + imD.ChannelColors = imD.ChannelColors(args.chanList,:); +else + imD.ChannelColors = []; +end +end diff --git a/src/MATLAB/+MicroscopeData/ReaderTIF.m b/src/MATLAB/+MicroscopeData/ReaderTIF.m new file mode 100644 index 0000000000000000000000000000000000000000..8141f486e07bb4d1ab1f7c40d20f400e3c6aa3fc --- /dev/null +++ b/src/MATLAB/+MicroscopeData/ReaderTIF.m @@ -0,0 +1,175 @@ +% [IM, IMAGEDATA] = MicroscopeData.Reader([path], varargin) +% +% Optional Parameters (Key,Value pairs): +% +% imageData - Input metadata, if specified, the optional path argument is ignored +% chanList - List of channels to read +% timeRange - Range min and max times to read +% roi_xyz - x,y,z min and max roi to read +% outType - Desired output type, conversion is applied if different from image +% normalize - Normalize images on [0,1] per frame before conersion to output type +% verbose - Display verbose output and timing information +% prompt - False to completely disable prompts, true to force prompt, leave unspecified or empty for default prompt behavior +% promptTitle - Open dialog title in the case that prompting is required + +function [im, imD] = ReaderTIF(varargin) +im = []; + +dataTypeLookup = {'uint8';'uint16';'uint32';'uint64'; + 'int8';'int16';'int32';'int64'; + 'single';'double'; + 'logical'}; + +dataTypeSize = [1;2;4;8; + 1;2;4;8; + 4;8; + 1]; + +args = MicroscopeData.Helper.ParseReaderInputs(varargin{:}); + +loadPath = ''; +if ( ~isempty(args.imageData) ) + loadPath = args.imageData.imageDir; +elseif ( ~isempty(args.path) ) + loadPath = args.path; +end + +if ( args.prompt ) + imD = MicroscopeData.ReadMetadata(loadPath,args.prompt,args.promptTitle); +elseif ( isempty(args.imageData) ) + imD = MicroscopeData.ReadMetadata(loadPath,args.prompt,args.promptTitle); +else + imD = args.imageData; +end + +if (isempty(imD)) + warning('No image read!'); + return +end + +imPath = imD.imageDir; + +if (isempty(args.chanList)) + args.chanList = 1:imD.NumberOfChannels; +end + +if (isempty(args.timeRange)) + args.timeRange = [1 imD.NumberOfFrames]; +end + +if (isempty(args.roi_xyz)) + args.roi_xyz = [1 1 1; imD.Dimensions]; +end + +if (isempty(args.normalize)) + args.normalize = false; +end + +if (~exist(fullfile(imPath,sprintf('%s_c%02d_t%04d_z%04d.tif',imD.DatasetName,1,1,1)),'file')) + warning('No image to read!'); + return +end + +useROI = (nnz(args.roi_xyz(:,1:2) ~= [1 1;imD.Dimensions(1:2)]) > 0); + +chkFilename = fullfile(imPath,sprintf('%s_c%02d_t%04d_z%04d.tif',imD.DatasetName,1,1,1)); +inType = MicroscopeData.Helper.GetPixelTypeTIF(chkFilename); +inIdx = find(strcmp(inType,dataTypeLookup)); +if ( ~isempty(inIdx) ) + inBytes = dataTypeSize(inIdx); +else + error('Unsupported image type!'); +end + +if (~isfield(imD,'PixelFormat')) + imD.PixelFormat = inType; +end + +if ( isempty(args.outType) ) + if (strcmp(imD.PixelFormat,'logical')) + args.outType = 'logical'; + else + args.outType = inType; + end +elseif ( ~any(strcmp(args.outType,dataTypeLookup)) ) + error('Unsupported output type!'); +end + +outIdx = find(strcmp(args.outType,dataTypeLookup)); +if ( ~isempty(outIdx) ) + outBytes = dataTypeSize(outIdx); +end + +convert = ~strcmpi(inType,args.outType) || args.normalize; +imSize = [diff(Utils.SwapXY_RC(args.roi_xyz),1)+1,length(args.chanList),(args.timeRange(2)-args.timeRange(1)+1)]; +if (~strcmpi(args.outType,'logical')) + im = zeros(imSize, args.outType); +else + im = false(imSize); +end + +if ( args.verbose ) + orgSize = [imD.Dimensions(1),imD.Dimensions(2),imD.Dimensions(3),imD.NumberOfChannels,imD.NumberOfFrames]; + fprintf('Reading (%d,%d,%d,%d,%d) %s %5.2fMB --> Into (%d,%d,%d,%d,%d) %s %5.2fMB,',... + orgSize(1),orgSize(2),orgSize(3),orgSize(4),orgSize(5),inType,... + (prod(orgSize)*inBytes)/(1024*1024),... + imSize(1),imSize(2),imSize(3),imSize(4),imSize(5),args.outType,... + (prod(imSize)*outBytes)/(1024*1024)); +end + +if ( args.verbose ) + iter = imSize(5)*length(args.chanList)*imSize(3); + cp = Utils.CmdlnProgress(iter,true,sprintf('Reading %s...',imD.DatasetName)); + i=1; +end + +tic +for t=1:imSize(5) + timeVal = t+args.timeRange(1)-1; + for c=1:length(args.chanList) + for z=1:imSize(3) + zVal = z+args.roi_xyz(1,3)-1; + + tifName = fullfile(imPath,sprintf('%s_c%02d_t%04d_z%04d.tif',imD.DatasetName,args.chanList(c),timeVal,zVal)); + if (convert || useROI) + tempIm(:,:,z) = imread(tifName,'TIF'); + else + im(:,:,z,c,t) = imread(tifName,'TIF'); + end + + if ( args.verbose ) + cp.PrintProgress(i); + i = i+1; + end + end + + if (convert) + im(:,:,:,c,t) = ImUtils.ConvertType(... + tempIm(args.roi_xyz(1,2):args.roi_xyz(2,2),args.roi_xyz(1,1):args.roi_xyz(2,1),:),... + args.outType,args.normalize); + elseif (useROI) + im(:,:,:,c,t) = tempIm(args.roi_xyz(1,2):args.roi_xyz(2,2),args.roi_xyz(1,1):args.roi_xyz(2,1),:); + end + end +end + +if ( args.verbose ) + cp.ClearProgress(true); + fprintf(' took:%s\n',Utils.PrintTime(toc)); +end + +imD.Dimensions = Utils.SwapXY_RC(imSize(1:3)); +imD.NumberOfChannels = size(im,4); +imD.NumberOfFrames = size(im,5); + +if (isfield(imD,'ChannelNames') && ~isempty(imD.ChannelNames)) + imD.ChannelNames = imD.ChannelNames(args.chanList)'; +else + imD.ChannelNames = {}; +end +if (isfield(imD,'ChannelColors') && ~isempty(imD.ChannelColors)) + imD.ChannelColors = imD.ChannelColors(args.chanList,:); +else + imD.ChannelColors = []; +end +end diff --git a/src/MATLAB/+MicroscopeData/Writer.m b/src/MATLAB/+MicroscopeData/Writer.m new file mode 100644 index 0000000000000000000000000000000000000000..a92373d112b18ce3f5cf365aec09100039c6a08f --- /dev/null +++ b/src/MATLAB/+MicroscopeData/Writer.m @@ -0,0 +1,192 @@ +% TIFFWRITER(IM, PREFIX, IMAGEDATA, TIMELIST, CHANLIST, ZLIST, QUIET) +% TIMELIST, CHANLIST, and ZLIST are optional; pass in empty [] for the +% arguments that come prior to the one you would like to populate. +% +% IM = the image data to write. Assumes a 5-D image in the format +% (X,Y,Z,channel,time). If the image already exists and TIMELIST, CHANLIST, +% and ZLIST are populated with less then the whole image, the existing +% image is updated. If the file does not exist and the image data doesn't +% fill the whole image, the rest will be filled in with black (zeros) +% frames. +% +% PREFIX = filepath in the format ('c:\path\FilePrefix') unless there is no +% imagedata in which case it should be ('c:\path) +% IMAGEDATA = metadata that will be written to accompany the image. If you +% want this generated from the image data only, this paramater should be +% just a string representing the dataset name. See PREFIX above in such +% case. +% TIMELIST = a list of frames that the fifth dimention represents +% CHANLIST = the channels that the input image represents +% ZLIST = the z slices that the input image represents +% QUITE = suppress printing out progress + +function Writer(im, outDir, imageData, timeList, chanList, zList, quiet) +if (exist('tifflib') ~= 3) + tifflibLocation = which('/private/tifflib'); + if (isempty(tifflibLocation)) + error('tifflib does not exits on this machine!'); + end + copyfile(tifflibLocation,'.'); +end + +if (~exist('quiet','var') || isempty(quiet)) + quiet = 0; +end + +if (exist('imageData','var') && ~isempty(imageData) && isfield(imageData,'DatasetName')) + idx = strfind(imageData.DatasetName,'"'); + imageData.DatasetName(idx) = []; +else + if isstruct(imageData) + error('ImageData struct is malformed!'); + end + dName = imageData; + imageData = []; + imageData.DatasetName = dName; + + imageData.Dimensions = Utils.SwapXY_RC(size(im)); + imageData.NumberOfChannels = size(im,4); + imageData.NumberOfFrames = size(im,5); + + imageData.PixelPhysicalSize = [1.0, 1.0, 1.0]; +end + +w = whos('im'); +switch w.class + case 'uint8' + tags.SampleFormat = Tiff.SampleFormat.UInt; + tags.BitsPerSample = 8; + case 'uint16' + tags.SampleFormat = Tiff.SampleFormat.UInt; + tags.BitsPerSample = 16; + case 'uint32' + tags.SampleFormat = Tiff.SampleFormat.UInt; + tags.BitsPerSample = 32; + case 'int8' + tags.SampleFormat = Tiff.SampleFormat.Int; + tags.BitsPerSample = 8; + case 'int16' + tags.SampleFormat = Tiff.SampleFormat.Int; + tags.BitsPerSample = 16; + case 'int32' + tags.SampleFormat = Tiff.SampleFormat.Int; + tags.BitsPerSample = 32; + case 'single' + tags.SampleFormat = Tiff.SampleFormat.IEEEFP; + tags.BitsPerSample = 32; + case 'double' + tags.SampleFormat = Tiff.SampleFormat.IEEEFP; + tags.BitsPerSample = 64; + case 'logical' + imtemp = zeros(size(im),'uint8'); + imtemp(im) = 255; + im = imtemp; + clear imtemp + tags.SampleFormat = Tiff.SampleFormat.UInt; + tags.BitsPerSample = 8; + otherwise + error('Image type unsupported!'); +end + +if (~isfield(imageData,'PixelFormat')) + imageData.PixelFormat = w.class; +end + +if (exist('outDir','var') && ~isempty(outDir)) + idx = strfind(outDir,'"'); + outDir(idx) = []; +elseif (isfield(imageData,'imageDir') && ~isempty(imageData.imageDir)) + outDir = imageData.imageDir; +else + outDir = fullfile('.',imageData.DatasetName); +end + +MicroscopeData.CreateMetadata(outDir,imageData,quiet); + +if (~exist('timeList','var') || isempty(timeList)) + timeList = 1:imageData.NumberOfFrames; +else + if (max(timeList(:))>imageData.NumberOfFrames) + error('A value in timeList is greater than the number of frames in the image data!'); + end +end +if (size(im,5)~=length(timeList)) + error('There are %d frames and %d frames to be written!',size(im,5),length(timeList)); +end + +if (~exist('chanList','var') || isempty(chanList)) + chanList = 1:imageData.NumberOfChannels; +else + if (max(chanList(:))>imageData.NumberOfChannels) + error('A value in chanList is greater than the number of channels in the image data!'); + end +end +if (size(im,4)~=length(chanList)) + error('There are %d channels and %d channels to be written!',size(im,4),length(chanList)); +end + +if (~exist('zList','var') || isempty(zList)) + zList = 1:imageData.Dimensions(3); +else + if (max(zList(:))>imageData.Dimensions(3)) + error('A value in zList is greater than the z dimension in the image data!'); + end +end +if (size(im,3)~=length(zList)) + error('There are %d z images and %d z images to be written!',size(im,3),length(zList)); +end + +tags.ImageLength = size(im,1); +tags.ImageWidth = size(im,2); +tags.RowsPerStrip = size(im,2); +tags.Photometric = Tiff.Photometric.MinIsBlack; +tags.ExtraSamples = Tiff.ExtraSamples.Unspecified; +tags.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky; +tags.SamplesPerPixel = 1; +tags.Compression = Tiff.Compression.LZW; +tags.Software = 'MATLAB'; + +if (~quiet) + iter = length(timeList)*length(chanList)*length(zList); + cp = Utils.CmdlnProgress(iter,true,sprintf('Writing %s...',imageData.DatasetName)); + i=1; +end + +isBig = false; +if (tags.BitsPerSample/8 * prod(imageData.Dimensions) > 0.95*2^32) + isBig = true; +end + +tic +for t=1:length(timeList) + for c=1:length(chanList) + for z=1:length(zList) + if (isBig) + tiffObj = Tiff(fullfile(outDir,[imageData.DatasetName,sprintf('_c%02d_t%04d_z%04d.tif',chanList(c),timeList(t),zList(z))]),'w8'); + else + tiffObj = Tiff(fullfile(outDir,[imageData.DatasetName,sprintf('_c%02d_t%04d_z%04d.tif',chanList(c),timeList(t),zList(z))]),'w'); + end + tiffObj.setTag(tags); + tiffObj.write(im(:,:,z,c,t),tags); + tiffObj.close(); + +% fname = fullfile(outDir,[imageData.DatasetName,sprintf('_c%02d_t%04d_z%04d.tif',chanList(c),timeList(t),zList(z))]); +% imwrite(im(:,:,z,c,t),fname,'Compression','lzw'); + + if (~quiet) + cp.PrintProgress(i); + i = i+1; + end + + end + end +end + +if (~quiet) + cp.ClearProgress(); + fprintf('Wrote %.0fMB in %s\n',... + ((tags.BitsPerSample/8)*prod(imageData.Dimensions)*imageData.NumberOfChannels*imageData.NumberOfFrames)/(1024*1024),... + Utils.PrintTime(toc)); +end +end + diff --git a/src/MATLAB/+Segmentation/+MitosisEditor/FindChildrenHulls.m b/src/MATLAB/+Segmentation/+MitosisEditor/FindChildrenHulls.m index b8f595482f199d774ca3c591aaf7cacbba95a1a2..91201ef0c05191a3e9aa2ccd2e35dd7d946b02b4 100644 --- a/src/MATLAB/+Segmentation/+MitosisEditor/FindChildrenHulls.m +++ b/src/MATLAB/+Segmentation/+MitosisEditor/FindChildrenHulls.m @@ -51,7 +51,7 @@ function newHulls = splitMitosisHull(hullID, linePoints, bForcePoints) mitVec = mitVec / norm(mitVec); - [r c] = ind2sub(CONSTANTS.imageSize, CellHulls(hullID).indexPixels); + [r c] = ind2sub(Metadata.GetDimensions('rc'), CellHulls(hullID).indexPixels); if ( bForcePoints ) distSq = ((c-linePoints(1,1)).^2 + (r-linePoints(1,2)).^2); @@ -150,7 +150,7 @@ function hullID = mergeOverlapping(chkHulls, chkPoint, time) objCOM = zeros(length(validHulls),2); for i=1:length(validHulls) - [r c] = ind2sub(CONSTANTS.imageSize, validHulls(i).indexPixels); + [r c] = ind2sub(Metadata.GetDimensions('rc'), validHulls(i).indexPixels); objCOM = mean([r c], 1); end @@ -159,7 +159,7 @@ function hullID = mergeOverlapping(chkHulls, chkPoint, time) newHull = validHulls(minIdx); - [r c] = ind2sub(CONSTANTS.imageSize, newHull.indexPixels); + [r c] = ind2sub(Metadata.GetDimensions('rc'), newHull.indexPixels); newHullEntry = createNewHullStruct(c, r, time); bMergeHulls = arrayfun(@(x)(nnz(ismember(newHullEntry.indexPixels,CellHulls(x).indexPixels)) > 5), frameHulls); @@ -197,14 +197,14 @@ function hullID = mergeOverlapping(chkHulls, chkPoint, time) end function outHullID = mergeHullValues(hullID, mergeStruct) - global CONSTANTS CellHulls + global CellHulls outHullID = hullID; [dump, idxA, idxB] = union(CellHulls(hullID).indexPixels, mergeStruct.indexPixels); CellHulls(hullID).indexPixels = [CellHulls(hullID).indexPixels(idxA); mergeStruct.indexPixels(idxB)]; - [r c] = ind2sub(CONSTANTS.imageSize, CellHulls(hullID).indexPixels); + [r c] = ind2sub(Metadata.GetDimensions('rc'), CellHulls(hullID).indexPixels); CellHulls(hullID).centerOfMass = mean([r c]); cvIdx = Helper.ConvexHull(c,r); if ( isempty(cvIdx) ) @@ -215,12 +215,12 @@ function outHullID = mergeHullValues(hullID, mergeStruct) end function subtractHulls(hullID, subHullID) - global CONSTANTS CellHulls + global CellHulls [dump, subIdx] = union(CellHulls(hullID).indexPixels, CellHulls(subHullID).indexPixels); CellHulls(hullID).indexPixels = CellHulls(hullID).indexPixels(subIdx); - [r c] = ind2sub(CONSTANTS.imageSize, CellHulls(hullID).indexPixels); + [r c] = ind2sub(Metadata.GetDimensions('rc'), CellHulls(hullID).indexPixels); CellHulls(hullID).centerOfMass = mean([r c]); cvIdx = Helper.ConvexHull(c,r); if ( isempty(cvIdx) ) @@ -239,20 +239,18 @@ function newHullID = addPointHullEntry(chkPoint, time) end function newHullID = addHullEntry(hull, time) - global CONSTANTS - - [r c] = ind2sub(CONSTANTS.imageSize, hull.indexPixels); + [r c] = ind2sub(Metadata.GetDimensions('rc'), hull.indexPixels); newHull = createNewHullStruct(c, r, time); newHullID = Hulls.SetCellHullEntries(0, newHull); end function newHull = createNewHullStruct(x,y, time) - global CONSTANTS CellHulls + global CellHulls newHull = Helper.MakeEmptyStruct(CellHulls); - idxPix = sub2ind(CONSTANTS.imageSize, y,x); + idxPix = sub2ind(Metadata.GetDimensions('rc'), y,x); newHull.indexPixels = idxPix; newHull.centerOfMass = mean([y x], 1); diff --git a/src/MATLAB/+Segmentation/+MitosisEditor/FindParentHull.m b/src/MATLAB/+Segmentation/+MitosisEditor/FindParentHull.m index 47a2793cf90a5d53172f08b89b593bd9f62b286a..32d77522727db5c1ad53484267e4df2c215bb51e 100644 --- a/src/MATLAB/+Segmentation/+MitosisEditor/FindParentHull.m +++ b/src/MATLAB/+Segmentation/+MitosisEditor/FindParentHull.m @@ -34,8 +34,9 @@ function parentHull = FindParentHull(childHulls, linePoints, time, forceParents) pointCounts = zeros(1,length(chkHulls)); + rcImageDims = Metadata.GetDimensions('rc'); for i=1:length(chkHulls) - [r c] = ind2sub(CONSTANTS.imageSize, CellHulls(chkHulls(i)).indexPixels); + [r c] = ind2sub(rcImageDims, CellHulls(chkHulls(i)).indexPixels); bContainsPoints = inpolygon(c,r, mitosisPoints(:,1), mitosisPoints(:,2)); pointCounts(i) = nnz(bContainsPoints); end @@ -66,9 +67,10 @@ function parentHull = addParentHull(midpoint, time, mitosisPoints) hulls = Segmentation.PartialImageSegment(imSet, midpoint, 200, CONSTANTS.primaryChannel, segFunc, segParams); + rcImageDims = Metadata.GetDimensions('rc'); pointCounts = zeros(1,length(hulls)); for i=1:length(hulls) - [r c] = ind2sub(CONSTANTS.imageSize, hulls(i).indexPixels); + [r c] = ind2sub(rcImageDims, hulls(i).indexPixels); bContainsPoints = inpolygon(c,r, mitosisPoints(:,1), mitosisPoints(:,2)); pointCounts(i) = nnz(bContainsPoints); end @@ -88,28 +90,25 @@ function newHullID = addPointHullEntry(chkPoint, time) x = round(chkPoint(1)); y = round(chkPoint(2)); - filename = Helper.GetFullImagePath(time); - img = Helper.LoadIntensityImage(filename); + img = Helper.LoadIntensityImage(time,CONSTANTS.primaryChannel); newHull = createNewHullStruct(x, y, time); newHullID = Hulls.SetCellHullEntries(0, newHull); end function newHullID = addHullEntry(hull, time) - global CONSTANTS - - [r c] = ind2sub(CONSTANTS.imageSize, hull.indexPixels); + [r c] = ind2sub(Metadata.GetDimensions('rc'), hull.indexPixels); newHull = createNewHullStruct(c, r, time); newHullID = Hulls.SetCellHullEntries(0, newHull); end function newHull = createNewHullStruct(x,y, time) - global CONSTANTS CellHulls + global CellHulls newHull = Helper.MakeEmptyStruct(CellHulls); - idxPix = sub2ind(CONSTANTS.imageSize, y,x); + idxPix = sub2ind(Metadata.GetDimensions('rc'), y,x); newHull.indexPixels = idxPix; newHull.centerOfMass = mean([y x], 1); diff --git a/src/MATLAB/+Segmentation/+ResegFromTree/AddSegmentation.m b/src/MATLAB/+Segmentation/+ResegFromTree/AddSegmentation.m index 5712b88ce9f902507741b866e88d59d768b75714..324a9fc4b8e9b9ef66f94768cd85d15aa69ce465 100644 --- a/src/MATLAB/+Segmentation/+ResegFromTree/AddSegmentation.m +++ b/src/MATLAB/+Segmentation/+ResegFromTree/AddSegmentation.m @@ -11,8 +11,7 @@ function [addedHull costMatrix nextHulls] = AddSegmentation(prevHull, costMatrix chanImSet = Helper.LoadIntensityImageSet(time); - guessPoint = Helper.SwapXY_RC(CellHulls(prevHull).centerOfMass); - + guessPoint = Utils.SwapXY_RC(CellHulls(prevHull).centerOfMass); chkHull = Segmentation.FindNewSegmentation(chanImSet, guessPoint, 200, bAggressive, CellHulls(prevHull).indexPixels, time); if ( isempty(chkHull) ) return; @@ -27,7 +26,7 @@ function [addedHull costMatrix nextHulls] = AddSegmentation(prevHull, costMatrix return; end - newHull = Hulls.CreateHull(CONSTANTS.imageSize, chkPix, time, false, chkHull.tag); + newHull = Hulls.CreateHull(Metadata.GetDimensions('rc'), chkPix, time, false, chkHull.tag); % Use temporary hull to verify cost (not on a track yet) chkIdx = find(checkHulls == prevHull); diff --git a/src/MATLAB/+Segmentation/+ResegFromTree/CanExtendTrack.m b/src/MATLAB/+Segmentation/+ResegFromTree/CanExtendTrack.m deleted file mode 100644 index 8afef1ed74d86be90c01d16142b40cebddfad804..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Segmentation/+ResegFromTree/CanExtendTrack.m +++ /dev/null @@ -1,25 +0,0 @@ - -function bCanExtend = CanExtendTrack(t, tracks) - global CellHulls - - bCanExtend = true(length(tracks),1); - - for i=1:length(tracks) - [phenotype phenoHullID] = Tracks.GetTrackPhenoypeTimes(tracks(i)); - if ( phenotype == 0 ) - continue; - end - - phenoTime = CellHulls(phenoHullID).time; - if ( t <= phenoTime ) - continue; - end - - prevHullID = Helper.GetNearestTrackHull(tracks(i), t-1, -1); - if ( prevHullID ~= phenoHullID ) - continue; - end - - bCanExtend(i) = false; - end -end \ No newline at end of file diff --git a/src/MATLAB/+Segmentation/+ResegFromTree/CheckIgnoreTracks.m b/src/MATLAB/+Segmentation/+ResegFromTree/CheckIgnoreTracks.m index 658d41bb3064dded632dfe5a6ff7e7b3eebd8cf1..55e46b1bdebb8e9c45100fe691d46c9cc739184b 100644 --- a/src/MATLAB/+Segmentation/+ResegFromTree/CheckIgnoreTracks.m +++ b/src/MATLAB/+Segmentation/+ResegFromTree/CheckIgnoreTracks.m @@ -41,7 +41,7 @@ function [bIgnoreEdges, bLongEdges] = CheckIgnoreTracks(t, trackIDs, viewLims) end function bInLims = checkHullCOMLims(hullID, xyViewLims) - global CONSTANTS CellHulls + global CellHulls if ( isempty(hullID) || hullID == 0 ) bInLims = false; @@ -51,15 +51,15 @@ function bInLims = checkHullCOMLims(hullID, xyViewLims) lenDims = xyViewLims(:,2) - xyViewLims(:,1); padScale = 0.05; - imSize = Helper.SwapXY_RC(CONSTANTS.imageSize); + xyImageDims = Metadata.GetDimensions('xy'); bNotEdgeMin = (xyViewLims(:,1) >= 1+5); - bNotEdgeMax = (xyViewLims(:,2) <= (imSize-5).'); + bNotEdgeMax = (xyViewLims(:,2) <= (xyImageDims-5).'); padInMin = bNotEdgeMin.*padScale.*lenDims; padInMax = bNotEdgeMax.*padScale.*lenDims; - hullCOM = Helper.SwapXY_RC(CellHulls(hullID).centerOfMass).'; + hullCOM = Utils.SwapXY_RC(CellHulls(hullID).centerOfMass).'; bInDim = ((hullCOM > xyViewLims(:,1)+padInMin) & (hullCOM < xyViewLims(:,2)-padInMax)); diff --git a/src/MATLAB/+Segmentation/+ResegFromTree/FindFrameReseg.m b/src/MATLAB/+Segmentation/+ResegFromTree/FindFrameReseg.m index c29d67aacf8aeb21207fa0f950b3482cb3acc4e3..11fe507f72533833afffcf0f4f297e65e48190b3 100644 --- a/src/MATLAB/+Segmentation/+ResegFromTree/FindFrameReseg.m +++ b/src/MATLAB/+Segmentation/+ResegFromTree/FindFrameReseg.m @@ -97,11 +97,18 @@ function newEdges = FindFrameReseg(t, curEdges, bIgnoreEdges) bAddedHull(i) = 1; end + % Bump up the cost of splitting a hull + [bestInCost,bestInIdx] = min(costMatrix,[],1); + idx = sub2ind(size(costMatrix), bestInIdx,(1:size(costMatrix,2))); + + splitCosts = 2*costMatrix; + splitCosts(idx) = bestInCost; + % Find hulls we may need to split desiredCellCount = zeros(length(nextHulls),1); desirers = cell(length(nextHulls),1); for i=1:length(checkHulls) - [desiredCosts desiredIdx] = sort(costMatrix(i,:)); + [desiredCosts,desiredIdx] = sort(splitCosts(i,:)); if ( isinf(desiredCosts(1)) ) continue; end diff --git a/src/MATLAB/+Segmentation/+ResegFromTree/GetSubtreeTracks.m b/src/MATLAB/+Segmentation/+ResegFromTree/GetSubtreeTracks.m deleted file mode 100644 index 59c0b45b864163288137cfbd2c0938a08d7c6785..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Segmentation/+ResegFromTree/GetSubtreeTracks.m +++ /dev/null @@ -1,18 +0,0 @@ -% childTracks = GetSubtreeTracks(rootTracks) -% -% Returns a list of all tracks which are children of the tracks listed in -% rootTracks (Includes the rootTracks). - -function childTracks = GetSubtreeTracks(rootTracks) - global CellTracks - - childTracks = rootTracks; - while ( any(~isempty([CellTracks(childTracks).childrenTracks])) ) - newTracks = setdiff([CellTracks(childTracks).childrenTracks], childTracks); - if ( isempty(newTracks) ) - return; - end - - childTracks = union(childTracks, newTracks); - end -end \ No newline at end of file diff --git a/src/MATLAB/+Segmentation/+ResegFromTree/SplitDeterministic.m b/src/MATLAB/+Segmentation/+ResegFromTree/SplitDeterministic.m index 6032433159996bfe6211af53ac0922a0d760c5da..a94958742108673f2d2c3953a99ab2b5a57f070f 100644 --- a/src/MATLAB/+Segmentation/+ResegFromTree/SplitDeterministic.m +++ b/src/MATLAB/+Segmentation/+ResegFromTree/SplitDeterministic.m @@ -9,24 +9,25 @@ function newHulls = SplitDeterministic(hull, k, checkHullIDs) return; end - oldMeans = zeros(k, 2); + rcImageDims = Metadata.GetDimensions('rc'); + xyOldMeans = zeros(k, length(rcImageDims)); for i=1:length(checkHullIDs) - oldCoord = Helper.IndexToCoord(CONSTANTS.imageSize, CellHulls(checkHullIDs(i)).indexPixels); - oldMeans(i,:) = Helper.SwapXY_RC(mean(oldCoord,1)); + rcOldCoord = Utils.IndToCoord(rcImageDims, CellHulls(checkHullIDs(i)).indexPixels); + xyOldMeans(i,:) = Utils.SwapXY_RC(mean(rcOldCoord,1)); end if ( length(hull.indexPixels) < 2 ) return; end - rcCoords = Helper.IndexToCoord(CONSTANTS.imageSize, hull.indexPixels); - xyCoords = Helper.SwapXY_RC(rcCoords); + rcCoords = Utils.IndToCoord(rcImageDims, hull.indexPixels); + xyCoords = Utils.SwapXY_RC(rcCoords); typeParams = Load.GetCellTypeStructure(CONSTANTS.cellType); if ( typeParams.splitParams.useGMM ) - kIdx = gmmCluster(xyCoords, k, oldMeans); + kIdx = gmmCluster(xyCoords, k, xyOldMeans); else - kIdx = kmeans(xyCoords, k, 'start',oldMeans, 'EmptyAction','drop'); + kIdx = kmeans(xyCoords, k, 'start',xyOldMeans, 'EmptyAction','drop'); end if ( any(isnan(kIdx)) ) @@ -36,7 +37,7 @@ function newHulls = SplitDeterministic(hull, k, checkHullIDs) for i=1:k newHullPixels = hull.indexPixels( kIdx==i ); - outputHull = Hulls.CreateHull(CONSTANTS.imageSize, newHullPixels, hull.time); + outputHull = Hulls.CreateHull(rcImageDims, newHullPixels, hull.time); newHulls = [newHulls outputHull]; end diff --git a/src/MATLAB/+Segmentation/AddNewSegmentHull.m b/src/MATLAB/+Segmentation/AddNewSegmentHull.m index 1a71ea6be6c9030f1c1752b91479e0318274f75a..8e15d4af44edb1f14e67ef58f325c2cb487f2e10 100644 --- a/src/MATLAB/+Segmentation/AddNewSegmentHull.m +++ b/src/MATLAB/+Segmentation/AddNewSegmentHull.m @@ -3,10 +3,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by @@ -24,34 +24,27 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -function newTrackID = AddNewSegmentHull(clickPt, time) - global CONSTANTS CellHulls +function newTrackID = AddNewSegmentHull(xyClickPt, time) + global CellHulls chanImSet = Helper.LoadIntensityImageSet(time); - - if strcmp(CONSTANTS.cellType, 'Hemato') - subSize = 100; - else - subSize = 200; - end - - - chkHull = Segmentation.FindNewSegmentation(chanImSet, clickPt, subSize, true, [], time); + chkHull = Segmentation.FindNewSegmentation(chanImSet, xyClickPt, 200, true, [], time); newHull = Helper.MakeEmptyStruct(CellHulls); newHull.userEdited = true; if ( ~isempty(chkHull) ) - chkHull = Segmentation.ForceDisjointSeg(chkHull, time, clickPt); + chkHull = Segmentation.ForceDisjointSeg(chkHull, time, xyClickPt); end % TODO: Update manual click hulls for 3D + rcImageDims = Metadata.GetDimensions('rc'); if ( isempty(chkHull) ) % Add a point hull since we couldn't find a segmentation containing the click - clickIndex = Helper.CoordToIndex(CONSTANTS.imageSize, round(Helper.SwapXY_RC(clickPt))); - newHull = Hulls.CreateHull(CONSTANTS.imageSize, clickIndex, time, true, 'Manual'); + clickIndex = Utils.CoordToInd(rcImageDims, round(Utils.SwapXY_RC(xyClickPt))); + newHull = Hulls.CreateHull(rcImageDims, clickIndex, time, true, 'Manual'); else - newHull = Hulls.CreateHull(CONSTANTS.imageSize, chkHull.indexPixels, time, true, chkHull.tag); + newHull = Hulls.CreateHull(rcImageDims, chkHull.indexPixels, time, true, chkHull.tag); end newHullID = Hulls.SetCellHullEntries(0, newHull); diff --git a/src/MATLAB/+Segmentation/AddSegmentationEdit.m b/src/MATLAB/+Segmentation/AddSegmentationEdit.m index 101a7f5b5816148cb9cbd3de015387ea11843581..c39e98f8ec316ec60d3220f8eec85df8e6799e8d 100644 --- a/src/MATLAB/+Segmentation/AddSegmentationEdit.m +++ b/src/MATLAB/+Segmentation/AddSegmentationEdit.m @@ -3,10 +3,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Segmentation/AssignPolyPix.m b/src/MATLAB/+Segmentation/AssignPolyPix.m deleted file mode 100644 index 3a462de605a0bc2b0b407be9c4b86a40b3faf686..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Segmentation/AssignPolyPix.m +++ /dev/null @@ -1,45 +0,0 @@ -function assignIdx = AssignPolyPix(polyPix, connComps, imSize) - [r c] = ind2sub(imSize, polyPix); - - xlims = Helper.Clamp([min(c) max(c)], 1, imSize(2)); - ylims = Helper.Clamp([min(r) max(r)], 1, imSize(1)); - - rCC = cell(1,length(connComps)); - cCC = cell(1,length(connComps)); - for i=1:length(connComps) - [rCC{i} cCC{i}] = ind2sub(imSize, connComps{i}); - - xlims = Helper.Clamp([min([xlims(1); cCC{i}]) max([xlims(2); cCC{i}])], 1, imSize(2)); - ylims = Helper.Clamp([min([ylims(1); rCC{i}]) max([ylims(2); rCC{i}])], 1, imSize(1)); - end - - locsz = [ylims(2)-ylims(1) xlims(2)-xlims(1)]+1; - - lblim = zeros(locsz); - bwim = false(locsz); - for i=1:length(connComps) - locr = rCC{i} - ylims(1) + 1; - locc = cCC{i} - xlims(1) + 1; - - locind = sub2ind(locsz, locr,locc); - - bwim(locind) = 1; - lblim(locind) = i; - end - - locr = r - ylims(1) + 1; - locc = c - xlims(1) + 1; - - locind = sub2ind(locsz, locr,locc); - - [d,L] = bwdist(bwim); - assignIdx = lblim(L(locind)); - -% cmap = hsv(length(connComps)); -% figure;imagesc(bwim);colormap(gray);hold on; -% for i=1:length(connComps) -% tr = locr(assignIdx == i); -% tc = locc(assignIdx == i); -% plot(tc, tr, '.', 'Color',cmap(i,:)); -% end -end \ No newline at end of file diff --git a/src/MATLAB/+Segmentation/BuildPerimPix.m b/src/MATLAB/+Segmentation/BuildPerimPix.m deleted file mode 100644 index b5df0b52e164d3f6014c2152b3fdfa2211101ade..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Segmentation/BuildPerimPix.m +++ /dev/null @@ -1,25 +0,0 @@ -function [perimPix, perimr, perimc] = BuildPerimPix(polyPix, imSize) - [r c] = ind2sub(imSize, polyPix); - - xlims = Helper.Clamp([min(c) max(c)], 1, imSize(2)); - ylims = Helper.Clamp([min(r) max(r)], 1, imSize(1)); - - locr = r - ylims(1) + 1; - locc = c - xlims(1) + 1; - - locsz = [ylims(2)-ylims(1) xlims(2)-xlims(1)]+1; - locind = sub2ind(locsz, locr, locc); - - bwim = false(locsz); - bwim(locind) = 1; - - B = bwboundaries(bwim, 4, 'noholes'); - perimr = []; - perimc = []; - for i=1:length(B) - perimr = [perimr; B{i}(:,1) + ylims(1) - 1]; - perimc = [perimc; B{i}(:,2) + xlims(1) - 1]; - end - - perimPix = unique(sub2ind(imSize, perimr, perimc)); -end \ No newline at end of file diff --git a/src/MATLAB/+Segmentation/FindCropRegion.m b/src/MATLAB/+Segmentation/FindCropRegion.m deleted file mode 100644 index e5e25bc73de9219e652e6b49f4d552a71aa276f2..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Segmentation/FindCropRegion.m +++ /dev/null @@ -1,22 +0,0 @@ -function [ region ] = findCropRegion( fname ) - alpha = 0.5; - border = 5; - - im = imread(fname); - im = mat2gray(im); - th = graythresh(im); - bw = im2bw(im, th * alpha); - % imagesc(bw), colormap(gray); - - CC = bwconncomp(bw); - numPixels = cellfun(@numel,CC.PixelIdxList); - [biggest idx] = max(numPixels); - [r c] = ind2sub(size(bw), CC.PixelIdxList{idx}); - minR = min(r); - minC = min(c); - maxR = max(r); - maxC = max(c); - - region = [(minR + border) (minC + border) (maxR - border) (maxC - border)]; -end - diff --git a/src/MATLAB/+Segmentation/FindNewSegmentation.m b/src/MATLAB/+Segmentation/FindNewSegmentation.m index 6ca14253ec2ff5b6c491367cfe62e983b598f7b5..57d8cb28b24ce6c7f2abf3e55f14a08265167111 100644 --- a/src/MATLAB/+Segmentation/FindNewSegmentation.m +++ b/src/MATLAB/+Segmentation/FindNewSegmentation.m @@ -1,4 +1,28 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function hull = FindNewSegmentation(chanImg, centerPt, subSize, bSearchParams, overlapPoints, time) global CONSTANTS diff --git a/src/MATLAB/+Segmentation/ForceDisjointSeg.m b/src/MATLAB/+Segmentation/ForceDisjointSeg.m index 28d9b1401f3830f9f6dea2ea733b4b233ee048b7..5e959a25cc1a8557f9989f7b4de4df6e7885e6e0 100644 --- a/src/MATLAB/+Segmentation/ForceDisjointSeg.m +++ b/src/MATLAB/+Segmentation/ForceDisjointSeg.m @@ -1,9 +1,33 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + %TODO: Maybe handle convex hull intersection instead of interior points as %the current method still allows considerable hull overlap in some cases. function newHull = ForceDisjointSeg(hull, time, centerPt) - global CONSTANTS CellHulls HashedCells + global CellHulls HashedCells newHull = []; @@ -17,7 +41,7 @@ function newHull = ForceDisjointSeg(hull, time, centerPt) return; end - bwimg = zeros(CONSTANTS.imageSize); + bwimg = zeros(Metadata.GetDimensions('rc')); bwimg(pix(bPickPix)) = 1; CC = bwconncomp(bwimg,8); diff --git a/src/MATLAB/+Segmentation/FrameSegmentor.m b/src/MATLAB/+Segmentation/FrameSegmentor.m index cf27503772dd86a833edfccb478842f83ec75e80..8a02934e94abda142c74225616c6d2e98359ca82 100644 --- a/src/MATLAB/+Segmentation/FrameSegmentor.m +++ b/src/MATLAB/+Segmentation/FrameSegmentor.m @@ -32,6 +32,30 @@ % % See also Load.GetSupportedCellTypes, Segmentation.FrameSegmentor_Adult, REGIONPROPS. % + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function hulls = FrameSegmentor(chanIm, primaryChan, t, vararagin) hulls = []; diff --git a/src/MATLAB/+Segmentation/FrameSegmentor_Adult.m b/src/MATLAB/+Segmentation/FrameSegmentor_Adult.m index 9aa0a01626586cd73f4899af72af7f7b73931f60..e834eaca84dcf3e345248ef9619406a3c4ed6865 100644 --- a/src/MATLAB/+Segmentation/FrameSegmentor_Adult.m +++ b/src/MATLAB/+Segmentation/FrameSegmentor_Adult.m @@ -22,6 +22,30 @@ % % See also Segmentation.FrameSegmentor. % + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function hulls = FrameSegmentor_Adult(chanIm, primaryChan, t, imageAlpha) hulls = []; levels = struct('haloLevel',{[]}, 'igLevel',{[]}); diff --git a/src/MATLAB/+Segmentation/FrameSegmentor_Embryonic.m b/src/MATLAB/+Segmentation/FrameSegmentor_Embryonic.m index f341ec299b8ccadec24c60e513cc6bbad99a8607..8f2ead2f269a59805e40cbf9eec45607d6f7f51b 100644 --- a/src/MATLAB/+Segmentation/FrameSegmentor_Embryonic.m +++ b/src/MATLAB/+Segmentation/FrameSegmentor_Embryonic.m @@ -22,6 +22,30 @@ % % See also Segmentation.FrameSegmentor. % + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function hulls = FrameSegmentor_Embryonic(chanIm, primaryChan, t, imageAlpha) hulls = []; diff --git a/src/MATLAB/+Segmentation/FrameSegmentor_MDK.m b/src/MATLAB/+Segmentation/FrameSegmentor_MDK.m new file mode 100644 index 0000000000000000000000000000000000000000..fdc3088bc4c264517f402873c526b1bc08f119d0 --- /dev/null +++ b/src/MATLAB/+Segmentation/FrameSegmentor_MDK.m @@ -0,0 +1,84 @@ +% FrameSegmentor_test - This is a frame segmentor example for identifying +% cell texture in brightfield imaging and splitting into components using a +% number of nuclear fluorescent channel markers. +% +% hulls = FrameSegmentor(chanIm, primaryChan, t, seRadius) +% INPUTS: +% chanIm - A cell array each chanIm{i} contains the image intensity date +% for the i-th channel at frame t. Some cells may be empty if they were +% unavailable or not imaged at frame t. +% +% primaryChan - A number between 1 and CONSTANTS.numChannels indicating +% the primary channel for the segmentation. Specific algorithms may use +% information from other available channels as well. +% +% t - The frame number of the image data being passed into the +% segmentation algorithm. +% +% seRadius - Radius of a neaighborhood element for the brightfield +% texture filter. Increasing the radius will generally connect +% segmentations. +% +% +% OUTPUTS: +% hulls - The hulls output should be a structure array with one entry per +% segmentation result. +% At a minimum, each hull must contain an 'indexPixels' field, a list of +% linear indices representing the interior pixels of segmentation results. +% For example, the PixelIdxList result from a call to regionprops could +% be used to fill the hulls indexPixels field. +% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function hulls = FrameSegmentor_MDK(chanIm, primaryChan, t, imageAlpha) + hulls = []; + + otherChan = setdiff(1:length(chanIm),primaryChan); + % Brightfield texture segmentation + im = chanIm{primaryChan}; + im=mat2gray(im); + thresh=imageAlpha*multithresh(im,3); + q=imquantize(im,thresh); + bw=0*im; + bw(q==1)=1; + bw=imclose(bw,strel('disk',4)); + + [L num]=bwlabel(bw); + for n=1:num + [r c]=find(L==n); + idx=find(L==n); + if length(r)<50 + continue + end + if length(r)>5000 + continue; + end + chIdx = Helper.ConvexHull(c,r); + if ( isempty(chIdx) ) + continue; + end + nh = struct('indexPixels',idx, 'points',{[c(chIdx), r(chIdx)]}); + hulls = [hulls nh]; + end \ No newline at end of file diff --git a/src/MATLAB/+Segmentation/GetCellTypeParams.m b/src/MATLAB/+Segmentation/GetCellTypeParams.m index 3532a63ed6c3cf4f4b0a175914ad0b8fb79dab3f..43c1161c8114da4b2a2697b1a305cc86f2fedb18 100644 --- a/src/MATLAB/+Segmentation/GetCellTypeParams.m +++ b/src/MATLAB/+Segmentation/GetCellTypeParams.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function segArgs = GetCellTypeParams() global CONSTANTS diff --git a/src/MATLAB/+Segmentation/MergeSplitCells.m b/src/MATLAB/+Segmentation/MergeSplitCells.m index d7b22b49d41735ad092669e9cfa17f1528461d69..935720168b96b337ee55c21ecb369575ee88a643 100644 --- a/src/MATLAB/+Segmentation/MergeSplitCells.m +++ b/src/MATLAB/+Segmentation/MergeSplitCells.m @@ -3,10 +3,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by @@ -126,7 +126,7 @@ function [mergeHull, deleteHullIDs] = createMergeCell(mergeIDs) deleteHullIDs = mergeIDs; newIndexPixels = vertcat(CellHulls(deleteHullIDs).indexPixels); - mergeHull = Hulls.CreateHull(CONSTANTS.imageSize, newIndexPixels, CellHulls(deleteHullIDs(1)).time, true); + mergeHull = Hulls.CreateHull(Metadata.GetDimensions('rc'), newIndexPixels, CellHulls(deleteHullIDs(1)).time, true); end function edge = getTrackEdge(t, trackID) diff --git a/src/MATLAB/+Segmentation/Michel.m b/src/MATLAB/+Segmentation/Michel.m index dfe252c3c8e6a60846c8f920f812f948e0bbb822..89ef91eb77586a998a2df43ed6cca463e3e4fd5e 100644 --- a/src/MATLAB/+Segmentation/Michel.m +++ b/src/MATLAB/+Segmentation/Michel.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function [bw] = Michel(im,neighborhood) % create a gaussian kernel and blur the image a lot h = fspecial('gaussian', 7, 5); diff --git a/src/MATLAB/+Segmentation/PartialImageSegment.m b/src/MATLAB/+Segmentation/PartialImageSegment.m index a120858061119608e0f84fc229d9f2f28f497c44..27e8bf97f098761919dcabb055fc52f24d24f42c 100644 --- a/src/MATLAB/+Segmentation/PartialImageSegment.m +++ b/src/MATLAB/+Segmentation/PartialImageSegment.m @@ -4,10 +4,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by @@ -36,8 +36,8 @@ function hulls = PartialImageSegment(chanImg, xyCenterPt, subSize, primaryChan, imSize = max([imSize; size(chanImg{c})],[],1); end - rcCoordMin = floor(Helper.SwapXY_RC(xyCenterPt) - subSize/2); - rcCoordMax = ceil(Helper.SwapXY_RC(xyCenterPt) + subSize/2); + rcCoordMin = floor(Utils.SwapXY_RC(xyCenterPt) - subSize/2); + rcCoordMax = ceil(Utils.SwapXY_RC(xyCenterPt) + subSize/2); rcCoordMin(rcCoordMin < 1) = 1; rcCoordMax(rcCoordMax > imSize) = imSize(rcCoordMax > imSize); @@ -62,15 +62,16 @@ function hulls = PartialImageSegment(chanImg, xyCenterPt, subSize, primaryChan, end function newHulls = fixupFromSubimage(rcCoordMin, origSize, subSize, hulls) - newHulls = hulls; + newHulls = []; rcOffset = rcCoordMin - 1; for i=1:length(hulls) - newHulls(i).indexPixels = makeGlobalPix(hulls(i).indexPixels, origSize, subSize, rcOffset); + idxPix = makeGlobalPix(hulls(i).indexPixels, origSize, subSize, rcOffset); + newHulls = [newHulls Hulls.CreateHull(origSize, idxPix)]; end end function globIdx = makeGlobalPix(locIdx, globSz, locSz, rcOffset) - globCoords = Helper.IndexToCoord(locSz, locIdx) + repmat(rcOffset, size(locIdx,1),1); - globIdx = Helper.CoordToIndex(globSz, globCoords); + globCoords = Utils.IndToCoord(locSz, locIdx) + repmat(rcOffset, size(locIdx,1),1); + globIdx = Utils.CoordToInd(globSz, globCoords); end diff --git a/src/MATLAB/+Segmentation/RemoveSegmentationEdit.m b/src/MATLAB/+Segmentation/RemoveSegmentationEdit.m index 2d5d93730b87fdcdcc211a43bed35a51e4595e32..c6e13bed56d11b07aa36224bbedacedfaa670689 100644 --- a/src/MATLAB/+Segmentation/RemoveSegmentationEdit.m +++ b/src/MATLAB/+Segmentation/RemoveSegmentationEdit.m @@ -3,10 +3,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Segmentation/ResegFromTree.m b/src/MATLAB/+Segmentation/ResegFromTree.m deleted file mode 100644 index f0146de5279d806c1101b41cea77db90e0aba4b6..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Segmentation/ResegFromTree.m +++ /dev/null @@ -1,68 +0,0 @@ -% segEdits = ResegFromTree(rootTracks) -% -% Attempt to correct segmentation (and tracking) errors by exploiting a -% corrected lineage tree. -% -% rootTracks - List of root tree tracks to resegment - -function tLast = ResegFromTree(rootTracks, tStart, tEnd) - global HashedCells CellTracks CellHulls Costs - - global Figures CONSTANTS - outMovieDir = fullfile('B:\Users\mwinter\Documents\Figures\Reseg',CONSTANTS.datasetName); - - if ( ~exist('tStart','var') ) - tStart = 2; - end - - if ( ~exist('tEnd','var') ) - tEnd = length(HashedCells); - end - - tStart = max(tStart,2); - tMax = length(HashedCells); - tEnd = min(tEnd, tMax); - - checkTracks = Segmentation.ResegFromTree.GetSubtreeTracks(rootTracks); - - invalidPreserveTracks = []; - - % Need to worry about deleted hulls? - costMatrix = Costs; - bDeleted = ([CellHulls.deleted] > 0); - costMatrix(bDeleted,:) = 0; - costMatrix(:,bDeleted) = 0; - - mexDijkstra('initGraph', costMatrix); - - for t=tStart:tEnd - checkTracks = setdiff(checkTracks, invalidPreserveTracks); - - newPreserveTracks = Segmentation.ResegFromTree.FixupSingleFrame(t, checkTracks, tMax); - - checkTracks = [checkTracks newPreserveTracks]; - [dump sortedIdx] = unique(checkTracks, 'first'); - sortedIdx = sort(sortedIdx); - checkTracks = checkTracks(sortedIdx); - - bInvalidPreserveTracks = cellfun(@(x)(isempty(x)),{CellTracks(checkTracks).startTime}); - invalidPreserveTracks = checkTracks(bInvalidPreserveTracks); - - % DEBUG - Figures.time = t; - validPreserveTracks = checkTracks(~bInvalidPreserveTracks); - famID = CellTracks(validPreserveTracks(1)).familyID; - - UI.DrawTree(famID); - UI.TimeChange(t); - drawnow(); - - % Make Movie code -% saveMovieFrame(t, famID, outMovieDir); - - tLast = t; - end - -% saveMovieFrame(1, famID, outMovieDir); -end - diff --git a/src/MATLAB/+Segmentation/ResegRetrackLink.m b/src/MATLAB/+Segmentation/ResegRetrackLink.m deleted file mode 100644 index 15f19d7292d6cbf827298c5e4c5e252a34104159..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Segmentation/ResegRetrackLink.m +++ /dev/null @@ -1,36 +0,0 @@ -function ResegRetrackLink() - global HashedCells CellTracks CellFamilies - -% [iters totalTime] = LinkFirstFrameTrees(); -% LogAction('Completed Tree Inference', [iters totalTime],[]); - - tic(); - % Resegment and track - goodTracks = []; - for i=1:length(HashedCells{1}) - trackID = HashedCells{1}(i).trackID; - familyID = CellTracks(trackID).familyID; - endTime = CellFamilies(familyID).endTime; - if ( endTime < length(HashedCells) ) - continue; - end - - goodTracks = [goodTracks trackID]; - end - - if ( isempty(goodTracks) ) - return; - end - - Segmentation.ResegmentFromTree(goodTracks); - tReseg = toc(); - - tic(); - Tracker.HematoTracker(); - tRetrack = toc(); - Error.LogAction('Resegmentation/Tracking',[tReseg tRetrack],[]); - - % Rerun tree-inference for first-frame cells - [iters totalTime] = Families.LinkFirstFrameTrees(); - Error.LogAction('Completed Tree Inference', [iters totalTime],[]); -end \ No newline at end of file diff --git a/src/MATLAB/+Segmentation/ResegmentHull.m b/src/MATLAB/+Segmentation/ResegmentHull.m index 8ab4b54a170c3cb27335252b6edceb3976ff3c14..e45d71badd0f2afb8777972b203f03634e938c9e 100644 --- a/src/MATLAB/+Segmentation/ResegmentHull.m +++ b/src/MATLAB/+Segmentation/ResegmentHull.m @@ -3,23 +3,23 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -% +% http://n2t.net/ark:/87918/d9rp4t for details +% % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation, either version 3 of the License, or % (at your option) any later version. -% +% % LEVer is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. -% +% % You should have received a copy of the GNU General Public License -% along with LEVer in file "gnu gpl v3.txt". If not, see +% along with LEVer in file "gnu gpl v3.txt". If not, see % <http://www.gnu.org/licenses/>. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -34,8 +34,9 @@ if ( ~exist('bUserEdit','var') ) end % guassian clustering (x,y,...) coordinates of cell interior -rcCoords = Helper.IndexToCoord(CONSTANTS.imageSize, hull.indexPixels); -xyCoords = Helper.SwapXY_RC(rcCoords); +rcImageDims = Metadata.GetDimensions('rc'); +rcCoords = Utils.IndToCoord(rcImageDims, hull.indexPixels); +xyCoords = Utils.SwapXY_RC(rcCoords); typeParams = Load.GetCellTypeStructure(CONSTANTS.cellType); if ( typeParams.splitParams.useGMM ) @@ -54,7 +55,7 @@ end for i=1:k newHullPixels = hull.indexPixels( kIdx==i ); - outputHull = Hulls.CreateHull(CONSTANTS.imageSize, newHullPixels, hull.time, bUserEdit); + outputHull = Hulls.CreateHull(rcImageDims, newHullPixels, hull.time, bUserEdit); newHulls = [newHulls outputHull]; end diff --git a/src/MATLAB/+Segmentation/SegAndTrack.m b/src/MATLAB/+Segmentation/SegAndTrack.m index 6e170204ade844af51775ebc133de1e0f2438241..995a48ba27a79d03f9a7959c878d3ed85ddace75 100644 --- a/src/MATLAB/+Segmentation/SegAndTrack.m +++ b/src/MATLAB/+Segmentation/SegAndTrack.m @@ -5,10 +5,10 @@ % EW - rewrite %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by @@ -35,7 +35,7 @@ function [errStatus, segInfo] = SegAndTrack() settings = Load.ReadSettings(); [settings.matFile,settings.matFilePath,FilterIndex] = uiputfile('.mat','Save edits',... - [CONSTANTS.datasetName '_LEVer.mat']); + [Metadata.GetDatasetName() '_LEVer.mat']); if(~FilterIndex) return; @@ -52,10 +52,10 @@ function [errStatus, segInfo] = SegAndTrack() end segArgs = Segmentation.GetCellTypeParams(); - [errStatus tSeg tTrack] = Segmentation.SegAndTrackDataset(CONSTANTS.rootImageFolder, CONSTANTS.datasetName, CONSTANTS.imageNamePattern, numProcessors, segArgs); + [errStatus,tSeg,tTrack] = Segmentation.SegAndTrackDataset(numProcessors, segArgs); if ( ~isempty(errStatus) ) - errFilename = [CONSTANTS.datasetName '_segtrack_err.log']; + errFilename = [Metadata.GetDatasetName() '_segtrack_err.log']; msgbox(['An error occured during segmentation and tracking. For further details see log file: ' errFilename],'SegAndTrack Error','warn'); diff --git a/src/MATLAB/+Segmentation/SegAndTrackDataset.m b/src/MATLAB/+Segmentation/SegAndTrackDataset.m index c3b8138498f24790e4c4ba8a01b4c3db522219c0..c5565d328f3a2b23ae599b8d0c447fbe763b36ec 100644 --- a/src/MATLAB/+Segmentation/SegAndTrackDataset.m +++ b/src/MATLAB/+Segmentation/SegAndTrackDataset.m @@ -1,4 +1,28 @@ -function [errStatus tSeg tTrack] = SegAndTrackDataset(rootFolder, datasetName, namePattern, numProcessors, segArgs) + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function [errStatus,tSeg,tTrack] = SegAndTrackDataset(numProcessors, segArgs) global CONSTANTS CellHulls HashedCells ConnectedDist errStatus = sprintf('Unknown Error\n'); @@ -8,24 +32,23 @@ function [errStatus tSeg tTrack] = SegAndTrackDataset(rootFolder, datasetName, n %% Segmentation tic - % Remove trailing \ or / from rootFolder - if ( (rootFolder(end) == '\') || (rootFolder(end) == '/') ) - rootFolder = rootFolder(1:end-1); + if ( Metadata.GetNumberOfFrames() < 1 ) + return; end - % Set CONSTANTS.imageSize as soon as possible - [channelList,frameList] = Helper.GetImListInfo(CONSTANTS.rootImageFolder, CONSTANTS.imageNamePattern); - - Load.AddConstant('numFrames', frameList(end),1); - Load.AddConstant('numChannels', channelList(end),1); - - numProcessors = min(numProcessors, CONSTANTS.numFrames); - - if ( CONSTANTS.numFrames < 1 ) - return; + numProcessors = min(numProcessors, Metadata.GetNumberOfFrames()); + + numProcessors = min(numProcessors, Metadata.GetNumberOfFrames()); + bytesPerIm = prod(Metadata.GetDimensions()) * Metadata.GetNumberOfChannels() * 8; + m = memory; + maxWorkers = min(numProcessors,floor(m.MaxPossibleArrayBytes / bytesPerIm)); + + % Remove trailing \ or / from rootFolder + if ( (CONSTANTS.rootImageFolder(end) == '\') || (CONSTANTS.rootImageFolder(end) == '/') ) + CONSTANTS.rootImageFolder = CONSTANTS.rootImageFolder(1:end-1); end - fprintf('Segmenting (using %s processors)...\n',num2str(numProcessors)); + fprintf('Segmenting (using %s processors)...\n',num2str(maxWorkers)); if(~isempty(dir('.\segmentationData'))) removeOldFiles('segmentationData', 'err_*.log'); @@ -33,18 +56,9 @@ function [errStatus tSeg tTrack] = SegAndTrackDataset(rootFolder, datasetName, n removeOldFiles('segmentationData', 'done_*.txt'); end - imSet = Helper.LoadIntensityImageSet(1); - - imSizes = zeros(length(imSet),2); - for i=1:length(imSet) - imSizes(i,:) = size(imSet{i}); - end - - Load.AddConstant('imageSize', max(imSizes,[],1),1); - - if ( ndims(CONSTANTS.imageSize) < 2 || ndims(CONSTANTS.imageSize) >= 3 ) + if ( isempty(Metadata.GetDimensions()) ) cltime = clock(); - errStatus = sprintf('%02d:%02d:%02.1f - Images are empty or have incorrect dimensions [%s]\n',cltime(4),cltime(5),cltime(6), num2str(CONSTANTS.imageSize)); + errStatus = sprintf('%02d:%02d:%02.1f - Images dimensions are empty\n',cltime(4),cltime(5),cltime(6)); return; end @@ -53,30 +67,69 @@ function [errStatus tSeg tTrack] = SegAndTrackDataset(rootFolder, datasetName, n mkdir('segmentationData'); end - for procID=1:numProcessors - segCmd = makeSegCommand(procID,numProcessors,CONSTANTS.numChannels,CONSTANTS.numFrames,CONSTANTS.cellType,CONSTANTS.primaryChannel,rootFolder,namePattern,segArgs); - system(['start ' segCmd ' && exit']); + metadataFile = fullfile(CONSTANTS.rootImageFolder, [Metadata.GetDatasetName() '.json']); + primaryChannel = CONSTANTS.primaryChannel; + cellType = CONSTANTS.cellType; + + if ( isdeployed() ) + %% compliled version + % Must use separately compiled segmentor algorithm in compiled LEVer + % because parallel processing toolkit is unsupported + for procID=1:maxWorkers + segCmd = makeSegCommand(procID,maxWorkers,primaryChannel,metadataFile,cellType,segArgs); + system(['start ' segCmd ' && exit']); + end + else + %% single threaded version +% for procID=1:maxWorkers +% Segmentor(procID,maxWorkers,primaryChannel,metadataFile,cellType,segArgs{:}); +% end + + %% spmd version + poolObj = gcp('nocreate'); + if (~isempty(poolObj)) + oldWorkers = poolObj.NumWorkers; + if (oldWorkers~=maxWorkers) + delete(poolObj); + parpool(maxWorkers); + end + else + oldWorkers = 0; + parpool(maxWorkers); + end + + spmd + Segmentor(labindex,numlabs,primaryChannel,metadataFile,cellType,segArgs{:}); + end + + if (oldWorkers~=0 && oldWorkers~=maxWorkers) + delete(gcp); + if (oldWorkers>0) + parpool(oldWorkers); + end + end end -% for procID=1:numProcessors -% Segmentor(procID,numProcessors,CONSTANTS.numChannels,CONSTANTS.numFrames,CONSTANTS.cellType,CONSTANTS.primaryChannel,rootFolder,namePattern,segArgs{:}); -% end - - bSegFileExists = false(1,numProcessors); - for procID=1:numProcessors - errFile = ['.\segmentationData\err_' num2str(procID) '.log']; - fileName = ['.\segmentationData\objs_' num2str(procID) '.mat']; - semFile = ['.\segmentationData\done_' num2str(procID) '.txt']; - semDesc = dir(semFile); - fileDescriptor = dir(fileName); - efd = dir(errFile); - while((isempty(fileDescriptor) || isempty(semDesc)) && isempty(efd)) - pause(3) - fileDescriptor = dir(fileName); - efd = dir(errFile); - semDesc = dir(semFile); + + %% collate output + bSegFileExists = false(1,maxWorkers); + bSemFileExists = false(1,maxWorkers); + bErrFileExists = false(1,maxWorkers); + + bProcFinish = false(1,maxWorkers); + while ( ~all(bProcFinish) ) + pause(3); + + for procID=1:maxWorkers + errFile = ['.\segmentationData\err_' num2str(procID) '.log']; + segFile = ['.\segmentationData\objs_' num2str(procID) '.mat']; + semFile = ['.\segmentationData\done_' num2str(procID) '.txt']; + + bErrFileExists(procID) = ~isempty(dir(errFile)); + bSegFileExists(procID) = ~isempty(dir(segFile)); + bSemFileExists(procID) = ~isempty(dir(semFile)); end - bSegFileExists(procID) = ~isempty(fileDescriptor); + bProcFinish = bErrFileExists | (bSegFileExists & bSemFileExists); end if ( ~all(bSegFileExists) ) @@ -104,16 +157,14 @@ function [errStatus tSeg tTrack] = SegAndTrackDataset(rootFolder, datasetName, n try cellSegments = []; - frameOrder = []; - for procID=1:numProcessors - fileName = ['.\segmentationData\objs_' num2str(procID) '.mat']; + for procID=1:maxWorkers + segFile = ['.\segmentationData\objs_' num2str(procID) '.mat']; - tstLoad = whos('-file', fileName); + tstLoad = whos('-file', segFile); - load(fileName); + load(segFile); cellSegments = [cellSegments hulls]; - frameOrder = [frameOrder frameTimes]; end catch excp @@ -133,20 +184,12 @@ function [errStatus tSeg tTrack] = SegAndTrackDataset(rootFolder, datasetName, n % Sort segmentations and fluorescent data so that they are time ordered segtimes = [cellSegments.time]; - [srtSegs srtIdx] = sort(segtimes); + [~,srtIdx] = sort(segtimes); CellHulls = Helper.MakeInitStruct(Helper.GetCellHullTemplate(), cellSegments(srtIdx)); - % Make sure center of mass is available - for i=1:length(CellHulls) - [r c] = ind2sub(CONSTANTS.imageSize, CellHulls(i).indexPixels); - CellHulls(i).centerOfMass = mean([r c], 1); - end - - [srtFrames srtIdx] = sort(frameOrder); - - fprintf('Building Connected Component Distances... '); - HashedCells = cell(1,CONSTANTS.numFrames); - for t=1:CONSTANTS.numFrames + %% Build hashed cell list + HashedCells = cell(1,Metadata.GetNumberOfFrames()); + for t=1:Metadata.GetNumberOfFrames() HashedCells{t} = struct('hullID',{}, 'trackID',{}); end @@ -154,9 +197,10 @@ function [errStatus tSeg tTrack] = SegAndTrackDataset(rootFolder, datasetName, n HashedCells{CellHulls(i).time} = [HashedCells{CellHulls(i).time} struct('hullID',{i}, 'trackID',{0})]; end + %% Create connected component distances for tracker + fprintf('Building Connected Component Distances... '); ConnectedDist = []; Tracker.BuildConnectedDistance(1:length(CellHulls), 0, 1); - Segmentation.WriteSegData('segmentationData',datasetName); fprintf(1,'\nDone\n'); tSeg = toc; @@ -164,19 +208,16 @@ function [errStatus tSeg tTrack] = SegAndTrackDataset(rootFolder, datasetName, n %% Tracking tic fprintf(1,'Tracking...'); - fnameIn=['.\segmentationData\SegObjs_' datasetName '.txt']; - fnameOut=['.\segmentationData\Tracked_' datasetName '.txt']; - system(['MTC.exe ' num2str(CONSTANTS.dMaxCenterOfMass) ' ' num2str(CONSTANTS.dMaxConnectComponentTracker) ' "' fnameIn '" "' fnameOut '" > out.txt']); + [hullTracks,gConnect] = trackerMex(CellHulls, ConnectedDist, Metadata.GetNumberOfFrames(), CONSTANTS.dMaxCenterOfMass, CONSTANTS.dMaxConnectComponentTracker); fprintf('Done\n'); tTrack = toc; %% Import into LEVer's data sturcture - [objTracks gConnect] = Tracker.ReadTrackData('segmentationData', CONSTANTS.datasetName); fprintf('Finalizing Data...'); try - Tracker.BuildTrackingData(objTracks, gConnect); + Tracker.BuildTrackingData(hullTracks, gConnect); catch excp cltime = clock(); @@ -190,16 +231,13 @@ function [errStatus tSeg tTrack] = SegAndTrackDataset(rootFolder, datasetName, n errStatus = ''; end -function segCmd = makeSegCommand(procID, numProc, numChannels, numFrames, cellType, primaryChannel, rootFolder, imagePattern, segArg) +function segCmd = makeSegCommand(procID, numProc, primaryChannel, metadataFile, cellType, segArg) segCmd = 'Segmentor'; segCmd = [segCmd ' "' num2str(procID) '"']; segCmd = [segCmd ' "' num2str(numProc) '"']; - segCmd = [segCmd ' "' num2str(numChannels) '"']; - segCmd = [segCmd ' "' num2str(numFrames) '"']; - segCmd = [segCmd ' "' cellType '"']; segCmd = [segCmd ' "' num2str(primaryChannel) '"']; - segCmd = [segCmd ' "' rootFolder '"']; - segCmd = [segCmd ' "' imagePattern '"']; + segCmd = [segCmd ' "' metadataFile '"']; + segCmd = [segCmd ' "' cellType '"']; for i=1:length(segArg) segCmd = [segCmd ' "' num2str(segArg{i}) '"']; diff --git a/src/MATLAB/+Segmentation/SplitHull.m b/src/MATLAB/+Segmentation/SplitHull.m index b5d2b79c12a06cbaca209ec10340b42300656982..3571e70c77eb447b864597384b32df6c84a51f6e 100644 --- a/src/MATLAB/+Segmentation/SplitHull.m +++ b/src/MATLAB/+Segmentation/SplitHull.m @@ -4,10 +4,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Segmentation/WriteSegData.m b/src/MATLAB/+Segmentation/WriteSegData.m index 0d5066fb1df28d866ed4b056b73e3c5139e7903d..87acbaf6e036d8855d6223a82f33638e82aab81b 100644 --- a/src/MATLAB/+Segmentation/WriteSegData.m +++ b/src/MATLAB/+Segmentation/WriteSegData.m @@ -1,5 +1,36 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function WriteSegData(DatasetDir, DatasetName) -global CONSTANTS CellHulls ConnectedDist +global CellHulls ConnectedDist + +% fname=Helper.GetFullImagePath(1); +% im = Helper.LoadIntensityImage(fname); +% if isempty(im) +% fprintf('error - unable to extract image size - tracking will fail\n'); +% end +rcImageDims = Metadata.GetDimensions('rc'); th = max([CellHulls.time]); hashedHulls = cell(th,1); @@ -15,7 +46,7 @@ fprintf(fid,'%d %d\n',th,length(CellHulls) ); for i=1:length(hashedHulls) fprintf(fid,'%d\n',length(hashedHulls{i}) ); for j=1:length(hashedHulls{i}) - [r c]=ind2sub(CONSTANTS.imageSize,CellHulls(hashedHulls{i}(j)).indexPixels); + [r c]=ind2sub(rcImageDims,CellHulls(hashedHulls{i}(j)).indexPixels); COM=round(mean([r c],1)); fprintf(fid,'%d %d %d %d:',COM(2),COM(1),length(r),size(ConnectedDist{hashedHulls{i}(j)},1) ); for k=1:size(ConnectedDist{hashedHulls{i}(j)},1) diff --git a/src/MATLAB/+Tracker/AssignEdge.m b/src/MATLAB/+Tracker/AssignEdge.m index 2e8876b21a9a2d25e92655ed4dbb3062e22992ef..d2d68935f54b4bec68bd3ec0aeff537a9cdcdaa6 100644 --- a/src/MATLAB/+Tracker/AssignEdge.m +++ b/src/MATLAB/+Tracker/AssignEdge.m @@ -4,6 +4,30 @@ % assignment for assignHull such that it will be on the same track as % trackHull. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function changedHulls = AssignEdge(trackHull, assignHull) global CellHulls CellTracks CellFamilies diff --git a/src/MATLAB/+Tracker/BuildConnectedDistance.m b/src/MATLAB/+Tracker/BuildConnectedDistance.m index 87f8ff76cce177ffe53b3b07da7e7029c6c4512e..a7395ddc7a5df5c3b8e5b85eb2e1f3cd36ca6f25 100644 --- a/src/MATLAB/+Tracker/BuildConnectedDistance.m +++ b/src/MATLAB/+Tracker/BuildConnectedDistance.m @@ -3,10 +3,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracker/BuildTrackingData.m b/src/MATLAB/+Tracker/BuildTrackingData.m index 8a57b9f09c0b58ec87e268d909a1c18d3fd68fc5..e31ebce6644de9773ac231b8bbe998b08beac7f6 100644 --- a/src/MATLAB/+Tracker/BuildTrackingData.m +++ b/src/MATLAB/+Tracker/BuildTrackingData.m @@ -1,5 +1,29 @@ -function BuildTrackingData(objTracks, gConnect) - global CONSTANTS Costs GraphEdits ResegLinks CellHulls CellFamilies CellTracks HashedCells CellPhenotypes + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function BuildTrackingData(hullTracks, gConnect) + global Costs GraphEdits ResegLinks CellHulls CellFamilies CellTracks HashedCells CellPhenotypes %ensure that the globals are empty Costs = gConnect; @@ -13,18 +37,15 @@ function BuildTrackingData(objTracks, gConnect) CellPhenotypes = struct('descriptions', {{'died'}}, 'hullPhenoSet', {zeros(2,0)}); hullList = []; - for i=length(objTracks):-1:1 - UI.Progressbar((length(objTracks)-i) / (length(objTracks))); + for i=length(hullTracks):-1:1 + UI.Progressbar((length(hullTracks)-i) / (length(hullTracks))); if ( any(ismember(hullList,i)) ) continue; end - if ( objTracks(i).inID ~= 0 ) - continue; - end - - hullList = addToTrack(i,hullList,objTracks); + allTrackHulls = find(hullTracks == hullTracks(i)); + hullList = [hullList addToTrack(allTrackHulls)]; end if ( length(hullList) ~= length(CellHulls) ) @@ -43,36 +64,19 @@ function BuildTrackingData(objTracks, gConnect) Dev.PrintIntegrityErrors(errors); end - %create the family trees Families.ProcessNewborns(); end -function hullList = addToTrack(hullID, hullList, objTracks) - global CellHulls - - if ( any(ismember(hullList,hullID)) || objTracks(hullID).inID ~= 0 ) +function hullList = addToTrack(allTrackHulls) + if ( isempty(allTrackHulls) ) return end - Families.NewCellFamily(hullID); - hullList = [hullList hullID]; - - nextHull = hullID; - while ( objTracks(nextHull).outID ~= 0 ) - nextHull = objTracks(nextHull).outID; - - if ( any(ismember(hullList,nextHull)) ) - break; - end - - if ( any(ismember(hullList,objTracks(nextHull).inID)) ) - Tracks.AddHullToTrack(nextHull,[],objTracks(nextHull).inID); - else - %this runs if there was an error in objTracks data structure - Families.NewCellFamily(hull); - end - - hullList = [hullList nextHull]; + Families.NewCellFamily(allTrackHulls(1)); + for i=2:length(allTrackHulls) + Tracks.AddHullToTrack(allTrackHulls(i),[],allTrackHulls(i-1)); end -end \ No newline at end of file + + hullList = allTrackHulls; +end diff --git a/src/MATLAB/+Tracker/CalcHullConnectedDistances.m b/src/MATLAB/+Tracker/CalcHullConnectedDistances.m index 77d42e286fc4e104b78e359aaa1b2a828cfabe12..4208bcb0af9b81fa79d9af0f7402c9e7222980cc 100644 --- a/src/MATLAB/+Tracker/CalcHullConnectedDistances.m +++ b/src/MATLAB/+Tracker/CalcHullConnectedDistances.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function ccDist = CalcHullConnectedDistances(hullID, nextHullIDs, hullPerims, hulls) global CONSTANTS @@ -20,8 +44,9 @@ function ccDist = CalcHullConnectedDistances(hullID, nextHullIDs, hullPerims, hu return; end + rcImageDims = Metadata.GetDimensions('rc'); for i=1:length(checkHullIDs) - chkDist = Helper.CalcConnectedDistance(hullID,checkHullIDs(i), CONSTANTS.imageSize, hullPerims, hulls); + chkDist = Helper.CalcConnectedDistance(hullID,checkHullIDs(i), rcImageDims, hullPerims, hulls); ccDist(chkHullIdx(i)) = chkDist; end end diff --git a/src/MATLAB/+Tracker/CheckGraphEdits.m b/src/MATLAB/+Tracker/CheckGraphEdits.m index 02423281fc181c9e78ad06b358af6870676cc106..5e9752749b481b736cf061387f8dcf39daa067eb 100644 --- a/src/MATLAB/+Tracker/CheckGraphEdits.m +++ b/src/MATLAB/+Tracker/CheckGraphEdits.m @@ -4,10 +4,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracker/ClearCostHulls.m b/src/MATLAB/+Tracker/ClearCostHulls.m deleted file mode 100644 index afe45286d5af4be792e1d9a3e4634784afb64d1d..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Tracker/ClearCostHulls.m +++ /dev/null @@ -1,18 +0,0 @@ -% ClearCostEdges(hulls) -% Zeros all incoming and outgoing edges from hulls in Costs graph, also -% updates GraphEdits and cached cost matrix. - -function ClearCostHulls(hulls) - global Costs GraphEdits CachedCostMatrix - - for i=1:length(hulls) - Costs(hulls(i),:) = 0; - CachedCostMatrix(hulls(i),:) = 0; - GraphEdits(hulls(i),:) = 0; - - Costs(:,hulls(i)) = 0; - CachedCostMatrix(:,hulls(i)) = 0; - GraphEdits(:,hulls(i)) = 0; - end -end - diff --git a/src/MATLAB/+Tracker/ConvertTrackingData.m b/src/MATLAB/+Tracker/ConvertTrackingData.m deleted file mode 100644 index 06ffffa6eacdfa7aa6bf3d182cb26f96d33e2b74..0000000000000000000000000000000000000000 --- a/src/MATLAB/+Tracker/ConvertTrackingData.m +++ /dev/null @@ -1,159 +0,0 @@ -% ConvertTrackingData.m - Takes the data structure from the tracking data -% and creates LEVer's data scheme - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter -% -% This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -% -% LEVer is free software: you can redistribute it and/or modify -% it under the terms of the GNU General Public License as published by -% the Free Software Foundation, either version 3 of the License, or -% (at your option) any later version. -% -% LEVer is distributed in the hope that it will be useful, -% but WITHOUT ANY WARRANTY; without even the implied warranty of -% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% GNU General Public License for more details. -% -% You should have received a copy of the GNU General Public License -% along with LEVer in file "gnu gpl v3.txt". If not, see -% <http://www.gnu.org/licenses/>. -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -function ConvertTrackingData(objHulls,gConnect) - -global Costs GraphEdits ResegLinks CellHulls CellFamilies CellTracks HashedCells CellPhenotypes ConnectedDist Log CONSTANTS - -%ensure that the globals are empty -Costs = []; -GraphEdits = []; -ResegLinks = []; -CellHulls = []; -CellFamilies = []; -CellTracks = []; -HashedCells = []; -ConnectedDist = []; -CellPhenotypes = []; -Log = []; - -Costs = gConnect; -GraphEdits = sparse([], [], [], size(Costs,1), size(Costs,2), round(0.1*size(Costs,2))); -ResegLinks = sparse([], [], [], size(Costs,1), size(Costs,2), round(0.1*size(Costs,2))); - -connDist = cell(1,length(objHulls)); - -%Initialize Structures -cellHulls = struct(... - 'time', {},... - 'points', {},... - 'centerOfMass', {},... - 'indexPixels', {},... - 'deleted', {},... - 'userEdited', {}); -%Initialize Cell types -CellPhenotypes = struct('descriptions', {{'died' 'ambiguous' 'off screen'}}, 'hullPhenoSet', {zeros(2,0)}, 'colors',{[0 0 0;.549 .28235 .6235;0 1 1]}); - -%loop through the Hulls -parfor i=1:length(objHulls) - cellHulls(i).time = objHulls(i).t; - cellHulls(i).points = objHulls(i).points; - cellHulls(i).centerOfMass = objHulls(i).COM; - cellHulls(i).indexPixels = objHulls(i).indPixels; - cellHulls(i).deleted = false; - cellHulls(i).userEdited = false; - - connDist{i} = updateConnectedDistance(objHulls(i), objHulls, objHulls(i).DarkConnectedHulls); -end -ConnectedDist = connDist; -CellHulls = cellHulls; - -% Initialize HashedCells such that -tmax = max([CellHulls.time]); -HashedCells = cell(1,tmax); -for t=1:tmax - HashedCells{t} = struct('hullID',{}, 'trackID',{}); -end - -%walk through the tracks -progress = 1; -iterations = length(objHulls); -hullList = []; -for i=length(objHulls):-1:1 - progress = progress+1; - UI.Progressbar(progress/iterations); - if(any(ismember(hullList,i))),continue,end - if(objHulls(i).inID~=0),continue,end - hullList = addToTrack(i,hullList,objHulls); -end - -%add any hulls that were missed -if(length(hullList)~=length(CellHulls)) - reprocess = find(ismember(1:length(CellHulls),hullList)==0); - progress = 1; - iterations = length(objHulls); - for i=1:length(reprocess) - progress = progress+1; - UI.Progressbar(progress/iterations); - Families.NewCellFamily(reprocess(i)); - end -end -UI.Progressbar(1);%clear it out - -errors = mexIntegrityCheck(); -if ( ~isempty(errors) ) - Dev.PrintIntegrityErrors(errors); -end - -% Build initial CachedCostMatrix for new data -Load.InitializeCachedCosts(1); - -% try to patch Wehi data -if strcmp(CONSTANTS.cellType, 'Wehi') - Tracker.PatchWehi(); -end - -%create the family trees -Families.ProcessNewborns(); -end - -function hullList = addToTrack(hull,hullList,objHulls) -%error checking -if(any(ismember(hullList,hull)) || objHulls(hull).inID ~= 0) - %already part of a track - return -end - -Families.NewCellFamily(hull); -hullList = [hullList hull]; - -while(objHulls(hull).outID~=0) - hull = objHulls(hull).outID; - if(any(ismember(hullList,hull))),break,end - if(any(ismember(hullList,objHulls(hull).inID))) - Tracks.AddHullToTrack(hull,[],objHulls(hull).inID); - else - %this runs if there was an error in objHulls data structure - Families.NewCellFamily(hull); - end - hullList = [hullList hull]; -end -end - -function connDist = updateConnectedDistance(fromObj, objHulls, connectedHulls) - connDist = connectedHulls; - - if ( isempty(connectedHulls) ) - return; - end - - zeroDist = find(connectedHulls(:,2) == 0); - for i=1:length(zeroDist) - toObj = objHulls(connectedHulls(zeroDist(i),1)); - isectDist = 1 - (length(intersect(fromObj.indPixels, toObj.indPixels)) / min(length(fromObj.indPixels), length( toObj.indPixels))); - connDist(zeroDist(i),2) = isectDist; - end -end diff --git a/src/MATLAB/+Tracker/GetConnectedDistance.m b/src/MATLAB/+Tracker/GetConnectedDistance.m index 87d48d139c4ccb87eeedc9408329e9310bae0680..a8a0329bd34f8b7847ea13d0da01480468085543 100644 --- a/src/MATLAB/+Tracker/GetConnectedDistance.m +++ b/src/MATLAB/+Tracker/GetConnectedDistance.m @@ -2,10 +2,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracker/GetCostClique.m b/src/MATLAB/+Tracker/GetCostClique.m index 6de8bedff77c310b63b038c906c0d7fda8ee1898..1a320075ee7020e3337ffa64e355c7d6955246f4 100644 --- a/src/MATLAB/+Tracker/GetCostClique.m +++ b/src/MATLAB/+Tracker/GetCostClique.m @@ -1,4 +1,28 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [startHulls nextHulls] = GetCostClique(startHulls, nextHulls, tMax) global CellHulls Costs diff --git a/src/MATLAB/+Tracker/GetCostMatrix.m b/src/MATLAB/+Tracker/GetCostMatrix.m index 593ec5233fe8d5ffbdcbbe6a7808709f0c486740..b0952c081e66c703c91f0f84672c4d7c7fe756d6 100644 --- a/src/MATLAB/+Tracker/GetCostMatrix.m +++ b/src/MATLAB/+Tracker/GetCostMatrix.m @@ -3,10 +3,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracker/GetCostSubmatrix.m b/src/MATLAB/+Tracker/GetCostSubmatrix.m index 2dd7650f5953b3c676b02b7ef87530e7565926ac..9addd2b6bca0cf4d348abd32f646d31b86cbdfd7 100644 --- a/src/MATLAB/+Tracker/GetCostSubmatrix.m +++ b/src/MATLAB/+Tracker/GetCostSubmatrix.m @@ -3,10 +3,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracker/GetTrackSegScore.m b/src/MATLAB/+Tracker/GetTrackSegScore.m index e5cd8767ea412d5c1b01e4dea154140cf05560e7..8ef911d4d694cbe699faf72ec143d21aa15459eb 100644 --- a/src/MATLAB/+Tracker/GetTrackSegScore.m +++ b/src/MATLAB/+Tracker/GetTrackSegScore.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function trackSegScore = GetTrackSegScore(trackID) trackSegScore = 1.0; end \ No newline at end of file diff --git a/src/MATLAB/+Tracker/GetTrackingCosts.m b/src/MATLAB/+Tracker/GetTrackingCosts.m index 3c010601392b020d1d3708b328225ef607d4aa4e..c2a38bd215811171ef8cf3e4bd25a8ff953f0d19 100644 --- a/src/MATLAB/+Tracker/GetTrackingCosts.m +++ b/src/MATLAB/+Tracker/GetTrackingCosts.m @@ -5,10 +5,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracker/GraphEditAddMitosis.m b/src/MATLAB/+Tracker/GraphEditAddMitosis.m index b98bc4772ce0af066ea780388b99dd2701e568e9..409130b09cb873647383dc2facb757d7ca8cae96 100644 --- a/src/MATLAB/+Tracker/GraphEditAddMitosis.m +++ b/src/MATLAB/+Tracker/GraphEditAddMitosis.m @@ -3,10 +3,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracker/GraphEditRemoveEdge.m b/src/MATLAB/+Tracker/GraphEditRemoveEdge.m index bdd58c83f7ebe52a5c91d80405294c6b22a4e398..bf1e997ca9b4921ff4744a29ed4018c8f80a4cb0 100644 --- a/src/MATLAB/+Tracker/GraphEditRemoveEdge.m +++ b/src/MATLAB/+Tracker/GraphEditRemoveEdge.m @@ -5,10 +5,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracker/GraphEditSetEdge.m b/src/MATLAB/+Tracker/GraphEditSetEdge.m index 3bef13801b291c286e80cf5c4014a3afe9b31f07..03eb9b0b5012f78115f63f62ee8afaf8ac412ad2 100644 --- a/src/MATLAB/+Tracker/GraphEditSetEdge.m +++ b/src/MATLAB/+Tracker/GraphEditSetEdge.m @@ -4,10 +4,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracker/GraphEditsResetHulls.m b/src/MATLAB/+Tracker/GraphEditsResetHulls.m index a1e3aa512f72682edf93cd49192f7bafc0e07985..3ce5e9a56ce68febe6cc87d7bf5322550c4ae32b 100644 --- a/src/MATLAB/+Tracker/GraphEditsResetHulls.m +++ b/src/MATLAB/+Tracker/GraphEditsResetHulls.m @@ -3,6 +3,30 @@ % Clears all user edits into (bResetBack) and/or out of (bResetForward) % a hull, updates associated cached costs. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function GraphEditsResetHulls(hulls, bResetForward, bResetBack) global Costs GraphEdits diff --git a/src/MATLAB/+Tracker/PatchMatchedTracks.m b/src/MATLAB/+Tracker/PatchMatchedTracks.m index 9a35dde3358cba28e47794d33639faac873a5f11..6b669771361afa262a14bf7a4ad9666fc9198823 100644 --- a/src/MATLAB/+Tracker/PatchMatchedTracks.m +++ b/src/MATLAB/+Tracker/PatchMatchedTracks.m @@ -5,10 +5,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracker/PatchTracks.m b/src/MATLAB/+Tracker/PatchTracks.m index 535d55245b7f7a1a72e85b0445eaeb8c527122c3..2b6571a6d74221921c721a601797a02823a60eff 100644 --- a/src/MATLAB/+Tracker/PatchTracks.m +++ b/src/MATLAB/+Tracker/PatchTracks.m @@ -5,10 +5,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracker/PatchWehi.m b/src/MATLAB/+Tracker/PatchWehi.m index 428a6759440056202ea6c122af7bb0dd96ca2b8e..acc5e87a180c9b3b99faff1994117bf15d97e517 100644 --- a/src/MATLAB/+Tracker/PatchWehi.m +++ b/src/MATLAB/+Tracker/PatchWehi.m @@ -5,10 +5,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Walt Mankowski, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracker/ReadTrackData.m b/src/MATLAB/+Tracker/ReadTrackData.m index ba6853f9f4909d17488a105d0dd461f65a2bbaa6..b3a7f31fcccf783b44e0fd8ffffa2ca3616423fa 100644 --- a/src/MATLAB/+Tracker/ReadTrackData.m +++ b/src/MATLAB/+Tracker/ReadTrackData.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function [objTracks gConnect] = ReadTrackData(DatasetDir, DatasetName) global CellHulls diff --git a/src/MATLAB/+Tracker/ReassignTracks.m b/src/MATLAB/+Tracker/ReassignTracks.m index 6140c443da6ab6aca0aef0709e5971006a54b065..1568d8dc26ff52f9dd414736358900cd437c27c7 100644 --- a/src/MATLAB/+Tracker/ReassignTracks.m +++ b/src/MATLAB/+Tracker/ReassignTracks.m @@ -3,10 +3,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracker/SiblingDistance.m b/src/MATLAB/+Tracker/SiblingDistance.m index 9b8e3faa64afbe3526dc9ecb8f4827c4f9c9f3bf..0d4cecd531452902186daa6d3b5b9b10f4496206 100644 --- a/src/MATLAB/+Tracker/SiblingDistance.m +++ b/src/MATLAB/+Tracker/SiblingDistance.m @@ -6,10 +6,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by @@ -43,7 +43,7 @@ end hullPerims = containers.Map('KeyType','uint32', 'ValueType','any'); -ccDist = Helper.CalcConnectedDistance(cell1HullID,cell2HullID, CONSTANTS.imageSize, hullPerims, CellHulls); +ccDist = Helper.CalcConnectedDistance(cell1HullID,cell2HullID, Metadata.GetDimensions('rc'), hullPerims, CellHulls); distanceCenterOfMass = norm(CellHulls(cell1HullID).centerOfMass - CellHulls(cell2HullID).centerOfMass); if(distanceCenterOfMass > CONSTANTS.maxCenterOfMassDistance || ccDist > CONSTANTS.maxPixelDistance) diff --git a/src/MATLAB/+Tracker/TrackAddedHulls.m b/src/MATLAB/+Tracker/TrackAddedHulls.m index a7f41144a4212170571651cdbb88d3862d03e4ea..f64cba9c9c37f0657c5abdfe14698dd9610d712c 100644 --- a/src/MATLAB/+Tracker/TrackAddedHulls.m +++ b/src/MATLAB/+Tracker/TrackAddedHulls.m @@ -3,10 +3,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracker/TrackThroughMerge.m b/src/MATLAB/+Tracker/TrackThroughMerge.m index f5fcc199948af332f9573e52c62497f6d1e7ae79..ded88adec16a32099e5f28ac9fca190a96120d6c 100644 --- a/src/MATLAB/+Tracker/TrackThroughMerge.m +++ b/src/MATLAB/+Tracker/TrackThroughMerge.m @@ -4,10 +4,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracker/TrackThroughSplit.m b/src/MATLAB/+Tracker/TrackThroughSplit.m index fa3c6221786bb94a8a1adb5aebdba96a85f3297e..6dc40baaf88860076392e41bc2e3917030b3c820 100644 --- a/src/MATLAB/+Tracker/TrackThroughSplit.m +++ b/src/MATLAB/+Tracker/TrackThroughSplit.m @@ -3,10 +3,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracker/UpdateCachedCosts.m b/src/MATLAB/+Tracker/UpdateCachedCosts.m index 4e174ea7b8c04957a2d66671d6ab3431038d4711..fc07da22c08ecf4870cd5fa1d151aedc7984e8ad 100644 --- a/src/MATLAB/+Tracker/UpdateCachedCosts.m +++ b/src/MATLAB/+Tracker/UpdateCachedCosts.m @@ -2,6 +2,30 @@ % This must be run after a cost matrix or graph-edits change to keep cached % costs up to date. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function UpdateCachedCosts(fromHulls, toHulls) global CellFamilies CellTracks CellHulls Costs GraphEdits CachedCostMatrix diff --git a/src/MATLAB/+Tracker/UpdateConnectedDistances.m b/src/MATLAB/+Tracker/UpdateConnectedDistances.m index 8dcc27a294dca4c5ae1c2abd263dfcc2ec21426f..6ee7ddab1d08b203dbaa203e2d7febdf88738d13 100644 --- a/src/MATLAB/+Tracker/UpdateConnectedDistances.m +++ b/src/MATLAB/+Tracker/UpdateConnectedDistances.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function connDist = UpdateConnectedDistances(updateCell, t, tNext, hullPerims, connDist, hulls, hash) global CONSTANTS diff --git a/src/MATLAB/+Tracker/UpdateCostEdges.m b/src/MATLAB/+Tracker/UpdateCostEdges.m index 88089ec6144e37699f003cea9e316957971c1677..7dd7a91b18c64f276d48589c13408d9f53e24892 100644 --- a/src/MATLAB/+Tracker/UpdateCostEdges.m +++ b/src/MATLAB/+Tracker/UpdateCostEdges.m @@ -2,6 +2,30 @@ % Updates full Cost graph with edges from the costMatrix subgraph. % Also handles updating the cached matrix used by GetCostMatrix() calls. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function UpdateCostEdges(costMatrix, fromHulls, toHulls) global Costs diff --git a/src/MATLAB/+Tracker/UpdateTrackingCosts.m b/src/MATLAB/+Tracker/UpdateTrackingCosts.m index 4ccecef162e23e63cf9a472c8db22ed1188ddee0..d8d56225ea6ebbc124af9ee65c3a988abb74bbfc 100644 --- a/src/MATLAB/+Tracker/UpdateTrackingCosts.m +++ b/src/MATLAB/+Tracker/UpdateTrackingCosts.m @@ -2,10 +2,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracks/AddHullToTrack.m b/src/MATLAB/+Tracks/AddHullToTrack.m index 894514a35afecd94651c4bc574f0f5f6eb2816a1..7c60c335eb8eca897fa58b51c047edc23a708865 100644 --- a/src/MATLAB/+Tracks/AddHullToTrack.m +++ b/src/MATLAB/+Tracks/AddHullToTrack.m @@ -13,10 +13,10 @@ % EW 6/8/12 rewrite %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracks/ChangeLabel.m b/src/MATLAB/+Tracks/ChangeLabel.m index 13b9690632cf455871765e0450fea795bb4358d6..643fd850287c1b816f2ccca51b17a85041b379a1 100644 --- a/src/MATLAB/+Tracks/ChangeLabel.m +++ b/src/MATLAB/+Tracks/ChangeLabel.m @@ -4,6 +4,30 @@ % time is an optional parameter. If time is not specified, the whole % currentTrack is changed to the desiredTrack +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + % ChangeLog: % EW 6/7/12 created function [droppedTracks bErr] = ChangeLabel(currentTrack, desiredTrack, time) diff --git a/src/MATLAB/+Tracks/ChangeTrackID.m b/src/MATLAB/+Tracks/ChangeTrackID.m index 223b1fa11278a680449019cb140aac0b711c7b8b..415cba744318f9b731fcaf5a3c6319cceb885c75 100644 --- a/src/MATLAB/+Tracks/ChangeTrackID.m +++ b/src/MATLAB/+Tracks/ChangeTrackID.m @@ -8,10 +8,10 @@ % EW 6/6/12 rewrite %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracks/CheckLockedChangeLabel.m b/src/MATLAB/+Tracks/CheckLockedChangeLabel.m index 4ee18099cb3bf093a381ba1cfc57f03781d050f3..c424399437f1381fde055510eb42390e6b557ce8 100644 --- a/src/MATLAB/+Tracks/CheckLockedChangeLabel.m +++ b/src/MATLAB/+Tracks/CheckLockedChangeLabel.m @@ -3,6 +3,30 @@ % This function will check to verify if a tree-preserving change-label % needs to be run for the requested change, and if it will succeed. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [bLocked bCanChange] = CheckLockedChangeLabel(currentTrack, desiredTrack, time) global CellTracks diff --git a/src/MATLAB/+Tracks/ClearTrack.m b/src/MATLAB/+Tracks/ClearTrack.m index a13f40f1a9966fa172ea32caa98b6d3883f706d4..f4a3e2619cc331fc36bc469a1fbb5c1864f8648e 100644 --- a/src/MATLAB/+Tracks/ClearTrack.m +++ b/src/MATLAB/+Tracks/ClearTrack.m @@ -2,10 +2,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracks/GetAllTrackPhenotypes.m b/src/MATLAB/+Tracks/GetAllTrackPhenotypes.m index 39f46006d4773c667bc61d8042edb8236b887c59..0c36809c267360ccc837a7ce075b35a2f7e82ce5 100644 --- a/src/MATLAB/+Tracks/GetAllTrackPhenotypes.m +++ b/src/MATLAB/+Tracks/GetAllTrackPhenotypes.m @@ -3,10 +3,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracks/GetHullID.m b/src/MATLAB/+Tracks/GetHullID.m index a9a7971ae17042a7c0c093358a9c0a426d904af2..885b9fade8ac74089bdce095e19a0df7359918cd 100644 --- a/src/MATLAB/+Tracks/GetHullID.m +++ b/src/MATLAB/+Tracks/GetHullID.m @@ -1,6 +1,30 @@ % hullID = GetHullID(time, trackID) % Helper function to get a hull given a trackID and time +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function hullID = GetHullID(time, trackID) global CellTracks hullID = 0; diff --git a/src/MATLAB/+Tracks/GetTimeOfDeath.m b/src/MATLAB/+Tracks/GetTimeOfDeath.m index e025cc0a5533fe3c977450bdc139af4894d5502e..9880a9dcafb75cdd82696a587dd85329f72f1e82 100644 --- a/src/MATLAB/+Tracks/GetTimeOfDeath.m +++ b/src/MATLAB/+Tracks/GetTimeOfDeath.m @@ -3,10 +3,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracks/GetTrackPhenotype.m b/src/MATLAB/+Tracks/GetTrackPhenotype.m index 52ec8b19958487aa7e056ce3b1c08276db8a1fef..2e8cfb20cb12748c90ac998a91fa8a693f42f2dc 100644 --- a/src/MATLAB/+Tracks/GetTrackPhenotype.m +++ b/src/MATLAB/+Tracks/GetTrackPhenotype.m @@ -2,10 +2,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracks/GetTrackPhenoypeTimes.m b/src/MATLAB/+Tracks/GetTrackPhenoypeTimes.m index ca8ff9a227cc82d3f462fc1495e1cf6d6a86d2d1..346e913f477d913e6f57666873200a3c1ed0600e 100644 --- a/src/MATLAB/+Tracks/GetTrackPhenoypeTimes.m +++ b/src/MATLAB/+Tracks/GetTrackPhenoypeTimes.m @@ -3,10 +3,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracks/LockedChangeLabel.m b/src/MATLAB/+Tracks/LockedChangeLabel.m index e1a2a53497540ddafccf003df09779dc009e40dd..33cd34552c028fc398ab6ef111185a28ca83d66e 100644 --- a/src/MATLAB/+Tracks/LockedChangeLabel.m +++ b/src/MATLAB/+Tracks/LockedChangeLabel.m @@ -6,6 +6,30 @@ % This means that the change will move only one hull from one % track to the other, rather than changing the entire track. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function LockedChangeLabel(currentTrack, desiredTrack, time) % Completely cop-out if we can't preserve structure diff --git a/src/MATLAB/+Tracks/LockedSwapLabels.m b/src/MATLAB/+Tracks/LockedSwapLabels.m index d432cd46d5a95e5829566dfbc968f66e04e956f7..05a8658894380a2d42dde129df3fa020361477da 100644 --- a/src/MATLAB/+Tracks/LockedSwapLabels.m +++ b/src/MATLAB/+Tracks/LockedSwapLabels.m @@ -4,6 +4,30 @@ % By it's nature this preserves structures because nothing but hull % associations are modified. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function LockedSwapLabels(trackA, trackB, time) %% Error Check diff --git a/src/MATLAB/+Tracks/NewCellTrack.m b/src/MATLAB/+Tracks/NewCellTrack.m index 779bfb360338d4b5f29bddf4563da5391cb33638..50f1b2125ebb11a460ee9d75e3be5e1c004b3895 100644 --- a/src/MATLAB/+Tracks/NewCellTrack.m +++ b/src/MATLAB/+Tracks/NewCellTrack.m @@ -4,10 +4,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracks/PropagateChanges.m b/src/MATLAB/+Tracks/PropagateChanges.m index 99f5dc44475999ab98a01a9a7a7f1348dfbbe68f..5810977e2fc0cffbc643a49c947afed49b3e631e 100644 --- a/src/MATLAB/+Tracks/PropagateChanges.m +++ b/src/MATLAB/+Tracks/PropagateChanges.m @@ -3,10 +3,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracks/RehashCellTracks.m b/src/MATLAB/+Tracks/RehashCellTracks.m index 7af2a1a8fa26243184344dbf361e53c82ff05954..2b642f5cbf1849d19fff8460c5491bc851685914 100644 --- a/src/MATLAB/+Tracks/RehashCellTracks.m +++ b/src/MATLAB/+Tracks/RehashCellTracks.m @@ -10,10 +10,10 @@ % EW 6/6/12 rewrite %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracks/RemoveHullFromTrack.m b/src/MATLAB/+Tracks/RemoveHullFromTrack.m index 3c40610be2becab075fe7332e123692b6d711089..dc4cd43ad10f00ae95ab8d9d539567522d576bb4 100644 --- a/src/MATLAB/+Tracks/RemoveHullFromTrack.m +++ b/src/MATLAB/+Tracks/RemoveHullFromTrack.m @@ -10,10 +10,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracks/SetPhenotype.m b/src/MATLAB/+Tracks/SetPhenotype.m index f08d4a5e9e65af6038ff4be016e72a2f0517b4c8..d86007eaa0689a10fc794044c2231ea78ec40f31 100644 --- a/src/MATLAB/+Tracks/SetPhenotype.m +++ b/src/MATLAB/+Tracks/SetPhenotype.m @@ -4,10 +4,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracks/StraightenTrack.m b/src/MATLAB/+Tracks/StraightenTrack.m index 42e6f20f8bea48e66bbf58fdf172dba31e692add..f90e4f30eb183e54a59f42edc6df8c17c4c9cb09 100644 --- a/src/MATLAB/+Tracks/StraightenTrack.m +++ b/src/MATLAB/+Tracks/StraightenTrack.m @@ -7,10 +7,10 @@ % EW 6/6/12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracks/SwapLabels.m b/src/MATLAB/+Tracks/SwapLabels.m index 425c197391eee0c44923c9a683564659c81c4b76..95e51be178c536951898bf15ce1cf6e9f8ae756b 100644 --- a/src/MATLAB/+Tracks/SwapLabels.m +++ b/src/MATLAB/+Tracks/SwapLabels.m @@ -9,10 +9,10 @@ % EW 6/7/12 rewrite %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/+Tracks/TearoffHull.m b/src/MATLAB/+Tracks/TearoffHull.m index b14dc68d0c532a31aeafa2428593728c2e0225eb..419f40974fddda8679c8576da91b982a2e71c1ef 100644 --- a/src/MATLAB/+Tracks/TearoffHull.m +++ b/src/MATLAB/+Tracks/TearoffHull.m @@ -1,3 +1,27 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function newTrackID = TearoffHull(hullID) global CellHulls CellTracks diff --git a/src/MATLAB/+UI/CreateContextMenuCells.m b/src/MATLAB/+UI/CreateContextMenuCells.m index a1c03c1c1f0edcc713a084b15ba3b2d3b651fc23..7abca911ca44629318766a2fd605b5abe5aaf0dd 100644 --- a/src/MATLAB/+UI/CreateContextMenuCells.m +++ b/src/MATLAB/+UI/CreateContextMenuCells.m @@ -85,19 +85,30 @@ uimenu(Figures.cells.contextMenuHandle,... 'Label', 'Remove From Tree',... 'CallBack', @removeFromTree); -uimenu(Figures.cells.contextMenuHandle,... - 'Label', 'Add To Extended Family',... - 'CallBack', @addToExtendedFamily,... +multiTreeMenu = uimenu(Figures.cells.contextMenuHandle,... + 'Label', 'Multi Tree',... 'Separator', 'on'); -uimenu(Figures.cells.contextMenuHandle,... +uimenu(multiTreeMenu,... + 'Label', 'Add To Extended Family',... + 'CallBack', @addToExtendedFamily) + +uimenu(multiTreeMenu,... 'Label', 'Remove From Extended Family',... 'CallBack', @removeFromExtendedFamily); -uimenu(Figures.cells.contextMenuHandle,... +uimenu(multiTreeMenu,... 'Label', 'Show Extended Family',... 'CallBack', @showExtendedFamily); +uimenu(multiTreeMenu,... + 'Label', 'Add All To Extended Family',... + 'CallBack', @addAllToExtendedFamily); + +uimenu(multiTreeMenu,... + 'Label', 'Remove All From Extended Family',... + 'CallBack', @removeAllFromExtendedFamily); + uimenu(Figures.cells.contextMenuHandle,... 'Label', 'Properties',... 'CallBack', @properties,... @@ -251,10 +262,13 @@ end function addToExtendedFamily(src,evnt) global Figures - [hullID trackID] = UI.GetClosestCell(0); - if(isempty(trackID)),return,end + hullIDs = Figures.cells.selectedHulls; + if isempty(hullIDs) + [hullIDs ~] = UI.GetClosestCell(0); + end + if(isempty(hullIDs)),return,end - Editor.ContextAddToExtendedFamily(trackID); + Editor.ContextAddToExtendedFamily(hullIDs); end function removeFromExtendedFamily(src,evnt) @@ -274,6 +288,18 @@ function showExtendedFamily(src,evnt) msgbox({'Extended family:', num2str(CellFamilies(familyID).extFamily)}) end +function addAllToExtendedFamily(src,evnt) + global Figures + + Editor.ContextAddAllToExtendedFamily(Figures.time); +end + +function removeAllFromExtendedFamily(src,evnt) + global Figures + + Editor.ContextRemoveAllFromExtendedFamily(); +end + function properties(src,evnt) [hullID trackID] = UI.GetClosestCell(0); if(isempty(trackID)),return,end diff --git a/src/MATLAB/+UI/CreateMenuBar.m b/src/MATLAB/+UI/CreateMenuBar.m index 0038941d072d88c9714c4cda061e16eacb62fd9e..2af0f6456323a61611416bda3a8b1d6555e6911c 100644 --- a/src/MATLAB/+UI/CreateMenuBar.m +++ b/src/MATLAB/+UI/CreateMenuBar.m @@ -454,7 +454,7 @@ function loadStainData(src,evt) chkDir = fileparts(CONSTANTS.matFullFile); end - [stainFile stainPath filterIdx] = uigetfile(fullfile(chkDir,'*_StainInfo.mat'), 'Open Staining Data',fullfile(chkDir, [CONSTANTS.datasetName '_StainInfo.mat'])); + [stainFile stainPath filterIdx] = uigetfile(fullfile(chkDir,'*_StainInfo.mat'), 'Open Staining Data',fullfile(chkDir, [Metadata.GetDatasetName() '_StainInfo.mat'])); if ( filterIdx == 0 ) return; end @@ -581,7 +581,7 @@ end function nextChannel(src,evnt) global Figures CONSTANTS Figures.chanIdx = Figures.chanIdx + 1; -if Figures.chanIdx > CONSTANTS.numChannels +if Figures.chanIdx > Metadata.GetNumberOfChannels() Figures.chanIdx = 1; end UI.DrawCells(); @@ -748,7 +748,7 @@ function urlStr = urlifyString(inStr) end function createBugReport(src,evnt) - verString = Helper.GetVersion('fullstring'); + verString = Dev.GetVersion('fullstring'); % issueLabels = 'bug'; % issueTitle = '<ISSUE TITLE>'; diff --git a/src/MATLAB/+UI/DrawCells.m b/src/MATLAB/+UI/DrawCells.m index 5bc79cc26896d5546279b15a6f25f847989a3d98..e0190cd52030faa46ac8fca5e01230325638f666 100644 --- a/src/MATLAB/+UI/DrawCells.m +++ b/src/MATLAB/+UI/DrawCells.m @@ -55,9 +55,9 @@ else end %read in image -img = Helper.LoadChannelIntensityImage(Figures.time,Figures.chanIdx); +img = Helper.LoadIntensityImage(Figures.time,Figures.chanIdx); if ( isempty(img) ) - img = zeros(CONSTANTS.imageSize); + img = zeros(Metadata.GetDimensions('rc')); end imMax = max(img(:)); @@ -177,7 +177,7 @@ if(strcmp(get(Figures.cells.menuHandles.labelsMenu, 'Checked'),'on')) colorStruct = UI.GetCellDrawProps(curTrackID, curHullID, drawString); if(Figures.cells.showInterior) - [r c] = ind2sub(CONSTANTS.imageSize, CellHulls(curHullID).indexPixels); + [r c] = ind2sub(Metadata.GetDimensions('rc'), CellHulls(curHullID).indexPixels); plot(curAx, c, r, '.', 'Color',colorStruct.edge); end @@ -189,7 +189,7 @@ if(strcmp(get(Figures.cells.menuHandles.labelsMenu, 'Checked'),'on')) 'uicontextmenu', Figures.cells.contextMenuHandle,... 'ButtonDownFcn',( @(src,evt) (UI.FigureCellDown(src,evt,curHullID))),... 'LineStyle', colorStruct.edgeStyle,... - 'LineWidth', colorStruct.edgeWidth); + 'LineWidth', 2); % Plot light-blue border if frozen track if ( Helper.CheckTreeFrozen(curTrackID) ) diff --git a/src/MATLAB/+UI/ExportAITPD.m b/src/MATLAB/+UI/ExportAITPD.m index c90b6574ad873239130e0d5fad7a4a4f6e015389..dcdaceaef4a7a172d095e67d9017543627cf81be 100644 --- a/src/MATLAB/+UI/ExportAITPD.m +++ b/src/MATLAB/+UI/ExportAITPD.m @@ -52,7 +52,7 @@ trackData = []; if(CellFamilies(track.familyID).endTime-CellFamilies(track.familyID).startTime < 0.50*length(HashedCells)),return,end -trackData.datasetName = CONSTANTS.datasetName; +trackData.datasetName = Metadata.GetDatasetName(); trackData.cellLabel = label; trackData.parent = track.parentTrack; trackData.sibling = track.siblingTrack; @@ -85,7 +85,7 @@ for i=1:length(track.hulls) trackData.times(length(trackData.times)+1,1) = track.startTime +i -1; - [x y] = ind2sub(CONSTANTS.imageSize,CellHulls(track.hulls(i)).indexPixels); + [x y] = ind2sub(Metadata.GetDimensions('rc'),CellHulls(track.hulls(i)).indexPixels); x = x(:) - min(x) +2; y = y(:) - min(y) +2; im = zeros(max(x)+2,max(y)+2); @@ -112,7 +112,7 @@ success = 0; settings = Load.ReadSettings(); [file,filePath,filterIndex] = uiputfile([settings.matFilePath '*.txt'],'Save data',... - [CONSTANTS.datasetName '_AITPD.txt']); + [Metadata.GetDatasetName() '_AITPD.txt']); if(filterIndex<1),return,end fout=fopen([filePath file],'w'); diff --git a/src/MATLAB/+UI/ExportTree.m b/src/MATLAB/+UI/ExportTree.m index aced74a5848815890e5e721eaf9dcbe3679eb5de..09c79f9a6d43ceafbb4b5cd020a5338c4c66686e 100644 --- a/src/MATLAB/+UI/ExportTree.m +++ b/src/MATLAB/+UI/ExportTree.m @@ -28,7 +28,7 @@ function ExportTree(src, evt) global CellFamilies HashedCells Figures CONSTANTS CellTracks CellPhenotypes figure -set(gcf,'name',CONSTANTS.datasetName) +set(gcf,'name', Metadata.GetDatasetName()) set(gcf,'numbertitle','off') set(gcf,'color','w') familyID=Figures.tree.familyID; diff --git a/src/MATLAB/+UI/ExportTreeMetrics.m b/src/MATLAB/+UI/ExportTreeMetrics.m index 488db45da3573a8e7f9cf4ca6b38ec2cd6b87400..0d15b7e076ce352259d7e6673f1333a24370cdfe 100644 --- a/src/MATLAB/+UI/ExportTreeMetrics.m +++ b/src/MATLAB/+UI/ExportTreeMetrics.m @@ -28,8 +28,6 @@ function ExportTreeMetrics(src,evnt) global CellTracks CellFamilies CONSTANTS Figures -trackMetrics = []; - familyID=Figures.tree.familyID; rootTrackID = CellFamilies(familyID).rootTrackID; @@ -38,15 +36,22 @@ famTracks = CellFamilies(familyID).tracks; settings = Load.ReadSettings(); -[outFile,outPath,FilterIndex] = uiputfile('*.csv',['Export Metrics for clone #' num2str(rootTrackID)],fullfile(settings.matFilePath,[CONSTANTS.datasetName '_' num2str(rootTrackID) '_metrics.csv'])); +[outFile,outPath,FilterIndex] = uiputfile('*.csv',['Export Metrics for clone #' num2str(rootTrackID)],fullfile(settings.matFilePath,[Metadata.GetDatasetName() '_' num2str(rootTrackID) '_metrics.csv'])); if ( FilterIndex == 0 ) return; end -trackSortList = zeros(1,length(famTracks)); +trackSortList = []; +trackMetrics = []; for i=1:length(famTracks) - trackSortList(i) = trackHeights(famTracks(i)); - trackMetrics = [trackMetrics getMetrics(famTracks(i),CellTracks(famTracks(i)))]; + trackEntry = getMetrics(famTracks(i),CellTracks(famTracks(i))); + + if ( isempty(trackEntry) ) + continue; + end + + trackSortList = [trackSortList trackHeights(famTracks(i))]; + trackMetrics = [trackMetrics trackEntry]; end [sortedHeights,srtIdx] = sort(trackSortList,'descend'); diff --git a/src/MATLAB/+UI/GenerateAVI.m b/src/MATLAB/+UI/GenerateAVI.m index 05e1f055c692902b8ddd15ee5e606625a62e6913..9e3ba40e7ff9c3b43941f32ea03680ea16007d56 100644 --- a/src/MATLAB/+UI/GenerateAVI.m +++ b/src/MATLAB/+UI/GenerateAVI.m @@ -28,7 +28,7 @@ function GenerateAVI(src, evt) global Figures CONSTANTS HashedCells defaultPath = fileparts(CONSTANTS.matFullFile); -defaultFile = [CONSTANTS.datasetName '.mp4']; +defaultFile = [Metadata.GetDatasetName() '.mp4']; [movieFile, moviePath] = uiputfile('*.mp4', 'Save Movie', fullfile(defaultPath, defaultFile)); if ( movieFile == 0 ) diff --git a/src/MATLAB/+UI/InitializeFigures.m b/src/MATLAB/+UI/InitializeFigures.m index ed9703fe95b734c2e30d6d2c30321094ba0cab02..23738962843eabde2bc7ab4f7fd161cf083f99a5 100644 --- a/src/MATLAB/+UI/InitializeFigures.m +++ b/src/MATLAB/+UI/InitializeFigures.m @@ -71,7 +71,7 @@ set(Figures.cells.handle,... 'Interruptible', 'off',... 'CloseRequestFcn', @UI.CloseFigure,... 'NumberTitle', 'off',... - 'Name', [CONSTANTS.datasetName ' Image Data'],... + 'Name', [Metadata.GetDatasetName() ' Image Data'],... 'Tag', 'cells',... 'ResizeFcn', @UI.UpdateSegmentationEditsMenu); @@ -117,7 +117,7 @@ set(Figures.tree.handle,... 'BusyAction', 'cancel',... 'Interruptible', 'off',... 'NumberTitle', 'off',... - 'Name', [CONSTANTS.datasetName ' Lineage'],... + 'Name', [Metadata.GetDatasetName() ' Lineage'],... 'Tag', 'tree'); addlistener(Figures.tree.handle, 'WindowKeyRelease', @UI.KeyStateRelease); diff --git a/src/MATLAB/+UI/SaveData.m b/src/MATLAB/+UI/SaveData.m index 628206bd7028b9cbe9c3236fda78a58433c772a4..2d21015ba50120ab35103bfa3148a01984c2a558 100644 --- a/src/MATLAB/+UI/SaveData.m +++ b/src/MATLAB/+UI/SaveData.m @@ -38,9 +38,9 @@ if isfield(CONSTANTS,'matFullFile') && ~isempty(CONSTANTS.matFullFile) Helper.SaveLEVerState([CONSTANTS.matFullFile]); else if(orginal) - Helper.SaveLEVerState([settings.matFilePath CONSTANTS.datasetName '_LEVer.mat']); + Helper.SaveLEVerState(fullfile(settings.matFilePath, [Metadata.GetDatasetName() '_LEVer.mat'])); else - Helper.SaveLEVerState([settings.matFilePath CONSTANTS.datasetName '_LEVer_edits.mat']); + Helper.SaveLEVerState(fullfile(settings.matFilePath, [Metadata.GetDatasetName() '_LEVer_edits.mat'])); end end diff --git a/src/MATLAB/+UI/SaveDataAs.m b/src/MATLAB/+UI/SaveDataAs.m index 5ede68a5ef27687325a5d83970268fb1554a3867..07a7d472a17a8557ed8058367bf09dcfa781e277 100644 --- a/src/MATLAB/+UI/SaveDataAs.m +++ b/src/MATLAB/+UI/SaveDataAs.m @@ -38,11 +38,11 @@ settings = Load.ReadSettings(); time = clock; fprintf('Choose a folder to save current data...\n'); -newName = [CONSTANTS.datasetName '_LEVer.mat']; +newName = [Metadata.GetDatasetName() '_LEVer.mat']; bEditName = (~bOverWrite && ~strcmp(settings.matFilePath,'.\')); if ( bEditName ) - newName = [CONSTANTS.datasetName ' edits ' num2str(time(1)) '-' num2str(time(2),'%02d') '-' num2str(time(3),'%02d') '_LEVer.mat']; + newName = [Metadata.GetDatasetName() ' edits ' num2str(time(1)) '-' num2str(time(2),'%02d') '-' num2str(time(3),'%02d') '_LEVer.mat']; end if(strcmp(settings.matFilePath,'.\')) diff --git a/src/MATLAB/+UI/SegPreview.m b/src/MATLAB/+UI/SegPreview.m index 2ba7a7b6071065cb2d44f9cbf855ef2139998f82..3b6be46edc17294c889340f8a75a52360af24f85 100644 --- a/src/MATLAB/+UI/SegPreview.m +++ b/src/MATLAB/+UI/SegPreview.m @@ -4,93 +4,22 @@ function SegPreview() hPreviewFig = figure(); - Load.SetImageInfo(); - hAx = axes('Parent',hPreviewFig, 'Position',[0.01 0.01 0.98 0.98], 'XTick',[],'YTick',[]); hTimeLabel = uicontrol(hPreviewFig,'Style','text', 'Position',[1 0 60 20],'String', ['Time: ' num2str(1)]); - set(hPreviewFig, 'CurrentAxes',hAx); + set(hPreviewFig, 'CurrentAxes',hAx, 'NumberTitle','off', 'Name',[Metadata.GetDatasetName() ' Preview']); - set(hPreviewFig, 'UserData',struct('time',{1}, 'chan',{1}, 'showInterior',{false} , 'hLabel',{hTimeLabel}), 'Toolbar','figure'); + set(hPreviewFig, 'UserData',struct('time',{1}, 'chan',{1}, 'showInterior',{false}, 'cacheHulls',{[]}, 'hLabel',{hTimeLabel}), 'Toolbar','figure'); set(hPreviewFig, 'WindowScrollWheelFcn',@windowScrollWheel, 'KeyPressFcn',@windowKeyPress, 'CloseRequestFcn',''); - hSegPropDlg = initSegPropDialog(hPreviewFig); + hSegPropDlg = UI.SegPropDialog(hPreviewFig); drawPreviewImage(hPreviewFig); uiwait(hSegPropDlg); end -function windowKeyPress(src, event) - previewInfo = get(src, 'UserData'); - - if ( strcmpi(event.Key, 'uparrow') ) - previewInfo.time = incrementFrame(previewInfo.time, -1); - elseif ( strcmpi(event.Key, 'leftarrow') ) - previewInfo.time = incrementFrame(previewInfo.time, -1); - elseif ( strcmpi(event.Key, 'downarrow') ) - previewInfo.time = incrementFrame(previewInfo.time, +1); - elseif ( strcmpi(event.Key, 'rightarrow') ) - previewInfo.time = incrementFrame(previewInfo.time, +1); - elseif ( strcmpi(event.Key, 'F12') ) - previewInfo.showInterior = ~previewInfo.showInterior; - elseif ( strcmpi(event.Key,'t') && any(strcmpi('control',event.Modifier)) ) - chkTime = inputdlg('Enter frame number:','Go to Time',1,{num2str(previewInfo.time)}); - if (isempty(chkTime)) - return; - end - - newTime = str2double(chkTime{1}); - if ( isnan(newTime) ) - return; - end - - newTime = setTime(newTime); - previewInfo.time = newTime; - end - - set(src, 'UserData',previewInfo); - - drawPreviewImage(src); -end - -function windowScrollWheel(src, event) - previewInfo = get(src, 'UserData'); - time = incrementFrame(previewInfo.time, event.VerticalScrollCount); - - previewInfo.time = time; - set(src, 'UserData',previewInfo); - - drawPreviewImage(src); -end - -function time = setTime(time) - global CONSTANTS - - if ( time < 1 ) - time = 1; - end - - if ( time > CONSTANTS.numFrames ) - time = CONSTANTS.numFrames; - end -end - -function newTime = incrementFrame(time, delta) - global CONSTANTS - - newTime = time + delta; - - if ( newTime < 1 ) - newTime = 1; - end - - if ( newTime > CONSTANTS.numFrames ) - newTime = newTime - CONSTANTS.numFrames; - end -end +%% Load and render a preview image with current hull overlays function drawPreviewImage(hFig) - global CONSTANTS - hAx = get(hFig, 'CurrentAxes'); frameInfo = get(hFig, 'UserData'); @@ -100,23 +29,27 @@ function drawPreviewImage(hFig) im = imSet{frameInfo.chan}; if ( isempty(im) ) - im = 0.5*ones(CONSTANTS.imageSize); + im = 0.5*ones(Metadata.GetDimensions()); end imMax = max(im(:)); im = mat2gray(im,[0 imMax]); + imDims = Metadata.GetDimensions(); + xl=xlim(hAx); yl=ylim(hAx); if ( all(xl == [0 1]) ) - xl = [1 CONSTANTS.imageSize(2)]; - yl = [1 CONSTANTS.imageSize(1)]; + xl = [1 imDims(1)]; + yl = [1 imDims(2)]; end hold(hAx, 'off'); imagesc(im, 'Parent',hAx, [0 1]); colormap(hAx, gray(256)); + zoom(hAx, 'reset'); + xlim(hAx, xl); ylim(hAx, yl); @@ -124,20 +57,26 @@ function drawPreviewImage(hFig) hold(hAx, 'all'); + if ( ~isempty(frameInfo.cacheHulls) && (frameInfo.cacheHulls(1).time == frameInfo.time) ) + drawSegHulls(hFig, frameInfo.cacheHulls, frameInfo.showInterior); + end + drawnow(); end +%% Render hull overlays on image function drawSegHulls(hFig,segHulls, bShowInterior) - global CONSTANTS - hAx = get(hFig, 'CurrentAxes'); hold(hAx, 'on'); - allIndexPixels = vertcat(segHulls.indexPixels); - + cmap = hsv(31); if ( bShowInterior ) - rcCoords = Helper.IndexToCoord(CONSTANTS.imageSize, allIndexPixels); - plot(hAx, rcCoords(:,2),rcCoords(:,1), '.r'); + for i=1:length(segHulls) + colorIdx = mod(i-1,31)+1; + + rcCoords = Utils.IndToCoord(Metadata.GetDimensions('rc'), segHulls(i).indexPixels); + plot(hAx, rcCoords(:,2),rcCoords(:,1), '.', 'Color',cmap(colorIdx,:)); + end end for i=1:length(segHulls) @@ -146,285 +85,68 @@ function drawSegHulls(hFig,segHulls, bShowInterior) hold(hAx, 'off'); end -function dialogInfo = setNewSegParams(dialogInfo) - selectSeg = dialogInfo.selectSeg; - chkSegInfo = dialogInfo.segInfo(selectSeg); + +function windowKeyPress(src, event) + previewInfo = get(src, 'UserData'); - for i=1:length(chkSegInfo.params) - paramValStr = get(dialogInfo.hParams(i), 'String'); + if ( strcmpi(event.Key, 'uparrow') ) + previewInfo.time = incrementFrame(previewInfo.time, -1); + elseif ( strcmpi(event.Key, 'leftarrow') ) + previewInfo.time = incrementFrame(previewInfo.time, -1); + elseif ( strcmpi(event.Key, 'downarrow') ) + previewInfo.time = incrementFrame(previewInfo.time, +1); + elseif ( strcmpi(event.Key, 'rightarrow') ) + previewInfo.time = incrementFrame(previewInfo.time, +1); + elseif ( strcmpi(event.Key, 'F12') ) + previewInfo.showInterior = ~previewInfo.showInterior; + elseif ( strcmpi(event.Key,'t') && any(strcmpi('control',event.Modifier)) ) + chkTime = inputdlg('Enter frame number:','Go to Time',1,{num2str(previewInfo.time)}); + if (isempty(chkTime)) + return; + end - chkType = chkSegInfo.params(i).value; - if ( isa(chkType, 'char') ) - chkSegInfo.params(i).value = paramValStr; - elseif ( isa(chkType, 'double') ) - chkSegInfo.params(i).value = str2double(paramValStr); - else - error('Unexpected parameter type'); + newTime = str2double(chkTime{1}); + if ( isnan(newTime) ) + return; end - end - - dialogInfo.segInfo(selectSeg) = chkSegInfo; -end - -function [segFunc,segArgs] = getSegInfo(dialogInfo) - selectSeg = dialogInfo.selectSeg; - chkSegInfo = dialogInfo.segInfo(selectSeg); - - segFunc = chkSegInfo.func; - segArgs = arrayfun(@(x)(x.value), chkSegInfo.params, 'UniformOutput',0); -end - -function previewSeg(src,event) - global CONSTANTS - - hPreviewSeg = src; - hSegPropDlg = get(hPreviewSeg,'Parent'); - - dialogInfo = get(hSegPropDlg, 'UserData'); - dialogInfo = setNewSegParams(dialogInfo); - set(hSegPropDlg, 'UserData',dialogInfo); - - hPreviewFig = dialogInfo.hPreviewFig; - frameInfo = get(hPreviewFig, 'UserData'); - - set(hPreviewFig, 'Pointer','watch'); - set(hSegPropDlg, 'Pointer','watch'); - drawnow(); - - imSet = Helper.LoadIntensityImageSet(frameInfo.time); - im = imSet{frameInfo.chan}; - - if ( ~isempty(im) ) - [segFunc, segArgs] = getSegInfo(dialogInfo); - segHulls = segFunc(imSet, frameInfo.chan, frameInfo.time, segArgs{:}); - end - - validHulls = []; - for i=1:length(segHulls) - validHulls = [validHulls Hulls.CreateHull(CONSTANTS.imageSize, segHulls(i).indexPixels, frameInfo.time)]; + newTime = setTime(newTime); + previewInfo.time = newTime; end - set(hPreviewFig, 'Pointer','arrow'); - set(hSegPropDlg, 'Pointer','arrow'); - - bShowInterior = frameInfo.showInterior; - - drawPreviewImage(hPreviewFig); - drawSegHulls(hPreviewFig, validHulls, bShowInterior); -end - -function runSeg(src,event) - hRunSeg = src; - hSegPropDlg = get(hRunSeg,'Parent'); - - dialogInfo = get(hSegPropDlg, 'UserData'); - dialogInfo = setNewSegParams(dialogInfo); - set(hSegPropDlg, 'UserData',dialogInfo); - - selectSeg = dialogInfo.selectSeg; - - SupportedTypes = Load.GetSupportedCellTypes(); - cellType = SupportedTypes(selectSeg).name; - Load.AddConstant('cellType',cellType,1); - Load.AddConstant('primaryChannel', dialogInfo.selectChan,1); - - Load.AddConstant('segInfo', dialogInfo.segInfo(selectSeg),1); - - closeFigures(hSegPropDlg,[]); -end - -function defaultParams(src,event) - hResetDefault = src; - hSegPropDlg = get(hResetDefault,'Parent'); - - dialogInfo = get(hSegPropDlg, 'UserData'); - selectSeg = dialogInfo.selectSeg; - - SupportedTypes = Load.GetSupportedCellTypes(); - defaultSegInfo = SupportedTypes(selectSeg).segRoutine; - - dialogInfo.segInfo(selectSeg) = defaultSegInfo; - set(hSegPropDlg, 'UserData',dialogInfo); - - setParamValues(hSegPropDlg, selectSeg); -end - -function closeFigures(src,event) - hSegPropDlg = src; - dialogInfo = get(hSegPropDlg, 'UserData'); - - hPreviewFig = dialogInfo.hPreviewFig; - delete(hPreviewFig); - delete(hSegPropDlg); -end - -function hSegPropDlg = initSegPropDialog(hFig) - global CONSTANTS - - hSegPropDlg = dialog('Name','Select Segmentation Properties', 'Visible','on', 'WindowStyle','normal', 'CloseRequestFcn',@closeFigures); -% WinOnTop(hSegPropDlg,true); - - SupportedTypes = Load.GetSupportedCellTypes(); - - typeNames = {SupportedTypes.name}; - chanStr = arrayfun(@(x)(num2str(x)), 1:CONSTANTS.numChannels, 'UniformOutput',0); - - hCellBox = uicontrol(hSegPropDlg, 'Style','popupmenu', 'String',typeNames, 'Callback',@selectedCellType, 'Position',[20 20 100 20]); - hChanBox = uicontrol(hSegPropDlg, 'Style','popupmenu', 'String',chanStr, 'Callback',@selectedChannel, 'Position',[20 20 100 20]); - hPreviewSeg = uicontrol(hSegPropDlg, 'Style','pushbutton', 'String','Preview Segmentation', 'Callback',@previewSeg, 'Position',[20 20 100 20]); - hRunSeg = uicontrol(hSegPropDlg, 'Style','pushbutton', 'String','Run Full Segmentation', 'Callback',@runSeg, 'Position',[20 20 100 20]); - hCancel = uicontrol(hSegPropDlg, 'Style','pushbutton', 'String','Default Parameters', 'Callback',@defaultParams, 'Position',[20 20 100 20]); - - segInfo = [SupportedTypes.segRoutine]; - dialogInfo = struct('hPreviewFig',{hFig}, 'hKeep',{[hCellBox hChanBox hPreviewSeg hRunSeg hCancel]}, 'hParams',{[]}, 'selectSeg',{1}, 'segInfo',{segInfo}); - set(hSegPropDlg, 'UserData',dialogInfo); - - selectedCellType(hCellBox, []) - selectedChannel(hChanBox,[]); -end - -function selectedChannel(src,event) - hChanBox = src; - hSegPropDlg = get(hChanBox,'Parent'); - - selectedIdx = get(hChanBox, 'Value'); - chanStr = get(hChanBox,'String'); - selectedChan = str2double(chanStr{selectedIdx}); - - dialogInfo = get(hSegPropDlg, 'UserData'); - dialogInfo.selectChan = selectedChan; - set(hSegPropDlg, 'UserData',dialogInfo); - - hPreviewFig = dialogInfo.hPreviewFig; - - previewInfo = get(hPreviewFig, 'UserData'); - previewInfo.chan = selectedChan; - set(hPreviewFig, 'UserData',previewInfo); + set(src, 'UserData',previewInfo); - drawPreviewImage(hPreviewFig); + drawPreviewImage(src); end -function selectedCellType(src,event) - hCellBox = src; - hSegPropDlg = get(hCellBox,'Parent'); +function windowScrollWheel(src, event) + previewInfo = get(src, 'UserData'); + time = incrementFrame(previewInfo.time, event.VerticalScrollCount); - selectedIdx = get(hCellBox, 'Value'); - createParamControls(hSegPropDlg, selectedIdx); - setParamValues(hSegPropDlg, selectedIdx); + previewInfo.time = time; + set(src, 'UserData',previewInfo); - dialogInfo = get(hSegPropDlg, 'UserData'); - dialogInfo.selectSeg = selectedIdx; - set(hSegPropDlg, 'UserData',dialogInfo); + drawPreviewImage(src); end -function setParamValues(hDlg, selectIdx) - dialogInfo = get(hDlg, 'UserData'); - hParams = dialogInfo.hParams; +function time = setTime(time) + if ( time < 1 ) + time = 1; + end - segInfo = dialogInfo.segInfo(selectIdx); - for i=1:length(hParams); - paramValue = segInfo.params(i).value; - set(hParams(i), 'String', num2str(paramValue)); + if ( time > Metadata.GetNumberOfFrames() ) + time = Metadata.GetNumberOfFrames(); end end -function createParamControls(hDlg, selectIdx) - labelWidth = 70; - labelHeight = 16; - labelPad = 1; - - controlHeight = 22; - controlWidth = 100; - - buttonWidth = 130; - - controlPad = 5; - controlLeft = 2*controlPad; - - dialogInfo = get(hDlg, 'UserData'); - - hDlgChildren = get(hDlg, 'Children'); - bRmChildren = ~ismember(hDlgChildren, dialogInfo.hKeep); - - hChildren = hDlgChildren(bRmChildren); - for i=1:length(hChildren) - delete(hChildren(i)); - end - - numParams = length(dialogInfo.segInfo(selectIdx).params); - segFunc = dialogInfo.segInfo(selectIdx).func; - - %% Load function help information - funcName = char(segFunc); - funcHelp = help(funcName); - if ( isempty(funcHelp) ) - funcHelp = funcName; - end - - numControls = max(3, numParams + 2); - dialogWidth = 2*controlPad + labelWidth + controlPad + controlWidth + 2*controlPad + buttonWidth + 2*controlPad; - dialogHeight = controlPad + controlHeight*numControls + 2*controlPad*(numControls-1) + controlPad; - - dialogPos = get(hDlg, 'Position'); - set(hDlg, 'Position',[dialogPos(1:2) dialogWidth dialogHeight]); - - hCellBox = dialogInfo.hKeep(1); - hChanBox = dialogInfo.hKeep(2); - - %% Put a segmentation summary from function help into the combo-box tooltip. - tokMatch = regexp(funcHelp,'^\s*FrameSegmentor_*\w*\s*-\s*(.+?)^\s*$', 'once','tokens','lineanchors'); - if ( isempty(tokMatch) ) - helpLines = strsplit(funcHelp,'\n'); - funcSummary = strtrim(helpLines{1}); - else - funcSummary = tokMatch{1}; - end - - curControlPos = [controlLeft, dialogHeight-controlPad]; - curControlPos = layoutLabelControls(hCellBox, curControlPos, 'Cell Type: ', funcSummary); - curControlPos = layoutLabelControls(hChanBox, curControlPos, 'Channel: ', ''); - - %% Try to find parameter help in function documentation to put in label/textbox tooltips - hParams = zeros(1,numParams); - for i=1:numParams - paramName = dialogInfo.segInfo(selectIdx).params(i).name; - - paramHelp = ''; - tokMatch = regexp(funcHelp,['^\s*(' paramName '.+?)^\s*$'], 'once','tokens','lineanchors'); - if ( ~isempty(tokMatch) ) - paramHelp = tokMatch{1}; - end - - hParams(i) = uicontrol(hDlg, 'Style','edit'); - curControlPos = layoutLabelControls(hParams(i), curControlPos, [paramName ': '], paramHelp); - end +function newTime = incrementFrame(time, delta) + newTime = time + delta; - hButtons = dialogInfo.hKeep(3:end); - curControlPos = [controlLeft + labelWidth + controlPad + controlWidth + 2*controlPad, dialogHeight-controlPad]; - for i=1:length(hButtons); - curControlPos = layoutButtonControls(hButtons(i), curControlPos); + if ( newTime < 1 ) + newTime = 1; end - dialogInfo.hParams = hParams; - set(hDlg, 'UserData',dialogInfo); - - function newPos = layoutLabelControls(hCtrl, startPos, labelStr, tooltip) - newPos = startPos - [0, controlHeight]; - - hLabel = uicontrol(hDlg, 'Style','text', 'HorizontalAlignment','right', 'String',labelStr, 'Position',[newPos(1), newPos(2)+labelPad, labelWidth, labelHeight]); - set(hCtrl, 'Position',[newPos(1) + labelWidth + controlPad, newPos(2), controlWidth, controlHeight]); - - set(hCtrl, 'ToolTipString',tooltip); - set(hLabel, 'ToolTipString',tooltip); - - newPos = newPos - [0, 2*controlPad]; - end - - function newPos = layoutButtonControls(hCtrl, startPos) - newPos = startPos - [0, controlHeight]; - set(hCtrl, 'Position',[newPos(1) + controlPad, newPos(2), buttonWidth, controlHeight]); - - newPos = newPos - [0, 2*controlPad]; + if ( newTime > Metadata.GetNumberOfFrames() ) + newTime = newTime - Metadata.GetNumberOfFrames(); end end diff --git a/src/MATLAB/+UI/SegPropDialog.m b/src/MATLAB/+UI/SegPropDialog.m new file mode 100644 index 0000000000000000000000000000000000000000..1031622112e4078958c0f6d90df0a29f6dd53086 --- /dev/null +++ b/src/MATLAB/+UI/SegPropDialog.m @@ -0,0 +1,328 @@ +function hSegPropDlg = SegPropDialog(hFig) + if ( ~exist('hFig','var') ) + hFig = []; + end + + hSegPropDlg = dialog('Name','Select Segmentation Properties', 'Visible','on', 'WindowStyle','normal', 'CloseRequestFcn',@closeFigures); + + SupportedTypes = Load.GetSupportedCellTypes(); + + typeNames = {SupportedTypes.name}; + + % Handle the case that we don't know number of channels + if ( Metadata.GetNumberOfChannels() < 1 ) + chanStr = {'1'}; + else + chanStr = arrayfun(@(x)(num2str(x)), 1:Metadata.GetNumberOfChannels(), 'UniformOutput',0); + end + + enableSegPreview = 'off'; + if ( ishandle(hFig) ) + enableSegPreview = 'on'; + end + + + hCellBox = uicontrol(hSegPropDlg, 'Style','popupmenu', 'String',typeNames, 'Callback',@selectedCellType, 'Position',[20 20 100 20]); + + % Handle the case that we don't know number of channels, use editbox + if ( Metadata.GetNumberOfChannels() < 1 ) + hChanBox = uicontrol(hSegPropDlg, 'Style','edit', 'String',chanStr, 'Callback',@selectedChannel, 'Position',[20 20 100 20]); + else + hChanBox = uicontrol(hSegPropDlg, 'Style','popupmenu', 'String',chanStr, 'Callback',@selectedChannel, 'Position',[20 20 100 20]); + end + + hPreviewSeg = uicontrol(hSegPropDlg, 'Style','pushbutton', 'String','Preview Segmentation', 'Callback',@previewSeg, 'Position',[20 20 100 20], 'Enable',enableSegPreview); + hRunSeg = uicontrol(hSegPropDlg, 'Style','pushbutton', 'String','Run Full Segmentation', 'Callback',@runSeg, 'Position',[20 20 100 20]); + hCancel = uicontrol(hSegPropDlg, 'Style','pushbutton', 'String','Default Parameters', 'Callback',@defaultParams, 'Position',[20 20 100 20]); + + segInfo = [SupportedTypes.segRoutine]; + dialogInfo = struct('hPreviewFig',{hFig}, 'hKeep',{[hCellBox hChanBox hPreviewSeg hRunSeg hCancel]}, 'hParams',{[]}, 'selectSeg',{1}, 'segInfo',{segInfo}); + set(hSegPropDlg, 'UserData',dialogInfo); + + selectedCellType(hCellBox, []) + selectedChannel(hChanBox,[]); +end + +%% Update preview window when new primary channel selected for viewing +function selectedChannel(src,event) + hChanBox = src; + hSegPropDlg = get(hChanBox,'Parent'); + + selectedIdx = get(hChanBox, 'Value'); + chanStr = get(hChanBox,'String'); + + + if ( selectedIdx < 1 ) + selectedChan = str2double(chanStr); + else + selectedChan = str2double(chanStr{selectedIdx}); + end + + dialogInfo = get(hSegPropDlg, 'UserData'); + dialogInfo.selectChan = selectedChan; + set(hSegPropDlg, 'UserData',dialogInfo); + + hPreviewFig = dialogInfo.hPreviewFig; + if ( isempty(hPreviewFig) ) + return; + end + + previewInfo = get(hPreviewFig, 'UserData'); + previewInfo.chan = selectedChan; + set(hPreviewFig, 'UserData',previewInfo); + + forceRefreshPreview(hPreviewFig); +end + + +%% Update parameters based on new cell type selection +function selectedCellType(src,event) + hCellBox = src; + hSegPropDlg = get(hCellBox,'Parent'); + + selectedIdx = get(hCellBox, 'Value'); + createParamControls(hSegPropDlg, selectedIdx); + setParamValues(hSegPropDlg, selectedIdx); + + dialogInfo = get(hSegPropDlg, 'UserData'); + dialogInfo.selectSeg = selectedIdx; + set(hSegPropDlg, 'UserData',dialogInfo); + + %Clear cached hull data on algorithm selection change. + hPreviewFig = dialogInfo.hPreviewFig; + if ( isempty(hPreviewFig) ) + return; + end + + frameInfo = get(hPreviewFig, 'UserData'); + frameInfo.cacheHulls = []; + set(hPreviewFig, 'UserData',frameInfo); + + forceRefreshPreview(hPreviewFig); +end + +%% Set new segmentation parameters +function dialogInfo = setNewSegParams(dialogInfo) + selectSeg = dialogInfo.selectSeg; + chkSegInfo = dialogInfo.segInfo(selectSeg); + + for i=1:length(chkSegInfo.params) + paramValStr = get(dialogInfo.hParams(i), 'String'); + + chkType = chkSegInfo.params(i).value; + if ( isa(chkType, 'char') ) + chkSegInfo.params(i).value = paramValStr; + elseif ( isa(chkType, 'double') ) + chkSegInfo.params(i).value = str2double(paramValStr); + else + error('Unexpected parameter type'); + end + end + + dialogInfo.segInfo(selectSeg) = chkSegInfo; +end + +%% Finalize parameter selection and close dialog boxes +function runSeg(src,event) + hRunSeg = src; + hSegPropDlg = get(hRunSeg,'Parent'); + + dialogInfo = get(hSegPropDlg, 'UserData'); + dialogInfo = setNewSegParams(dialogInfo); + set(hSegPropDlg, 'UserData',dialogInfo); + + selectSeg = dialogInfo.selectSeg; + + SupportedTypes = Load.GetSupportedCellTypes(); + cellType = SupportedTypes(selectSeg).name; + Load.AddConstant('cellType',cellType,1); + Load.AddConstant('primaryChannel', dialogInfo.selectChan,1); + + Load.AddConstant('segInfo', dialogInfo.segInfo(selectSeg),1); + + closeFigures(hSegPropDlg,[]); +end + +%% Preview single frame segmentation +function previewSeg(src,event) + hPreviewSeg = src; + hSegPropDlg = get(hPreviewSeg,'Parent'); + + dialogInfo = get(hSegPropDlg, 'UserData'); + dialogInfo = setNewSegParams(dialogInfo); + set(hSegPropDlg, 'UserData',dialogInfo); + + hPreviewFig = dialogInfo.hPreviewFig; + frameInfo = get(hPreviewFig, 'UserData'); + + set(hPreviewFig, 'Pointer','watch'); + set(hSegPropDlg, 'Pointer','watch'); + drawnow(); + + imSet = Helper.LoadIntensityImageSet(frameInfo.time); + im = imSet{frameInfo.chan}; + + if ( ~isempty(im) ) + [segFunc, segArgs] = getSegInfo(dialogInfo); + + segHulls = segFunc(imSet, frameInfo.chan, frameInfo.time, segArgs{:}); + end + + validHulls = []; + for i=1:length(segHulls) + validHulls = [validHulls Hulls.CreateHull(Metadata.GetDimensions('rc'), segHulls(i).indexPixels, frameInfo.time, false, segHulls(i).tag)]; + end + + frameInfo.cacheHulls = validHulls; + + set(hPreviewFig, 'Pointer','arrow'); + set(hSegPropDlg, 'Pointer','arrow'); + + set(hPreviewFig, 'UserData',frameInfo); + + forceRefreshPreview(hPreviewFig); +end + +%% Hack to force redraw of preview figure +function forceRefreshPreview(hFig) + scrollFunc = get(hFig, 'WindowScrollWheelFcn'); + scrollFunc(hFig,struct('VerticalScrollCount',{0})); +end + +%% Reset current cell parameters to defaults +function defaultParams(src,event) + hResetDefault = src; + hSegPropDlg = get(hResetDefault,'Parent'); + + dialogInfo = get(hSegPropDlg, 'UserData'); + selectSeg = dialogInfo.selectSeg; + + SupportedTypes = Load.GetSupportedCellTypes(); + defaultSegInfo = SupportedTypes(selectSeg).segRoutine; + + dialogInfo.segInfo(selectSeg) = defaultSegInfo; + set(hSegPropDlg, 'UserData',dialogInfo); + + setParamValues(hSegPropDlg, selectSeg); +end + +%% Set up parameter value display +function setParamValues(hDlg, selectIdx) + dialogInfo = get(hDlg, 'UserData'); + hParams = dialogInfo.hParams; + + segInfo = dialogInfo.segInfo(selectIdx); + for i=1:length(hParams); + paramValue = segInfo.params(i).value; + set(hParams(i), 'String', num2str(paramValue)); + end +end + + +%% Close this figure and possibly associated preview windows. +function closeFigures(src,event) + hSegPropDlg = src; + dialogInfo = get(hSegPropDlg, 'UserData'); + + hPreviewFig = dialogInfo.hPreviewFig; + if ( ~isempty(hPreviewFig) ) + delete(hPreviewFig); + end + + delete(hSegPropDlg); +end + +%% +function [segFunc,segArgs] = getSegInfo(dialogInfo) + selectSeg = dialogInfo.selectSeg; + chkSegInfo = dialogInfo.segInfo(selectSeg); + + segFunc = chkSegInfo.func; + segArgs = arrayfun(@(x)(x.value), chkSegInfo.params, 'UniformOutput',0); +end + + +%% Create all controls associated with cell type parameters +function createParamControls(hDlg, selectIdx) + labelWidth = 70; + labelHeight = 16; + labelPad = 1; + + controlHeight = 22; + controlWidth = 100; + + buttonWidth = 130; + + controlPad = 5; + controlLeft = 2*controlPad; + + dialogInfo = get(hDlg, 'UserData'); + + hDlgChildren = get(hDlg, 'Children'); + bRmChildren = ~ismember(hDlgChildren, dialogInfo.hKeep); + + hChildren = hDlgChildren(bRmChildren); + for i=1:length(hChildren) + delete(hChildren(i)); + end + + numParams = length(dialogInfo.segInfo(selectIdx).params); + segFunc = dialogInfo.segInfo(selectIdx).func; + + %% Load function help information + funcName = char(segFunc); + helpStruct = Dev.FrameSegHelp(funcName); + + numControls = max(3, numParams + 2); + dialogWidth = 2*controlPad + labelWidth + controlPad + controlWidth + 2*controlPad + buttonWidth + 2*controlPad; + dialogHeight = controlPad + controlHeight*numControls + 2*controlPad*(numControls-1) + controlPad; + + dialogPos = get(hDlg, 'Position'); + set(hDlg, 'Position',[dialogPos(1:2) dialogWidth dialogHeight]); + + hCellBox = dialogInfo.hKeep(1); + hChanBox = dialogInfo.hKeep(2); + + curControlPos = [controlLeft, dialogHeight-controlPad]; + curControlPos = layoutLabelControls(hCellBox, curControlPos, 'Cell Type: ', sprintf(helpStruct.summary)); + curControlPos = layoutLabelControls(hChanBox, curControlPos, 'Channel: ', ''); + + %% Try to find parameter help in function documentation to put in label/textbox tooltips + hParams = zeros(1,numParams); + for i=1:numParams + paramName = dialogInfo.segInfo(selectIdx).params(i).name; + + hParams(i) = uicontrol(hDlg, 'Style','edit'); + curControlPos = layoutLabelControls(hParams(i), curControlPos, [paramName ': '], sprintf(helpStruct.paramHelp{i})); + end + + hButtons = dialogInfo.hKeep(3:end); + curControlPos = [controlLeft + labelWidth + controlPad + controlWidth + 2*controlPad, dialogHeight-controlPad]; + for i=1:length(hButtons); + curControlPos = layoutButtonControls(hButtons(i), curControlPos); + end + + dialogInfo.hParams = hParams; + set(hDlg, 'UserData',dialogInfo); + + function newPos = layoutLabelControls(hCtrl, startPos, labelStr, tooltip) + newPos = startPos - [0, controlHeight]; + + hLabel = uicontrol(hDlg, 'Style','text', 'HorizontalAlignment','right', 'String',labelStr, 'Position',[newPos(1), newPos(2)+labelPad, labelWidth, labelHeight]); + set(hCtrl, 'Position',[newPos(1) + labelWidth + controlPad, newPos(2), controlWidth, controlHeight]); + + set(hCtrl, 'ToolTipString',tooltip); + set(hLabel, 'ToolTipString',tooltip); + + newPos = newPos - [0, 2*controlPad]; + end + + function newPos = layoutButtonControls(hCtrl, startPos) + newPos = startPos - [0, controlHeight]; + set(hCtrl, 'Position',[newPos(1) + controlPad, newPos(2), buttonWidth, controlHeight]); + + newPos = newPos - [0, 2*controlPad]; + end +end + + diff --git a/src/MATLAB/+UI/about.m b/src/MATLAB/+UI/about.m index bff555b78c3effe1a0272bf317833871ec00960b..89be030ea54c1513b32d7f085e32bacd83fbc1da 100644 --- a/src/MATLAB/+UI/about.m +++ b/src/MATLAB/+UI/about.m @@ -64,9 +64,9 @@ else im=255*ones(339,608); end imagesc(im) -softwareVersion = Helper.GetVersion(); -buildNumber = Helper.GetVersion('buildString'); -buildHash = Helper.GetVersion('buildHash'); +softwareVersion = Dev.GetVersion(); +buildNumber = Dev.GetVersion('buildString'); +buildHash = Dev.GetVersion('primaryHash'); cDate = clock(); if ( ~isempty(softwareVersion) ) set(handles.text1,'string',{['LEVER: ' softwareVersion] ; [' ' buildNumber ' '] ;[' ' buildHash(1:20) ' '] ; ['(c) ' num2str(cDate(1))] }); diff --git a/src/MATLAB/+Utils/CmdlnProgress.m b/src/MATLAB/+Utils/CmdlnProgress.m new file mode 100644 index 0000000000000000000000000000000000000000..320d8a5f59495a18b1b8d8038ec49b0ee39b4de3 --- /dev/null +++ b/src/MATLAB/+Utils/CmdlnProgress.m @@ -0,0 +1,130 @@ +classdef CmdlnProgress<handle + %PRINTPROGRESS prints the progress and the estimated time of completion on + %the commandline. + %ENSURE that the code that is being monitored does not have internal + %printing to the commandline. + % INIT - if init is true, then the val passed in will be used as the + % denominator when figuring out the percent completed. + % When init is false, the progress is deleted from the command line and the + % internal valuse reset. + % VAL - when updating the progress enter the number that will be used as + % the numerator for the percent completed and ensure that the second + % paramater is not used or empty. + % + % Usage -- Initalize by using CmdlnProgress(number of iterations, true, optionalTitle); + % Update by using PrintProgress(current iteration); + % Clean up by using PrintProgress(0,false); + + properties + backspaces + firstTime + total + useBs + titleText + end + + methods + function obj = CmdlnProgress(iterations,useBackspace,optionalTitle) + if(~exist('useBackspace', 'var') || isempty(useBackspace)) + obj.useBs = true; + else + obj.useBs = useBackspace; + end + + if (~exist('optionalTitle','var') || isempty(optionalTitle)) + obj.titleText = ''; + else + obj.titleText = optionalTitle; + end + + obj.total = iterations; + + obj.backspaces = []; + obj.firstTime = now; + end + + function SetMaxIterations(obj,iterations) + obj.total = iterations; + end + + function PrintProgress(obj,val) + cur = now; + + prcntDone = val / obj.total; + elpsTime = (cur - obj.firstTime) * 86400; + totalSec = elpsTime / prcntDone; + finDate = obj.firstTime + (totalSec / 86400); + timeLeft = (finDate - cur)*86400; + + if (~isempty(obj.titleText)) + doneStr = sprintf('%s: %5.2f%%%% est. %s @ %s\n',... + obj.titleText,... + prcntDone*100,... + Utils.PrintTime(timeLeft),... + datestr(finDate,'HH:MM:SS dd-mmm-yy')); + else + doneStr = sprintf('%5.2f%%%% est. %s @ %s\n',... + prcntDone*100,... + Utils.PrintTime(timeLeft),... + datestr(finDate,'HH:MM:SS dd-mmm-yy')); + end + fprintf([obj.backspaces,doneStr]); + + if(obj.useBs) + obj.backspaces = repmat(sprintf('\b'),1,length(doneStr)-1); + else + fprintf('\n'); + end + end + + function ReprintProgress(obj,val) + cur = now; + + prcntDone = val / obj.total; + elpsTime = (cur - obj.firstTime) * 86400; + totalSec = elpsTime / prcntDone; + finDate = obj.firstTime + (totalSec / 86400); + timeLeft = (finDate - cur)*86400; + + if (~isempty(obj.titleText)) + doneStr = sprintf('%s: %5.2f%%%% est. %s @ %s\n',... + obj.titleText,... + prcntDone*100,... + Utils.PrintTime(timeLeft),... + datestr(finDate,'HH:MM:SS dd-mmm-yy')); + else + doneStr = sprintf('%5.2f%%%% est. %s @ %s\n',... + prcntDone*100,... + Utils.PrintTime(timeLeft),... + datestr(finDate,'HH:MM:SS dd-mmm-yy')); + end + + fprintf(doneStr); + + if(obj.useBs) + obj.backspaces = repmat(sprintf('\b'),1,length(doneStr)-1); + else + fprintf('\n'); + end + end + + function ClearProgress(obj,printTotal) + if (~isempty(obj.backspaces)) + fprintf(obj.backspaces); + end + if (exist('printTotal','var') && ~isempty(printTotal) && printTotal) + cur = now; + elpsTime = (cur - obj.firstTime) * 86400; + if (~isempty(obj.titleText)) + fprintf('%s took: %s\n',obj.titleText,Utils.PrintTime(elpsTime)) + else + fprintf('Took: %s\n',Utils.PrintTime(elpsTime)) + end + end + obj.backspaces = []; + obj.firstTime = 0; + obj.total = 0; + obj.useBs = false; + end + end +end diff --git a/src/MATLAB/+Utils/CoordToInd.m b/src/MATLAB/+Utils/CoordToInd.m new file mode 100644 index 0000000000000000000000000000000000000000..0a5ae3e55574b389e66c73e2ee1a2b5036d6387c --- /dev/null +++ b/src/MATLAB/+Utils/CoordToInd.m @@ -0,0 +1,7 @@ +% CoordToInd - Convert subscript indices to linear array indices. +% +% arrayIdx = CoordToInd(arraySize, coords) +function arrayIdx = CoordToInd(arraySize, coords) + linSize = [1 cumprod(arraySize(1:end-1))]; + arrayIdx = sum((coords-1) .* repmat(linSize, size(coords,1),1), 2) + 1; +end diff --git a/src/MATLAB/+Utils/CreateJSON.m b/src/MATLAB/+Utils/CreateJSON.m new file mode 100644 index 0000000000000000000000000000000000000000..6d9d970d990a85353036fb8f11955bced226e586 --- /dev/null +++ b/src/MATLAB/+Utils/CreateJSON.m @@ -0,0 +1,155 @@ +function json = CreateJSON(data,bWhitespace) + if ( ~exist('bWhitespace','var') ) + bWhitespace = true; + end + + spaceStruct = struct('line',{''}, 'space',{''}, 'indent',{''}); + if ( bWhitespace ) + spaceStruct = struct('line',{'\n'}, 'space',{' '}, 'indent',{' '}); + end + + if ( isstruct(data) ) + json = writeObject(data,'', spaceStruct); + else + json = writeArray(data,'', spaceStruct); + end +end + +function json = writeObject(data, spacePrefix, spaceStruct) + fields = fieldnames(data); + + fieldSep = ','; + objJSON = ''; + + fieldPattern = ['%s"%s"' spaceStruct.space ':' spaceStruct.space '%s%s']; + patternPad = length(sprintf(fieldPattern,'','','','')); + + fieldPrefix = [spacePrefix spaceStruct.indent]; + for i=1:length(fields) + if ( i == length(fields) ) + fieldSep = ''; + end + + elemPad = repmat(spaceStruct.space, 1,patternPad+length(fields{i})); + elemPrefix = [fieldPrefix elemPad]; + + valJSON = writeValue(data.(fields{i}), elemPrefix, spaceStruct); + fieldJSON = sprintf([spaceStruct.line fieldPattern], fieldPrefix, fields{i}, valJSON,fieldSep); + + objJSON = [objJSON fieldJSON]; + end + + objectPattern = ['{%s' spaceStruct.line '%s}']; + json = sprintf(objectPattern, objJSON,spacePrefix); +end + +function [json,bSingleLine] = writeArray(data, spacePrefix, spaceStruct) + bSingleLine = false; + if ( isnumeric(data) && (size(data,1) == numel(data)) ) + bSingleLine = true; + json = writeSingleLineArray(data, spaceStruct); + return; + end + + valSep = ','; + arrayJSON = ''; + + valPattern = '%s%s%s'; + + valuePrefix = [spacePrefix spaceStruct.indent]; + for i=1:size(data,1) + if ( i == size(data,1) ) + valSep = ''; + end + + arrayEntry = squashSelect(data, i); + if ( numel(arrayEntry) == 1 ) + if ( iscell(arrayEntry) ) + valJSON = writeValue(arrayEntry{1}, valuePrefix, spaceStruct); + else + valJSON = writeValue(arrayEntry, valuePrefix, spaceStruct); + end + else + [valJSON,bSingleLine] = writeArray(arrayEntry, valuePrefix, spaceStruct); + end + + % Combine brackets on one line if all the root array is a single line + if ( bSingleLine && (size(data,1) == 1) ) + json = sprintf('[%s]',valJSON); + return + else + arrayJSON = [arrayJSON sprintf([spaceStruct.line valPattern], valuePrefix, valJSON, valSep)]; + end + end + + arrayPattern = ['[%s' spaceStruct.line '%s]']; + json = sprintf(arrayPattern, arrayJSON,spacePrefix); +end + +function arrayEntry = squashSelect(arrayData, i) + if ( ndims(arrayData) == 1 ) + arrayEntry = arrayData(i); + return; + end + + dimSizes = size(arrayData); + if ( length(dimSizes) < 3 ) + dimSizes = [dimSizes 1]; + end + + arrayEntry = reshape(arrayData(i,:), dimSizes(2:end)); +end + +function json = writeSingleLineArray(data, spaceStruct) + valSep = [',' spaceStruct.space]; + arrayJSON = ''; + for i=1:length(data) + if ( i == length(data) ) + valSep = ''; + end + + valJSON = writeValue(data(i),'', spaceStruct); + arrayJSON = [arrayJSON sprintf('%s%s', valJSON,valSep)]; + end + json = sprintf('[%s]', arrayJSON); +end + +function json = writeValue(data, spacePrefix, spaceStruct) + if ( ischar(data) ) + json = sprintf('"%s"',escapeString(data)); + elseif ( iscell(data) || any(size(data) > 1) ) + json = writeArray(data, spacePrefix, spaceStruct); + elseif ( isstruct(data) ) + json = writeObject(data, spacePrefix, spaceStruct); + elseif ( islogical(data) ) + if ( data ) + json = 'true'; + else + json = 'false'; + end + elseif ( isempty(data) ) + json = 'null'; + elseif ( isnumeric(data) ) + json = num2str(data); + else + ME = MException('json:save','Cannot save unsupported type'); + ME.throw; + end +end + +function quotedStr = escapeString(inStr) + escChars = {'\' '"' char(8) char(12) char(10) char(13) char(9)}; + escStr = {'\\' '\"','\b','\f','\n','\r','\t'}; + + escMap = containers.Map(escChars,escStr); + + quotedStr = ''; + for i=1:length(inStr) + nextChar = inStr(i); + if ( isKey(escMap,nextChar) ) + nextChar = escMap(nextChar); + end + + quotedStr = [quotedStr nextChar]; + end +end diff --git a/src/MATLAB/+Utils/IndToCoord.m b/src/MATLAB/+Utils/IndToCoord.m new file mode 100644 index 0000000000000000000000000000000000000000..c9edc7b69d15af289c85832d03b66bc343b169a2 --- /dev/null +++ b/src/MATLAB/+Utils/IndToCoord.m @@ -0,0 +1,17 @@ +% IndToCoord - Convert linear array indices into a list of subscript +% indices. +% +% coords = IndToCoord(arraySize, arrayIdx) +function coords = IndToCoord(arraySize, arrayIdx) + coords = zeros(length(arrayIdx),length(arraySize)); + + linSize = [1 cumprod(arraySize)]; + partialIdx = arrayIdx; + for i = length(arraySize):-1:1 + r = rem(partialIdx-1, linSize(i)) + 1; + q = floor((partialIdx-r) / linSize(i)) + 1; + + coords(:,i) = q; + partialIdx = r; + end +end diff --git a/src/MATLAB/+Utils/ParseJSON.m b/src/MATLAB/+Utils/ParseJSON.m new file mode 100644 index 0000000000000000000000000000000000000000..b4e9f740fc105268e78cf9ed992a04e454e3e22e --- /dev/null +++ b/src/MATLAB/+Utils/ParseJSON.m @@ -0,0 +1,308 @@ +function data = ParseJSON(json) + quoteIdx = regexp(json,'\"', 'start'); + escStart = regexp(json,'\\([/\"\\bfnrt]|u[a-fA-F\d]{4})', 'start'); + + strQuotes = setdiff(quoteIdx,escStart+1); + quoteMap = containers.Map(strQuotes(1:end-1),strQuotes(2:end)); + + parsePos = ignoreSpace(json,1); + assertChar('parse', {'{','['}, json,parsePos); + + if ( json(parsePos) == '{' ) + [data parsePos] = parseObjectJSON(json,parsePos+1, quoteMap); + elseif ( json(parsePos) == '[' ) + [data parsePos] = parseArrayJSON(json,parsePos+1, quoteMap); + end + + data = postprocessObjects(data); +end + +function [objData parsePos] = parseObjectJSON(json, startPos, quoteMap) + parsePos = ignoreSpace(json,startPos); + + objData = []; + assertInStr('parseObject', '''STRING'' or ''}''', json, parsePos); + if ( json(parsePos) == '}' ) + parsePos = ignoreSpace(json,parsePos+1); + return; + end + + while ( parsePos <= length(json) ) + assertChar('parseObject', '"', json,parsePos); + [keyStr parsePos] = parseStringJSON(json,parsePos, quoteMap); + + assertChar('parseObject', ':', json,parsePos); + [value parsePos] = parseValueJSON(json,parsePos+1, quoteMap); +% if ( isempty(value) ) +% throwError('parseObject','Expecting ''STRING'', ''NUMBER'', ''NULL'', ''TRUE'', ''FALSE'', ''{'', ''[''', json, parsePos); +% end + + objData.(validFieldName(keyStr)) = value; + + assertInStr('parseObject', '''}''', json, parsePos); + if ( json(parsePos) == '}' ) + parsePos = ignoreSpace(json,parsePos+1); + return; + end + + assertChar('parseObject', {',','}'}, json,parsePos); + parsePos = ignoreSpace(json,parsePos+1); + end + + throwError('parseObject','Expecting closing ''}''', json, parsePos); +end + +function [arrayData parsePos] = parseArrayJSON(json, startPos, quoteMap) + parsePos = ignoreSpace(json,startPos); + + arrayData = cell(0,1); + if ( json(parsePos) == ']' ) + parsePos = ignoreSpace(json,parsePos+1); + return; + end + + while ( parsePos <= length(json) ) + [value parsePos] = parseValueJSON(json,parsePos, quoteMap); +% if ( isempty(value) ) +% throwError('parseArray','Expecting ''STRING'', ''NUMBER'', ''NULL'', ''TRUE'', ''FALSE'', ''{'', ''[''', json, parsePos); +% end + + arrayData{end+1} = value; + + assertInStr('parseArray', ''']''', json, parsePos); + if ( json(parsePos) == ']' ) + parsePos = ignoreSpace(json,parsePos+1); + return; + end + + assertChar('parseArray', {',',']'}, json,parsePos); + + parsePos = ignoreSpace(json,parsePos+1); + end + + throwError('parseArray','Expecting closing '']''', json, parsePos); +end + +function [valueData parsePos] = parseValueJSON(json, startPos, quoteMap) + parsePos = ignoreSpace(json,startPos); + + assertInStr('parseValue', '''STRING'', ''NUMBER'', ''NULL'', ''TRUE'', ''FALSE'', ''{'', ''[''', json, parsePos); + chkChar = json(parsePos); + + keywordMap = {'true',true; 'false',false; 'null',[]}; + + switch(chkChar) + case '[' + [valueData parsePos] = parseArrayJSON(json,parsePos+1, quoteMap); + case '{' + [valueData parsePos] = parseObjectJSON(json,parsePos+1, quoteMap); + case '"' + [valueData parsePos] = parseStringJSON(json,parsePos, quoteMap); + case {'-','0','1','2','3','4','5','6','7','8','9'} + [valueData parsePos] = parseNumberJSON(json,parsePos); + otherwise + for i=1:size(keywordMap,1) + [bMatched parsePos] = matchKeyword(json,parsePos,keywordMap{i,1}); + if ( bMatched ) + valueData = keywordMap{i,2}; + return; + end + end + throwError('parseValue','Expecting ''STRING'', ''NUMBER'', ''NULL'', ''TRUE'', ''FALSE'', ''{'', ''[''', json, parsePos); + end +end + +function [stringData parsePos] = parseStringJSON(json, startPos, quoteMap) + if ( ~isKey(quoteMap,startPos) ) + throwError('parseString','Expecting ''STRING''', json, parsePos); + end + + startQuote = startPos; + endQuote = quoteMap(startPos); + escapedStr = json(startQuote+1:endQuote-1); + + stringData = validExpandString(escapedStr, json, startPos); + parsePos = ignoreSpace(json,endQuote + 1); +end + +function [numberData parsePos] = parseNumberJSON(json, startPos) + numPad = 20; + chkEnd = min(startPos+numPad,length(json)); + + matchStr = regexp(json(startPos:chkEnd),'^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?', 'once','match'); + if ( isempty(matchStr) ) + throwError('parseNumber','Expecting ''NUMBER''', json, startPos); + end + + numberData = str2double(matchStr); + parsePos = ignoreSpace(json,startPos+length(matchStr)); +end + +function [bMatched parsePos] = matchKeyword(json,parsePos, keywordStr) + bMatched = false; + if ( length(json) < parsePos+length(keywordStr) ) + return; + end + + keywordEnd = parsePos+length(keywordStr)-1; + if ( ~strcmpi(json(parsePos:keywordEnd), keywordStr) ) + return; + end + + parsePos = ignoreSpace(json,keywordEnd+1); + bMatched = true; +end + +function fieldStr = validFieldName(inStr) + fieldStr = inStr; + bAlphaNum = isstrprop(inStr,'alphanum'); + fieldStr(~bAlphaNum) = '_'; + + if ( ~isletter(fieldStr(1)) ) + fieldStr = ['s_' fieldStr]; + end +end + +function expandStr = validExpandString(escapedStr, json,strPos) + + expandSeq = {'\"','\b','\f','\n','\r','\t'}; + unescStart = regexp(escapedStr,['[' [expandSeq{:}] ']'], 'start'); + + if ( ~isempty(unescStart) ) + throwError('parseString', 'Invalid character in string', json, strPos+unescStart(1)); + end + + expandStr = ''; + bEscape = false; + for i=1:length(escapedStr) + expandChar = escapedStr(i); + + if ( bEscape ) + bEscape = false; + if ( expandChar == 'u' ) + continue; + end + + if ( ~any(expandChar == '\"bfnrt/') ) + throwError('parseString', 'Invalid escape sequence in string', json, strPos+i); + end + + expandChar = sprintf(['\' expandChar]); + elseif ( expandChar == '\' ) + bEscape = true; + continue; + end + + expandStr(end+1) = expandChar; + end +end + +function dataOut = postprocessObjects(dataEntry) + if ( isstruct(dataEntry) ) + fields = fieldnames(dataEntry); + for i=1:length(fields) + dataEntry.(fields{i}) = postprocessObjects(dataEntry.(fields{i})); + end + elseif ( iscell(dataEntry) ) + dataEntry = postprocessArrays(dataEntry); + end + + dataOut = dataEntry; +end + +function dataEntry = postprocessArrays(dataEntry) + finalDims = length(dataEntry); + + [bCanExpand expandDims expandTypes] = canExpandArray(dataEntry); + if ( ~bCanExpand ) + finalDims = [finalDims 1]; + end + + while ( bCanExpand ) + dataEntry = reshape(dataEntry, numel(dataEntry),1); + dataEntry = vertcat(dataEntry{:}); + + finalDims = [finalDims expandDims]; + [bCanExpand expandDims expandTypes] = canExpandArray(dataEntry); + end + + dataEntry = reshape(dataEntry, finalDims); + if ( length(expandDims) > 1 ) + for i=1:numel(dataEntry) + dataEntry{i} = postprocessObjects(dataEntry{i}); + end + elseif ( length(expandTypes) == 1 && strcmpi(expandTypes{1},'double') ) + dataEntry = cell2mat(dataEntry); + end +end + +function [bCanExpand expandDims expandTypes] = canExpandArray(cellArray) + chkType = unique(cellfun(@(x)(class(x)), cellArray(:), 'UniformOutput',0)); + chkDims = unique(cellfun(@(x)(length(x)), cellArray(:))); + + bCanExpand = (length(chkDims) == 1) && (length(chkType) == 1) && strcmpi(chkType{1},'cell'); + + expandTypes = chkType; + expandDims = chkDims; +end + +function parsePos = ignoreSpace(json,startPos) + for parsePos=startPos:length(json) + if ( ~isspace(json(parsePos)) ) + return; + end + end +end + +function assertInStr(type, expect, json, parsePos) + if ( parsePos > length(json) ) + if ( isempty(expect) ) + throwError(type, 'Unexpected end of file', json, parsePos); + else + throwError(type, ['Unexpected end of file, expecting ' expect], json, parsePos); + end + end +end + +function assertChar(type, charValue, json, parsePos) + if ( ischar(charValue) ) + charValue = {charValue}; + end + + if ( parsePos > length(json) ) + throwError(type, makeAssertStr(charValue), json, parsePos) + end + + for i=1:length(charValue) + if ( json(parsePos) == charValue{i} ) + return; + end + end + + throwError(type,makeAssertStr(charValue), json, parsePos) +end + +function errStr = makeAssertStr(charValues) + errStr = 'Expecting'; + + for i=1:length(charValues)-1 + errStr = [errStr ' ''' charValues{i} ''' or']; + end + + errStr = [errStr ' ''' charValues{end} '''']; +end + +function throwError(type,message, json, pos) + contextPad = 5; + contextStart = max(pos-contextPad,1); + contextEnd = min(pos+3*contextPad,length(json)); + + arrowPos = pos-contextStart; + arrowSpace = repmat(' ',1,arrowPos); + + contextStr = json(contextStart:contextEnd); + contextStr = strtok(contextStr,sprintf('\n')); + + ME = MException(['json:' type],'Parse error: %s\n\n%s\n%s^', message,contextStr,arrowSpace); + ME.throw; +end diff --git a/src/MATLAB/+Utils/PrintTime.m b/src/MATLAB/+Utils/PrintTime.m new file mode 100644 index 0000000000000000000000000000000000000000..5060ef568877fb436d364ac24ad4675e684eea9e --- /dev/null +++ b/src/MATLAB/+Utils/PrintTime.m @@ -0,0 +1,12 @@ +function [ strOut ] = printTime( timeIn ) +%PRINTTIME takes time in sec and outputs a string in the form HH:MM:SS.ss + +hr = floor(timeIn/3600); +tmNew = timeIn - hr*3600; +mn = floor(tmNew/60); +tmNew = tmNew - mn*60; +sc = tmNew; + +strOut = sprintf('%02dh:%02dm:%05.2fs',hr,mn,sc); +end + diff --git a/src/MATLAB/+Helper/SwapXY_RC.m b/src/MATLAB/+Utils/SwapXY_RC.m similarity index 100% rename from src/MATLAB/+Helper/SwapXY_RC.m rename to src/MATLAB/+Utils/SwapXY_RC.m diff --git a/src/MATLAB/+license/LicenseHeader.c b/src/MATLAB/+license/LicenseHeader.c new file mode 100644 index 0000000000000000000000000000000000000000..0ce60879fc5e555c1d63e8c363212b004ec3dbc2 --- /dev/null +++ b/src/MATLAB/+license/LicenseHeader.c @@ -0,0 +1,21 @@ +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ diff --git a/src/MATLAB/+license/LicenseHeader.m b/src/MATLAB/+license/LicenseHeader.m new file mode 100644 index 0000000000000000000000000000000000000000..24b8cb2bd9ce35e299a5dbb25d363f8841821aea --- /dev/null +++ b/src/MATLAB/+license/LicenseHeader.m @@ -0,0 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/MATLAB/+license/doAllFolders.m b/src/MATLAB/+license/doAllFolders.m new file mode 100644 index 0000000000000000000000000000000000000000..b159827792e3a33a864d07f96661d520206caae3 --- /dev/null +++ b/src/MATLAB/+license/doAllFolders.m @@ -0,0 +1,45 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +dlist = dir('*'); +for dd=1:length(dlist) + if ~dlist(dd).isdir || length(dlist(dd).name)<4 + continue + end + if strcmp(dlist(dd).name,'+assign') | strcmp(dlist(dd).name,'+matlab_bgl') + continue + end + license.goHeader(['.\' dlist(dd).name '\']); + +end +license.goHeader('.\'); + +% c files +excludeFiles={'sha1.h','sha1.c'}; +dlist=dir('..\c'); +for dd=1:length(dlist) + if ~dlist(dd).isdir || length(dlist(dd).name)<4 + continue + end + license.goHeader(['..\c\' dlist(dd).name '\'],1,excludeFiles); +end diff --git a/src/MATLAB/+license/getFileText.m b/src/MATLAB/+license/getFileText.m new file mode 100644 index 0000000000000000000000000000000000000000..6bb3e0843963954f3ebc1278b78d4d5465cc1646 --- /dev/null +++ b/src/MATLAB/+license/getFileText.m @@ -0,0 +1,38 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +function txt=getFileText(filename) + +fid = fopen(filename,'rt'); +i=1; +txt= {}; + +nextLine = fgets(fid); +while ischar(nextLine) + + txt{i} = nextLine; + nextLine=fgets(fid); + i=i+1; +end + +fclose(fid); + diff --git a/src/MATLAB/+license/goHeader.m b/src/MATLAB/+license/goHeader.m new file mode 100644 index 0000000000000000000000000000000000000000..410031d348dbf91ea888f3e5661b95f8fccf9842 --- /dev/null +++ b/src/MATLAB/+license/goHeader.m @@ -0,0 +1,70 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +function goHeader(folder,bC,excludeFiles) +if nargin<2 + bC=0; +end +if nargin<3 + excludeFiles={}; +end +if bC + flist = dir(fullfile(folder, '*.cpp')); + flist = [flist;dir(fullfile(folder, '*.c'))]; + flist = [flist;dir(fullfile(folder, '*.h'))]; + % note - this is the old token for the c code. this will need to change + % to ******* as per the new licenseheader.c + % strToken='//////////'; + strToken='**********'; + % get matlab headers out of c files... +% strToken='%%%%%%%%%%'; + fnamePreamble='.\+license\LicenseHeader.c'; +else + flist = dir(fullfile(folder, '*.m')); + strToken='%%%%%%%%%%'; + fnamePreamble='.\+license\LicenseHeader.m'; +end +for ff=1:length(flist) + if any(strcmp(excludeFiles,flist(ff).name)) + continue + end + txt = license.getFileText(fullfile(folder,flist(ff).name)); + txtPreamble = license.getFileText(fnamePreamble); + idxPreamble = find(cellfun(@(x) ~isempty(strfind(x,strToken)),txt),2); + if length(idxPreamble)~=2 + fprintf(1,'found file with no license: %s\n',flist(ff).name); + % find the first non-comment line + idxPreamble = find(cellfun(@(x) x(1)~='%',txt),1); + if isempty(idxPreamble) + continue + end + txtPreamble={ char(10), txtPreamble{:}, char(10)}; + + else + txt(idxPreamble(1):idxPreamble(2))=[]; + end + + txtRedone={txt{1:idxPreamble(1)-1} txtPreamble{:} txt{idxPreamble(1):end}}; + license.writeFileText(fullfile(folder,flist(ff).name),txtRedone); +end diff --git a/src/MATLAB/+license/writeFileText.m b/src/MATLAB/+license/writeFileText.m new file mode 100644 index 0000000000000000000000000000000000000000..12d6f817ec23bc275e4cf58a60d8e318d9a8efe1 --- /dev/null +++ b/src/MATLAB/+license/writeFileText.m @@ -0,0 +1,30 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Copyright 2011-2016 Andrew Cohen +% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function writeFileText(filename,txt) +fid = fopen(filename,'wt'); +for i=1:length(txt) + fprintf(fid,'%s',txt{i}); +end +fclose(fid); diff --git a/src/MATLAB/LEVER_SegAndTrackFolders.exe b/src/MATLAB/LEVER_SegAndTrackFolders.exe index 1d9f15730b67a1dc6f68cc25a76dd4fc5471f4b4..59b002c7389308f269cd3415c3c5fbb0a80cf299 100644 Binary files a/src/MATLAB/LEVER_SegAndTrackFolders.exe and b/src/MATLAB/LEVER_SegAndTrackFolders.exe differ diff --git a/src/MATLAB/LEVER_SegAndTrackFolders.m b/src/MATLAB/LEVER_SegAndTrackFolders.m index 089ecba18d0dbde03d05fde90f53b7cf2678491d..57d8b74335cb604bc9bbf1cf3314caf1e944f52f 100644 --- a/src/MATLAB/LEVER_SegAndTrackFolders.m +++ b/src/MATLAB/LEVER_SegAndTrackFolders.m @@ -1,44 +1,91 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% This file is part of LEVer.exe -% (C) 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of LEVer - the tool for stem cell lineaging. See +% http://n2t.net/ark:/87918/d9rp4t for details +% +% LEVer is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% LEVer is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LEVer in file "gnu gpl v3.txt". If not, see +% <http://www.gnu.org/licenses/>. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % mcc -m LEVER_SegAndTrackFolders.m function LEVER_SegAndTrackFolders(outputDir, maxProcessors) global CONSTANTS CellPhenotypes CONSTANTS=[]; -softwareVersion = Helper.GetVersion(); +if ( ~exist('outputDir','var') ) + outputDir = ''; +end + +% Trial run command +bTrialRun = false; +if ( strncmpi(outputDir,'-T',2) ) + outputDir = outputDir(3:end); + bTrialRun = true; +end + +softwareVersion = Dev.GetVersion(); if (isdeployed()) Load.SetWorkingDir(); end -cellType = Load.QueryCellType(); -Load.AddConstant('cellType',cellType,1); - directory_name = uigetdir('','Select Root Folder for Seg and Track'); if ( ~directory_name ),return,end -if ( ~exist('outputDir','var') ) - outputDir = directory_name; +% Get initial cell segmentation parameters +Load.AddConstant('cellType', [], 1); + +hDlg = UI.SegPropDialog(); +uiwait(hDlg); + +if ( isempty(CONSTANTS.cellType) ) + return; end -% Trial run command -bTrialRun = 0; -if ( strcmpi(outputDir(1:2),'-T') ) - outputDir = outputDir(3:end); - if ( isempty(outputDir) ) - outputDir = directory_name; - end - bTrialRun = 1; +%% Run export of subdirectories if necessary. +exportRoot = Load.FolderExport(directory_name); +if ( isempty(exportRoot) ) + return; end -processedDatasets = {}; +if ( isempty(outputDir) ) + outputDir = exportRoot; +end + +%% Find valid images in exported folder. +[chkPaths,invalidFile] = Load.CheckFolderExport(exportRoot); +validJSON = chkPaths(~invalidFile); +if ( isempty(validJSON) ) + warning(['No valid data found at: ' exportRoot]); + return; +end + +%% Use previewer on first valid directory to get cell type and segmentation parameters +Load.AddConstant('version',softwareVersion,1); + +[imageData,imagePath] = MicroscopeData.ReadMetadataFile(fullfile(exportRoot,validJSON{1})); +Metadata.SetMetadata(imageData); + +Load.AddConstant('rootImageFolder', imagePath, 1); +Load.AddConstant('matFullFile', fullfile(outputDir, Metadata.GetDatasetName()),1); + +%% Use total number of processors or max from command-line numProcessors = getenv('Number_of_processors'); numProcessors = str2double(numProcessors); if(isempty(numProcessors) || isnan(numProcessors) || numProcessors < 4) @@ -52,58 +99,38 @@ if ( exist('maxProcessors','var') ) numProcessors = min(maxProcessors, numProcessors); end -dirList = dir(directory_name); - -bInvalidName = arrayfun(@(x)(strncmpi(x.name,'.',1) || strncmpi(x.name,'..',2)), dirList); -bValidDir = ~bInvalidName & (vertcat(dirList.isdir) > 0); -dirList = dirList(bValidDir); - -for dirIdx=1:length(dirList) - if ( ~(dirList(dirIdx).isdir) ) - continue - end - - validStartFilename = getValidStartFileName(fullfile(directory_name, dirList(dirIdx).name)); - if ( isempty(validStartFilename) ) - fprintf('\n**** Image list does not begin with frame 1 for %s. Skipping\n\n', directory_name); - continue; - end +%% Run segmentation for all valid directories +processedDatasets = {}; +for dirIdx=1:length(validJSON) + subDir = fileparts(validJSON{dirIdx}); + dataDir = fileparts(subDir); - [datasetName namePattern] = Helper.ParseImageName(validStartFilename); - if ( isempty(datasetName) ) - fprintf('\n**** Image names not formatted correctly for %s. Skipping\n\n', directory_name); - continue; - end - - CONSTANTS.rootImageFolder = fullfile(directory_name, dirList(dirIdx).name); - CONSTANTS.datasetName = datasetName; - CONSTANTS.imageNamePattern = namePattern; - CONSTANTS.matFullFile = fullfile(outputDir, [CONSTANTS.datasetName '_LEVer.mat']); + [imageData,imagePath] = MicroscopeData.ReadMetadataFile(fullfile(exportRoot,validJSON{dirIdx})); + Metadata.SetMetadata(imageData); + + Load.AddConstant('rootImageFolder', imagePath, 1); + Load.AddConstant('matFullFile', fullfile(outputDir,dataDir, [Metadata.GetDatasetName() '_LEVer.mat']),1); if ( exist(CONSTANTS.matFullFile,'file') ) - fprintf('%s - LEVer data already exists. Skipping\n', CONSTANTS.datasetName); - continue - end - - fileList = dir(fullfile(directory_name, dirList(dirIdx).name, '*.tif')); - if ( isempty(fileList) ) + fprintf('%s - LEVer data already exists. Skipping\n', Metadata.GetDatasetName()); continue end Load.AddConstant('version',softwareVersion,1); - fprintf('Segment & track file : %s\n', CONSTANTS.datasetName); - + %% Segment and track folder + fprintf('Segment & track file : %s\n', Metadata.GetDatasetName()); tic - Load.InitializeConstants(); if ( ~bTrialRun ) + Load.InitializeConstants(); + segArgs = Segmentation.GetCellTypeParams(); - [errStatus tSeg tTrack] = Segmentation.SegAndTrackDataset(CONSTANTS.rootImageFolder, CONSTANTS.datasetName, CONSTANTS.imageNamePattern, numProcessors, segArgs); + [errStatus tSeg tTrack] = Segmentation.SegAndTrackDataset(numProcessors, segArgs); if ( ~isempty(errStatus) ) - fprintf('\n\n*** Segmentation/Tracking failed for %s\n\n', CONSTANTS.datasetName); + fprintf('\n\n*** Segmentation/Tracking failed for %s\n\n', Metadata.GetDatasetName()); - errFilename = fullfile(outputDir, [CONSTANTS.datasetName '_segtrack_err.log']); + errFilename = fullfile(outputDir, [Metadata.GetDatasetName() '_segtrack_err.log']); fid = fopen(errFilename, 'wt'); fprintf(fid, '%s', errStatus); fclose(fid); @@ -119,35 +146,11 @@ for dirIdx=1:length(dirList) Editor.ReplayableEditAction(@Editor.OriginAction, 1); Helper.SaveLEVerState([CONSTANTS.matFullFile]); - Error.LogAction('Segmentation time - Tracking time',tSeg,tTrack); end - processedDatasets = [processedDatasets; {CONSTANTS.datasetName}]; + processedDatasets = [processedDatasets; {Metadata.GetDatasetName()}]; end %dd clear global; end - -% This function tries to quickly find one or more files that qualify as an -% initial image frame for parsing dataset names, etc. Returns the first -% file name found -function filename = getValidStartFileName(chkPath) - filename = ''; - - flist = []; - chkDigits = 7:-1:2; - for i=1:length(chkDigits) - digitStr = ['%0' num2str(chkDigits(i)) 'd']; - flist = dir(fullfile(chkPath,['*_t' num2str(1,digitStr) '*.tif'])); - if ( ~isempty(flist) ) - break; - end - end - - if ( isempty(flist) ) - return; - end - - filename = flist(1).name; -end diff --git a/src/MATLAB/LEVer.exe b/src/MATLAB/LEVer.exe index fc1b01a469a5d4ec7664a39cabc50e9a44b7fd2d..e8d5b9d9561db81d894b43758ebd9937a07bce62 100644 Binary files a/src/MATLAB/LEVer.exe and b/src/MATLAB/LEVer.exe differ diff --git a/src/MATLAB/LEVer.m b/src/MATLAB/LEVer.m index 582d6b4a843fb0a4c520f2594874a7167a5d0c86..1ed0724d6383633f99d457334098c5b879226c22 100644 --- a/src/MATLAB/LEVer.m +++ b/src/MATLAB/LEVer.m @@ -2,10 +2,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by diff --git a/src/MATLAB/MTC.exe b/src/MATLAB/MTC.exe deleted file mode 100644 index 041116cabb278981321a8cd7f5978cd015dc6819..0000000000000000000000000000000000000000 Binary files a/src/MATLAB/MTC.exe and /dev/null differ diff --git a/src/MATLAB/Segmentor.exe b/src/MATLAB/Segmentor.exe index 6f743777da97bf502da52284a6acce4d84ea218d..a79c01b79d1a5e6138f0c41f584d167ac68e1170 100644 Binary files a/src/MATLAB/Segmentor.exe and b/src/MATLAB/Segmentor.exe differ diff --git a/src/MATLAB/Segmentor.m b/src/MATLAB/Segmentor.m index e1079bd0357f3f7c0d3351027a304ccc56f76c34..94e0e227eec68800eb5344f750b877db7281b82e 100644 --- a/src/MATLAB/Segmentor.m +++ b/src/MATLAB/Segmentor.m @@ -7,10 +7,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter +% Copyright 2011-2016 Andrew Cohen % % This file is part of LEVer - the tool for stem cell lineaging. See -% https://pantherfile.uwm.edu/cohena/www/LEVer.html for details +% http://n2t.net/ark:/87918/d9rp4t for details % % LEVer is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by @@ -28,10 +28,9 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -function [hulls frameTimes] = Segmentor(varargin) +function hulls = Segmentor(varargin) hulls = []; -frameTimes = []; supportedCellTypes = Load.GetSupportedCellTypes(); [procArgs,segArgs] = setSegArgs(supportedCellTypes, varargin); @@ -51,31 +50,32 @@ funcPath = which(funcName); if ( ~isempty(funcPath) ) segFunc = supportedCellTypes(typeIdx).segRoutine.func; else - fprintf(['WARNING: Could not find ' funcName '() using default Segmentation.FrameSegmentor() routine\n']); + deployPrint(['WARNING: Could not find ' funcName '() using default Segmentation.FrameSegmentor() routine\n']); segFunc = @Segmentation.FrameSegmentor; end segParams = struct2cell(segArgs); try - fprintf(1,'%s\n',procArgs.imagePath); - fprintf(1,'%s\n',procArgs.imagePattern); + deployPrint(1,'%s\n',procArgs.metadataFile); + + imageData = MicroscopeData.ReadMetadata(procArgs.metadataFile,false); + if ( isempty(imageData) ) + error(['Unable to read image metadata file: ' procArgs.metadataFile]); + end - Load.AddConstant('rootImageFolder', procArgs.imagePath, 1); - Load.AddConstant('imageNamePattern', procArgs.imagePattern, 1); - Load.AddConstant('numChannels', procArgs.numChannels, 1); - Load.AddConstant('numFrames', procArgs.numFrames, 1); Load.AddConstant('primaryChannel', procArgs.primaryChannel, 1); + Metadata.SetMetadata(imageData); tStart = procArgs.procID; - tEnd = procArgs.numFrames; + tEnd = Metadata.GetNumberOfFrames(); tStep = procArgs.numProcesses; primaryChan = procArgs.primaryChannel; numImages = floor(tEnd/tStep); for t = tStart:tStep:tEnd - fprintf('%d%%...', round(100 * floor(t/tStep) / numImages)); + deployPrint('%d%%...', round(100 * floor(t/tStep) / numImages)); chanImSet = Helper.LoadIntensityImageSet(t); if ( isempty(chanImSet) ) @@ -83,17 +83,24 @@ try end frameHulls = segFunc(chanImSet, primaryChan, t, segParams{:}); + if ( isempty(frameHulls) ) + continue; + end + + rcImageDims = Metadata.GetDimensions('rc'); + validHulls = []; for i=1:length(frameHulls) - frameHulls(i).time = t; - if ( ~isfield(frameHulls(i),'tag') || isempty(frameHulls(i).tag) ) - frameHulls(i).tag = char(segFunc); - else - frameHulls(i).tag = [char(segFunc) ':' frameHulls(i).tag]; + tag = char(segFunc); + if ( isfield(frameHulls(i),'tag') && ~isempty(frameHulls(i).tag) ) + tag = [char(segFunc) ':' frameHulls(i).tag]; end + + newHull = Hulls.CreateHull(rcImageDims, frameHulls(i).indexPixels, t, false, tag); + validHulls = [validHulls newHull]; end - hulls = [hulls frameHulls]; + hulls = [hulls validHulls]; end catch excp @@ -112,19 +119,28 @@ catch excp end fileName = fullfile('segmentationData',['objs_' num2str(tStart) '.mat']); -save(fileName,'hulls','frameTimes'); +save(fileName,'hulls'); % Write this file to indicate that the segmentaiton data is actually fully saved fSempahore = fopen(fullfile('segmentationData',['done_' num2str(tStart) '.txt']), 'w'); fclose(fSempahore); -fprintf('\tDone\n'); +deployPrint('\tDone\n'); +end + +function deployPrint(varargin) + if ( ~isdeployed() ) + return; + end + + fprintf(varargin{:}); end -function [procArgs segArgs] = setSegArgs(supportedCellTypes, argCell) - procArgs = struct('procID',{1}, 'numProcesses',{1}, 'numChannels',{0}, 'numFrames',{0}, 'cellType',{''}, 'primaryChannel',{[]}, 'imagePath',{''}, 'imagePattern',{''}); +function [procArgs, segArgs] = setSegArgs(supportedCellTypes, argCell) + procArgs = struct('procID',{1}, 'numProcesses',{1}, 'primaryChannel',{1}, 'metadataFile',{''}, 'cellType',{''}); procArgFields = fieldnames(procArgs); + procArgFields = reshape(procArgFields,1,length(procArgFields)); procArgTypes = cellfun(@(x)(class(x)), struct2cell(procArgs), 'UniformOutput',0); segArgs = []; diff --git a/src/MATLAB/mexDijkstra.mexw64 b/src/MATLAB/mexDijkstra.mexw64 index 6a9e06765e7083af173d46a9e3ab4758f9cc27e6..ae9b02f715bab15572c23277f3d6bbd09975dccd 100644 Binary files a/src/MATLAB/mexDijkstra.mexw64 and b/src/MATLAB/mexDijkstra.mexw64 differ diff --git a/src/MATLAB/mexGraph.mexw64 b/src/MATLAB/mexGraph.mexw64 index fad04f2e0ef49aaa6ca258bd23ee2f4a7b0358e6..e325cd9768b1ce5ee908d69fdae77362c777c28c 100644 Binary files a/src/MATLAB/mexGraph.mexw64 and b/src/MATLAB/mexGraph.mexw64 differ diff --git a/src/MATLAB/mexHashData.mexw64 b/src/MATLAB/mexHashData.mexw64 index 2d5cb421a604d490235b4541b7a4c6b17566413e..fbb4ec6535921290d6bc699c647c0ce3158f35e3 100644 Binary files a/src/MATLAB/mexHashData.mexw64 and b/src/MATLAB/mexHashData.mexw64 differ diff --git a/src/MATLAB/mexIntegrityCheck.mexw64 b/src/MATLAB/mexIntegrityCheck.mexw64 index 80fdbf84abc29dbef2817062d49a18cadebb1dc2..3eec2172e9115d65e94031bbd8bdb23f5e18b262 100644 Binary files a/src/MATLAB/mexIntegrityCheck.mexw64 and b/src/MATLAB/mexIntegrityCheck.mexw64 differ diff --git a/src/MATLAB/mexMAT.mexw64 b/src/MATLAB/mexMAT.mexw64 index a9ad704988183e8f91c7fa37973cbdaf263ba820..b95eba51d25f605bac2a427efa3b3526ae4d8765 100644 Binary files a/src/MATLAB/mexMAT.mexw64 and b/src/MATLAB/mexMAT.mexw64 differ diff --git a/src/MATLAB/trackerMex.mexw64 b/src/MATLAB/trackerMex.mexw64 new file mode 100644 index 0000000000000000000000000000000000000000..b251121253d8a3a59c73b8d3a852476d3380e261 Binary files /dev/null and b/src/MATLAB/trackerMex.mexw64 differ diff --git a/src/MATLAB/tryAutoReseg.m b/src/MATLAB/tryAutoReseg.m deleted file mode 100644 index c37fc4a499810abd69caa9f348136e8ccc545acd..0000000000000000000000000000000000000000 --- a/src/MATLAB/tryAutoReseg.m +++ /dev/null @@ -1,110 +0,0 @@ -function tryAutoReseg(filename, outFilename) - rootImageDir = 'B:\Data\NYNSCI\Embryonic\SKG_100312_E12_Ant_vs_Post-0003'; - - if ( ~exist('outFilename','var') ) - [inPath inName, inExt] = fileparts(filename); - outFilename = fullfile(inPath,[inName '_autoreseg' inExt]); - end - - load(filename); - Load.AddConstant('matFullFile', filename); - - findImageDir(rootImageDir); - - Load.InitializeConstants(); - Load.FixOldFileVersions(); - - % Check this at the end of load now for new and old data alike - errors = mexIntegrityCheck(); - if ( ~isempty(errors) ) - Dev.PrintIntegrityErrors(errors); - end - - % Initialized cached costs here if necessary (placed after fix old file versions for compatibility) - Load.InitializeCachedCosts(0); - - Editor.ReplayableEditAction(@Editor.InitHistory); - - runTreeInference(); - runAutoReseg(); -end - -function runTreeInference() - global CellFamilies HashedCells - - neFam = find(arrayfun(@(x)(~isempty(x.startTime)), CellFamilies)); - runFamilies = neFam(arrayfun(@(x)(x.startTime == 1), CellFamilies(neFam))); - - Editor.ReplayableEditAction(@Editor.TreeInference, runFamilies,length(HashedCells)); -end - -function runAutoReseg() - global CONSTANTS CellFamilies CellHulls HashedCells Costs - - neFam = find(arrayfun(@(x)(~isempty(x.startTime)), CellFamilies)); - runFamilies = neFam(arrayfun(@(x)(x.startTime == 1), CellFamilies(neFam))); - - tStart = 2; - tEnd = length(HashedCells); - - bErr = Editor.ReplayableEditAction(@Editor.ResegInitializeAction, runFamilies, 2); - - Editor.ReplayableEditAction(@Editor.StartReplayableSubtask, 'AutoResegTask'); - -%%%%%%%%% - bFinished = false; - - % Need to worry about deleted hulls? - costMatrix = Costs; - bDeleted = ([CellHulls.deleted] > 0); - costMatrix(bDeleted,:) = 0; - costMatrix(:,bDeleted) = 0; - - mexDijkstra('initGraph', costMatrix); - - - - for t=2:tEnd - xl = [1 CONSTANTS.imageSize(2)]; - yl = [1 CONSTANTS.imageSize(1)]; - - bErr = Editor.ReplayableEditAction(@Editor.ResegFrameAction, t, tEnd, [xl;yl]); - - if ( bErr ) - return; - end - end - -%%%%%%%%% - [bErr finishTime] = Editor.ReplayableEditAction(@Editor.ResegFinishAction); - Editor.ReplayableEditAction(@Editor.StopReplayableSubtask, tEnd-1, 'AutoResegTask'); -end - -function findImageDir(rootSearchDir) - global CONSTANTS - - fileList = dir(fullfile(rootSearchDir,'*')); - bInvalidName = arrayfun(@(x)(strncmpi(x.name,'.',1) || strncmpi(x.name,'..',2)), fileList); - bValidDir = ~bInvalidName & (vertcat(fileList.isdir) > 0); - - dirList = fileList(bValidDir); - - subDirIdx = find(strcmpi(CONSTANTS.datasetName(1:(end-1)),{dirList.name})); - if ( isempty(subDirIdx) ) - error('Could not find images in specified directory'); - end - - imageDir = fullfile(rootSearchDir,dirList(subDirIdx).name); - imageList = dir(fullfile(imageDir,'*.tif')); - if ( isempty(imageList) ) - error('Could not find images in specified directory'); - end - - [sigDigits imageDataset] = Helper.ParseImageName(imageList(1).name); - if ( ~strcmpi(imageDataset,CONSTANTS.datasetName) ) - error('Dataset name mismatch'); - end - - Load.AddConstant('rootImageFolder', imageDir, 1); - Load.AddConstant('imageSignificantDigits', sigDigits, 1); -end diff --git a/src/MATLAB/version.json b/src/MATLAB/version.json new file mode 100644 index 0000000000000000000000000000000000000000..6899acbaad0530a54823e20bf3e448544c641940 --- /dev/null +++ b/src/MATLAB/version.json @@ -0,0 +1,12 @@ +{ + "name" : "LEVER", + "majorVersion" : 7, + "minorVersion" : 14, + "branchName" : "master", + "buildNumber" : "2016.07.05.18", + "buildMachine" : "bioimage28", + "commitHash" : [ + "lever.git : f3caa208f9dfe30ce840b56fd5274a62f15a43b1", + "utilities.git : 6537681200925800e61251113576f525237b0af7" + ] +} diff --git a/src/MATLAB/version.txt b/src/MATLAB/version.txt deleted file mode 100644 index 6e5a1f11221494a95d31de53629ab5e393595dab..0000000000000000000000000000000000000000 --- a/src/MATLAB/version.txt +++ /dev/null @@ -1,3 +0,0 @@ -v7.13.2 -master - diff --git a/src/c/MTC.sln b/src/c/MTC.sln deleted file mode 100644 index 83b641615c917a2804bf3817b9ee6919a9f41ad2..0000000000000000000000000000000000000000 --- a/src/c/MTC.sln +++ /dev/null @@ -1,26 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MTC", "MTC.vcxproj", "{7991491A-3C3A-4159-B5AA-D801638BD570}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7991491A-3C3A-4159-B5AA-D801638BD570}.Debug|Win32.ActiveCfg = Debug|Win32 - {7991491A-3C3A-4159-B5AA-D801638BD570}.Debug|Win32.Build.0 = Debug|Win32 - {7991491A-3C3A-4159-B5AA-D801638BD570}.Debug|x64.ActiveCfg = Debug|x64 - {7991491A-3C3A-4159-B5AA-D801638BD570}.Debug|x64.Build.0 = Debug|x64 - {7991491A-3C3A-4159-B5AA-D801638BD570}.Release|Win32.ActiveCfg = Release|Win32 - {7991491A-3C3A-4159-B5AA-D801638BD570}.Release|Win32.Build.0 = Release|Win32 - {7991491A-3C3A-4159-B5AA-D801638BD570}.Release|x64.ActiveCfg = Release|x64 - {7991491A-3C3A-4159-B5AA-D801638BD570}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/src/c/MTC.vcxproj b/src/c/MTC.vcxproj deleted file mode 100644 index afdb25d72247f20aadc4c8150ecca4dda9a454be..0000000000000000000000000000000000000000 --- a/src/c/MTC.vcxproj +++ /dev/null @@ -1,190 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|Win32"> - <Configuration>Debug</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Debug|x64"> - <Configuration>Debug</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|Win32"> - <Configuration>Release</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|x64"> - <Configuration>Release</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - </ItemGroup> - <PropertyGroup Label="Globals"> - <ProjectGuid>{7991491A-3C3A-4159-B5AA-D801638BD570}</ProjectGuid> - <RootNamespace>MTC</RootNamespace> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <CharacterSet>MultiByte</CharacterSet> - <WholeProgramOptimization>true</WholeProgramOptimization> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <CharacterSet>MultiByte</CharacterSet> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <CharacterSet>MultiByte</CharacterSet> - <WholeProgramOptimization>true</WholeProgramOptimization> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <CharacterSet>MultiByte</CharacterSet> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> - <ImportGroup Label="ExtensionSettings"> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <PropertyGroup Label="UserMacros" /> - <PropertyGroup> - <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(ProjectName)\$(Configuration)_$(Platform)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectName)\Intermediate\$(Configuration)_$(Platform)\</IntDir> - <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</PostBuildEventUseInBuild> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(ProjectName)\$(Configuration)_$(Platform)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectName)\Intermediate\$(Configuration)_$(Platform)\</IntDir> - <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</PostBuildEventUseInBuild> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(ProjectName)\$(Configuration)_$(Platform)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectName)\Intermediate\$(Configuration)_$(Platform)\</IntDir> - <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</PostBuildEventUseInBuild> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(ProjectName)\$(Configuration)_$(Platform)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectName)\Intermediate\$(Configuration)_$(Platform)\</IntDir> - <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</PostBuildEventUseInBuild> - </PropertyGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <ClCompile> - <Optimization>Disabled</Optimization> - <MinimalRebuild>true</MinimalRebuild> - <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> - <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> - <WarningLevel>Level3</WarningLevel> - <DebugInformationFormat>EditAndContinue</DebugInformationFormat> - </ClCompile> - <Link> - <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile> - <GenerateDebugInformation>true</GenerateDebugInformation> - <RandomizedBaseAddress>false</RandomizedBaseAddress> - <DataExecutionPrevention> - </DataExecutionPrevention> - <TargetMachine>MachineX86</TargetMachine> - </Link> - <PostBuildEvent> - <Message>Copy binaries to bin directory</Message> - <Command>copy /Y "$(OutDir)$(ProjectName).exe" ..\..\bin -copy /Y "$(OutDir)$(ProjectName).pdb" ..\..\bin -</Command> - </PostBuildEvent> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <Midl> - <TargetEnvironment>X64</TargetEnvironment> - </Midl> - <ClCompile> - <Optimization>Disabled</Optimization> - <MinimalRebuild>true</MinimalRebuild> - <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> - <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> - <WarningLevel>Level3</WarningLevel> - <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> - </ClCompile> - <Link> - <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile> - <GenerateDebugInformation>true</GenerateDebugInformation> - <RandomizedBaseAddress>false</RandomizedBaseAddress> - <DataExecutionPrevention> - </DataExecutionPrevention> - <TargetMachine>MachineX64</TargetMachine> - </Link> - <PostBuildEvent> - <Message>Copy binaries to bin directory</Message> - <Command>copy /Y "$(OutDir)$(ProjectName).exe" ..\..\bin -copy /Y "$(OutDir)$(ProjectName).pdb" ..\..\bin -</Command> - </PostBuildEvent> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <ClCompile> - <RuntimeLibrary>MultiThreaded</RuntimeLibrary> - <WarningLevel>Level3</WarningLevel> - <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> - </ClCompile> - <Link> - <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile> - <GenerateDebugInformation>true</GenerateDebugInformation> - <OptimizeReferences>true</OptimizeReferences> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <RandomizedBaseAddress>false</RandomizedBaseAddress> - <DataExecutionPrevention> - </DataExecutionPrevention> - <TargetMachine>MachineX86</TargetMachine> - </Link> - <PostBuildEvent> - <Message>Copy binaries to bin directory</Message> - <Command>copy /Y "$(OutDir)$(ProjectName).exe" ..\..\bin -copy /Y "$(OutDir)$(ProjectName).pdb" ..\..\bin -</Command> - </PostBuildEvent> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <Midl> - <TargetEnvironment>X64</TargetEnvironment> - </Midl> - <ClCompile> - <RuntimeLibrary>MultiThreaded</RuntimeLibrary> - <WarningLevel>Level3</WarningLevel> - <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> - </ClCompile> - <Link> - <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile> - <GenerateDebugInformation>true</GenerateDebugInformation> - <OptimizeReferences>true</OptimizeReferences> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <RandomizedBaseAddress>false</RandomizedBaseAddress> - <DataExecutionPrevention> - </DataExecutionPrevention> - <TargetMachine>MachineX64</TargetMachine> - </Link> - <PostBuildEvent> - <Message>Copy binaries to bin directory</Message> - <Command>copy /Y "$(OutDir)$(ProjectName).exe" ..\..\bin -copy /Y "$(OutDir)$(ProjectName).pdb" ..\..\bin -</Command> - </PostBuildEvent> - </ItemDefinitionGroup> - <ItemGroup> - <ClCompile Include="MTC\cost.cpp" /> - <ClCompile Include="MTC\detection.cpp" /> - <ClCompile Include="MTC\paths.cpp" /> - <ClCompile Include="MTC\tracker.cpp" /> - </ItemGroup> - <ItemGroup> - <ClInclude Include="MTC\cost.h" /> - <ClInclude Include="MTC\detection.h" /> - <ClInclude Include="MTC\paths.h" /> - <ClInclude Include="MTC\tracker.h" /> - </ItemGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> - <ImportGroup Label="ExtensionTargets"> - </ImportGroup> -</Project> diff --git a/src/c/MTC/cost.cpp b/src/c/MTC/cost.cpp deleted file mode 100644 index e512a17ed8aa78a1bed67ce992407681818196d7..0000000000000000000000000000000000000000 --- a/src/c/MTC/cost.cpp +++ /dev/null @@ -1,227 +0,0 @@ -//*********************************************************************** -// -// Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter -// -// This file is part of LEVer - the tool for stem cell lineaging. See -// https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -// -// LEVer is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// LEVer is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with LEVer in file "gnu gpl v3.txt". If not, see -// <http://www.gnu.org/licenses/>. -// -// -//*********************************************************************** - -#include "tracker.h" - - -#undef max -#undef min - -// Convenience defines -#define SQR(x) ((x)*(x)) -#define DOT(x1,y1,x2,y2) ((x1)*(x2) + (y1)*(y2)) -#define LENGTH(x,y) (sqrt((SQR(x))+(SQR(y)))) -#define SIGN(x) (((x) >= 0.0) ? (1.0) : (-1.0) ) - -const double costEpsilon = 1e-3; - -double CCDist(int t0,int i0,int t1,int i1) -{ - int i; - int nHull1; - - nHull1=GetGlobalIdx(t1, i1); - - for (i=0;i<rgDetect[t0][i0].nConnectedHulls;i++) - { - if (rgDetect[t0][i0].DarkConnectedHulls[i]==nHull1) - // connected! - return rgDetect[t0][i0].DarkConnectedCost[i]; - } - return gCCMax+1.; //dbltype::infinity(); - - -} // CCDist - -double HullDist(int t0,int i0,int t1,int i1) -{ - double dx,dy,d; - - d=(SQR(rgDetect[t0][i0].X-rgDetect[t1][i1].X) + SQR(rgDetect[t0][i0].Y-rgDetect[t1][i1].Y)); - - return sqrt(d); -} // HullDist - -double CCHullDist(int t0,int i0,int t1,int i1,double vmax,double ccmax) -{ - double hd,sd; - double nmax,nmin,cd; - int nHull0,nHull1; - // - nHull0=GetGlobalIdx(t0, i0); - nHull1=GetGlobalIdx(t1, i1); - - hd=HullDist(t0,i0,t1,i1); - if (hd>vmax) - return dbltype::infinity(); - - nmax=std::max<double>(rgDetect[t0][i0].nPixels, rgDetect[t1][i1].nPixels); - nmin=std::min<double>(rgDetect[t0][i0].nPixels, rgDetect[t1][i1].nPixels); - - cd=CCDist(t0,i0,t1,i1); - if (cd>ccmax ) - return dbltype::infinity(); - - if ((cd>ccmax ) && (hd>vmax/2.)) - return dbltype::infinity(); - - sd = (nmax-nmin)/nmax; - - return (10*hd+100.*sd+1000.*cd); - -} // CCHullDist - -int GetDestinyNode(int nSourceGIdx,int nOffset,int tOffset) -{ - // Find the assigned in-edge - int histIndex2 = -1; - - int histIdx = gAssignedConnectIn[nSourceGIdx]; - if ( histIdx >=0 ) - { - CSourcePath* histpath = gConnectIn[nSourceGIdx][histIdx]; - if ( (histpath->frame.size() > nOffset) && (histpath->frame[nOffset] == tOffset) ) - histIndex2 = histpath->index[nOffset]; - } - - return histIndex2; -} // GetDestinyNode - -double GetCost(std::vector<int>& frame, std::vector<int>& index, int srcFrameIdx, int bCheck) -{ - const double intensityCostWeight = 1.0; - double velo_max= gVMax,cc_max=gCCMax; - double LocalCost = 0.0; - double OcclusionCost=1.; - double DestinyCost=1.; - double TotalCost = 0.0; - double localLinearCost = 0.0; - double dlcd,dccd; - double LocationCost = 0.0; - double dlocnX,dlocnY; - int k; - int startIdx; - int ptLoc[3][2]; - int srcGIdx; - - int nHull0,nHull1; - // - nHull0=GetGlobalIdx(frame[srcFrameIdx], index[srcFrameIdx]); - nHull1=GetGlobalIdx(frame[srcFrameIdx+1], index[srcFrameIdx+1]); - - if ( frame.size() < 2 ) - { - return dbltype::infinity(); - } - - if (bCheck) - startIdx=frame.size()-2; - else - { - int tStart; - - tStart=frame[srcFrameIdx]-gWindowSize+1; - tStart=std::max<double>(0., tStart); - startIdx=srcFrameIdx; - while ((frame[startIdx]>tStart) && (startIdx>0)) - startIdx--; - - } - - for ( k=startIdx; k < frame.size()-1; ++k ) - { - dlcd=HullDist(frame[k],index[k],frame[k+1],index[k+1]); - if (dlcd > velo_max) - return dbltype::infinity(); - - OcclusionCost+=frame[k+1]-frame[k]-1; - } - - if (bCheck) - return 1.; - - LocalCost=3*CCHullDist(frame[srcFrameIdx],index[srcFrameIdx],frame[srcFrameIdx+1],index[srcFrameIdx+1],velo_max,cc_max); - - if ( LocalCost == dbltype::infinity() ) - return dbltype::infinity(); - - if (srcFrameIdx>0) - LocalCost+=CCHullDist(frame[srcFrameIdx-1],index[srcFrameIdx-1],frame[srcFrameIdx+1],index[srcFrameIdx+1], 2*velo_max, 2*cc_max); - else - LocalCost*=2; - - if ( LocalCost == dbltype::infinity() ) - return dbltype::infinity(); - - if ((srcFrameIdx<frame.size()-2)) - LocalCost+=CCHullDist(frame[srcFrameIdx],index[srcFrameIdx],frame[srcFrameIdx+2],index[srcFrameIdx+2], 2*velo_max, 2*cc_max); - else - LocalCost*=2; - - if ( LocalCost == dbltype::infinity() ) - return dbltype::infinity(); - - //int nDestiny2,nDestiny3; - // - //if (srcFrameIdx>0 && frame.size()>srcFrameIdx+2) - //{ - - // srcGIdx = GetGlobalIdx(frame[srcFrameIdx], index[srcFrameIdx]); - // nDestiny2=GetDestinyNode(srcGIdx,2,frame[srcFrameIdx+1]); - // if (nDestiny2==index[srcFrameIdx+1]) - // LocalCost*=0.5; - //} - - dlocnX=double(rgDetect[frame[srcFrameIdx]][index[srcFrameIdx]].X); - dlocnY=double(rgDetect[frame[srcFrameIdx]][index[srcFrameIdx]].Y); - for ( k=startIdx; k < srcFrameIdx; ++k ) - { - dlocnX+=double(rgDetect[frame[k]][index[k]].X); - dlocnY+=double(rgDetect[frame[k]][index[k]].Y); - } - dlocnX/=(srcFrameIdx-startIdx+1); - dlocnY/=(srcFrameIdx-startIdx+1); - for ( k=srcFrameIdx; k < frame.size(); ++k ) - { - LocationCost+=SQR(double(rgDetect[frame[k]][index[k]].X)-dlocnX)+SQR(double(rgDetect[frame[k]][index[k]].Y)-dlocnY); - } - LocationCost/=(frame.size()-srcFrameIdx); - LocationCost=sqrt(LocationCost); - - TotalCost = LocalCost + LocationCost; // + localLinearCost; - if (frame.size()<2*gWindowSize+1) - { - double LengthPenalty; - LengthPenalty=(2*gWindowSize+1)-frame.size(); - TotalCost = TotalCost*2*LengthPenalty; - } - - if (OcclusionCost>1) - OcclusionCost*=2; - TotalCost*=OcclusionCost; - - if ( TotalCost < costEpsilon ) - TotalCost = costEpsilon; - - return TotalCost; -} diff --git a/src/c/MTC/cost.h b/src/c/MTC/cost.h deleted file mode 100644 index 2afcbdeb48aec5476d8e1175fcf2edcc06f81fd1..0000000000000000000000000000000000000000 --- a/src/c/MTC/cost.h +++ /dev/null @@ -1,29 +0,0 @@ -//*********************************************************************** -// -// Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter -// -// This file is part of LEVer - the tool for stem cell lineaging. See -// https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -// -// LEVer is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// LEVer is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with LEVer in file "gnu gpl v3.txt". If not, see -// <http://www.gnu.org/licenses/>. -// -// -//*********************************************************************** - - - -// Get cost based on a frame and index list. The srcFrameIdx is used if there, it is the index into -// frame/index vectors of the source point(start of new path). srcFrameIdx is trivially 0 if there is -// no history being used. -double GetCost(std::vector<int>& frame, std::vector<int>& index, int srcFrameIdx,int bCheck); \ No newline at end of file diff --git a/src/c/MTC/detection.cpp b/src/c/MTC/detection.cpp deleted file mode 100644 index deadbf116573e010698eaf8959bca5029c859527..0000000000000000000000000000000000000000 --- a/src/c/MTC/detection.cpp +++ /dev/null @@ -1,143 +0,0 @@ -//*********************************************************************** -// -// Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter -// -// This file is part of LEVer - the tool for stem cell lineaging. See -// https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -// -// LEVer is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// LEVer is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with LEVer in file "gnu gpl v3.txt". If not, see -// <http://www.gnu.org/licenses/>. -// -// -//*********************************************************************** - -#include "tracker.h" - - -int gnumPts; - -int ReadSegmentationData(char* filename, int* numTotalPts, SDetection*** rgDetect, int** detectLengths, int** detectLengthSum) -{ - int numFrames; - int numPts; - - int* lengthPtr; - int* lengthSumPtr; - SDetection* dataPtr; - SDetection** arrayIdxPtr; - int nDCH; - double dDCH; - FILE* fp; - - fp = fopen(filename, "r"); - if ( !fp ) - return -1; - - fscanf(fp, "%d %d\n\n", &numFrames, &numPts); - - dataPtr = new SDetection[numPts]; - arrayIdxPtr = new SDetection*[numFrames]; - lengthPtr = new int[numFrames]; - lengthSumPtr = new int[numFrames]; - - int frameOffset = 0; - for ( int t=0; t < numFrames; ++t ) - { - int frameDetections; - fscanf(fp, "%d\n", &frameDetections); - - lengthPtr[t] = frameDetections; - if ( t > 0 ) - lengthSumPtr[t] = lengthSumPtr[t-1] + lengthPtr[t-1]; - else - lengthSumPtr[t] = 0; - - arrayIdxPtr[t] = dataPtr + frameOffset; - - for ( int ptItr = 0; ptItr < frameDetections; ++ptItr ) - { - SDetection* curPt = &arrayIdxPtr[t][ptItr]; - fscanf(fp, "%d %d %d %d:", &(curPt->X), &(curPt->Y),&(curPt->nPixels),&(curPt->nConnectedHulls)); - - for ( int pixItr = 0; pixItr < curPt->nConnectedHulls; ++pixItr ) - { - fscanf(fp, " %d,%lf", &(nDCH),&(dDCH)); - nDCH--; //Make 0 offset - curPt->DarkConnectedHulls.push_back(nDCH); - curPt->DarkConnectedCost.push_back(dDCH); - } - - fscanf(fp,"\n"); - } - - frameOffset += frameDetections; - } - - fclose(fp); - - (*numTotalPts) = numPts; - (*rgDetect) = arrayIdxPtr; - (*detectLengths) = lengthPtr; - (*detectLengthSum) = lengthSumPtr; - - return numFrames; -} - - -void DeleteDetections() -{ - delete[] rgDetect[0]; - delete[] rgDetect; - - delete[] rgDetectLengths; - delete[] rgDetectLengthSum; -} - -int ReadDetectionData(int argc, char* argv[]) -{ - - int checkResult; - - int nxtArg = 1; - if ( argc >= 5 ) - { - nxtArg = 3; - sscanf(argv[1], "%lf", &gVMax); - sscanf(argv[2], "%lf", &gCCMax); - } - - checkResult = ReadSegmentationData(argv[nxtArg], &gnumPts, &rgDetect, &rgDetectLengths, &rgDetectLengthSum); - if ( checkResult < 0 ) - return -1; - - gNumFrames = checkResult; - - gMaxDetections = 0; - for ( int t=0; t < gNumFrames; ++t ) - gMaxDetections = std::max<int>(gMaxDetections, rgDetectLengths[t]); - - - gConnectOut = new std::map<int,CSourcePath*>[gnumPts]; - gConnectIn = new std::map<int,CSourcePath*>[gnumPts]; - gAssignedConnectIn = new int[gnumPts]; - gAssignedConnectOut = new int[gnumPts]; - gAssignedTrackID = new int[gnumPts]; - for ( int i=0; i < gnumPts; ++i ) - { - gAssignedConnectIn[i] = -1; - gAssignedConnectOut[i] = -1; - gAssignedTrackID[i] = -1; - } - - return (nxtArg+1); -} diff --git a/src/c/MTC/detection.h b/src/c/MTC/detection.h deleted file mode 100644 index 6b117d180fb2e5c405cbff2cda621dd620b59397..0000000000000000000000000000000000000000 --- a/src/c/MTC/detection.h +++ /dev/null @@ -1,47 +0,0 @@ -//*********************************************************************** -// -// Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter -// -// This file is part of LEVer - the tool for stem cell lineaging. See -// https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -// -// LEVer is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// LEVer is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with LEVer in file "gnu gpl v3.txt". If not, see -// <http://www.gnu.org/licenses/>. - -// -//*********************************************************************** - -// Detection related types and variables -struct SDetection -{ - int X; - int Y; - int nPixels; - int nConnectedHulls; - std::vector<int>DarkConnectedHulls; - std::vector<double>DarkConnectedCost; - - -}; - -// Read and initialize detection related data. All globals listed below must be filled or initialized by the end of this routine. -// Globals: -// rgDetect - filled with detection data -// gNumFrames - length of rows of rgDetect -// rgDetectLengths - the length of each column of rgDetect -// rgDetectLengthSum - the cumulative sum of rgDetectLengths, rgDetectLengthSum[0] = 0, rgDetectLengthSum[1] = rgDetectLengths[0], etc. -// gMaxDetections - maximum detections in any frame -// gConnectOut,gConnectIn - initialized to numPts(total detections) empty std::maps each -// gAssignedConnectIn - same size as gConnectIn, initialized to -1 -// gAssignedConnectOut - same as gAssignedConnectIn, these are for quick lookup of assigned paths -int ReadDetectionData(int argc, char* argv[]); \ No newline at end of file diff --git a/src/c/MTC/paths.cpp b/src/c/MTC/paths.cpp deleted file mode 100644 index c0ab42ff2193c3f3276359e4980daf0d64da8c9a..0000000000000000000000000000000000000000 --- a/src/c/MTC/paths.cpp +++ /dev/null @@ -1,161 +0,0 @@ -//*********************************************************************** -// -// Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter -// -// This file is part of LEVer - the tool for stem cell lineaging. See -// https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -// -// LEVer is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// LEVer is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with LEVer in file "gnu gpl v3.txt". If not, see -// <http://www.gnu.org/licenses/>. -// -// -//*********************************************************************** - -#include "tracker.h" - -int GetGlobalIdx(int t, int idx) -{ - return rgDetectLengthSum[t] + idx; -} - -int GetLocalIdx(int globalIdx) -{ - int t; - for ( t=1; t < gNumFrames; ++t ) - { - if ( globalIdx < rgDetectLengthSum[t] ) - { - break; - } - } - - return (globalIdx - rgDetectLengthSum[t-1]); -} - -int BuildHistoryPath(CSourcePath* historyPath, CSourcePath* path, int occlLookback) -{ - int pathStartGIdx = GetGlobalIdx(path->frame[0], path->index[0]); - - // Find the assigned in-edge - int histTrackID = -1; - int histIdx = gAssignedConnectIn[pathStartGIdx]; - if ( histIdx >=0 ) - { - CSourcePath* histpath = gConnectIn[pathStartGIdx][histIdx]; - // Single segment agreement requirement - if ( histpath->frame.size() > 2 ) - histTrackID = histpath->trackletID; - } - - if ( histTrackID >= 0 ) - { - tPathList::iterator histIter = gAssignedTracklets[histTrackID].begin(); - while ( histIter != gAssignedTracklets[histTrackID].end() ) - { - CSourcePath* curPath = *histIter; - - historyPath->PushPoint(curPath->frame[0], curPath->index[0]); - ++histIter; - } - } - - for ( int i=0; i < path->frame.size(); ++i ) - historyPath->PushPoint(path->frame[i], path->index[i]); - - return histTrackID; -} - -int DepthFirstBestPathSearch(CSourcePath path, int bestGIdx, int t, int tEnd, int occlLookback) -{ - bool bFinishedSearch = true; - if ( t < tEnd ) - { - int nextDetections = rgDetectLengths[t]; - for ( int nextPt=0; nextPt < nextDetections; ++nextPt ) - { - path.PushPoint(t, nextPt); - double chkCost = GetCost(path.frame, path.index, 0,1); - path.PopPoint(); - - if ( chkCost == dbltype::infinity() ) - continue; - - bFinishedSearch = false; - - path.PushPoint(t, nextPt); - bestGIdx = DepthFirstBestPathSearch(path, bestGIdx, t+1, tEnd, occlLookback); - path.PopPoint(); - } - } - - if ( bFinishedSearch && (path.frame.size() > 1) ) - { - CSourcePath historyPath; - - int startGIdx = GetGlobalIdx(path.frame[0], path.index[0]); - int nextGIdx = GetGlobalIdx(path.frame[1], path.index[1]); - - int historyTrackID = BuildHistoryPath(&historyPath, &path, occlLookback); - int srcPathIdx = historyPath.frame.size() - path.frame.size(); - - double newPathCost = GetCost(historyPath.frame, historyPath.index, srcPathIdx,0); - if ( newPathCost == dbltype::infinity() ) - return bestGIdx; - - path.trackletID = historyTrackID; - path.cost = newPathCost; - - if ( gConnectOut[startGIdx].count(nextGIdx) == 0 ) - { - CSourcePath* newPath = new CSourcePath(path); - gConnectOut[startGIdx].insert(std::pair<int,CSourcePath*>(nextGIdx, newPath)); - gConnectIn[nextGIdx].insert(std::pair<int,CSourcePath*>(startGIdx, newPath)); - } - else if ( newPathCost < gConnectOut[startGIdx][nextGIdx]->cost ) - { - *(gConnectOut[startGIdx][nextGIdx]) = path; - } - - if ( bestGIdx < 0 || newPathCost < gConnectOut[startGIdx][bestGIdx]->cost ) - { - bestGIdx = nextGIdx; - } - } - - return bestGIdx; -} - -void BuildBestPaths(std::map<int,int>& bestOutEdges, int t, int occlLookback) -{ - if ( t-occlLookback < 0 ) - return; - - int numDetections = rgDetectLengths[t-occlLookback]; - - int tEnd = std::min<int>(t+gWindowSize, gNumFrames); - - for ( int srcIdx=0; srcIdx < numDetections; ++srcIdx ) - { - int startGIdx = GetGlobalIdx(t-occlLookback, srcIdx); - if ( occlLookback > 0 && gAssignedConnectOut[startGIdx] > 0 ) - continue; - - CSourcePath srcPath; - srcPath.PushPoint(t-occlLookback, srcIdx); - int bestGIdx = DepthFirstBestPathSearch(srcPath, -1, t+1, tEnd, occlLookback); - if ( bestGIdx >= 0 ) - { - bestOutEdges[startGIdx] = bestGIdx; - } - } -} \ No newline at end of file diff --git a/src/c/MTC/paths.h b/src/c/MTC/paths.h deleted file mode 100644 index f0f1c74ddebcc70ff9f892e99b9e26b653640598..0000000000000000000000000000000000000000 --- a/src/c/MTC/paths.h +++ /dev/null @@ -1,66 +0,0 @@ -//*********************************************************************** -// -// Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter -// -// This file is part of LEVer - the tool for stem cell lineaging. See -// https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -// -// LEVer is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// LEVer is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with LEVer in file "gnu gpl v3.txt". If not, see -// <http://www.gnu.org/licenses/>. -// -// -//*********************************************************************** - -#include <vector> -#include <list> -#include <map> - -typedef std::numeric_limits<double> dbltype; - -class CSourcePath -{ -public: - CSourcePath() - { - trackletID = -1; - cost = dbltype::infinity(); - } - - void PushPoint(int t, int idx) - { - frame.push_back(t); - index.push_back(idx); - } - - void PopPoint() - { - if ( frame.size() <= 1 ) - return; - - frame.pop_back(); - index.pop_back(); - } - -public: - - int trackletID; - double cost; - - std::vector<int> frame; - std::vector<int> index; - -}; - -int GetGlobalIdx(int t, int idx); -int GetLocalIdx(int globalIdx); -void BuildBestPaths(std::map<int,int>& bestOutEdges, int t, int occlLookcback = 0); diff --git a/src/c/MTC/tracker.cpp b/src/c/MTC/tracker.cpp deleted file mode 100644 index 6b724ae39e8b40fb69b0c7c9a1df2155b15e94fc..0000000000000000000000000000000000000000 --- a/src/c/MTC/tracker.cpp +++ /dev/null @@ -1,220 +0,0 @@ -//*********************************************************************** -// -// Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter -// -// This file is part of LEVer - the tool for stem cell lineaging. See -// https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -// -// LEVer is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// LEVer is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with LEVer in file "gnu gpl v3.txt". If not, see -// <http://www.gnu.org/licenses/>. -// -// -//*********************************************************************** - -#include "tracker.h" - -//Global variables -int gNumFrames; -int gMaxDetections; -int* rgDetectLengths; -int* rgDetectLengthSum; -SDetection** rgDetect; -std::map<int,CSourcePath*>* gConnectOut; -std::map<int,CSourcePath*>* gConnectIn; -int* gAssignedConnectOut; -int* gAssignedConnectIn; -int* gAssignedTrackID; - -std::vector<tPathList> gAssignedTracklets; - -int gWindowSize = 4; - -double gVMax; -double gCCMax; - - -void WriteTracklets(int argc, char* argv[], int argIdx) -{ - -std::map<int,CSourcePath*>::iterator cIter; - CSourcePath* inPath; - double dinCost; - - if ( argIdx >= argc ) - return; - FILE* fPathFile = fopen(argv[argIdx], "w"); - - if ( !fPathFile ) - return; - - for ( int i=0; i < gAssignedTracklets.size(); ++i ) - { - tPathList::iterator trackIter; - tPathList::iterator lastPathIter = (--gAssignedTracklets[i].end()); - for ( trackIter=gAssignedTracklets[i].begin(); trackIter != gAssignedTracklets[i].end(); ++trackIter ) - { - fprintf(fPathFile, "%d,%d,%d,%d,%d\n", i+1,(*trackIter)->frame[0] + 1,(*trackIter)->frame[1] + 1,(*trackIter)->index[0] + 1,(*trackIter)->index[1] + 1); - } - } - - fprintf(fPathFile, "-1,-1,-1,-1,-1\n"); - for ( int i=0; i < gnumPts; ++i ) - { - cIter = gConnectIn[i].begin(); - for ( int j=0; j < gConnectIn[i].size(); ++j ) - { - inPath=cIter->second; - dinCost=inPath->cost; - if (dinCost!=dinCost) // test for -1.#IND! - continue; - fprintf(fPathFile, "%d,%d,%lf\n",i+1,cIter->first+1,dinCost); - cIter++; - - } - } - - fclose(fPathFile); -} - -void ClearEdges(std::vector<CSourcePath*>* inEdges, CSourcePath** outEdges) -{ - for ( int i=0; i < gMaxDetections; ++i ) - { - outEdges[i] = NULL; - inEdges[i].clear(); - } -} - -double FindMinCostIn(int ID) -{ - double cmin=dbltype::infinity(); - CSourcePath* inPath; - std::map<int,CSourcePath*>::iterator cIter; - - cIter = gConnectIn[ID].begin(); - for ( int j=0; j < gConnectIn[ID].size(); ++j ) - { - inPath=cIter->second; - if (inPath->cost<cmin) - cmin=inPath->cost; - - cIter++; - - } - - return cmin; -} - -int FindMinInEdgeIdx(int nextGIdx) -{ - double cmin = dbltype::infinity(); - int bestIdx = -1; - - std::map<int,CSourcePath*>::iterator cIter = gConnectIn[nextGIdx].begin(); - while ( cIter != gConnectIn[nextGIdx].end() ) - { - CSourcePath* inPath = cIter->second; - if ( inPath->cost < cmin ) - { - cmin = inPath->cost; - bestIdx = cIter->first; - } - - ++cIter; - } - - return bestIdx; -} - -int FindMinCostIdx(std::vector<CSourcePath*>& edges) -{ - int minidx = -1; - double mincost = dbltype::infinity(); - for ( int i=0; i < edges.size(); ++i ) - { - if ( edges[i]->cost < mincost ) - { - minidx = i; - mincost = edges[i]->cost; - } - } - - return minidx; -} - -int main(int argc, char* argv[]) -{ - system("echo %TIME% > ttt.txt"); - - // Set default gate values. - gVMax = 40.0; - gCCMax = 20.0; - - int outputargidx = ReadDetectionData(argc, argv); - - if ( outputargidx < 0 ) - return 0; - - std::map<int,int> bestOutEdges; - for ( int t=0; t < gNumFrames-1; ++t ) - { - bestOutEdges.clear(); - BuildBestPaths(bestOutEdges, t); - - //Occlusions - for ( int iLookback=1; iLookback < 2; ++iLookback ) - { - BuildBestPaths(bestOutEdges, t, iLookback); - } - - printf("t = %d, %d detections\n", t, rgDetectLengths[t]); - - for ( int destPtIdx=0; destPtIdx < rgDetectLengths[t+1]; ++destPtIdx) - { - int nextGIdx = GetGlobalIdx(t+1, destPtIdx); - int bestTrackletIdx = FindMinInEdgeIdx(nextGIdx); - if ( bestTrackletIdx < 0 ) - continue; - - if ( (bestOutEdges.count(bestTrackletIdx) == 0) || bestOutEdges[bestTrackletIdx] != nextGIdx ) - continue; - - int newTrackletID = gConnectOut[bestTrackletIdx][nextGIdx]->trackletID; - - if ( newTrackletID < 0 ) - { - //Add new tracklet to list etc. and set id - newTrackletID = gAssignedTracklets.size(); - gConnectOut[bestTrackletIdx][nextGIdx]->trackletID = newTrackletID; - - tPathList newList; - gAssignedTracklets.push_back(newList); - - gAssignedTrackID[bestTrackletIdx] = newTrackletID; - } - - //Add path to tracklet list - gAssignedTracklets[newTrackletID].push_back(gConnectOut[bestTrackletIdx][nextGIdx]); - - //Keep track of assignment for fast lookup - gAssignedConnectIn[nextGIdx] = bestTrackletIdx; - gAssignedConnectOut[bestTrackletIdx] = nextGIdx; - gAssignedTrackID[nextGIdx] = newTrackletID; - } - } - - WriteTracklets(argc, argv, outputargidx); - - system("echo %TIME% >> ttt.txt"); - -} diff --git a/src/c/MTC/tracker.h b/src/c/MTC/tracker.h deleted file mode 100644 index 30687b972ee0858463b1ce19ffa2b2dfe65291c1..0000000000000000000000000000000000000000 --- a/src/c/MTC/tracker.h +++ /dev/null @@ -1,58 +0,0 @@ -//*********************************************************************** -// -// Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter -// -// This file is part of LEVer - the tool for stem cell lineaging. See -// https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -// -// LEVer is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// LEVer is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with LEVer in file "gnu gpl v3.txt". If not, see -// <http://www.gnu.org/licenses/>. -// -// -//*********************************************************************** - -#include <stdio.h> - -#include <list> -#include <vector> -#include <limits> - -#include "detection.h" -#include "cost.h" -#include "paths.h" - -typedef std::list<CSourcePath*> tPathList; - -//Detection related global variables -extern int gNumFrames; -extern int gnumPts; -extern int gMaxDetections; -extern int* rgDetectLengths; -extern int* rgDetectLengthSum; -extern SDetection** rgDetect; - -//Path global variables -extern std::map<int,CSourcePath*>* gConnectOut; -extern std::map<int,CSourcePath*>* gConnectIn; - -//For quick edge lookup from point (like inID/outID) -extern int* gAssignedConnectOut; -extern int* gAssignedConnectIn; -extern int* gAssignedTrackID; - -//Global variables -extern int gWindowSize; -extern double gVMax; -extern double gCCMax; - -extern std::vector<tPathList> gAssignedTracklets; \ No newline at end of file diff --git a/src/c/Tracker.sln b/src/c/Tracker.sln new file mode 100644 index 0000000000000000000000000000000000000000..942d3d655006dfac6c345a69cc70048603f491a9 --- /dev/null +++ b/src/c/Tracker.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TrackerMex", "Tracker.vcxproj", "{EA17F87B-2278-4F65-928A-5F20AD8633D6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EA17F87B-2278-4F65-928A-5F20AD8633D6}.Debug|x64.ActiveCfg = Debug|x64 + {EA17F87B-2278-4F65-928A-5F20AD8633D6}.Debug|x64.Build.0 = Debug|x64 + {EA17F87B-2278-4F65-928A-5F20AD8633D6}.Release|x64.ActiveCfg = Release|x64 + {EA17F87B-2278-4F65-928A-5F20AD8633D6}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/c/Tracker.vcxproj b/src/c/Tracker.vcxproj new file mode 100644 index 0000000000000000000000000000000000000000..b2af52f64d317a0b45248116da2f089cc6ab6370 --- /dev/null +++ b/src/c/Tracker.vcxproj @@ -0,0 +1,197 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{EA17F87B-2278-4F65-928A-5F20AD8633D6}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <RootNamespace>Tracker</RootNamespace> + <ProjectName>TrackerMex</ProjectName> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v140</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + <PlatformToolset>v140</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v140</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + <PlatformToolset>v140</PlatformToolset> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <LinkIncremental>true</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <LinkIncremental>true</LinkIncremental> + <OutDir>$(SolutionDir)Output\$(ProjectName)\$(Configuration)_$(PlatformName)\</OutDir> + <IntDir>$(SolutionDir)Intermediate\$(ProjectName)\$(Configuration)_$(PlatformName)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <LinkIncremental>false</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <LinkIncremental>false</LinkIncremental> + <OutDir>$(SolutionDir)Output\$(ProjectName)\$(Configuration)_$(PlatformName)\</OutDir> + <IntDir>$(SolutionDir)Intermediate\$(ProjectName)\$(Configuration)_$(PlatformName)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;TRACKER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <ClCompile> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;TRACKER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <AdditionalIncludeDirectories>$(MATLAB_DIR)\extern\include;.\Tracker</AdditionalIncludeDirectories> + <OpenMPSupport>true</OpenMPSupport> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <AdditionalLibraryDirectories>$(MATLAB_DIR)\extern\lib\win64\microsoft</AdditionalLibraryDirectories> + <AdditionalDependencies>libmx.lib;libmex.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> + <ModuleDefinitionFile>.\Tracker\trackerMex.def</ModuleDefinitionFile> + </Link> + <PostBuildEvent> + <Command>echo copy" $(OutDir)trakerMex.dll" "$(ProjectDir)" +copy "$(OutDir)trackerMex.dll" "$(ProjectDir)" +echo copy "$(OutDir)trackerMex.pdb" "$(ProjectDir)" +copy "$(OutDir)trackerMex.pdb" "$(ProjectDir)" +echo move "$(ProjectDir)trackerMex.dll" "$(ProjectDir)trackerMex.mexw64" +move "$(ProjectDir)trackerMex.dll" "$(ProjectDir)trackerMex.mexw64" +echo copy "$(ProjectDir)trackerMex.mexw64" "$(ProjectDir)..\MATLAB\." +copy "$(ProjectDir)trackerMex.mexw64" "$(ProjectDir)..\MATLAB\."</Command> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader> + </PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;TRACKER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader> + </PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;TRACKER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <AdditionalIncludeDirectories>$(MATLAB_DIR)\extern\include;.\Tracker</AdditionalIncludeDirectories> + <OpenMPSupport>true</OpenMPSupport> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + <AdditionalLibraryDirectories>$(MATLAB_DIR)\extern\lib\win64\microsoft</AdditionalLibraryDirectories> + <AdditionalDependencies>libmx.lib;libmex.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> + <ModuleDefinitionFile>.\Tracker\trackerMex.def</ModuleDefinitionFile> + </Link> + <PostBuildEvent> + <Command>echo copy" $(OutDir)trakerMex.dll" "$(ProjectDir)" +copy "$(OutDir)trackerMex.dll" "$(ProjectDir)" +echo copy "$(OutDir)trackerMex.pdb" "$(ProjectDir)" +copy "$(OutDir)trackerMex.pdb" "$(ProjectDir)" +echo move "$(ProjectDir)trackerMex.dll" "$(ProjectDir)trackerMex.mexw64" +move "$(ProjectDir)trackerMex.dll" "$(ProjectDir)trackerMex.mexw64" +echo copy "$(ProjectDir)trackerMex.mexw64" "$(ProjectDir)..\MATLAB\." +copy "$(ProjectDir)trackerMex.mexw64" "$(ProjectDir)..\MATLAB\."</Command> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="Tracker\cost.cpp" /> + <ClCompile Include="Tracker\Hull.cpp" /> + <ClCompile Include="Tracker\paths.cpp" /> + <ClCompile Include="Tracker\tracker.cpp" /> + <ClCompile Include="Tracker\trackerMex.cpp" /> + <ClCompile Include="Tracker\Utility.cpp" /> + </ItemGroup> + <ItemGroup> + <None Include="Tracker\trackerMex.def" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="Tracker\cost.h" /> + <ClInclude Include="Tracker\Hull.h" /> + <ClInclude Include="Tracker\paths.h" /> + <ClInclude Include="Tracker\tracker.h" /> + <ClInclude Include="Tracker\Utility.h" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project> \ No newline at end of file diff --git a/src/c/MTC.vcxproj.filters b/src/c/Tracker.vcxproj.filters similarity index 60% rename from src/c/MTC.vcxproj.filters rename to src/c/Tracker.vcxproj.filters index fb8d41c4c353bfac46f0736086dbe99a81dc9153..aab2d9ef51721e6d558ff72af1767a95beb11294 100644 --- a/src/c/MTC.vcxproj.filters +++ b/src/c/Tracker.vcxproj.filters @@ -11,34 +11,48 @@ </Filter> <Filter Include="Resource Files"> <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> - <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions> + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> </Filter> </ItemGroup> <ItemGroup> - <ClCompile Include="MTC\cost.cpp"> + <ClCompile Include="Tracker\cost.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="MTC\detection.cpp"> + <ClCompile Include="Tracker\paths.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="MTC\paths.cpp"> + <ClCompile Include="Tracker\trackerMex.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="MTC\tracker.cpp"> + <ClCompile Include="Tracker\Hull.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="Tracker\Utility.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="Tracker\tracker.cpp"> <Filter>Source Files</Filter> </ClCompile> </ItemGroup> <ItemGroup> - <ClInclude Include="MTC\cost.h"> + <None Include="Tracker\trackerMex.def"> + <Filter>Resource Files</Filter> + </None> + </ItemGroup> + <ItemGroup> + <ClInclude Include="Tracker\tracker.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="Tracker\cost.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="MTC\detection.h"> + <ClInclude Include="Tracker\paths.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="MTC\paths.h"> + <ClInclude Include="Tracker\Hull.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="MTC\tracker.h"> + <ClInclude Include="Tracker\Utility.h"> <Filter>Header Files</Filter> </ClInclude> </ItemGroup> diff --git a/src/c/Tracker/Hull.cpp b/src/c/Tracker/Hull.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f0dd370e3139c9b6168ae51da0a0a859ec647d6b --- /dev/null +++ b/src/c/Tracker/Hull.cpp @@ -0,0 +1,67 @@ +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ +#include "Hull.h" + +#include <set> + +std::vector<Hull> gHulls; +std::vector<std::set<int>> gHashedHulls; + +void Hull::clear() +{ + frame = UNSET_VAR; + centerOfMass.x = UNSET_VAR; + centerOfMass.y = UNSET_VAR; + centerOfMass.z = UNSET_VAR; + track = UNSET_VAR; +} + + +Hull::Hull() +{ + clear(); +} + +Hull::Hull(unsigned int frame) +{ + clear(); + this->frame = frame; +} + +Hull::~Hull() +{ + clear(); +} + + +void Hull::setCenterOfMass(double* com) +{ + centerOfMass.x = com[0]; + centerOfMass.y = com[1]; + centerOfMass.z = com[2]; +} + + +void Hull::setFrame(unsigned int frame) +{ + this->frame = frame; +} \ No newline at end of file diff --git a/src/c/Tracker/Hull.h b/src/c/Tracker/Hull.h new file mode 100644 index 0000000000000000000000000000000000000000..fedb5ac3d090c92dde8b0910e49e6292389973bd --- /dev/null +++ b/src/c/Tracker/Hull.h @@ -0,0 +1,69 @@ +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ +#ifndef HULL_H +#define HULL_H + +#include "Utility.h" +#include <vector> +#include <set> + +typedef Vec<double> PointType; + +class Hull +{ +public: + Hull(); + Hull(unsigned int frame); + ~Hull(); + + //getters + unsigned int getFrame(){return frame;} + Vec<double> getCenterOfMass(){return centerOfMass;} + size_t getNumberofVoxels(){return numPixels;} + unsigned int getTrack(){return track;} + + void getColor(double* colorOut); + + //setters + void setCenterOfMass(double* com); + void setFrame(unsigned int frame); + void setTrack(double* label){this->track=*label;} + void setTrack(int label){this->track=label;} + void setNumPixels(size_t numPixels) { this->numPixels = numPixels; } + + void clearTrack(){track=UNSET_VAR;} + void logicallyDelete(unsigned int hull); + +private: + unsigned int frame; + Vec<double> centerOfMass; + unsigned int track; + size_t numPixels; + + void clear(); + void clearBoundingBox(); +}; + +extern std::vector<Hull> gHulls; +extern std::vector<std::set<int>> gHashedHulls; + +#endif \ No newline at end of file diff --git a/src/c/Tracker/Utility.cpp b/src/c/Tracker/Utility.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ba91fdab66e9ae7ae57920eb3a6d24fc9b6885db --- /dev/null +++ b/src/c/Tracker/Utility.cpp @@ -0,0 +1,45 @@ +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ +#include "Utility.h" + +Vec<float> gColors[NCOLORS] = { + Vec<float>(1,0,0), + Vec<float>(1,0.5,0), + Vec<float>(1,1,0), + Vec<float>(0,1,1), + Vec<float>(0,0.5,1), + Vec<float>(0.5,0,1), + Vec<float>(1,0,0.5), + Vec<float>(0,0.75,0.75), + Vec<float>(0.75,0,0.75), + Vec<float>(0.75,0.75,0), + Vec<float>(0.7969,0,0.3984), + Vec<float>(0.5977,0.3984,0), + Vec<float>(0,0.7969,1), + Vec<float>(1,0.5977,0.3984), + Vec<float>(0.7969,0.5977,0) +}; + +Vec<float> PickColor() +{ + return gColors[rand()%NCOLORS]; +} \ No newline at end of file diff --git a/src/c/Tracker/Utility.h b/src/c/Tracker/Utility.h new file mode 100644 index 0000000000000000000000000000000000000000..c6f20d8b052173f346f4bbff602318174628ab59 --- /dev/null +++ b/src/c/Tracker/Utility.h @@ -0,0 +1,131 @@ +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ +#ifndef UTILITY_H +#define UTILITY_H + +#include <string> +#include <Windows.h> + +#define SQR(x) ((x)*(x)) + +#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0])) + +#ifndef SAFE_DELETE +#define SAFE_DELETE(p) { if (p) { delete (p); (p)=NULL; } } +#endif +#ifndef SAFE_DELETE_ARRAY +#define SAFE_DELETE_ARRAY(p) { if (p) { delete[] (p); (p)=NULL; } } +#endif +#ifndef SAFE_RELEASE +#define SAFE_RELEASE(p) { if (p) { (p)->Release(); (p)=NULL; } } +#endif + +#define MatToC(x) (x-1) +#define CToMat(x) (x+1) + +#define UNSET_VAR (-1) +#define NCOLORS (15) + +#define MAX(x,y) ((x>y)?(x):(y)) +#define MIN(x,y) ((x<y)?(x):(y)) + +template<typename T> +struct Vec +{ + T x; + T y; + T z; + + Vec() + { + x=0; + y=0; + z=0; + } + + Vec(T x, T y, T z) + { + this->x = x; + this->y = y; + this->z = z; + } + + Vec<T> operator+ (Vec<T> other) const + { + Vec<T> outVec; + outVec.x = x + other.x; + outVec.y = y + other.y; + outVec.z = z + other.z; + + return outVec; + } + + Vec<T> operator- (Vec<T> other) const + { + Vec<T> outVec; + outVec.x = x - other.x; + outVec.y = y - other.y; + outVec.z = z - other.z; + + return outVec; + } + + Vec<T> operator- () const + { + Vec<T> outVec; + outVec.x = -x; + outVec.y = -y; + outVec.z = -z; + + return outVec; + } + + Vec<T>& operator= (const Vec<T> inVec) + { + x = inVec.x; + y = inVec.y; + z = inVec.z; + + return *this; + } + + size_t product() const + { + return x*y*z; + } + + double EuclideanDistanceTo(Vec<T> other) + { + return sqrt(SQR((double)x-other.x)+SQR((double)y-other.y)+SQR((double)z-other.z)); + } + + double SquareDistanceTo(Vec<T> other) + { + return SQR((double)x-other.x)+SQR((double)y-other.y)+SQR((double)z-other.z); + } +}; + +extern Vec<float> gColors[NCOLORS]; + +Vec<float> PickColor(); + +#endif \ No newline at end of file diff --git a/src/c/Tracker/cost.cpp b/src/c/Tracker/cost.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7f098c982b2a96b6d75be87a02ac2d050839b8d1 --- /dev/null +++ b/src/c/Tracker/cost.cpp @@ -0,0 +1,171 @@ +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ +#include "tracker.h" +#include "Utility.h" +#include "Hull.h" + +// Convenience defines +#define DOT(x1,y1,x2,y2) ((x1)*(x2) + (y1)*(y2)) +#define LENGTH(x,y) (sqrt((SQR(x))+(SQR(y)))) +#define SIGN(x) (((x) >= 0.0) ? (1.0) : (-1.0) ) + +double calcHullDist(int startCellIdx, int nextCellIdx) +{ + return gHulls[startCellIdx].getCenterOfMass().EuclideanDistanceTo(gHulls[nextCellIdx].getCenterOfMass()); +} + +double calcCCDist(int startCellIdx, int nextCellIdx) +{ + if ( gHulls[startCellIdx].getFrame() > gHulls[nextCellIdx].getFrame() ) + { + int tmp = startCellIdx; + startCellIdx = nextCellIdx; + nextCellIdx = tmp; + } + return gTrackerData.getDistance(startCellIdx,nextCellIdx,gCCMax); + + //if ( gCCDistMap[startCellIdx].count(nextCellIdx) == 0 ) + // return gCCMax + 1.0; + + //return gCCDistMap[startCellIdx][nextCellIdx]; +} + +double calcFullCellDist(int startCellIdx, int nextCellIdx, double vmax, double ccmax) +{ + double hdist = calcHullDist(startCellIdx, nextCellIdx); + + if ( hdist > vmax ) + return dbltype::infinity(); + + double cdist = calcCCDist(startCellIdx, nextCellIdx); + + if ( (cdist > ccmax) && (hdist > (vmax/2.0)) ) + return dbltype::infinity(); + + int startCellSize = gHulls[startCellIdx].getNumberofVoxels(); + int nextCellSize = gHulls[nextCellIdx].getNumberofVoxels(); + + int nmax = MAX(startCellSize, nextCellSize); + int nmin = MIN(startCellSize, nextCellSize); + + double sdist = ((double) (nmax - nmin)) / nmax; + + return (10.0*hdist + 100.0*sdist + 1000.0*cdist); +} + +double getCost(std::vector<int>& indices, int sourceIdx, int bCheck) +{ + double vmax = gVMax; + double ccmax = gCCMax; + + if ( indices.size() - sourceIdx <= 1 ) + return dbltype::infinity(); + + int sourceHull = indices[sourceIdx]; + int nextHull = indices[sourceIdx+1]; + + int dir = 1; + + int startIdx; + if ( bCheck ) + startIdx = indices.size() - 2; + else + { + dir = (gHulls[nextHull].getFrame() - gHulls[sourceHull].getFrame() >= 0) ? 1 : -1; + + int tStart = MAX(gHulls[indices[sourceIdx]].getFrame() - gWindowSize + 1, 0); + int tPathStart = gHulls[indices[0]].getFrame(); + if ( dir < 0 ) + { + tStart = MAX(gHulls[indices[sourceIdx]].getFrame() + gWindowSize - 1, 0); + tPathStart = gHulls[indices[0]].getFrame(); + startIdx = MAX(tPathStart - tStart, 0); + } + else + startIdx = MAX(tStart - tPathStart, 0); + } + + for ( int k=startIdx; k < indices.size()-1; ++k ) + { + double dlcd = calcHullDist(indices[k], indices[k+1]); + + if ( dlcd > vmax ) + return dbltype::infinity(); + } + + // Just return non-infinite for a successful check. + if ( bCheck ) + return 1.0; + + double localCost = 3*calcFullCellDist(indices[sourceIdx], indices[sourceIdx+1], vmax, ccmax); + + if ( localCost == dbltype::infinity() ) + return dbltype::infinity(); + + // Calculate local surrounding connected-component distance if possible + if ( sourceIdx > 0 ) + localCost += calcFullCellDist(indices[sourceIdx-1], indices[sourceIdx+1], 2*vmax, 2*ccmax); + else + localCost *= 2.0; + + if ( localCost == dbltype::infinity() ) + return dbltype::infinity(); + + // Calculate forward cc cost if path is long enough + if ( sourceIdx < indices.size()-2 ) + localCost += calcFullCellDist(indices[sourceIdx], indices[sourceIdx+2], 2*vmax, 2*ccmax); + else + localCost *= 2.0; + + if ( localCost == dbltype::infinity() ) + return dbltype::infinity(); + + double dCenterLoc[3] = {0.0, 0.0, 0.0}; + + // Calculate historical center of mass of cell + for ( int k=startIdx; k <= sourceIdx; ++k ) + { + dCenterLoc[0] += gHulls[indices[k]].getCenterOfMass().x; + dCenterLoc[1] += gHulls[indices[k]].getCenterOfMass().y; + dCenterLoc[2] += gHulls[indices[k]].getCenterOfMass().z; + } + dCenterLoc[0] /= (sourceIdx - startIdx + 1); + dCenterLoc[1] /= (sourceIdx - startIdx + 1); + dCenterLoc[2] /= (sourceIdx - startIdx + 1); + + // Calculate mean squared deviation of path from historical center + double locationCost = 0.0; + for ( int k=sourceIdx; k < indices.size(); ++k ) + { + locationCost += SQR(gHulls[indices[k]].getCenterOfMass().x - dCenterLoc[0]) + SQR(gHulls[indices[k]].getCenterOfMass().y - dCenterLoc[1]) + SQR(gHulls[indices[k]].getCenterOfMass().z - dCenterLoc[2]); + } + locationCost = sqrt(locationCost/(indices.size() - sourceIdx)); + + double totalCost = localCost + locationCost; + if ( indices.size() < 2*gWindowSize+1 ) + { + double lengthPenalty = (2*gWindowSize+1) - indices.size(); + totalCost *= (2*lengthPenalty); + } + + return totalCost; +} \ No newline at end of file diff --git a/src/c/Tracker/cost.h b/src/c/Tracker/cost.h new file mode 100644 index 0000000000000000000000000000000000000000..7c5464594f7ae4351f6c1ff29214d5eb0fd1641f --- /dev/null +++ b/src/c/Tracker/cost.h @@ -0,0 +1,32 @@ +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ +#ifndef COSTS_H +#define COSTS_H + +#include <vector> + +// Get cost based on a frame and index list. The srcFrameIdx is used if there, it is the index into +// frame/index vectors of the source point(start of new path). srcFrameIdx is trivially 0 if there is +// no history being used. +double getCost(std::vector<int>& indices, int sourceIdx, int bCheck = 1); + +#endif \ No newline at end of file diff --git a/src/c/Tracker/paths.cpp b/src/c/Tracker/paths.cpp new file mode 100644 index 0000000000000000000000000000000000000000..faf1ea8ee6ad29035ed0be994e91425bc8a2022b --- /dev/null +++ b/src/c/Tracker/paths.cpp @@ -0,0 +1,162 @@ +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ +#include "tracker.h" +#include "Hull.h" + +#include <set> + +int buildHistoryPath(CSourcePath* historyPath, CSourcePath* path) +{ + int pathStartGIdx = path->indices[0]; + + // Find the assigned in-edge + int histTrackID = -1; + int histIdx = gAssignedConnectIn[pathStartGIdx]; + if ( histIdx >=0 ) + { + CSourcePath* histpath = gTrackerData.connectIn[pathStartGIdx][histIdx]; + histTrackID = histpath->trackletID; + } + + if ( histTrackID >= 0 ) + { + tPathList::iterator histIter = gAssignedTracklets[histTrackID].begin(); + while ( (histIter != gAssignedTracklets[histTrackID].end()) ) + { + CSourcePath* curPath = *histIter; + + int startGIdx = curPath->indices[0]; + int endGIdx = gAssignedConnectOut[startGIdx]; + + unsigned int endT = gHulls[endGIdx].getFrame(); + + for (unsigned int i=0; gHulls[curPath->indices[i]].getFrame() < endT; ++i ) + { + historyPath->pushPoint(curPath->indices[i]); + } + + ++histIter; + } + } + + for (unsigned int i=0; i < path->length(); ++i ) + historyPath->pushPoint(path->indices[i]); + + return histTrackID; +} + +int addBestPath(CSourcePath &path, int bestGIdx) +{ + if ( path.length() > 1 ) + { + CSourcePath historyPath; + + int startGIdx = path.indices[0]; + int nextGIdx = path.indices[1]; + + int historyTrackID = buildHistoryPath(&historyPath, &path); + int srcPathIdx = historyPath.length() - path.length(); + + double newPathCost = getCost(historyPath.indices, srcPathIdx, 0); + if ( newPathCost == dbltype::infinity() ) + return bestGIdx; + + path.trackletID = historyTrackID; + path.cost = newPathCost; + + if ( gTrackerData.connectOut[startGIdx].count(nextGIdx) == 0 ) + { + CSourcePath* newPath = new CSourcePath(path); + gTrackerData.connectOut[startGIdx].insert(std::pair<int,CSourcePath*>(nextGIdx, newPath)); + gTrackerData.connectIn[nextGIdx].insert(std::pair<int,CSourcePath*>(startGIdx, newPath)); + } + else if ( newPathCost < gTrackerData.connectOut[startGIdx][nextGIdx]->cost ) + { + *(gTrackerData.connectOut[startGIdx][nextGIdx]) = path; + } + + if ( (bestGIdx < 0) || (newPathCost < gTrackerData.connectOut[startGIdx][bestGIdx]->cost) ) + { + bestGIdx = nextGIdx; + } + } + + return bestGIdx; +} + +int bestDepthFirstPathSearch(CSourcePath partialPath, int bestGIdx, int t, int tEnd, int occlLookback) +{ + bool bFinishedSearch = true; + if ( t < tEnd ) + { + std::set<int>::iterator hullIter = gHashedHulls[t-occlLookback].begin(); + for ( ; hullIter != gHashedHulls[t-occlLookback].end(); ++hullIter ) + { + int nextIdx = (*hullIter); + + partialPath.pushPoint(nextIdx); + double chkCost = getCost(partialPath.indices, 0); + partialPath.popPoint(); + + if ( chkCost == dbltype::infinity() ) + continue; + + bFinishedSearch = false; + + partialPath.pushPoint(nextIdx); + + bestGIdx = bestDepthFirstPathSearch(partialPath, bestGIdx, t+1, tEnd, occlLookback); + partialPath.popPoint(); + } + } + + if ( bFinishedSearch ) + { + bestGIdx = addBestPath(partialPath, bestGIdx); + } + + return bestGIdx; +} + +void BuildBestPaths(std::map<int,int>& bestOutEdges, int t, int occlLookback) +{ + if ( t-occlLookback < 0 ) + return; + + int tEnd = min((unsigned int)t+gWindowSize, (unsigned int)gHashedHulls.size()); + + std::set<int>::iterator hullIter = gHashedHulls[t-occlLookback].begin(); + for ( ; hullIter != gHashedHulls[t-occlLookback].end(); ++hullIter ) + { + int startGIdx = (*hullIter); + if ( occlLookback > 0 && gAssignedConnectOut[startGIdx] >= 0 ) + continue; + + CSourcePath srcPath; + srcPath.pushPoint(startGIdx); + + int bestGIdx = bestDepthFirstPathSearch(srcPath, -1, t+1, tEnd, occlLookback); + + if ( bestGIdx >= 0 ) + bestOutEdges[startGIdx] = bestGIdx; + } +} \ No newline at end of file diff --git a/src/c/Tracker/paths.h b/src/c/Tracker/paths.h new file mode 100644 index 0000000000000000000000000000000000000000..c8a2e477b93b96476e30c192d6beb3810beeada9 --- /dev/null +++ b/src/c/Tracker/paths.h @@ -0,0 +1,78 @@ +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ +#ifndef PATHS_H +#define PATHS_H + +#include "Utility.h" + +#include <climits> +#include <vector> +#include <map> + +typedef std::numeric_limits<double> dbltype; + +class CSourcePath +{ +public: + CSourcePath() + { + trackletID = UNSET_VAR; + cost = dbltype::infinity(); + } + + unsigned int length() + { + return (unsigned int)indices.size(); + } + + void pushPoint(int newIdx) + { + indices.push_back(newIdx); + } + + void popPoint() + { + if ( indices.size() <= 1 ) + return; + + indices.pop_back(); + } + + void clear() + { + trackletID = UNSET_VAR; + cost = dbltype::infinity(); + + indices.clear(); + } + +public: + + int trackletID; + double cost; + + std::vector<int> indices; +}; + +void BuildBestPaths(std::map<int,int>& bestOutEdges, int t, int occlLookcback = 0); + +#endif \ No newline at end of file diff --git a/src/c/Tracker/tracker.cpp b/src/c/Tracker/tracker.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9b1f0b8af1423acadb8166c9597a523f9ab18d74 --- /dev/null +++ b/src/c/Tracker/tracker.cpp @@ -0,0 +1,383 @@ +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ +#include "tracker.h" +#include "Hull.h" + +TrackerData gTrackerData; + +int* gAssignedConnectOut; +int* gAssignedConnectIn; + +std::vector<tPathList> gAssignedTracklets; + +double gVMax = 20.0;//TODO try these values +double gCCMax = 10.0; + +int gWindowSize = 4; + +TrackerData::TrackerData() +{ + connectIn = NULL; + connectOut = NULL; + ccDistMap = NULL; +} + +TrackerData::~TrackerData() +{ + clear(); +} + +void TrackerData::clear() +{ + if ( connectOut ) + { + delete[] connectOut; + connectOut = NULL; + } + + if ( connectIn ) + { + delete[] connectIn; + connectIn = NULL; + } + + if (ccDistMap) + { + delete[] ccDistMap; + ccDistMap = NULL; + } +} + +int FindMinInEdgeIdx(int nextGIdx) +{ + double cmin = dbltype::infinity(); + int bestIdx = -1; + + std::map<int,CSourcePath*>::iterator cIter = gTrackerData.connectIn[nextGIdx].begin(); + while ( cIter != gTrackerData.connectIn[nextGIdx].end() ) + { + CSourcePath* inPath = cIter->second; + if ( inPath->cost < cmin ) + { + cmin = inPath->cost; + bestIdx = cIter->first; + } + + ++cIter; + } + + return bestIdx; +} + +void resetIdxTrackletIds(int nodeIdx, int newTrackletID) +{ + std::map<int,CSourcePath*>::iterator pathIter = gTrackerData.connectOut[nodeIdx].begin(); + while ( pathIter != gTrackerData.connectOut[nodeIdx].end() ) + { + pathIter->second->trackletID = newTrackletID; + + ++pathIter; + } +} + +void resetForwardTrackletIds(int startingGIdx, int newTrackletID) +{ + int oldTrackletID = -1; + int nxtGIdx = gAssignedConnectOut[startingGIdx]; + if ( nxtGIdx >= 0 ) + oldTrackletID = gTrackerData.connectOut[startingGIdx][nxtGIdx]->trackletID; + + resetIdxTrackletIds(startingGIdx, newTrackletID); + while ( nxtGIdx >= 0 ) + { + CSourcePath* curPath = gTrackerData.connectOut[startingGIdx][nxtGIdx]; + gAssignedTracklets[newTrackletID].push_back(curPath); + + resetIdxTrackletIds(nxtGIdx, newTrackletID); + + startingGIdx = nxtGIdx; + nxtGIdx = gAssignedConnectOut[startingGIdx]; + } + + if ( oldTrackletID >= 0 ) + gAssignedTracklets[oldTrackletID].clear(); +} + +void patchUpResults() +{ + std::multimap<double,std::pair<int,int>> patchupList; + // Make sorted list of possible patch assignments (maps automatically sort internally) + for ( int i=0; i < gHulls.size(); ++i ) + { + if ( gAssignedConnectIn[i] >= 0 ) + continue; + + std::map<int,CSourcePath*>::iterator inIter = gTrackerData.connectIn[i].begin(); + while ( inIter != gTrackerData.connectIn[i].end() ) + { + int inGIdx = inIter->first; + if ( gAssignedConnectOut[inGIdx] < 0 ) + { + patchupList.insert(std::pair<double,std::pair<int,int>>(inIter->second->cost, std::pair<int,int>(inGIdx,i))); + } + + ++inIter; + } + } + + int totalPatches = 0; + std::multimap<double,std::pair<int,int>>::iterator srtIter = patchupList.begin(); + while ( srtIter != patchupList.end() ) + { + int startGIdx = srtIter->second.first; + int destGIdx = srtIter->second.second; + + CSourcePath* curPath = gTrackerData.connectOut[startGIdx][destGIdx]; + if ( gAssignedConnectOut[startGIdx] < 0 && gAssignedConnectIn[destGIdx] < 0 ) + { + // Get Tracklet ID first from incoming assignment + int newTrackletID = curPath->trackletID; + if ( newTrackletID < 0 ) + { + // Or from incoming assignment made during patching + int prevIdx = gAssignedConnectIn[startGIdx]; + if ( prevIdx >= 0 ) + { + newTrackletID = gTrackerData.connectOut[prevIdx][startGIdx]->trackletID; + curPath->trackletID = newTrackletID; + } + } + //if ( newTrackletID < 0 ) + //{ + // // Or from outgoing assignment if the other two don't exist + // int nxtGIdx = gAssignedConnectOut[destGIdx]; + // if ( nxtGIdx >= 0 ) + // { + // newTrackletID = gTrackerData.connectOut[destGIdx][nxtGIdx]->trackletID; + // curPath->trackletID = newTrackletID; + // } + //} + if ( newTrackletID < 0 ) + { + //Otherwise add new tracklet to list etc. and set id + newTrackletID = gAssignedTracklets.size(); + curPath->trackletID = newTrackletID; + + tPathList newList; + gAssignedTracklets.push_back(newList); + } + + int mergeTrackletId = -1; + int nxtGIdx = gAssignedConnectOut[destGIdx]; + if ( nxtGIdx >= 0 ) + { + mergeTrackletId = gTrackerData.connectOut[destGIdx][nxtGIdx]->trackletID; + } + + //Add path to tracklet list + gAssignedTracklets[newTrackletID].push_back(curPath); + + if ( mergeTrackletId >= 0 ) + resetForwardTrackletIds(destGIdx, newTrackletID); + + //Keep track of assignment for fast lookup + gAssignedConnectIn[destGIdx] = startGIdx; + gAssignedConnectOut[startGIdx] = destGIdx; + + ++totalPatches; + } + + ++srtIter; + } +} + +void destroyTrackStructures() +{ + if ( gTrackerData.connectOut ) + { + delete[] gTrackerData.connectOut; + gTrackerData.connectOut = NULL; + } + + if ( gTrackerData.connectIn ) + { + delete[] gTrackerData.connectIn; + gTrackerData.connectIn = NULL; + } + + if ( gAssignedConnectOut ) + { + delete[] gAssignedConnectOut; + gAssignedConnectOut = NULL; + } + + if ( gAssignedConnectIn ) + { + delete[] gAssignedConnectIn; + gAssignedConnectIn = NULL; + } + + gAssignedTracklets.clear(); +} + +void initTrackStrucutres() +{ + destroyTrackStructures(); + + gTrackerData.connectOut = new std::map<int,CSourcePath*>[gHulls.size()]; + gTrackerData.connectIn = new std::map<int,CSourcePath*>[gHulls.size()]; + + gAssignedConnectOut = new int[gHulls.size()]; + gAssignedConnectIn = new int[gHulls.size()]; + + for ( int i=0; i < gHulls.size(); ++i ) + { + gAssignedConnectOut[i] = -1; + gAssignedConnectIn[i] = -1; + } +} + +//void setHullInfo(int hullID, int trackID) +//{ +// //gHulls[hullID].label = trackID; +// for ( int i=0; i < gHulls[hullID].getNumberOfVertices(); ++i ) +// { +// gHulls[hullID].getMesh()->m_vertices[i].texUV = gTracks[trackID]->getColor(); +// } +//} + +void trackHulls(unsigned int numFrames) +{ + initTrackStrucutres(); + + std::map<int,int> bestOutEdges; + + for (unsigned int frame=0; frame<numFrames; ++frame) + { + + if (gHashedHulls.size()>frame+1) + //for ( int frame=0; frame < gHashedHulls.size()-1; ++frame ) + { + +#ifdef _DEBUG + char buffer[255]; + sprintf_s(buffer,"Tracking frame: %d",frame); + printf(buffer); +#endif // _DEBUG + + + bestOutEdges.clear(); + BuildBestPaths(bestOutEdges, frame); + + //Occlusions + for ( int iLookback=1; iLookback <= 1; ++iLookback ) + { + //TODO Fix comparison occlusion handling + BuildBestPaths(bestOutEdges, frame, iLookback); + } + + std::set<int>::iterator nextIdxIter = gHashedHulls[frame+1].begin(); + for ( ; nextIdxIter != gHashedHulls[frame+1].end(); ++nextIdxIter) + { + int nextGIdx = *nextIdxIter; + int bestTrackletIdx = FindMinInEdgeIdx(nextGIdx); + if ( bestTrackletIdx < 0 ) + continue; + + if ( (bestOutEdges.count(bestTrackletIdx) == 0) || bestOutEdges[bestTrackletIdx] != nextGIdx ) + continue; + + int newTrackletID = gTrackerData.connectOut[bestTrackletIdx][nextGIdx]->trackletID; + + if ( newTrackletID < 0 ) + { + //Add new tracklet to list etc. and set id + newTrackletID = gAssignedTracklets.size(); + gTrackerData.connectOut[bestTrackletIdx][nextGIdx]->trackletID = newTrackletID; + + tPathList newList; + gAssignedTracklets.push_back(newList); + } + + //Add path to tracklet list + gAssignedTracklets[newTrackletID].push_back(gTrackerData.connectOut[bestTrackletIdx][nextGIdx]); + + //Keep track of assignment for fast lookup + gAssignedConnectIn[nextGIdx] = bestTrackletIdx; + gAssignedConnectOut[bestTrackletIdx] = nextGIdx; + } + } + } + + patchUpResults(); + + int trackIdx = 0; + for(int i = 0; i<gAssignedTracklets.size(); ++i) + { + if(gAssignedTracklets[i].empty()) + continue; + + tPathList::iterator pathIter = gAssignedTracklets[i].begin(); + int startIdx = (*pathIter)->indices[0]; + + gHulls[startIdx].setTrack(trackIdx); + + for(; pathIter!=gAssignedTracklets[i].end(); ++pathIter) + { + int nextIdx = (*pathIter)->indices[1]; + gHulls[nextIdx].setTrack(trackIdx); + } + + ++trackIdx; + } + + for (unsigned int i=0; i<gHulls.size(); ++i) + { + if (UNSET_VAR==gHulls[i].getTrack()) + { + gHulls[i].setTrack(trackIdx); + ++trackIdx; + } + } +} + +void TrackerData::setCCdistMap(std::map<int,double>* cCDistMap) +{ + if (NULL!=cCDistMap) + { + if (NULL!=this->ccDistMap) + { + delete[] this->ccDistMap; + ccDistMap = NULL; + } + + this->ccDistMap = cCDistMap; + } +} + +double TrackerData::getDistance(int hull1, int hull2, double ccMax) +{ + if ( gTrackerData.ccDistMap[hull1].count(hull2) == 0 ) + return ccMax + 1.0; + + return ccDistMap[hull1][hull2]; +} diff --git a/src/c/Tracker/tracker.h b/src/c/Tracker/tracker.h new file mode 100644 index 0000000000000000000000000000000000000000..b43cd5bc62d2bb7a639f7015b57a5f3685366a97 --- /dev/null +++ b/src/c/Tracker/tracker.h @@ -0,0 +1,69 @@ +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ +#ifndef _TRACKER_H_ +#define _TRACKER_H_ + +#include <list> +#include <vector> + +#include "cost.h" +#include "paths.h" + +//For quick edge lookup from point (like inID/outID) +extern int* gAssignedConnectOut; +extern int* gAssignedConnectIn; + +//Global variables +extern int gWindowSize; + +extern double gVMax; +extern double gCCMax; + +typedef std::list<CSourcePath*> tPathList; +extern std::vector<tPathList> gAssignedTracklets; + +//main tracker function: +void trackHulls(unsigned int numFrames); + +void destroyTrackStructures(); + +class TrackerData +{ +public: + TrackerData(); + ~TrackerData(); + + //savers + void clear(); + + double getDistance(int hull1, int hull2, double ccMax); + void setCCdistMap(std::map<int,double>* cCDistMap); + + //member variables + std::map<int,CSourcePath*>* connectOut; + std::map<int,CSourcePath*>* connectIn; + std::map<int,double>* ccDistMap; +}; + +extern TrackerData gTrackerData; + +#endif //_TRACKER_H_ \ No newline at end of file diff --git a/src/c/Tracker/trackerMex.cpp b/src/c/Tracker/trackerMex.cpp new file mode 100644 index 0000000000000000000000000000000000000000..297eca6367519187b047e2f426098ca9c70a6a85 --- /dev/null +++ b/src/c/Tracker/trackerMex.cpp @@ -0,0 +1,137 @@ +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ +#include "mex.h" + +#include "tracker.h" +#include "Hull.h" + +void loadHulls( const mxArray * hulls, int numFrames ) +{ + int numHulls = mxGetNumberOfElements(hulls); + + gHulls.clear(); + gHulls.resize(numHulls); + gHashedHulls.clear(); + gHashedHulls.resize(numFrames); + + for(int hullIdx=0; hullIdx<numHulls; ++hullIdx) + { + Hull& hull = gHulls[hullIdx]; + mxArray* framePtr = mxGetField(hulls,hullIdx,"time"); + if (framePtr==NULL) mexErrMsgTxt("Missing Time!\n"); + hull.setFrame(MatToC((unsigned int)mxGetScalar(framePtr))); + + mxArray* comPtr = mxGetField(hulls,hullIdx,"centerOfMass"); + if (comPtr==NULL) mexErrMsgTxt("Missing Center of Mass!\n"); + hull.setCenterOfMass((double*)mxGetData(comPtr)); + + mxArray* pixelPtr = mxGetField(hulls,hullIdx,"indexPixels"); + if (pixelPtr==NULL) mexErrMsgTxt("Missing pixels!\n"); + + size_t numPixels = mxGetM(pixelPtr); + hull.setNumPixels(numPixels); + + gHashedHulls[hull.getFrame()].insert(hullIdx); + } +} + +void returnHulls(mxArray* plhs[]) +{ + + plhs[0] = mxCreateNumericMatrix(1, gHulls.size(), mxDOUBLE_CLASS, mxREAL); + double* trackList = (double*)mxGetData(plhs[0]); + int numEdges = 0; + + for(int i=0; i<gHulls.size(); ++i) + { + trackList[i] = gHulls[i].getTrack(); + numEdges += gTrackerData.connectOut[i].size(); + } + + mxArray* sparseArray = mxCreateSparse(gHulls.size(), gHulls.size(),numEdges,mxREAL); + mwIndex* mxjc = mxGetJc(sparseArray); + mwIndex* mxir = mxGetIr(sparseArray); + double* mxpr = mxGetPr(sparseArray); + + mxjc[0] = 0; + + std::map<int,CSourcePath*>* inEdges; + for (int i=0; i<gHulls.size(); ++i) + { + inEdges = &gTrackerData.connectIn[i]; + mxjc[i+1] = mxjc[i]+inEdges->size(); + std::map<int,CSourcePath*>::iterator it = inEdges->begin(); + for (int j=0; j<inEdges->size(); ++j, ++it) + { + mxir[mxjc[i]+j] = it->first; + mxpr[mxjc[i]+j] = it->second->cost; + } + } + + plhs[1] = sparseArray; +} + +void loadDists(const mxArray* ccDists) +{ + std::map<int, double>* ccDistMap = new std::map<int, double>[gHulls.size()]; + + size_t numHulls = mxGetN(ccDists); + for (int i = 0; i < numHulls ; ++i) + { + mxArray* nextHulls = mxGetCell(ccDists, i); + size_t m = mxGetM(nextHulls); + + double* distPairs = (double*)mxGetData(nextHulls); + + for (int j = 0; j < m ; j++) + { + int nextHull = (int)(distPairs[j*2]); + double dist = distPairs[j*2+1]; + + ccDistMap[i].insert(std::pair<int, double>(nextHull,dist)); + } + } + + gTrackerData.ccDistMap = ccDistMap; +} + +void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) +{ + if (nrhs!=5) mexErrMsgTxt("Usage: hulls, CCdists, numFrames, velocity, ccMaxDist\n"); + if (nlhs!=2) mexErrMsgTxt("Incorrect number of output arguments!\n"); + + int numFrames = mxGetScalar(prhs[2]); + const mxArray* hulls = prhs[0]; + if (hulls==NULL) mexErrMsgTxt("No hulls passed as the second argument!\n"); + + gVMax = mxGetScalar(prhs[3]); + gCCMax = mxGetScalar(prhs[4]); + + const mxArray* ccDists = prhs[1]; + + loadHulls(hulls,numFrames); + loadDists(ccDists); + trackHulls(numFrames); + returnHulls(plhs); + + destroyTrackStructures(); +} \ No newline at end of file diff --git a/src/c/Tracker/trackerMex.def b/src/c/Tracker/trackerMex.def new file mode 100644 index 0000000000000000000000000000000000000000..f3dde54921ba04a9f1f6ee0009507831b322b74c --- /dev/null +++ b/src/c/Tracker/trackerMex.def @@ -0,0 +1,3 @@ +LIBRARY "trackerMex" +EXPORTS DllMain +EXPORTS mexFunction \ No newline at end of file diff --git a/src/c/mexDijkstra.sln b/src/c/mexDijkstra.sln index 931ac812797f5b3be3b7206625648db89ad1e958..f2b8e9668e75e90dcfa000f07c39db522b7d29d3 100644 --- a/src/c/mexDijkstra.sln +++ b/src/c/mexDijkstra.sln @@ -1,22 +1,18 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.24720.0 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mexDijkstra", "mexDijkstra.vcxproj", "{4E22BB6D-1C4B-441D-9436-81224FA01AC3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Debug|Win32.ActiveCfg = Debug|Win32 - {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Debug|Win32.Build.0 = Debug|Win32 {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Debug|x64.ActiveCfg = Debug|x64 {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Debug|x64.Build.0 = Debug|x64 - {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Release|Win32.ActiveCfg = Release|Win32 - {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Release|Win32.Build.0 = Release|Win32 {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Release|x64.ActiveCfg = Release|x64 {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Release|x64.Build.0 = Release|x64 EndGlobalSection diff --git a/src/c/mexDijkstra.vcxproj b/src/c/mexDijkstra.vcxproj index 12ac3faa0c8b34219b9ae4838f4c819380dcc9f7..4aa0fd1c4e0961b4a83ea6f35ad09c4c874b3b65 100644 --- a/src/c/mexDijkstra.vcxproj +++ b/src/c/mexDijkstra.vcxproj @@ -1,18 +1,10 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|Win32"> - <Configuration>Debug</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> <ProjectConfiguration Include="Debug|x64"> <Configuration>Debug</Configuration> <Platform>x64</Platform> </ProjectConfiguration> - <ProjectConfiguration Include="Release|Win32"> - <Configuration>Release</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> <ProjectConfiguration Include="Release|x64"> <Configuration>Release</Configuration> <Platform>x64</Platform> @@ -35,33 +27,20 @@ <Keyword>Win32Proj</Keyword> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <CharacterSet>Unicode</CharacterSet> - <WholeProgramOptimization>true</WholeProgramOptimization> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <WholeProgramOptimization>true</WholeProgramOptimization> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> @@ -71,56 +50,16 @@ <PropertyGroup Label="UserMacros" /> <PropertyGroup> <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(ProjectName)\$(Configuration)_$(Platform)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectName)\Intermediate\$(Configuration)_$(Platform)\</IntDir> - <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental> - <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</PostBuildEventUseInBuild> <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(ProjectName)\$(Configuration)_$(Platform)\</OutDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectName)\Intermediate\$(Configuration)_$(Platform)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental> <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</PostBuildEventUseInBuild> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(ProjectName)\$(Configuration)_$(Platform)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectName)\Intermediate\$(Configuration)_$(Platform)\</IntDir> - <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> - <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</PostBuildEventUseInBuild> <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(ProjectName)\$(Configuration)_$(Platform)\</OutDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectName)\Intermediate\$(Configuration)_$(Platform)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental> <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</PostBuildEventUseInBuild> - <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.mexw32</TargetExt> <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.mexw64</TargetExt> </PropertyGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <ClCompile> - <Optimization>Disabled</Optimization> - <AdditionalIncludeDirectories>$(MATLAB_DIR)\extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MEXMAT_EXPORTS;MATLAB_MEX_FILE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <PreprocessToFile>false</PreprocessToFile> - <PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers> - <MinimalRebuild>true</MinimalRebuild> - <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> - <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> - <PrecompiledHeader> - </PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <DebugInformationFormat>EditAndContinue</DebugInformationFormat> - </ClCompile> - <Link> - <AdditionalDependencies>libmx.lib;libmex.lib;libmat.lib;%(AdditionalDependencies)</AdditionalDependencies> - <OutputFile>$(OutDir)..\..\..\MATLAB\$(ProjectName).mexw32</OutputFile> - <AdditionalLibraryDirectories>$(MATLAB_DIR)\extern\lib\win32\microsoft;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> - <ModuleDefinitionFile>mexDijkstra/mexDijkstra.def</ModuleDefinitionFile> - <GenerateDebugInformation>true</GenerateDebugInformation> - <SubSystem>Windows</SubSystem> - <TargetMachine>MachineX86</TargetMachine> - </Link> - <PostBuildEvent> - <Message>Copy pdb and mex files to bin and MATLAB directories</Message> - <Command>copy "$(OutDir)$(ProjectName).dll" "..\MATLAB\$(ProjectName).mexw32" -copy "$(OutDir)$(ProjectName).pdb" ..\MATLAB -</Command> - </PostBuildEvent> - </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <Midl> <TargetEnvironment>X64</TargetEnvironment> @@ -152,37 +91,6 @@ copy "$(OutDir)$(ProjectName).pdb" ..\MATLAB <Message>Copy pdb and mex files to bin and MATLAB directories</Message> <Command>copy "$(OutDir)$(ProjectName).dll" "..\MATLAB\$(ProjectName).mexw64" copy "$(OutDir)$(ProjectName).pdb" ..\MATLAB -</Command> - </PostBuildEvent> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <ClCompile> - <Optimization>MaxSpeed</Optimization> - <IntrinsicFunctions>true</IntrinsicFunctions> - <AdditionalIncludeDirectories>$(MATLAB_DIR)\extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MEXMAT_EXPORTS;MATLAB_MEX_FILE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <RuntimeLibrary>MultiThreaded</RuntimeLibrary> - <FunctionLevelLinking>true</FunctionLevelLinking> - <PrecompiledHeader> - </PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> - </ClCompile> - <Link> - <AdditionalDependencies>libmx.lib;libmex.lib;libmat.lib;%(AdditionalDependencies)</AdditionalDependencies> - <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile> - <AdditionalLibraryDirectories>$(MATLAB_DIR)\extern\lib\win32\microsoft;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> - <ModuleDefinitionFile>mexDijkstra/mexDijkstra.def</ModuleDefinitionFile> - <GenerateDebugInformation>true</GenerateDebugInformation> - <SubSystem>Windows</SubSystem> - <OptimizeReferences>true</OptimizeReferences> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <TargetMachine>MachineX86</TargetMachine> - </Link> - <PostBuildEvent> - <Message>Copy pdb and mex files to bin and MATLAB directories</Message> - <Command>copy "$(OutDir)$(ProjectName).dll" "..\MATLAB\$(ProjectName).mexw32" -"copy $(OutDir)$(ProjectName).pdb" ..\MATLAB </Command> </PostBuildEvent> </ItemDefinitionGroup> @@ -223,4 +131,4 @@ copy "$(OutDir)$(ProjectName).pdb" ..\MATLAB <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> -</Project> +</Project> \ No newline at end of file diff --git a/src/c/mexDijkstra/CSparseWrapper.cpp b/src/c/mexDijkstra/CSparseWrapper.cpp index a270057e4622f4601865ef20e106e26a3f2effee..789ebb8f71f858baa499f711eae8983966301228 100644 --- a/src/c/mexDijkstra/CSparseWrapper.cpp +++ b/src/c/mexDijkstra/CSparseWrapper.cpp @@ -1,6 +1,30 @@ + +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ #include "mexDijkstra.h" #include "CSparseWrapper.h" +#include <algorithm> + const double CSparseWrapper::noEdge = std::numeric_limits<double>::infinity(); CSparseWrapper::CSparseWrapper(const mxArray* sparseArray) diff --git a/src/c/mexDijkstra/CSparseWrapper.h b/src/c/mexDijkstra/CSparseWrapper.h index ca34b85d15bce366060c4a6a036eaa3e8296a076..00761375fedb70b589849daa3917a91a92808fdb 100644 --- a/src/c/mexDijkstra/CSparseWrapper.h +++ b/src/c/mexDijkstra/CSparseWrapper.h @@ -1,3 +1,27 @@ + + +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ + #ifndef CSPARSEWRAPPER_H #define CSPARSEWRAPPER_H 1 diff --git a/src/c/mexDijkstra/mexDijkstra.cpp b/src/c/mexDijkstra/mexDijkstra.cpp index 3fa0435d46bf1cde7795ca23a028d3dce782dc73..a80497a4ab601197d9e45fbb29237c2f3ea52f31 100644 --- a/src/c/mexDijkstra/mexDijkstra.cpp +++ b/src/c/mexDijkstra/mexDijkstra.cpp @@ -1,25 +1,25 @@ -//*********************************************************************** -// -// Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter -// -// This file is part of LEVer - the tool for stem cell lineaging. See -// https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -// -// LEVer is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// LEVer is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with LEVer in file "gnu gpl v3.txt". If not, see -// <http://www.gnu.org/licenses/>. -// -// -//*********************************************************************** + +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ #include "mexDijkstra.h" #include "CSparseWrapper.h" diff --git a/src/c/mexDijkstra/mexDijkstra.h b/src/c/mexDijkstra/mexDijkstra.h index 8a49d79f83da3d78c37d15963dd0ac5f3b920b63..8078f56e9063edb0a87a24a7b6dc3106556a69a0 100644 --- a/src/c/mexDijkstra/mexDijkstra.h +++ b/src/c/mexDijkstra/mexDijkstra.h @@ -1,25 +1,27 @@ -//*********************************************************************** -// -// Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter -// -// This file is part of LEVer - the tool for stem cell lineaging. See -// https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -// -// LEVer is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// LEVer is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with LEVer in file "gnu gpl v3.txt". If not, see -// <http://www.gnu.org/licenses/>. -// -// -//*********************************************************************** + + +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ + #include "mex.h" diff --git a/src/c/mexGraph.sln b/src/c/mexGraph.sln index 7da86f7f084f18eefff9c8be9264cfbc5f6d5bd2..e2bd3c1adc3a806d54d2ef0bbba1b0450b8fef59 100644 --- a/src/c/mexGraph.sln +++ b/src/c/mexGraph.sln @@ -1,22 +1,18 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.24720.0 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mexGraph", "mexGraph.vcxproj", "{4E22BB6D-1C4B-441D-9436-81224FA01AC3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Debug|Win32.ActiveCfg = Debug|Win32 - {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Debug|Win32.Build.0 = Debug|Win32 {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Debug|x64.ActiveCfg = Debug|x64 {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Debug|x64.Build.0 = Debug|x64 - {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Release|Win32.ActiveCfg = Release|Win32 - {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Release|Win32.Build.0 = Release|Win32 {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Release|x64.ActiveCfg = Release|x64 {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Release|x64.Build.0 = Release|x64 EndGlobalSection diff --git a/src/c/mexGraph.vcxproj b/src/c/mexGraph.vcxproj index 4f7c69925a0bc21a4d34f5324efa8cbad41d88ad..d69692c7772be852f6a14be0ad125d81e4bbe578 100644 --- a/src/c/mexGraph.vcxproj +++ b/src/c/mexGraph.vcxproj @@ -1,18 +1,10 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|Win32"> - <Configuration>Debug</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> <ProjectConfiguration Include="Debug|x64"> <Configuration>Debug</Configuration> <Platform>x64</Platform> </ProjectConfiguration> - <ProjectConfiguration Include="Release|Win32"> - <Configuration>Release</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> <ProjectConfiguration Include="Release|x64"> <Configuration>Release</Configuration> <Platform>x64</Platform> @@ -35,33 +27,20 @@ <Keyword>Win32Proj</Keyword> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <CharacterSet>Unicode</CharacterSet> - <WholeProgramOptimization>true</WholeProgramOptimization> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <WholeProgramOptimization>true</WholeProgramOptimization> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> @@ -71,56 +50,16 @@ <PropertyGroup Label="UserMacros" /> <PropertyGroup> <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(ProjectName)\$(Configuration)_$(Platform)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectName)\Intermediate\$(Configuration)_$(Platform)\</IntDir> - <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental> - <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</PostBuildEventUseInBuild> <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(ProjectName)\$(Configuration)_$(Platform)\</OutDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectName)\Intermediate\$(Configuration)_$(Platform)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental> <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</PostBuildEventUseInBuild> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(ProjectName)\$(Configuration)_$(Platform)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectName)\Intermediate\$(Configuration)_$(Platform)\</IntDir> - <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> - <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</PostBuildEventUseInBuild> <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(ProjectName)\$(Configuration)_$(Platform)\</OutDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectName)\Intermediate\$(Configuration)_$(Platform)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental> <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</PostBuildEventUseInBuild> - <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.mexw32</TargetExt> <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.mexw64</TargetExt> </PropertyGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <ClCompile> - <Optimization>Disabled</Optimization> - <AdditionalIncludeDirectories>$(MATLAB_DIR)\extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MEXMAT_EXPORTS;MATLAB_MEX_FILE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <PreprocessToFile>false</PreprocessToFile> - <PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers> - <MinimalRebuild>true</MinimalRebuild> - <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> - <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> - <PrecompiledHeader> - </PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <DebugInformationFormat>EditAndContinue</DebugInformationFormat> - </ClCompile> - <Link> - <AdditionalDependencies>libmx.lib;libmex.lib;libmat.lib;%(AdditionalDependencies)</AdditionalDependencies> - <OutputFile>$(OutDir)..\..\..\MATLAB\$(ProjectName).mexw32</OutputFile> - <AdditionalLibraryDirectories>$(MATLAB_DIR)\extern\lib\win32\microsoft;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> - <ModuleDefinitionFile>mexGraph/mexGraph.def</ModuleDefinitionFile> - <GenerateDebugInformation>true</GenerateDebugInformation> - <SubSystem>Windows</SubSystem> - <TargetMachine>MachineX86</TargetMachine> - </Link> - <PostBuildEvent> - <Message>Copy pdb and mex files to bin and MATLAB directories</Message> - <Command>copy "$(OutDir)$(ProjectName).dll" "..\MATLAB\$(ProjectName).mexw32" -copy "$(OutDir)$(ProjectName).pdb" ..\MATLAB -</Command> - </PostBuildEvent> - </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <Midl> <TargetEnvironment>X64</TargetEnvironment> @@ -152,37 +91,6 @@ copy "$(OutDir)$(ProjectName).pdb" ..\MATLAB <Message>Copy pdb and mex files to bin and MATLAB directories</Message> <Command>copy "$(OutDir)$(ProjectName).dll" "..\MATLAB\$(ProjectName).mexw64" copy "$(OutDir)$(ProjectName).pdb" ..\MATLAB -</Command> - </PostBuildEvent> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <ClCompile> - <Optimization>MaxSpeed</Optimization> - <IntrinsicFunctions>true</IntrinsicFunctions> - <AdditionalIncludeDirectories>$(MATLAB_DIR)\extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MEXMAT_EXPORTS;MATLAB_MEX_FILE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <RuntimeLibrary>MultiThreaded</RuntimeLibrary> - <FunctionLevelLinking>true</FunctionLevelLinking> - <PrecompiledHeader> - </PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> - </ClCompile> - <Link> - <AdditionalDependencies>libmx.lib;libmex.lib;libmat.lib;%(AdditionalDependencies)</AdditionalDependencies> - <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile> - <AdditionalLibraryDirectories>$(MATLAB_DIR)\extern\lib\win32\microsoft;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> - <ModuleDefinitionFile>mexGraph/mexGraph.def</ModuleDefinitionFile> - <GenerateDebugInformation>true</GenerateDebugInformation> - <SubSystem>Windows</SubSystem> - <OptimizeReferences>true</OptimizeReferences> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <TargetMachine>MachineX86</TargetMachine> - </Link> - <PostBuildEvent> - <Message>Copy pdb and mex files to bin and MATLAB directories</Message> - <Command>copy "$(OutDir)$(ProjectName).dll" "..\MATLAB\$(ProjectName).mexw32" -copy "$(OutDir)$(ProjectName).pdb" ..\MATLAB </Command> </PostBuildEvent> </ItemDefinitionGroup> @@ -223,4 +131,4 @@ copy "$(OutDir)$(ProjectName).pdb" ..\MATLAB <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> -</Project> +</Project> \ No newline at end of file diff --git a/src/c/mexGraph/CSparseWrapper.cpp b/src/c/mexGraph/CSparseWrapper.cpp index 2b004c22bab9a28fab4700821b94c24f4a2fd3d7..914d04a0c624987e485e2fe9f90b60fbd965d6c7 100644 --- a/src/c/mexGraph/CSparseWrapper.cpp +++ b/src/c/mexGraph/CSparseWrapper.cpp @@ -1,6 +1,30 @@ + +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ #include "mexGraph.h" #include "CSparseWrapper.h" +#include <algorithm> + const double CSparseGraph::noEdge = std::numeric_limits<double>::infinity(); CSparseGraph::CSparseGraph(mwSize numHulls) diff --git a/src/c/mexGraph/CSparseWrapper.h b/src/c/mexGraph/CSparseWrapper.h index 1d7155e81cb01556bf87c4e5fd4111237c5297c3..9a7e95e44f931c95d90f1d40179394909217756d 100644 --- a/src/c/mexGraph/CSparseWrapper.h +++ b/src/c/mexGraph/CSparseWrapper.h @@ -1,3 +1,27 @@ + + +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ + #ifndef CSPARSEWRAPPER_H #define CSPARSEWRAPPER_H 1 diff --git a/src/c/mexGraph/mexGraph.cpp b/src/c/mexGraph/mexGraph.cpp index 224d811edc99821c3db9fd757a6f558babc7e3aa..f21eb373a57003afb56376c4baa5ac3171fb15d3 100644 --- a/src/c/mexGraph/mexGraph.cpp +++ b/src/c/mexGraph/mexGraph.cpp @@ -1,25 +1,25 @@ -//*********************************************************************** -// -// Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter -// -// This file is part of LEVer - the tool for stem cell lineaging. See -// https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -// -// LEVer is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// LEVer is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with LEVer in file "gnu gpl v3.txt". If not, see -// <http://www.gnu.org/licenses/>. -// -// -//*********************************************************************** + +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ #include "mexGraph.h" #include "CSparseWrapper.h" diff --git a/src/c/mexGraph/mexGraph.h b/src/c/mexGraph/mexGraph.h index 8a49d79f83da3d78c37d15963dd0ac5f3b920b63..8078f56e9063edb0a87a24a7b6dc3106556a69a0 100644 --- a/src/c/mexGraph/mexGraph.h +++ b/src/c/mexGraph/mexGraph.h @@ -1,25 +1,27 @@ -//*********************************************************************** -// -// Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter -// -// This file is part of LEVer - the tool for stem cell lineaging. See -// https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -// -// LEVer is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// LEVer is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with LEVer in file "gnu gpl v3.txt". If not, see -// <http://www.gnu.org/licenses/>. -// -// -//*********************************************************************** + + +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ + #include "mex.h" diff --git a/src/c/mexHashData.sln b/src/c/mexHashData.sln index 1dd7e359245f6e3d645f21b7a507fb7c6609972b..2633b50fa44218c5aaeaf22a5ec7eecee0355054 100644 --- a/src/c/mexHashData.sln +++ b/src/c/mexHashData.sln @@ -1,22 +1,18 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.24720.0 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mexHashData", "mexHashData.vcxproj", "{4E22BB6D-1C4B-441D-9436-81224FA01AC3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Debug|Win32.ActiveCfg = Debug|Win32 - {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Debug|Win32.Build.0 = Debug|Win32 {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Debug|x64.ActiveCfg = Debug|x64 {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Debug|x64.Build.0 = Debug|x64 - {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Release|Win32.ActiveCfg = Release|Win32 - {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Release|Win32.Build.0 = Release|Win32 {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Release|x64.ActiveCfg = Release|x64 {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Release|x64.Build.0 = Release|x64 EndGlobalSection diff --git a/src/c/mexHashData.vcxproj b/src/c/mexHashData.vcxproj index 4805b70138c8fec7922232bf011dfe37c742224f..fb809dfa22a49b4ab94b8752f51d7b4aae02a5ee 100644 --- a/src/c/mexHashData.vcxproj +++ b/src/c/mexHashData.vcxproj @@ -1,18 +1,10 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|Win32"> - <Configuration>Debug</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> <ProjectConfiguration Include="Debug|x64"> <Configuration>Debug</Configuration> <Platform>x64</Platform> </ProjectConfiguration> - <ProjectConfiguration Include="Release|Win32"> - <Configuration>Release</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> <ProjectConfiguration Include="Release|x64"> <Configuration>Release</Configuration> <Platform>x64</Platform> @@ -35,33 +27,20 @@ <Keyword>Win32Proj</Keyword> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <CharacterSet>Unicode</CharacterSet> - <WholeProgramOptimization>true</WholeProgramOptimization> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <WholeProgramOptimization>true</WholeProgramOptimization> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> @@ -71,56 +50,16 @@ <PropertyGroup Label="UserMacros" /> <PropertyGroup> <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(ProjectName)\$(Configuration)_$(Platform)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectName)\Intermediate\$(Configuration)_$(Platform)\</IntDir> - <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental> - <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</PostBuildEventUseInBuild> <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(ProjectName)\$(Configuration)_$(Platform)\</OutDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectName)\Intermediate\$(Configuration)_$(Platform)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental> <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</PostBuildEventUseInBuild> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(ProjectName)\$(Configuration)_$(Platform)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectName)\Intermediate\$(Configuration)_$(Platform)\</IntDir> - <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> - <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</PostBuildEventUseInBuild> <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(ProjectName)\$(Configuration)_$(Platform)\</OutDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectName)\Intermediate\$(Configuration)_$(Platform)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental> <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</PostBuildEventUseInBuild> - <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.mexw32</TargetExt> <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.mexw64</TargetExt> </PropertyGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <ClCompile> - <Optimization>Disabled</Optimization> - <AdditionalIncludeDirectories>$(MATLAB_DIR)\extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MEXMAT_EXPORTS;MATLAB_MEX_FILE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <PreprocessToFile>false</PreprocessToFile> - <PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers> - <MinimalRebuild>true</MinimalRebuild> - <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> - <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> - <PrecompiledHeader> - </PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <DebugInformationFormat>EditAndContinue</DebugInformationFormat> - </ClCompile> - <Link> - <AdditionalDependencies>libmx.lib;libmex.lib;libmat.lib;%(AdditionalDependencies)</AdditionalDependencies> - <OutputFile>$(OutDir)..\..\..\MATLAB\$(ProjectName).mexw32</OutputFile> - <AdditionalLibraryDirectories>$(MATLAB_DIR)\extern\lib\win32\microsoft;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> - <ModuleDefinitionFile>mexDijkstra/mexDijkstra.def</ModuleDefinitionFile> - <GenerateDebugInformation>true</GenerateDebugInformation> - <SubSystem>Windows</SubSystem> - <TargetMachine>MachineX86</TargetMachine> - </Link> - <PostBuildEvent> - <Message>Copy pdb and mex files to bin and MATLAB directories</Message> - <Command>copy "$(OutDir)$(ProjectName).dll" "..\MATLAB\$(ProjectName).mexw32" -copy "$(OutDir)$(ProjectName).pdb" ..\MATLAB -</Command> - </PostBuildEvent> - </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <Midl> <TargetEnvironment>X64</TargetEnvironment> @@ -152,37 +91,6 @@ copy "$(OutDir)$(ProjectName).pdb" ..\MATLAB <Message>Copy pdb and mex files to bin and MATLAB directories</Message> <Command>copy "$(OutDir)$(ProjectName).dll" "..\MATLAB\$(ProjectName).mexw64" copy "$(OutDir)$(ProjectName).pdb" ..\MATLAB -</Command> - </PostBuildEvent> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <ClCompile> - <Optimization>MaxSpeed</Optimization> - <IntrinsicFunctions>true</IntrinsicFunctions> - <AdditionalIncludeDirectories>$(MATLAB_DIR)\extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MEXMAT_EXPORTS;MATLAB_MEX_FILE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <RuntimeLibrary>MultiThreaded</RuntimeLibrary> - <FunctionLevelLinking>true</FunctionLevelLinking> - <PrecompiledHeader> - </PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> - </ClCompile> - <Link> - <AdditionalDependencies>libmx.lib;libmex.lib;libmat.lib;%(AdditionalDependencies)</AdditionalDependencies> - <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile> - <AdditionalLibraryDirectories>$(MATLAB_DIR)\extern\lib\win32\microsoft;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> - <ModuleDefinitionFile>mexDijkstra/mexDijkstra.def</ModuleDefinitionFile> - <GenerateDebugInformation>true</GenerateDebugInformation> - <SubSystem>Windows</SubSystem> - <OptimizeReferences>true</OptimizeReferences> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <TargetMachine>MachineX86</TargetMachine> - </Link> - <PostBuildEvent> - <Message>Copy pdb and mex files to bin and MATLAB directories</Message> - <Command>copy "$(OutDir)$(ProjectName).dll" "..\MATLAB\$(ProjectName).mexw32" -copy "$(OutDir)$(ProjectName).pdb" ..\MATLAB </Command> </PostBuildEvent> </ItemDefinitionGroup> @@ -223,4 +131,4 @@ copy "$(OutDir)$(ProjectName).pdb" ..\MATLAB <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> -</Project> +</Project> \ No newline at end of file diff --git a/src/c/mexHashData/mexHashData.cpp b/src/c/mexHashData/mexHashData.cpp index 1bd6d9a30a4425f976f1c85251e394ad8b852af5..35d03862bd11a582bd3b22a84d95c010b3036c12 100644 --- a/src/c/mexHashData/mexHashData.cpp +++ b/src/c/mexHashData/mexHashData.cpp @@ -1,26 +1,24 @@ -//*********************************************************************** -// -// Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter -// -// This file is part of LEVer - the tool for stem cell lineaging. See -// https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -// -// LEVer is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// LEVer is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with LEVer in file "gnu gpl v3.txt". If not, see -// <http://www.gnu.org/licenses/>. -// -// -//*********************************************************************** - +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ #include "mexHashData.h" #include <string.h> diff --git a/src/c/mexHashData/mexHashData.h b/src/c/mexHashData/mexHashData.h index fe4c84ac73fb581625fc9b175b3f502de1cbb738..2c17449e563b490f5704f49b862b492889fdf9f3 100644 --- a/src/c/mexHashData/mexHashData.h +++ b/src/c/mexHashData/mexHashData.h @@ -1,26 +1,24 @@ -//*********************************************************************** -// -// Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter -// -// This file is part of LEVer - the tool for stem cell lineaging. See -// https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -// -// LEVer is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// LEVer is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with LEVer in file "gnu gpl v3.txt". If not, see -// <http://www.gnu.org/licenses/>. -// -// -//*********************************************************************** - +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ #include "mex.h" extern "C" diff --git a/src/c/mexIntegrityCheck.sln b/src/c/mexIntegrityCheck.sln index f6aad26503df382a18f1c9a8e84ce993e7db42c0..e532320714f0db8ae869e38b0a91e2a3270ed6c8 100644 --- a/src/c/mexIntegrityCheck.sln +++ b/src/c/mexIntegrityCheck.sln @@ -1,22 +1,18 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.24720.0 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mexIntegrityCheck", "mexIntegrityCheck.vcxproj", "{4E22BB6D-1C4B-441D-9436-81224FA01AC3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Debug|Win32.ActiveCfg = Debug|Win32 - {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Debug|Win32.Build.0 = Debug|Win32 {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Debug|x64.ActiveCfg = Debug|x64 {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Debug|x64.Build.0 = Debug|x64 - {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Release|Win32.ActiveCfg = Release|Win32 - {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Release|Win32.Build.0 = Release|Win32 {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Release|x64.ActiveCfg = Release|x64 {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Release|x64.Build.0 = Release|x64 EndGlobalSection diff --git a/src/c/mexIntegrityCheck.vcxproj b/src/c/mexIntegrityCheck.vcxproj index ea5e3577189e0c97c6dba77951cb3d9ebab627a0..aec2705b63f208cc70abd6c8b0191c963c9f05b0 100644 --- a/src/c/mexIntegrityCheck.vcxproj +++ b/src/c/mexIntegrityCheck.vcxproj @@ -1,18 +1,10 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|Win32"> - <Configuration>Debug</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> <ProjectConfiguration Include="Debug|x64"> <Configuration>Debug</Configuration> <Platform>x64</Platform> </ProjectConfiguration> - <ProjectConfiguration Include="Release|Win32"> - <Configuration>Release</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> <ProjectConfiguration Include="Release|x64"> <Configuration>Release</Configuration> <Platform>x64</Platform> @@ -33,33 +25,20 @@ <Keyword>Win32Proj</Keyword> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <CharacterSet>Unicode</CharacterSet> - <WholeProgramOptimization>true</WholeProgramOptimization> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <WholeProgramOptimization>true</WholeProgramOptimization> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> @@ -69,56 +48,16 @@ <PropertyGroup Label="UserMacros" /> <PropertyGroup> <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(ProjectName)\$(Configuration)_$(Platform)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectName)\Intermediate\$(Configuration)_$(Platform)\</IntDir> - <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental> - <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</PostBuildEventUseInBuild> <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(ProjectName)\$(Configuration)_$(Platform)\</OutDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectName)\Intermediate\$(Configuration)_$(Platform)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental> <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</PostBuildEventUseInBuild> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(ProjectName)\$(Configuration)_$(Platform)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectName)\Intermediate\$(Configuration)_$(Platform)\</IntDir> - <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> - <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</PostBuildEventUseInBuild> <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(ProjectName)\$(Configuration)_$(Platform)\</OutDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectName)\Intermediate\$(Configuration)_$(Platform)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental> <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</PostBuildEventUseInBuild> - <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.mexw32</TargetExt> <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.mexw64</TargetExt> </PropertyGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <ClCompile> - <Optimization>Disabled</Optimization> - <AdditionalIncludeDirectories>$(MATLAB_DIR)\extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MEXMAT_EXPORTS;MATLAB_MEX_FILE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <PreprocessToFile>false</PreprocessToFile> - <PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers> - <MinimalRebuild>true</MinimalRebuild> - <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> - <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> - <PrecompiledHeader> - </PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <DebugInformationFormat>EditAndContinue</DebugInformationFormat> - </ClCompile> - <Link> - <AdditionalDependencies>libmx.lib;libmex.lib;libmat.lib;%(AdditionalDependencies)</AdditionalDependencies> - <OutputFile>$(OutDir)..\..\..\MATLAB\$(ProjectName).mexw32</OutputFile> - <AdditionalLibraryDirectories>$(MATLAB_DIR)\extern\lib\win32\microsoft;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> - <ModuleDefinitionFile>mexDijkstra/mexDijkstra.def</ModuleDefinitionFile> - <GenerateDebugInformation>true</GenerateDebugInformation> - <SubSystem>Windows</SubSystem> - <TargetMachine>MachineX86</TargetMachine> - </Link> - <PostBuildEvent> - <Message>Copy pdb and mex files to bin and MATLAB directories</Message> - <Command>copy "$(OutDir)$(ProjectName).dll" "..\MATLAB\$(ProjectName).mexw32" -copy "$(OutDir)$(ProjectName).pdb" ..\MATLAB -</Command> - </PostBuildEvent> - </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <Midl> <TargetEnvironment>X64</TargetEnvironment> @@ -150,37 +89,6 @@ copy "$(OutDir)$(ProjectName).pdb" ..\MATLAB <Message>Copy pdb and mex files to bin and MATLAB directories</Message> <Command>copy "$(OutDir)$(ProjectName).dll" "..\MATLAB\$(ProjectName).mexw64" copy "$(OutDir)$(ProjectName).pdb" ..\MATLAB -</Command> - </PostBuildEvent> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <ClCompile> - <Optimization>MaxSpeed</Optimization> - <IntrinsicFunctions>true</IntrinsicFunctions> - <AdditionalIncludeDirectories>$(MATLAB_DIR)\extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MEXMAT_EXPORTS;MATLAB_MEX_FILE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <RuntimeLibrary>MultiThreaded</RuntimeLibrary> - <FunctionLevelLinking>true</FunctionLevelLinking> - <PrecompiledHeader> - </PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> - </ClCompile> - <Link> - <AdditionalDependencies>libmx.lib;libmex.lib;libmat.lib;%(AdditionalDependencies)</AdditionalDependencies> - <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile> - <AdditionalLibraryDirectories>$(MATLAB_DIR)\extern\lib\win32\microsoft;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> - <ModuleDefinitionFile>mexDijkstra/mexDijkstra.def</ModuleDefinitionFile> - <GenerateDebugInformation>true</GenerateDebugInformation> - <SubSystem>Windows</SubSystem> - <OptimizeReferences>true</OptimizeReferences> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <TargetMachine>MachineX86</TargetMachine> - </Link> - <PostBuildEvent> - <Message>Copy pdb and mex files to bin and MATLAB directories</Message> - <Command>copy "$(OutDir)$(ProjectName).dll" "..\MATLAB\$(ProjectName).mexw32" -copy "$(OutDir)$(ProjectName).pdb" ..\MATLAB </Command> </PostBuildEvent> </ItemDefinitionGroup> @@ -221,4 +129,4 @@ copy "$(OutDir)$(ProjectName).pdb" ..\MATLAB <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> -</Project> +</Project> \ No newline at end of file diff --git a/src/c/mexIntegrityCheck/mexIntegrityCheck.cpp b/src/c/mexIntegrityCheck/mexIntegrityCheck.cpp index 5e580d14b679120b21982146c5e23b929ce1e1d2..8274011096ed6ffc3f2626e5d2801c7bbb6f9fd7 100644 --- a/src/c/mexIntegrityCheck/mexIntegrityCheck.cpp +++ b/src/c/mexIntegrityCheck/mexIntegrityCheck.cpp @@ -1,26 +1,24 @@ -//*********************************************************************** -// -// Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter -// -// This file is part of LEVer - the tool for stem cell lineaging. See -// https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -// -// LEVer is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// LEVer is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with LEVer in file "gnu gpl v3.txt". If not, see -// <http://www.gnu.org/licenses/>. -// -// -//*********************************************************************** - +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ #include "mexIntegrityCheck.h" #include <vector> diff --git a/src/c/mexIntegrityCheck/mexIntegrityCheck.h b/src/c/mexIntegrityCheck/mexIntegrityCheck.h index 8a49d79f83da3d78c37d15963dd0ac5f3b920b63..c4d0801b12d186c028537fa31315f184ee313c13 100644 --- a/src/c/mexIntegrityCheck/mexIntegrityCheck.h +++ b/src/c/mexIntegrityCheck/mexIntegrityCheck.h @@ -1,26 +1,24 @@ -//*********************************************************************** -// -// Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter -// -// This file is part of LEVer - the tool for stem cell lineaging. See -// https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -// -// LEVer is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// LEVer is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with LEVer in file "gnu gpl v3.txt". If not, see -// <http://www.gnu.org/licenses/>. -// -// -//*********************************************************************** - +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ #include "mex.h" #ifdef MEXMAT_EXPORTS diff --git a/src/c/mexMAT.sln b/src/c/mexMAT.sln index 19927e4bc14e51d45a4a72832ec0ca387bbdf7fb..7065e7f6002ed6a94ae5d06da23304d802848cbc 100644 --- a/src/c/mexMAT.sln +++ b/src/c/mexMAT.sln @@ -1,22 +1,18 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.24720.0 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mexMAT", "mexMAT.vcxproj", "{4E22BB6D-1C4B-441D-9436-81224FA01AC3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Debug|Win32.ActiveCfg = Debug|Win32 - {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Debug|Win32.Build.0 = Debug|Win32 {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Debug|x64.ActiveCfg = Debug|x64 {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Debug|x64.Build.0 = Debug|x64 - {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Release|Win32.ActiveCfg = Release|Win32 - {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Release|Win32.Build.0 = Release|Win32 {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Release|x64.ActiveCfg = Release|x64 {4E22BB6D-1C4B-441D-9436-81224FA01AC3}.Release|x64.Build.0 = Release|x64 EndGlobalSection diff --git a/src/c/mexMAT.vcxproj b/src/c/mexMAT.vcxproj index 4dff8fd476dd972c8cffe6cbe99f68cf67575bef..ef20f881aee85854a877593e23b330c2f8f1c696 100644 --- a/src/c/mexMAT.vcxproj +++ b/src/c/mexMAT.vcxproj @@ -1,18 +1,10 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|Win32"> - <Configuration>Debug</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> <ProjectConfiguration Include="Debug|x64"> <Configuration>Debug</Configuration> <Platform>x64</Platform> </ProjectConfiguration> - <ProjectConfiguration Include="Release|Win32"> - <Configuration>Release</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> <ProjectConfiguration Include="Release|x64"> <Configuration>Release</Configuration> <Platform>x64</Platform> @@ -24,33 +16,20 @@ <Keyword>Win32Proj</Keyword> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <CharacterSet>Unicode</CharacterSet> - <WholeProgramOptimization>true</WholeProgramOptimization> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <WholeProgramOptimization>true</WholeProgramOptimization> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> @@ -60,56 +39,16 @@ <PropertyGroup Label="UserMacros" /> <PropertyGroup> <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(ProjectName)\$(Configuration)_$(Platform)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectName)\Intermediate\$(Configuration)_$(Platform)\</IntDir> - <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental> - <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</PostBuildEventUseInBuild> <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(ProjectName)\$(Configuration)_$(Platform)\</OutDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectName)\Intermediate\$(Configuration)_$(Platform)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental> <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</PostBuildEventUseInBuild> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(ProjectName)\$(Configuration)_$(Platform)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectName)\Intermediate\$(Configuration)_$(Platform)\</IntDir> - <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> - <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</PostBuildEventUseInBuild> <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(ProjectName)\$(Configuration)_$(Platform)\</OutDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectName)\Intermediate\$(Configuration)_$(Platform)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental> <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</PostBuildEventUseInBuild> - <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.mexw32</TargetExt> <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.mexw64</TargetExt> </PropertyGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <ClCompile> - <Optimization>Disabled</Optimization> - <AdditionalIncludeDirectories>$(MATLAB_DIR)\extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MEXMAT_EXPORTS;MATLAB_MEX_FILE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <PreprocessToFile>false</PreprocessToFile> - <PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers> - <MinimalRebuild>true</MinimalRebuild> - <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> - <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> - <PrecompiledHeader> - </PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <DebugInformationFormat>EditAndContinue</DebugInformationFormat> - </ClCompile> - <Link> - <AdditionalDependencies>libmx.lib;libmex.lib;libmat.lib;%(AdditionalDependencies)</AdditionalDependencies> - <OutputFile>$(OutDir)..\..\..\MATLAB\$(ProjectName).mexw32</OutputFile> - <AdditionalLibraryDirectories>$(MATLAB_DIR)\extern\lib\win32\microsoft;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> - <ModuleDefinitionFile>mexMAT/mexMAT.def</ModuleDefinitionFile> - <GenerateDebugInformation>true</GenerateDebugInformation> - <SubSystem>Windows</SubSystem> - <TargetMachine>MachineX86</TargetMachine> - </Link> - <PostBuildEvent> - <Message>Copy pdb and mex files to bin and MATLAB directories</Message> - <Command>copy "$(OutDir)$(ProjectName).dll" "..\MATLAB\$(ProjectName).mexw32" -copy "$(OutDir)$(ProjectName).pdb" ..\MATLAB -</Command> - </PostBuildEvent> - </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <Midl> <TargetEnvironment>X64</TargetEnvironment> @@ -141,37 +80,6 @@ copy "$(OutDir)$(ProjectName).pdb" ..\MATLAB <Message>Copy pdb and mex files to bin and MATLAB directories</Message> <Command>copy "$(OutDir)$(ProjectName).dll" "..\MATLAB\$(ProjectName).mexw64" copy "$(OutDir)$(ProjectName).pdb" ..\MATLAB -</Command> - </PostBuildEvent> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <ClCompile> - <Optimization>MaxSpeed</Optimization> - <IntrinsicFunctions>true</IntrinsicFunctions> - <AdditionalIncludeDirectories>$(MATLAB_DIR)\extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MEXMAT_EXPORTS;MATLAB_MEX_FILE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <RuntimeLibrary>MultiThreaded</RuntimeLibrary> - <FunctionLevelLinking>true</FunctionLevelLinking> - <PrecompiledHeader> - </PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> - </ClCompile> - <Link> - <AdditionalDependencies>libmx.lib;libmex.lib;libmat.lib;%(AdditionalDependencies)</AdditionalDependencies> - <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile> - <AdditionalLibraryDirectories>$(MATLAB_DIR)\extern\lib\win32\microsoft;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> - <ModuleDefinitionFile>mexMAT/mexMAT.def</ModuleDefinitionFile> - <GenerateDebugInformation>true</GenerateDebugInformation> - <SubSystem>Windows</SubSystem> - <OptimizeReferences>true</OptimizeReferences> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <TargetMachine>MachineX86</TargetMachine> - </Link> - <PostBuildEvent> - <Message>Copy pdb and mex files to bin and MATLAB directories</Message> - <Command>copy "$(OutDir)$(ProjectName).dll" "..\MATLAB\$(ProjectName).mexw32" -copy "$(OutDir)$(ProjectName).pdb" ..\MATLAB </Command> </PostBuildEvent> </ItemDefinitionGroup> @@ -226,4 +134,4 @@ copy "$(OutDir)$(ProjectName).pdb" ..\MATLAB <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> -</Project> +</Project> \ No newline at end of file diff --git a/src/c/mexMAT/CEdgeSubgraph.h b/src/c/mexMAT/CEdgeSubgraph.h index d94c9fa8f5f8c3be0fec4a089839bd44773f8ad9..90e932fba9d728dd50cc03895570c5c756bf1857 100644 --- a/src/c/mexMAT/CEdgeSubgraph.h +++ b/src/c/mexMAT/CEdgeSubgraph.h @@ -1,26 +1,24 @@ -//*********************************************************************** -// -// Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter -// -// This file is part of LEVer - the tool for stem cell lineaging. See -// https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -// -// LEVer is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// LEVer is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with LEVer in file "gnu gpl v3.txt". If not, see -// <http://www.gnu.org/licenses/>. -// -// -//*********************************************************************** - +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ #ifndef _CEDGESUBGRAPH_H_ #define _CEDGESUBGRAPH_H_ 1 diff --git a/src/c/mexMAT/bestPaths.cpp b/src/c/mexMAT/bestPaths.cpp index 2b4761ba0d9eba8f4b2df6193cf69c38e2fde1ec..c07b999c6cd86a5b3d94c9003f628f3cf795b7db 100644 --- a/src/c/mexMAT/bestPaths.cpp +++ b/src/c/mexMAT/bestPaths.cpp @@ -1,28 +1,28 @@ -//*********************************************************************** -// -// Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter -// -// This file is part of LEVer - the tool for stem cell lineaging. See -// https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -// -// LEVer is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// LEVer is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with LEVer in file "gnu gpl v3.txt". If not, see -// <http://www.gnu.org/licenses/>. -// -// -//*********************************************************************** - +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ #include "mexMAT.h" +#include <algorithm> + std::vector<CSourcePath> gTrackHistory; // Find all trackIDs from source hullIDs diff --git a/src/c/mexMAT/bestPaths.h b/src/c/mexMAT/bestPaths.h index a533913a64bc0842b88dfb78ecf801e52471c3ee..66175761fd6bef548c49cd574f610ade6968cbe3 100644 --- a/src/c/mexMAT/bestPaths.h +++ b/src/c/mexMAT/bestPaths.h @@ -1,26 +1,24 @@ -//*********************************************************************** -// -// Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter -// -// This file is part of LEVer - the tool for stem cell lineaging. See -// https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -// -// LEVer is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// LEVer is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with LEVer in file "gnu gpl v3.txt". If not, see -// <http://www.gnu.org/licenses/>. -// -// -//*********************************************************************** - +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ // Double limits convenience definition typedef std::numeric_limits<double> DoubleLims; diff --git a/src/c/mexMAT/cost.cpp b/src/c/mexMAT/cost.cpp index 258e1af551274c4f3e8c419009a60056f5c3a397..f88b65ca9cdb83156ce9dc788ff820623c8e9443 100644 --- a/src/c/mexMAT/cost.cpp +++ b/src/c/mexMAT/cost.cpp @@ -1,28 +1,27 @@ -//*********************************************************************** -// -// Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter -// -// This file is part of LEVer - the tool for stem cell lineaging. See -// https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -// -// LEVer is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// LEVer is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with LEVer in file "gnu gpl v3.txt". If not, see -// <http://www.gnu.org/licenses/>. -// -// -//*********************************************************************** - +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ #include "mexMAT.h" +#include <algorithm> #include <math.h> #undef max diff --git a/src/c/mexMAT/cost.h b/src/c/mexMAT/cost.h index f4ddf675b920bd359d6daf28045636491497c0be..030cc5ccafbe389f3f95ccbbfa6c7afd39c0da4c 100644 --- a/src/c/mexMAT/cost.h +++ b/src/c/mexMAT/cost.h @@ -1,26 +1,24 @@ -//*********************************************************************** -// -// Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter -// -// This file is part of LEVer - the tool for stem cell lineaging. See -// https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -// -// LEVer is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// LEVer is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with LEVer in file "gnu gpl v3.txt". If not, see -// <http://www.gnu.org/licenses/>. -// -// -//*********************************************************************** - +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ // Get cost based on a frame and index list. The srcFrameIdx is used if there, it is the index into // path vector of the source point(start of new path). srcFrameIdx is trivially 0 if there is diff --git a/src/c/mexMAT/mexMAT.cpp b/src/c/mexMAT/mexMAT.cpp index 66d3cd9903cc6857e0b7fba864f9a303c91da69a..c626847af52944879699c8a35799f7b182bf6b31 100644 --- a/src/c/mexMAT/mexMAT.cpp +++ b/src/c/mexMAT/mexMAT.cpp @@ -1,26 +1,24 @@ -//*********************************************************************** -// -// Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter -// -// This file is part of LEVer - the tool for stem cell lineaging. See -// https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -// -// LEVer is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// LEVer is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with LEVer in file "gnu gpl v3.txt". If not, see -// <http://www.gnu.org/licenses/>. -// -// -//*********************************************************************** - +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ #include "mexMAT.h" #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) diff --git a/src/c/mexMAT/mexMAT.h b/src/c/mexMAT/mexMAT.h index f9d16074327471ac2bc6cf493a1dc461de982874..b432707ab1b589e7f2557d7d27dd68fc5ed6dde1 100644 --- a/src/c/mexMAT/mexMAT.h +++ b/src/c/mexMAT/mexMAT.h @@ -1,26 +1,24 @@ -//*********************************************************************** -// -// Copyright 2011 Andrew Cohen, Eric Wait and Mark Winter -// -// This file is part of LEVer - the tool for stem cell lineaging. See -// https://pantherfile.uwm.edu/cohena/www/LEVer.html for details -// -// LEVer is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// LEVer is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with LEVer in file "gnu gpl v3.txt". If not, see -// <http://www.gnu.org/licenses/>. -// -// -//*********************************************************************** - +/*********************************************************************** +* Copyright 2011-2016 Andrew Cohen +* +* This file is part of LEVer - the tool for stem cell lineaging. See +* http://n2t.net/ark:/87918/d9rp4t for details +* +* LEVer is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* LEVer is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with LEVer in file "gnu gpl v3.txt". If not, see +* <http://www.gnu.org/licenses/>. +* +***********************************************************************/ #include "mex.h" #include <map>