-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from bahanonu/bahanonu/functionUpdates
Adding ciapkg API sub-package, improved directory management, etc.
- Loading branch information
Showing
38 changed files
with
914 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# CIAtah API | ||
|
||
Biafra Ahanonu | ||
|
||
All functions in the `ciapkg.api` package are just pass-through functions to the actual underlying functions. This allows users to import all CIAtah functions into their function or script with `import ciapkg.api.*` as opposed to having to do that for each `ciapkg` sub-package. | ||
|
||
Else, users can call nearly all CIAtah functions using `ciapkg.api.[Function Name]`, which allows easier namespacing. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
function [outputMovie, movieDims, nPixels, nFrames] = loadMovieList(movieList, varargin) | ||
% Load movies, automatically detects type (avi, tif, or hdf5) and concatenates if multiple movies in a list. | ||
% NOTE: | ||
% The function assumes input is 2D time series movies with [x y frames] as dimensions | ||
% If movies are different sizes, use largest dimensions and align all movies to top-left corner. | ||
% Biafra Ahanonu | ||
% started: 2013.11.01 | ||
|
||
[outputMovie, movieDims, nPixels, nFrames] = loadMovieList(movieList, 'passArgs', varargin); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function [success] = manageParallelWorkers(varargin) | ||
% Manages loading and stopping parallel processing workers. | ||
% Biafra Ahanonu | ||
% started: 2015.12.01 | ||
|
||
[success] = manageParallelWorkers('passArgs', varargin); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function [exitSignal, ostruct] = playMovie(inputMovie, varargin) | ||
[exitSignal, ostruct] = playMovie(inputMovie,'passArgs', varargin); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
function loadDependencies(varargin) | ||
% Download and load CIAtah dependencies. | ||
% Biafra Ahanonu | ||
% started: 2014.07.31 | ||
% 2021.02.01 [15:09:46] branched from CIAtah | ||
% branch from calciumImagingAnalysis 2020.05.07 [15:47:29] | ||
% inputs | ||
% | ||
% outputs | ||
% | ||
|
||
% changelog | ||
% 2020.05.12 [17:40:37] - Updated to enable GUI-less loading of dependencies. In particular for easier unit testing. | ||
% 2020.06.28 [14:25:04] - Added ability for users to force update. | ||
% 2021.01.22 [13:42:36] - NWB from specific release to reduce compatibility errors. | ||
% 2021.02.01 [15:10:41] - Separated into non-class function for use in more functions without needing to load CIAtah class. | ||
% 2021.02.01 [15:19:40] - Update `_external_programs` to call ciapkg.getDirExternalPrograms() to standardize call across all functions. | ||
% TODO | ||
% Verify all dependencies download and if not ask user to download again. | ||
|
||
%======================== | ||
% DESCRIPTION | ||
options.externalProgramsDir = ciapkg.getDirExternalPrograms(); | ||
options.guiEnabled = 1; | ||
options.dependencyStr = {'downloadMiji','downloadCnmfGithubRepositories','example_downloadTestData','loadMiji','downloadNeuroDataWithoutBorders'}; | ||
|
||
options.dispStr = {'Download Fiji (to run Miji)','Download CNMF, CNMF-E, and CVX code.','Download test one- and two photon datasets.','Load Fiji/Miji into MATLAB path.','Download NWB (NeuroDataWithoutBorders)'}; | ||
% Int vector: index of options.dependencyStr to run by default with no GUI | ||
options.depIdxArray = [1 2 3 5]; | ||
% Binary: 1 = force update even if already downloaded. 0 = skip if already downloaded | ||
options.forceUpdate = 0; | ||
% get options | ||
options = getOptions(options,varargin); | ||
% display(options) | ||
% unpack options into current workspace | ||
% fn=fieldnames(options); | ||
% for i=1:length(fn) | ||
% eval([fn{i} '=options.' fn{i} ';']); | ||
% end | ||
%======================== | ||
|
||
scnsize = get(0,'ScreenSize'); | ||
if ischar(options.dispStr) | ||
options.dispStr = {options.dispStr}; | ||
end | ||
if ischar(options.dependencyStr) | ||
options.dependencyStr = {options.dependencyStr}; | ||
end | ||
dependencyStr = options.dependencyStr; | ||
|
||
dispStr = options.dispStr; | ||
if options.guiEnabled==1 | ||
[depIdxArray, ~] = listdlg('ListString',dispStr,'ListSize',[scnsize(3)*0.3 scnsize(4)*0.3],'Name','Which dependencies to load? (Can select multiple)','InitialValue',options.depIdxArray); | ||
|
||
forceDownloadVec = [0 1]; | ||
[forceUpdate, ~] = listdlg('ListString',{'No - skip installing dependency if already available.','Yes - force update to most recent version of dependency.'},'ListSize',[scnsize(3)*0.3 scnsize(4)*0.3],'Name','Force download/update? (e.g. "Yes" to update dependencies)','InitialValue',[1]); | ||
forceUpdate = forceDownloadVec(forceUpdate); | ||
else | ||
depIdxArray = options.depIdxArray; | ||
forceUpdate = 0; | ||
end | ||
analysisTypeD = dependencyStr(depIdxArray); | ||
dispStr = dispStr(depIdxArray); | ||
for depNo = 1:length(depIdxArray) | ||
disp([10 repmat('>',1,42)]) | ||
disp(dispStr{depNo}) | ||
switch analysisTypeD{depNo} | ||
case 'downloadCnmfGithubRepositories' | ||
[success] = downloadCnmfGithubRepositories('forceUpdate',forceUpdate); | ||
case 'downloadMiji' | ||
depStr = {'Save Fiji to default directory','Save Fiji to custom directory'}; | ||
if options.guiEnabled==1 | ||
[depIdxArray, ~] = listdlg('ListString',depStr,'ListSize',[scnsize(3)*0.2 scnsize(4)*0.25],'Name','Where to save Fiji?'); | ||
else | ||
depIdxArray = 1; | ||
end | ||
depStr = depStr{depIdxArray}; | ||
if depIdxArray==1 | ||
downloadMiji(); | ||
else | ||
downloadMiji('defaultDir',''); | ||
end | ||
% if exist('pathtoMiji','var') | ||
% end | ||
case 'loadMiji' | ||
modelAddOutsideDependencies('miji'); | ||
case 'example_downloadTestData' | ||
example_downloadTestData(); | ||
case 'downloadCellExtraction' | ||
optionsH.forceUpdate = forceUpdate; | ||
optionsH.signalExtractionDir = options.externalProgramsDir; | ||
optionsH.gitNameDisp = {'cellmax_clean','extract'}; | ||
optionsH.gitRepos = {'https://github.com/schnitzer-lab/CELLMax_CLEAN','https://github.com/schnitzer-lab/EXTRACT'}; | ||
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); | ||
[success] = downloadGithubRepositories('options',optionsH); | ||
case 'downloadNeuroDataWithoutBorders' | ||
optionsH.forceUpdate = forceUpdate; | ||
optionsH.signalExtractionDir = options.externalProgramsDir; | ||
optionsH.gitNameDisp = {'nwb_schnitzer_lab','yamlmatlab','matnwb'}; | ||
optionsH.gitRepos = {'https://github.com/schnitzer-lab/nwb_schnitzer_lab','https://github.com/ewiger/yamlmatlab'}; | ||
|
||
% 'https://github.com/NeurodataWithoutBorders/matnwb' | ||
optionsH.gitRepos = cellfun(@(x) [x '/archive/master.zip'],optionsH.gitRepos,'UniformOutput',false); | ||
optionsH.gitRepos = [optionsH.gitRepos 'https://github.com/NeurodataWithoutBorders/matnwb/archive/v2.2.5.3.zip']; | ||
optionsH.outputDir = optionsH.gitNameDisp; | ||
optionsH.gitName = cellfun(@(x) [x '-master'],optionsH.gitNameDisp,'UniformOutput',false); | ||
optionsH.gitName{end} = 'matnwb-2.2.5.3'; | ||
[success] = downloadGithubRepositories('options',optionsH); | ||
|
||
% Add NWB folders to path. | ||
ciapkg.nwb.setupNwb; | ||
% obj.loadBatchFunctionFolders; | ||
otherwise | ||
% nothing | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
function [externalProgramsDir] = getDirExternalPrograms(varargin) | ||
% Returns the directory where external programs are stored. All functions should call this to find external program directory. | ||
% Biafra Ahanonu | ||
% started: 2021.02.02 [10:55:23] | ||
% inputs | ||
% | ||
% outputs | ||
% | ||
|
||
% changelog | ||
% | ||
% TODO | ||
% | ||
|
||
%======================== | ||
% DESCRIPTION | ||
% options.exampleOption = ''; | ||
% get options | ||
% options = getOptions(options,varargin); | ||
% display(options) | ||
% unpack options into current workspace | ||
% fn=fieldnames(options); | ||
% for i=1:length(fn) | ||
% eval([fn{i} '=options.' fn{i} ';']); | ||
% end | ||
%======================== | ||
|
||
try | ||
externalProgramsDir = [ciapkg.getDir() filesep '_external_programs']; | ||
catch err | ||
disp(repmat('@',1,7)) | ||
disp(getReport(err,'extended','hyperlinks','on')); | ||
disp(repmat('@',1,7)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
function [ciapkgDir] = getDirPkg(dirType,varargin) | ||
% Standardized location to obtain relevant CIAtah directories, e.g. location of default data folder. | ||
% Biafra Ahanonu | ||
% started: 2020.08.31 [12:46:57] | ||
% inputs | ||
% | ||
% outputs | ||
% | ||
|
||
% changelog | ||
% | ||
% TODO | ||
% | ||
|
||
%======================== | ||
% DESCRIPTION | ||
% options.exampleOption = ''; | ||
% get options | ||
% options = getOptions(options,varargin); | ||
% display(options) | ||
% unpack options into current workspace | ||
% fn=fieldnames(options); | ||
% for i=1:length(fn) | ||
% eval([fn{i} '=options.' fn{i} ';']); | ||
% end | ||
%======================== | ||
|
||
try | ||
switch dirType | ||
case 'data' | ||
ciapkgDir = [ciapkg.getDir() filesep 'data']; | ||
otherwise | ||
ciapkgDir = ''; | ||
disp('Incorrect input, returning null.') | ||
end | ||
catch err | ||
disp(repmat('@',1,7)) | ||
disp(getReport(err,'extended','hyperlinks','on')); | ||
disp(repmat('@',1,7)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.