From 9f4b48c1f8b5ee9d13813294a93c744cc214010b Mon Sep 17 00:00:00 2001 From: Biafra Ahanonu Date: Mon, 27 Jun 2022 13:45:29 -0700 Subject: [PATCH 1/5] Update README and initializeObj - `README` - update to include pain imaging book chapter information. - `initializeObj` - Ensure all save paths (pics, data, log, settings, video, etc.) use absolute CIAtah private directory to match CIAtah default properties initialization and to avoid instances where users have non-CIAtah root path working directory. --- @ciatah/initializeObj.m | 11 ++++++----- README.md | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/@ciatah/initializeObj.m b/@ciatah/initializeObj.m index b288487..f43bf4a 100644 --- a/@ciatah/initializeObj.m +++ b/@ciatah/initializeObj.m @@ -11,6 +11,7 @@ % 2020.06.05 [11:29:24] - Improved toolbox check. % 2021.08.10 [09:57:36] - Updated to handle CIAtah v4.0 switch to all functions inside ciapkg package. % 2021.11.16 [11:13:07] - Wrap calls to diverging_map to avoid potential ciatah initialization errors on macOS. + % 2022.06.27 [12:48:22] - Ensure all save paths (pics, data, log, settings, video, etc.) use absolute CIAtah private directory to match CIAtah default properties initialization and to avoid instances where users have non-CIAtah root path working directory. % TODO % @@ -47,11 +48,11 @@ disp(repmat('*',1,42)) % Ensure date paths are up to date - obj.picsSavePath = ['private' filesep 'pics' filesep datestr(now,'yyyymmdd','local') filesep]; - obj.dataSavePath = ['private' filesep 'data' filesep datestr(now,'yyyymmdd','local') filesep]; - obj.logSavePath = ['private' filesep 'logs' filesep datestr(now,'yyyymmdd','local') filesep]; - obj.settingsSavePath = ['private' filesep 'settings']; - obj.videoSaveDir = ['private' filesep 'vids' filesep datestr(now,'yyyymmdd','local') filesep]; + obj.picsSavePath = [ciapkg.getDir() filesep 'private' filesep 'pics' filesep datestr(now,'yyyymmdd','local') filesep]; + obj.dataSavePath = [ciapkg.getDir() filesep 'private' filesep 'data' filesep datestr(now,'yyyymmdd','local') filesep]; + obj.logSavePath = [ciapkg.getDir() filesep 'private' filesep 'logs' filesep datestr(now,'yyyymmdd','local') filesep]; + obj.settingsSavePath = [ciapkg.getDir() filesep 'private' filesep 'settings']; + obj.videoSaveDir = [ciapkg.getDir() filesep 'private' filesep 'vids' filesep datestr(now,'yyyymmdd','local') filesep]; % ensure private folders are set if ~exist(obj.picsSavePath,'dir');mkdir(obj.picsSavePath);fprintf('Creating directory: %s\n',obj.picsSavePath);end diff --git a/README.md b/README.md index b1d33c1..5fcdce6 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,9 @@ Below are recordings and additional documents for users who want to learn more about calcium imaging analysis/experiments and the CIAtah pipeline. + __Book chapter__ — We have a book chapter that goes over all steps of miniscope imaging: viral injections, GRIN lens probe implant, pain experimental design, data processing and neural/behavioral analysis, and more. +- See [Ahanonu, B., Corder, G. (2022). _Recording Pain-Related Brain Activity in Behaving Animals Using Calcium Imaging and Miniature Microscopes_](https://doi.org/10.1007/978-1-0716-2039-7_13) (https://doi.org/10.1007/978-1-0716-2039-7_13). + __Webinar__ — This webinar gives an overview of calcium imaging analysis (with a focus on CIAtah) along with tips for improving experiments and analysis: https://info.inscopix.com/inscopix-inspire-view-webinarbiafra-ahanonu-signal-in-the-noise-distinguishing-relevant-neural-activity-in-calcium-imaging. __Workshop tutorial__ — This recording gives an overview of setting up and using CIAtah: https://www.youtube.com/watch?v=I6abW3uuJJw. @@ -66,6 +69,7 @@ Made in USA.
- Includes all major calcium imaging analysis steps: - Movie visualization (including reading from disk, for fast viewing of large movies); - pre-processing (motion correction, spatiotemporal downsampling, spatial filtering, relative fluorescence calculation, etc.); + - support for multiple cell-extraction methods (CELLMax, PCA-ICA, CNMF, CNMF-E, EXTRACT, etc.); - manual classification of cells via GUIs; - automated cell classification (i.e. CLEAN algorithm, coming soon!); @@ -161,6 +165,12 @@ ciapkg.io.matlabToolboxCheck(); ### Setup `CIAtah` +- Download and install `CIAtah` dependencies. These will all be located in the `_external_programs` sub-folder within the CIAtah main code directory. + +```MATLAB +ciapkg.io.loadDependencies; +``` + - Run `CIAtah` using the below MATLAB commands. Call `obj;` in the MATLAB command window each time you want to go back to the main GUI. __Note: `calciumImagingAnalysis` class is now called `ciatah`, all functionality is the same.__ ```MATLAB @@ -245,6 +255,19 @@ Please cite [Corder*, Ahanonu*, et al. 2019](http://science.sciencemag.org/conte } ``` +Please cite the [Ahanonu and Corder, 2022](https://doi.org/10.1007/978-1-0716-2039-7_13) book chapter if you used procedures detailed therein. + +```bibtex +@incollection{ahanonu2022recording, + title={Recording Pain-Related Brain Activity in Behaving Animals Using Calcium Imaging and Miniature Microscopes}, + author={Ahanonu, Biafra and Corder, Gregory}, + booktitle={Contemporary Approaches to the Study of Pain}, + pages={217--276}, + year={2022}, + publisher={Springer} +} +``` + Please see https://bahanonu.github.io/ciatah/references/ for additional references depending on processing steps undertaken. \ No newline at end of file From c591b57ac215f7bded23f9f1771cda7ea460b894 Mon Sep 17 00:00:00 2001 From: Biafra Ahanonu Date: Mon, 27 Jun 2022 13:53:43 -0700 Subject: [PATCH 2/5] Update VERSION --- +ciapkg/VERSION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/+ciapkg/VERSION b/+ciapkg/VERSION index 1899238..b78bccc 100644 --- a/+ciapkg/VERSION +++ b/+ciapkg/VERSION @@ -1,2 +1,2 @@ -v4.2.0 -2022.03.01 [04:18:22] \ No newline at end of file +v4.4.2 +2022.06.27 [13:51:31] \ No newline at end of file From c103785cd1232d9c4c9f5744e3188d5b78b0839e Mon Sep 17 00:00:00 2001 From: Biafra Ahanonu Date: Mon, 27 Jun 2022 14:29:49 -0700 Subject: [PATCH 3/5] Update downloadCnmfGithubRepositories.m - `downloadCnmfGithubRepositories` - Download CVX from a custom URL since the main URL sometimes has a long response time, leading to timeouts. --- +ciapkg/+download/downloadCnmfGithubRepositories.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/+ciapkg/+download/downloadCnmfGithubRepositories.m b/+ciapkg/+download/downloadCnmfGithubRepositories.m index 69e12e9..e3c5650 100644 --- a/+ciapkg/+download/downloadCnmfGithubRepositories.m +++ b/+ciapkg/+download/downloadCnmfGithubRepositories.m @@ -6,9 +6,10 @@ % 2020.04.03 [14:02:33] - Save downloaded compressed files (e.g. zips) to a sub-folder. % 2020.06.28 [13:08:16] - Final implementation of force update, to bring to most current version of all git directories. % 2020.06.28 [14:01:17] - Switch to calling downloadGithubRepositories for downloads to prevent bugs introduced by similar code between two functions. - % 2021.02.01 [‏‎15:19:40] - Update `_external_programs` to call ciapkg.getDirExternalPrograms() to standardize call across all functions. + % 2021.02.01 [15:19:40] - Update `_external_programs` to call ciapkg.getDirExternalPrograms() to standardize call across all functions. % 2021.08.08 [19:30:20] - Updated to handle CIAtah v4.0 switch to all functions inside ciapkg package. % 2021.12.01 [20:09:10] - Update display of information if CVX is not automatically found. + % 2022.04.08 [15:37:36] - Download CVX from a custom URL since the main URL sometimes has a long response time, leading to timeouts. import ciapkg.api.* % import CIAtah functions in ciapkg package API. @@ -31,7 +32,12 @@ signalExtractionDir = options.defaultExternalProgramDir; gitNameDisp = {'CNMF-E','CNMF | CaImAn','cvx-rd'}; - gitRepos = {'https://github.com/bahanonu/CNMF_E/archive/master.zip','https://github.com/flatironinstitute/CaImAn-MATLAB/archive/master.zip','http://web.cvxr.com/cvx/cvx-rd.zip'}; + gitRepos = {... + 'https://github.com/bahanonu/CNMF_E/archive/master.zip'; + 'https://github.com/flatironinstitute/CaImAn-MATLAB/archive/master.zip'; + 'http://tiny.ucsf.edu/YR4gfF'; + }; + % 'http://web.cvxr.com/cvx/cvx-rd.zip'; outputDir = {'cnmfe','cnmf_current','cvx_rd'}; gitName = {'CNMF_E-master','CaImAn-MATLAB-master','cvx'}; nRepos = length(outputDir); From b4f883b936bf07d43ac232411ebbff0c2416a3fa Mon Sep 17 00:00:00 2001 From: Biafra Ahanonu Date: Mon, 27 Jun 2022 15:36:07 -0700 Subject: [PATCH 4/5] Update modelExtractSignalsFromMovie.m - `modelExtractSignalsFromMovie` - matlab.desktop.editor.openDocument no longer uses pwd since options.settingsPrivateSaveFolder is based on an absolute path. --- @ciatah/modelExtractSignalsFromMovie.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/@ciatah/modelExtractSignalsFromMovie.m b/@ciatah/modelExtractSignalsFromMovie.m index aca7b5c..ff2784a 100644 --- a/@ciatah/modelExtractSignalsFromMovie.m +++ b/@ciatah/modelExtractSignalsFromMovie.m @@ -20,7 +20,7 @@ % 2019.10.29 [17:21:23] - Added a check to make sure that filenames produced are valid MATLAB ones for settings, e.g. for CNMF-e. % 2019.11.10 [20:34:42] - Add a warning with some common tips for users if error during cell extraction. Skip modelVarsFromFiles and viewObjmaps loading to reduce user confusion for any folders that had issues during cell extraction. % 2020.05.08 [20:01:52] - Make creation of settings an explicit option that the user can change. - % 2021.02.01 [??‎15:19:40] - Update `_external_programs` to call ciapkg.getDirExternalPrograms() to standardize call across all functions. + % 2021.02.01 [15:19:40] - Update `_external_programs` to call ciapkg.getDirExternalPrograms() to standardize call across all functions. % 2021.02.25 [16:44:41] - Update `saveRunTimes` to handle case in which user selects multiple movies for cell extraction. % 2021.03.20 [19:23:25] - Convert ndSparse outputs to single from cell-extraction algorithms (e.g. for CELLMax/EXTRACT) when saving as NWB. Updated EXTRACT support to include additional options. % 2021.04.08 [16:23:20] - Use filesep in getAlgorithmRootPath to avoid issues in Unix-based systems. @@ -29,6 +29,7 @@ % 2021.08.10 [09:57:36] - Updated to handle CIAtah v4.0 switch to all functions inside ciapkg package. % 2021.11.08 [12:42:12] - Add nwbpkg support. % 2021.11.09 [15:29:01] - Updated EXTRACT support. + % 2022.06.27 [15:33:57] - matlab.desktop.editor.openDocument no longer uses pwd since options.settingsPrivateSaveFolder is based on an absolute path. % TODO % @@ -1041,7 +1042,7 @@ function getAlgorithmOptions() end fclose(fileID); - h1 = matlab.desktop.editor.openDocument([pwd filesep newSettings]); + h1 = matlab.desktop.editor.openDocument([newSettings]); disp(['Close "' newFile '.m" file in Editor to continue!']) % pause while user edits while h1.Opened==1;end From 052b718c532ad6cad9532d7605248e6dd39c04e7 Mon Sep 17 00:00:00 2001 From: Biafra Ahanonu Date: Mon, 27 Jun 2022 19:32:24 -0700 Subject: [PATCH 5/5] Update modelSaveMatchObjBtwnTrials.m - `modelSaveMatchObjBtwnTrials` - Remove user selecting folder to save structure to and add additional instructions. --- @ciatah/modelSaveMatchObjBtwnTrials.m | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/@ciatah/modelSaveMatchObjBtwnTrials.m b/@ciatah/modelSaveMatchObjBtwnTrials.m index 801e3c6..fe9a64d 100644 --- a/@ciatah/modelSaveMatchObjBtwnTrials.m +++ b/@ciatah/modelSaveMatchObjBtwnTrials.m @@ -10,6 +10,7 @@ % changelog % 2020.06.29 [19:28:33] - Updated implementation. % 2021.08.10 [09:57:36] - Updated to handle CIAtah v4.0 switch to all functions inside ciapkg package. + % 2022.06.27 [19:25:42] - Remove user selecting folder to save structure to and add additional instructions. % TODO % @@ -29,22 +30,28 @@ %======================== try - disp('Method not implemented!') + % disp('Method not implemented!') - [filePath,folderPath,~] = uiputfile('*.*','select folder to save object mat file to','calciumImagingAnalysis_properties.mat'); + % [filePath,folderPath,~] = uiputfile('*.*','select folder to save object mat file to','calciumImagingAnalysis_properties.mat'); % exit if user picks nothing % if folderListInfo==0; return; end - savePath = [folderPath filesep filePath]; + % savePath = [folderPath filesep filePath]; + disp('Saving MAT-file for each subject (animal) containing structure. Global ID matrix [globalID sessionID] is found in alignmentStruct variable and fieldname alignmentStruct.globalIDs.') + disp('See additional details at https://bahanonu.github.io/ciatah/pipeline_detailed_cross_session/#output-of-computematchobjbtwntrials.') subjList = fieldnames(obj.globalIDStruct); for subjNo = 1:length(subjList) + display(repmat('=',1,7)) thisSubjectStr = subjList{subjNo}; alignmentStruct = obj.globalIDStruct.(thisSubjectStr); - structSavePath = [obj.dataSavePath filesep 'ciapkg_crossSessionAlignment_' thisSubjectStr '_' datestr(now,'yyyymmdd_HHMMSS','local') '.mat']; + fprintf('Saving cross-session alignment for subject/animal: %s.\n',thisSubjectStr); + saveFileName = ['ciapkg_crossSessionAlignment_' thisSubjectStr '_' datestr(now,'yyyymmdd_HHMMSS','local') '.mat']; + structSavePath = fullfile(obj.dataSavePath,saveFileName); fprintf('Saving to: %s\n',structSavePath) save(structSavePath,'alignmentStruct','-v7.3'); end + catch err display(repmat('@',1,7)) disp(getReport(err,'extended','hyperlinks','on'));