Skip to content

Commit

Permalink
Merge pull request #82 from bahanonu/bahanonu/functionUpdates
Browse files Browse the repository at this point in the history
Updated to MIT license, move functions into ciapkg package, gramm graphics, detrend support, speed improvements, and more
  • Loading branch information
bahanonu authored Jul 26, 2021
2 parents 6170323 + 328941d commit ae9632b
Show file tree
Hide file tree
Showing 58 changed files with 507 additions and 819 deletions.
6 changes: 3 additions & 3 deletions +ciapkg/+demo/cmdLinePipeline.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
nwbFileFolderPath = [analysisFolderPath filesep 'nwbFiles'];

% Load CIAtah functions
loadBatchFxns();
ciapkg.loadBatchFxns();

% =================================================
%% Download test data, only a single session
Expand Down Expand Up @@ -166,7 +166,7 @@
% =================================================
%% Run EXTRACT cell extraction. Check each function with "edit" for options.
% Load default configuration
loadBatchFxns('loadEverything');
ciapkg.loadBatchFxns('loadEverything');
extractConfig = get_defaults([]);

% See https://github.com/schnitzer-lab/EXTRACT-public#configurations.
Expand Down Expand Up @@ -196,7 +196,7 @@
end

% Remove EXTRACT from the path.
loadBatchFxns();
ciapkg.loadBatchFxns();

% =================================================
%% USER INTERFACE Run cell sorting using matrix outputs from cell extraction.
Expand Down
2 changes: 1 addition & 1 deletion +ciapkg/+download/updatePathCleanup.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

% Remove references to MEX files
clear mex
loadBatchFxns('excludeExternalPrograms');
ciapkg.loadBatchFxns('excludeExternalPrograms');

pathCell = regexp(path, pathsep, 'split');
if verLessThan('matlab','9.1')
Expand Down
17 changes: 14 additions & 3 deletions +ciapkg/+io/loadDependencies.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@ function loadDependencies(varargin)
% 2021.06.19 [23:46:58] - Switched to support for original MIJ calling of ImageJ using just jar files, easier compatibility across MATLAB versions and OSes.
% 2021.06.21 [16:45:59] - Update order.
% 2021.07.13 [08:34:18] - Added backup URL for downloading mij.jar.
% 2021.07.23 [00:22:22] - Added gramm (https://github.com/piermorel/gramm) support/downloading for graphics plotting.
% TODO
% Verify all dependencies download and if not ask user to download again.

%========================
% DESCRIPTION
options.externalProgramsDir = ciapkg.getDirExternalPrograms();
options.guiEnabled = 1;
options.dependencyStr = {'downloadImageJ','downloadCnmfGithubRepositories','example_downloadTestData','downloadNeuroDataWithoutBorders','downloadEXTRACT','downloadBioFormats','downloadNoRMCorre','downloadMiji','loadMiji'};
options.dependencyStr = {'downloadImageJ','downloadCnmfGithubRepositories','example_downloadTestData','downloadNeuroDataWithoutBorders','downloadEXTRACT','downloadBioFormats','downloadGramm','downloadNoRMCorre','downloadMiji','loadMiji'};

options.dispStr = {'Download ImageJ','Download CNMF, CNMF-E, and CVX code.','Download test one- and two photon datasets.','Download NWB (NeuroDataWithoutBorders)','Download EXTRACT','Download Bio-Formats','Download NoRMCorre (motion correction)','Download Fiji (to run Miji)','Load Fiji/Miji into MATLAB path.'};
options.dispStr = {'Download ImageJ','Download CNMF, CNMF-E, and CVX code.','Download test one- and two photon datasets.','Download NWB (NeuroDataWithoutBorders)','Download EXTRACT','Download Bio-Formats','Download gramm (GRAMmar of graphics for Matlab, e.g. ggplot2-like)','Download NoRMCorre (motion correction)','Download Fiji (to run Miji)','Load Fiji/Miji into MATLAB path.'};
% Int vector: index of options.dependencyStr to run by default with no GUI
options.depIdxArray = [1 2 3 4 5 6];
options.depIdxArray = [1 2 3 4 5 6 7];
% Binary: 1 = force update even if already downloaded. 0 = skip if already downloaded
options.forceUpdate = 0;
% get options
Expand Down Expand Up @@ -109,6 +110,16 @@ function loadDependencies(varargin)
% optionsH.gitName = cellfun(@(x) [x '-master'],optionsH.gitNameDisp,'UniformOutput',false);
optionsH.gitName = {'NoRMCorre-public-master'};
[success] = downloadGithubRepositories('options',optionsH);
case 'downloadGramm'
optionsH.forceUpdate = forceUpdate;
optionsH.signalExtractionDir = options.externalProgramsDir;
optionsH.gitNameDisp = {'gramm'};
optionsH.gitRepos = {'https://github.com/piermorel/gramm'};
optionsH.gitRepos = cellfun(@(x) [x '/archive/master.zip'],optionsH.gitRepos,'UniformOutput',false);
optionsH.outputDir = optionsH.gitNameDisp;
% optionsH.gitName = cellfun(@(x) [x '-master'],optionsH.gitNameDisp,'UniformOutput',false);
optionsH.gitName = {'gramm-master'};
[success] = downloadGithubRepositories('options',optionsH);
case 'downloadEXTRACT'
optionsH.forceUpdate = forceUpdate;
optionsH.signalExtractionDir = options.externalProgramsDir;
Expand Down
4 changes: 2 additions & 2 deletions +ciapkg/+io/updatePkg.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@
verInfoStr = sprintf('%s\n Local version: %s (%s).\n Online version %s (%s).\n',verInfoStr2,currentVersion,currentDateTimeStr,onlineVersionTmp,onlineDateTimeStr);
warning(verInfoStr)
if verCompare<1
msgbox(verInfoStr,'Note on CIAtah version.')
ciapkg.overloaded.msgbox(verInfoStr,'Note on CIAtah version.')
end
success = 1;
return
end

disp(verInfoStr)
if options.showGui==1
uiwait(msgbox(verInfoStr));
uiwait(ciapkg.overloaded.msgbox(verInfoStr));
end

% If the user is behind, ask if they want to update then initiate download and update from online repository
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions +ciapkg/VERSION
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
v3.33.0
2021.07.13 [13:22:16]
v3.35.1
2021.07.25 [14:22:59]
2 changes: 1 addition & 1 deletion +ciapkg/loadAllDirs.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function loadAllDirs()
%========================

try
loadBatchFxns('loadEverything');
ciapkg.loadBatchFxns('loadEverything');
catch err
disp(repmat('@',1,7))
disp(getReport(err,'extended','hyperlinks','on'));
Expand Down
44 changes: 33 additions & 11 deletions loadBatchFxns.m → +ciapkg/loadBatchFxns.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ function loadBatchFxns(varargin)
% 2020.07.21 [14:11:42] - Fix to make sure all sub-folders (not just the root) are also removed in the case of certain external_programs.
% 2021.02.01 [‏‎15:19:40] - Update `_external_programs` to call ciapkg.getDirExternalPrograms() to standardize call across all functions.
% 2021.06.20 [00:22:38] - Added manageMiji('startStop','closeAllWindows'); support.
% 2021.07.16 [13:38:55] - Remove redundant loading and unloading of external programs via additional checks.
% 2021.07.22 [19:51:50] - Moved loadBatchFxns into ciapkg package. Use ciapkg.getDir to get directory as standard IO.
% TODO
%

Expand All @@ -30,10 +32,14 @@ function loadBatchFxns(varargin)

externalProgramsDir = ciapkg.getDirExternalPrograms();

removeDirFxnToFind = {'runCELLMax.m','extractor.m','normcorre.m'};
% 'cellmax.runCELLMax', 'CELLMax_Wrapper.m'

% Add calciumImagingAnalysis directory and subdirectories to path, use dbstack to ensure only add in the root directory regardless of where user has current MATLAB folder.
functionLocation = dbstack('-completenames');
functionLocation = functionLocation(1).file;
[functionDir,~,~] = fileparts(functionLocation);
% functionLocation = dbstack('-completenames');
% functionLocation = functionLocation(1).file;
% [functionDir,~,~] = fileparts(functionLocation);
functionDir = ciapkg.getDir;
pathList = genpath(functionDir);
% pathList = genpath(pwd);
pathListArray = strsplit(pathList,pathsep);
Expand Down Expand Up @@ -66,8 +72,16 @@ function loadBatchFxns(varargin)
pathListArray = pathListArray(~pathFilter);
pathFilter = ismember(pathListArray,strsplit(path,pathsep));
pathListArray = pathListArray(~pathFilter);

% If going to remove directories in removeDirFxnToFind then do so now to prevent redundant calls to addpath, etc.
if isempty(varargin)
[pathListArray] = subfxnRemoveDirs(0,pathListArray);
end

skipRemovePath = 0;
if isempty(pathListArray)
fprintf('MATALB path already has all needed non-private folders under: %s\n',functionDir);
skipRemovePath = 1;
else
fprintf('Adding all non-private folders under: %s\n',functionDir);
pathList = strjoin(pathListArray,pathsep);
Expand All @@ -84,7 +98,9 @@ function loadBatchFxns(varargin)
matchIdx2 = contains(pathListArray,externalProgramsDir);
pathListArray = pathListArray(~matchIdx2);
else
pathListArray = subfxnRemoveDirs(1,pathListArrayOriginal);
if skipRemovePath==0
pathListArray = subfxnRemoveDirs(1,pathListArrayOriginal);
end
end

% =================================================
Expand Down Expand Up @@ -203,23 +219,27 @@ function loadBatchFxns(varargin)
% =================================================
% List of functions in root of external program directories that should not be included by default.
try
fxnRootFolder = {'CELLMax_Wrapper.m','cellmax.runCELLMax','extractor.m','normcorre.m'};
fxnRootFolder = removeDirFxnToFind;
pathToRmCell = {};
for iNo = 1:length(fxnRootFolder)
thisFxn = fxnRootFolder{iNo};
if rmPathFlag==1
[pathToRm,~,~] = fileparts(which(thisFxn));
else
extDir = dir([functionDir filesep externalProgramsDir]);
% extDir = dir([functionDir filesep externalProgramsDir]);
extDir = dir([externalProgramsDir]);
extDir = extDir([extDir.isdir]);
if length(extDir)<3
disp('No external programs!')
return;
end
extDir = extDir(3:end);

foundFiles = dir(fullfile([functionDir filesep externalProgramsDir], ['**\' thisFxn '']));
pathToRm = foundFiles.folder;
foundFiles = dir(fullfile([externalProgramsDir], ['**\' thisFxn '']));
if isempty(foundFiles)
pathToRm = [];
else
pathToRm = foundFiles.folder;
end
end
if ~isempty(pathToRm)
if strcmp(thisFxn,'CELLMax_Wrapper.m')|strcmp(thisFxn,'cellmax.runCELLMax')
Expand All @@ -246,8 +266,10 @@ function loadBatchFxns(varargin)
end
end

%
rmpath(strjoin(pathToRmCell,pathsep));
% Only remove path if user requests
if rmPathFlag==1
rmpath(strjoin(pathToRmCell,pathsep));
end
catch err
disp(repmat('@',1,7))
disp(getReport(err,'extended','hyperlinks','on'));
Expand Down
2 changes: 1 addition & 1 deletion +ciapkg/loadDirs.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function loadDirs()
%========================

try
loadBatchFxns;
ciapkg.loadBatchFxns;
catch err
disp(repmat('@',1,7))
disp(getReport(err,'extended','hyperlinks','on'));
Expand Down
6 changes: 4 additions & 2 deletions startup.m → +ciapkg/startup.m
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
% Startup commands and graphics defaults
% Biafra Ahanonu
% started: 2013.12.07 [17:28:44]
% changelog
% 2021.07.22 [19:55:49] - loadBatchFxns to ciapkg.loadBatchFxns.

% If using startup, then restore default path before running
% If using startup, then restore default path before running startup operations.
restoredefaultpath

% Load all needed ciapkg directories
loadBatchFxns('skipLoadMiji');
ciapkg.loadBatchFxns('skipLoadMiji');

% set default figure properties
setFigureDefaults();
Expand Down
Loading

0 comments on commit ae9632b

Please sign in to comment.