Skip to content

Commit

Permalink
Merge pull request #106 from bahanonu/bahanonu/functionUpdates
Browse files Browse the repository at this point in the history
Update README and misc CIAtah methods
  • Loading branch information
bahanonu authored Jun 28, 2022
2 parents a2001ed + 052b718 commit 53b424b
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 15 deletions.
10 changes: 8 additions & 2 deletions +ciapkg/+download/downloadCnmfGithubRepositories.m
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions +ciapkg/VERSION
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
v4.2.0
2022.03.01 [04:18:22]
v4.4.2
2022.06.27 [13:51:31]
11 changes: 6 additions & 5 deletions @ciatah/initializeObj.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
%

Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions @ciatah/modelExtractSignalsFromMovie.m
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
%

Expand Down Expand Up @@ -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
Expand Down
15 changes: 11 additions & 4 deletions @ciatah/modelSaveMatchObjBtwnTrials.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
%

Expand All @@ -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 <strong>alignmentStruct</strong> variable and fieldname <strong>alignmentStruct.globalIDs</strong>.')
disp('See additional details at <a href="https://bahanonu.github.io/ciatah/pipeline_detailed_cross_session/#output-of-computematchobjbtwntrials">https://bahanonu.github.io/ciatah/pipeline_detailed_cross_session/#output-of-computematchobjbtwntrials</a>.')
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: <strong>%s</strong>.\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'));
Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<ins> __Book chapter__ </ins> — 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).

<ins>__Webinar__</ins> — 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.

<ins>__Workshop tutorial__</ins> — This recording gives an overview of setting up and using CIAtah: https://www.youtube.com/watch?v=I6abW3uuJJw.
Expand Down Expand Up @@ -66,6 +69,7 @@ Made in USA.<br>
- 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.);
<!-- - Pre-processing supports read-from-disk based analysis for movies that are too large to fit into RAM. -->
- support for multiple cell-extraction methods (CELLMax, PCA-ICA, <a href='https://github.com/flatironinstitute/CaImAn-MATLAB' target='_blank'>CNMF</a>, CNMF-E, <a href='https://github.com/schnitzer-lab/EXTRACT-public' target='_blank'>EXTRACT</a>, etc.);
- manual classification of cells via GUIs;
- automated cell classification (i.e. CLEAN algorithm, coming soon!);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.

<!--
Expand Down Expand Up @@ -274,4 +297,6 @@ This project is licensed under the terms of the MIT license. See LICENSE file fo
## Repository stats
- ![visitors](https://visitor-badge.glitch.me/badge?page_id=bahanonu.calciumImagingAnalysis) (starting 2020.09.22)
- ![Hits](https://hitcounter.pythonanywhere.com/count/tag.svg?url=https%3A%2F%2Fgithub.com%2Fbahanonu%2FcalciumImagingAnalysis) (starting 2020.09.16)
- ![visitors](https://page-views.glitch.me/badge?page_id=bahanonu.ciatah) (starting 2022.03.02, backup)
- ![visitors](https://visitor-badge.deta.dev/badge?page_id=bahanonu.ciatah&left_color=gray&right_color=red) (starting 2022.03.02, backup)
<!-- - [![HitCount](http://hits.dwyl.com/bahanonu/calciumImagingAnalysis.svg)](http://hits.dwyl.com/bahanonu/calciumImagingAnalysis) (starting 2020.08.16), frozen til `dwyl` migrates to new server. -->

0 comments on commit 53b424b

Please sign in to comment.