bahanonu / ciatah

CIAtah (pronounced cheetah): a software package for calcium imaging analysis of one- and two-photon imaging datasets. Documentation: https://git.io/ciatah_docs. Formerly known as calciumImagingAnalysis (ciapkg).
https://git.io/ciatah_docs
MIT License
80 stars 20 forks source link

Error when trying to view miniscope avi #58

Open hsw28 opened 3 years ago

hsw28 commented 3 years ago

I am trying to view a .avi file created using miniscope software. I am on a mac and have tried in matlab 2016b and 2018b. I keep getting the error:

Error using VideoReader/init (line 619)
Could not read file due to an unexpected error. Reason: Cannot Decode

I am able to open the video in VLC though not in quicktime. I thought perhaps it was an issue with matlab 2018b based on this thread but going down to 2016b also did not work. Any advice? Thanks!

bahanonu commented 3 years ago

Couple question to help narrow down the issue:

It is possible that we can use ffmpeg or another video processing tool to convert your file to compatible codec for mac (assuming loading works fine on Windows/Linux).

hsw28 commented 3 years ago

Ok, I figured that initial problem out which is that I couldn't read that codec on my mac with matlab. So I took the video and converted it into a tiff stack using imageJ, and now I can read the file in matlab.

I am now trying to run preprocessing to remove horizontal lines. I have entered these parameters image

>  MAIN______________: {'====================='}
>                       checkConcurrentAnalysis: 0
>                             resetParallelPool: 0
>                               analyzeFromDisk: 0
>                    calcDroppedFramesFromMovie: []
>                    REGISTRATION______________: {'====================='}
>                                      parallel: 1
>                               registrationFxn: 'transfturboreg'
>                              turboregRotation: 0
>                                     RegisType: 1
>                         numTurboregIterations: 1
>                       turboregNumFramesSubset: 5000
>                                      pxToCrop: 14
>                      motionCorrectionRefFrame: 100
>      REGISTRATION_NORMALIZATION______________: {'====================='}
>                         normalizeMeanSubtract: 1
>                normalizeMeanSubtractNormalize: 1
>                     normalizeComplementMatrix: 1
>                                 normalizeType: 'bandpass'
>                              normalizeFreqLow: 70
>                             normalizeFreqHigh: 100
>                         normalizeBandpassType: 'bandpass'
>                         normalizeBandpassMask: 'gaussian'
>                                       SmoothX: 10
>                                       SmoothY: 10
>                                       zapMean: 0
>             MOVIE_NORMALIZATION______________: {'====================='}
>                          filterBeforeRegister: []
>                      saveBeforeFilterRegister: 0
>                      saveFilterBeforeRegister: []
>                        filterBeforeRegFreqLow: 0
>                       filterBeforeRegFreqHigh: 10
>                 filterBeforeRegImagejFFTLarge: 10000
>                 filterBeforeRegImagejFFTSmall: 80
>                              medianFilterSize: 3
>              MOVIE_DOWNSAMPLING______________: {'====================='}
>                          downsampleFactorTime: 4
>                         downsampleFactorSpace: 2
>     IO_and_MOVIE_IDENTIFICATION______________: {'====================='}
>                              inputDatasetName: [1×0 char]
>                             outputDatasetName: [1×0 char]
>                              fileFilterRegexp: 'testvideo'
>                       processMoviesSeparately: 0
>                        loadMoviesFrameByFrame: 0
>                 treatMoviesAsContinuousSwitch: 1
>                         loadMovieInEqualParts: 0
>                                   useParallel: 1
>                              nParallelWorkers: 7
>                  STRIPE_REMOVAL______________: {'====================='}
>                        stripOrientationRemove: 'horizontal'
>                                     stripSize: 7
>                           stripfreqLowExclude: 20
>                          stripfreqHighExclude: 20
>                         stripfreqBandpassType: 'highpass'
>                                  refCropFrame: 100

When it finished running I got this output:

> 
> Elapsed time is 15.546693 seconds.
> Changing calciumImagingAnalysis input HDF5 dataset name ""->""

Yet even thought I requested a new video be saved as HDF5 I do not have that video anywhere, and when the preview opens to see the video there is no video.

However, if in the parameters I choose "save movie to NWB format" with all other parameters the same, an NWB movie does save in the directory and is available to view in imageJ, although the movie is entirely black.

I am unsure if this is something to do with my parameters or how I am using the software (both the HDF5 problem as well as the video being black with NWB). I can upload the tiff if that would make it easier.

Many thanks

bahanonu commented 3 years ago

Good to hear you solved the codec issue.

Does the raw video appear as expected if you run playMovie('PATH_TO_TIFF');?

If you could send a link to the tiff, I could take a quick look and get back with what the issue might be or any settings that need to be changed.

hsw28 commented 3 years ago

great, thank you!! here is a (temporary) link to the tiff file https://t.co/FvJ25lmDBO?amp=1

hsw28 commented 3 years ago

and yes the raw movie plays

bahanonu commented 3 years ago

Great! Quick question, are the dark stripes in the original video before conversion as well? I've seen this before with data from UCLA miniscopes, can remove to a certain degree using removeStripsFromMovie, see https://bahanonu.github.io/calciumImagingAnalysis/help_stripe_removal/. It's also an option on the 2nd page of modelPreprocessMovie.

image image

hsw28 commented 3 years ago

the stripes are an artifact from one of the focusing lenses on the miniscope. that was what i was attempting to remove but I wasnt successful (see above). am I using the software incorrectly? thanks again!

bahanonu commented 3 years ago

👍 Good to know. Below is some info on running the movie, I've also downsampled 3x in space as that normally speeds up processing without sacrificing downstream analysis when looking at cells, you can skip that step if needed. Can then run cell extraction (would need to do some optimization for this movie, due to stripes) as below. If anything's confusing, let me know and I can look to update the GUI accordingly.

Processed movie

result-1

Settings

image

Cell extraction

image

modelPreprocessMovie settings

options.turboreg:
                           MAIN______________: {'====================='}
                      checkConcurrentAnalysis: 0
                            resetParallelPool: 0
                              analyzeFromDisk: 0
                   calcDroppedFramesFromMovie: []
                   REGISTRATION______________: {'====================='}
                                     parallel: 1
                              registrationFxn: 'transfturboreg'
                             turboregRotation: 0
                                    RegisType: 1
                        numTurboregIterations: 1
                      turboregNumFramesSubset: 5000
                                     pxToCrop: 14
                     motionCorrectionRefFrame: 100
     REGISTRATION_NORMALIZATION______________: {'====================='}
                        normalizeMeanSubtract: 1
               normalizeMeanSubtractNormalize: 1
                    normalizeComplementMatrix: 1
                                normalizeType: 'bandpass'
                             normalizeFreqLow: 70
                            normalizeFreqHigh: 100
                        normalizeBandpassType: 'bandpass'
                        normalizeBandpassMask: 'gaussian'
                                      SmoothX: 10
                                      SmoothY: 10
                                      zapMean: 0
            MOVIE_NORMALIZATION______________: {'====================='}
                         filterBeforeRegister: 'divideByLowpass'
                     saveBeforeFilterRegister: 0
                     saveFilterBeforeRegister: []
                       filterBeforeRegFreqLow: 0
                      filterBeforeRegFreqHigh: 7
                filterBeforeRegImagejFFTLarge: 10000
                filterBeforeRegImagejFFTSmall: 80
                             medianFilterSize: 3
             MOVIE_DOWNSAMPLING______________: {'====================='}
                         downsampleFactorTime: 8
                        downsampleFactorSpace: 3
    IO_and_MOVIE_IDENTIFICATION______________: {'====================='}
                             inputDatasetName: '/1'
                            outputDatasetName: '/1'
                             fileFilterRegexp: 'testmovie'
                      processMoviesSeparately: 0
                       loadMoviesFrameByFrame: 0
                treatMoviesAsContinuousSwitch: 1
                        loadMovieInEqualParts: 0
                                  useParallel: 1
                             nParallelWorkers: 7
                 STRIPE_REMOVAL______________: {'====================='}
                       stripOrientationRemove: 'horizontal'
                                    stripSize: 7
                          stripfreqLowExclude: 20
                         stripfreqHighExclude: 20
                        stripfreqBandpassType: 'highpass'
                                 refCropFrame: 100
hsw28 commented 3 years ago

Ahh that looks awesome!! thank you so much. I am still having some issues that are probably just due to my inaptitude at the program. I attempted to use the same parameters as you did above:

First, I can't seem to get out of this window even with double clicking image

If I remove any of the movement adjustment processing steps it seems to work ok!

I dont have these toolboxes installed (secondary toolboxes), could it be something with them? As I said before probably me just not using the software correctly.

2nd tier toolbox check (not required for main pre-processing pipeline). Warning: Toolbox license available but toolbox is NOT installed. Computer Vision System Toolbox (Video_and_Image_Blockset). Warning: Toolbox license available but toolbox is NOT installed. Financial Toolbox (Financial_Toolbox).

hsw28 commented 3 years ago

and thanks again for all your help!! this has been a good day

bahanonu commented 3 years ago

Sure thing! Regarding that window, you are supposed to double click to move on (just a function of how imrect works in Matlab, may change that to be a button going forward).

Is the image you showed representative of where you've been selecting for cropping to determine motion correction coordinates? What is likely happening (if you send me the _preprocess.log file in the processing_info sub-folder I can confirm) is that coordinates outside the movie are being passed to downstream functions, leading to the motion correction functions to crash. Preferably you'd have a rectangle like below (I'd added a constraint to prevent this from happening in the GUI).

Those toolboxes aren't needed for the pre-processing (but looks like you already have the license, so you could go ahead and install them using the Add-On explorer).

image

bahanonu commented 3 years ago

@hsw28 Got email notification of your message but don't see it here. Could you send me the .log file in the processing_info folder? Will help me debug. Thanks!

hsw28 commented 3 years ago

Sorry, I realized my error right after I posted the message! working through it now :)

hsw28 commented 3 years ago

OK, so everything seems to work if I do a single video, but if I try to do a folder with 18 videos I run into this issue:

> 00
> -------
> pre-allocating single ones matrix...
> @@@@@@@
> Error using ones
> Requested 608x608x17871 (24.6GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information.
> 
> Error in loadMovieList (line 390)
>               outputMovie = ones([xDimMax yDimMax zDimLength],imgClass);
> 
> Error in calciumImagingAnalysis/modelPreprocessMovieFunction (line 628)
>                   thisMovie = loadMovieList(movieList,'convertToDouble',0,'frameList',thisFrameList,'inputDatasetName',options.datasetName,'treatMoviesAsContinuous',options.turboreg.treatMoviesAsContinuousSwitch,'loadSpecificImgClass','single');
> 
> Error in calciumImagingAnalysis/modelPreprocessMovie (line 37)
>   obj.modelPreprocessMovieFunction('folderListPath',folderListInfo,'fileFilterRegexp',options.fileFilterRegexp,'datasetName',options.datasetName,'frameList',[]);
> 
> Error in calciumImagingAnalysis/runPipeline (line 202)
>               obj.(thisFxn{1});
> 
> Error in calciumImagingAnalysis/display (line 817)
>           obj.runPipeline;
> @@@@@@@
> pre-allocating movies to display...
> +++++++
> no movie!
> --------------------------------------------------------------
> MIJ 1.3.6-fiji: Matlab to ImageJ Interface
> --------------------------------------------------------------
> More Info: http://bigwww.epfl.ch/sage/soft/mij/
> Help: MIJ.help
> JVM> 1.3.6-fiji
> JVM> Version: 1.8.0_152
> JVM> Total amount of memory: 246784 Kb
> JVM> Amount of free memory: 108079 Kb
> ImageJ> Version:1.50e
> ImageJ> Memory:144MB of 2325MB (6%)
> ImageJ> Directory plugins: /Users/Hannah/Programming/calciumImagingAnalysis-master/_external_programs/Fiji.app/plugins/
> ImageJ> Directory macros: /Users/Hannah/Programming/calciumImagingAnalysis-master/_external_programs/Fiji.app/macros/
> ImageJ> Directory luts: /Users/Hannah/Programming/calciumImagingAnalysis-master/_external_programs/Fiji.app/luts/
> ImageJ> Directory image: Not specified
> ImageJ> Directory imagej: /Users/Hannah/Programming/calciumImagingAnalysis-master/_external_programs/Fiji.app/
> ImageJ> Directory startup: /Users/Hannah/Programming/calciumImagingAnalysis-master/_external_programs/Fiji.app/
> ImageJ> Directory home: /Users/Hannah/
> --------------------------------------------------------------
> Status> ImageJ is running.
> --------------------------------------------------------------
> Warning: The DrawMode property will be removed in a future release. Use the SortMethod property
> instead. 
> > In msgbox (line 284)
>   In calciumImagingAnalysis/modelPreprocessMovieFunction>playOutputMovies (line 2122)
>   In calciumImagingAnalysis/modelPreprocessMovieFunction (line 984)
>   In calciumImagingAnalysis/modelPreprocessMovie (line 37)
>   In calciumImagingAnalysis/runPipeline (line 202)
>   In calciumImagingAnalysis/display (line 817) 
> +++++++
> no movie!
> ImageJ instance ended cleanly
> 
> ostruct = 
> 
>   struct with fields:
> 
>         folderList: {'/Volumes/VERBATIM/Miniscope/tiff'}
>     savedFilePaths: {[]}
>        fileNumList: {}
> 
> 
> options = 
> 
>   struct with fields:
> 
>                    showFigures: 1
>                 folderListPath: {'/Volumes/VERBATIM/Miniscope/tiff'}
>        checkConcurrentAnalysis: 0
>     concurrentAnalysisFilename: '_currentlyAnalyzingFolderCheck.mat'
>        processMoviesSeparately: 0
>                  processMovies: 1
>            loadOptionsFromFile: 0
>        turboregNumFramesSubset: 5000
>                   turboregType: 'preselect'
>                       turboreg: [1×1 struct]
>                      dfofMovie: 1
>                       dfofType: 'dfof'
>               downsampleFactor: 4
>                       pxToCrop: 14
>               fileFilterRegexp: 'mov'
>                    inputPCAICA: 0
>                    askForPCICs: 0
>                      frameList: []
>                    datasetName: '/1'
>              outputDatasetName: '/1'
>                   refCropFrame: 100
>                   deflateLevel: 1
>                 supportedTypes: {'.h5'  '.hdf5'  '.tif'  '.tiff'  '.avi'  '.isxd'}
>     calcDroppedFramesFromMovie: []
>                     saveMovies: 0
>                  saveDfofMovie: 0
>                  turboregMovie: 1
>                 normalizeMovie: 0
>                downsampleMovie: 1
>                  logFileRegexp: '(recording.*.(txt|xml)|.*_metadata.mat)'
>         nwbSettingsDatasetname: '/general/optophysiology/imaging_plane/description'
> 
> Elapsed time is 5.998427 seconds.
> Changing calciumImagingAnalysis input HDF5 dataset name "/1"->"/1"
> 
> >> 
hsw28 commented 3 years ago

I realize this might just be a pure memory issue. Is there a way to avoid this, such as by down sampling (time and space) extensively before doing any other processing?

hsw28 commented 3 years ago

also what cell extraction method/parameters did you use above? thanks again

hsw28 commented 3 years ago

Also, I am using the same parameters as you are above, on the same video, and my post processing video looks completely different. Here is a gif from it and you can see there is like no contrast or anything remotely like your gif :)

test

bahanonu commented 3 years ago

Yep, you can downsample in advance using several ways below. In the near future this will be seamless (modelPreprocessMovie will read from disk like other parts of ciatah pipeline to get around memory issues).

option 1

Use modelPreprocessMovie, run first using the below parameters then run again on the downsampled movies.

image

Change the settings so it will process each movie separately as below:

image

option 2

Use modelDownsampleRawMovies module before modelPreprocessMovie, see:

option 3

Via the command-line using the below code or see:

thisFileList = getFileList('PATH_TO_FOLDER');
nFiles = length(thisFileList);
for fileNo = 1:nFiles
    thisFilePath = thisFileList{fileNo};

    % Downsample in space
    inputMovieD = downsampleMovie(thisFilePath,'downsampleDimension','space','downsampleFactor',4);

    % Downsample in time
    inputMovieD = downsampleMovie(inputMovieD,'downsampleDimension','time','downsampleFactor',4);

    % Save out as HDF5 file
    [path,file,ext] = fileparts(thisFilePath);
    saveMatrixToFile(inputMovie,[path filesep file '_dsSpaceTime.h5']);
end
hsw28 commented 3 years ago

thank you thank you!! Sorry for all the questions, just want to make sure I thoroughly understand everything if I will be using this for my analysis pipeline. Sorry also that I am cross-talk asking new questions as you answer

bahanonu commented 3 years ago

Also, I am using the same parameters as you are above, on the same video, and my post processing video looks completely different. Here is a gif from it and you can see there is like no contrast or anything remotely like your gif :)

test

Great! If you adjust the contrast in ImageJ or in Matlab (press J in playMovie interface), should look similar to the movie I'd attached :D

bahanonu commented 3 years ago

thank you thank you!! Sorry for all the questions, just want to make sure I thoroughly understand everything if I will be using this for my analysis pipeline. Sorry also that I am cross-talk asking new questions as you answer

No problem! I'll also update the guide to make this more straight forward, as others have emailed/asked me about similar questions.

hsw28 commented 3 years ago

Also, I am using the same parameters as you are above, on the same video, and my post processing video looks completely different. Here is a gif from it and you can see there is like no contrast or anything remotely like your gif :) test

Great! If you adjust the contrast in ImageJ or in Matlab (press J in playMovie interface), should look similar to the movie I'd attached :D

Ah ok!! I thought your gif was unedited after post processing. Got it, thank you!!

bahanonu commented 3 years ago

also what cell extraction method/parameters did you use above? thanks again

The results I showed were from a method (CELLMax) we haven't released yet; I'd have to look in more detail to find parameters that work with PCA-ICA or CNMF(-E) given the stripes caused issues with those methods on first pass. You could try to run PCA-ICA with 100-200 ICs, but will likely get a lot of non-cells/artifacts that you have to manually sort.

hsw28 commented 3 years ago

also what cell extraction method/parameters did you use above? thanks again

The results I showed were from a method (CELLMax) we haven't released yet; I'd have to look in more detail to find parameters that work with PCA-ICA or CNMF(-E) given the stripes caused issues with those methods on first pass. You could try to run PCA-ICA with 100-200 ICs, but will likely get a lot of non-cells/artifacts that you have to manually sort.

great thanks! your results look great but the methods I tried all looked questionable. I await the cellmax method release!

hsw28 commented 3 years ago

Hi, it's me again!! I am trying to do modelExtractSignalsFromMovie and i get this error/output: Is this just because of the type of extraction I am trying to do? thanks for any tips, yet again!

> 
> !!!!!!!!!!!!!!!!!!!!!
> Running: obj.modelExtractSignalsFromMovie
> @@@@@@@
> Error using dir
> Characters adjacent to a ** wildcard must be file separators.
> 
> Error in calciumImagingAnalysis/modelExtractSignalsFromMovie/getAlgorithmRootPath (line 466)
>           foundFiles = dir(fullfile([obj.defaultObjDir filesep obj.externalProgramsDir], ['**\' algorithmFile '']));
> 
> Error in calciumImagingAnalysis/modelExtractSignalsFromMovie (line 85)
>               getAlgorithmRootPath('runCELLMax.m','CELLMax',obj,1);
> 
> Error in calciumImagingAnalysis/runPipeline (line 202)
>               obj.(thisFxn{1});
> 
> Error in calciumImagingAnalysis/display (line 817)
>           obj.runPipeline;
> @@@@@@@
> /Volumes/VERBATIM/Rat1/2020_12_07/19_00_35/Miniscope/processing_info
> Adding folders: /Volumes/VERBATIM/Rat1/2020_12_07/19_00_35/Miniscope/processing_info:
> =====================
> Subject: m000
> ###
> Getting movie info for 1\1: /Volumes/VERBATIM/Rat1/2020_12_07/19_00_35/Miniscope/2020_12_07_p000_m000_NULL000_strpRm_dsSpace_spFltBfReg_treg_crop_fxFrms_dfof_dsTime_1.h5
> loading chunk | offset: 0  0  1 | block: 304  304    1
> movie size: 0.35254Mb | 304  304 | single
> checking movies: 100|
> 
> ans =
> 
>   1×1 cell array
> 
>     {[250]}
> 
> 
> ans =
> 
>   1×1 cell array
> 
>     {[1]}
> 
> -------
> pre-allocating single NaN matrix...
> -------
> loading 1/1: /Volumes/VERBATIM/Rat1/2020_12_07/19_00_35/Miniscope/2020_12_07_p000_m000_NULL000_strpRm_dsSpace_spFltBfReg_treg_crop_fxFrms_dfof_dsTime_1.h5
> loading movie as contiguous chunk: 0  0  0 | 304  304  250
> loading chunk | offset: 0  0  0 | block: 304  304  250
> movie size: 88.1347Mb | 304  304  250 | single
> movie class: single
> movie size: 304  304  500
> x-dims: 304
> y-dims: 304
> z-dims: 250
> movie size: 176.2695Mb | 304  304  500 | single
> Elapsed time is 0.802823 seconds.
> ###
> =====================
> Subject: m000
> Warning: Converting NaN inputs to 0. 
> > In imhist (line 88)
>   In getHistogramData>computeHistogramData (line 126)
>   In getHistogramData (line 21)
>   In imcontrast>isDisplayRangeOutsideDataRange (line 1576)
>   In imcontrast (line 116)
>   In calciumImagingAnalysis/modelExtractSignalsFromMovie/subfxnSignalSizeSpacing (line 1554)
>   In calciumImagingAnalysis/modelExtractSignalsFromMovie (line 163)
>   In calciumImagingAnalysis/runPipeline (line 202)
>   In calciumImagingAnalysis/display (line 817) 
> Warning: Cannot set Position while WindowStyle is 'docked' 
> > In imcontrast>createHistogramPalette (line 196)
>   In imcontrast (line 135)
>   In calciumImagingAnalysis/modelExtractSignalsFromMovie/subfxnSignalSizeSpacing (line 1554)
>   In calciumImagingAnalysis/modelExtractSignalsFromMovie (line 163)
>   In calciumImagingAnalysis/runPipeline (line 202)
>   In calciumImagingAnalysis/display (line 817) 
> Warning: Cannot set Position while WindowStyle is 'docked' 
> > In imcontrast>createHistogramPalette (line 239)
>   In imcontrast (line 135)
>   In calciumImagingAnalysis/modelExtractSignalsFromMovie/subfxnSignalSizeSpacing (line 1554)
>   In calciumImagingAnalysis/modelExtractSignalsFromMovie (line 163)
>   In calciumImagingAnalysis/runPipeline (line 202)
>   In calciumImagingAnalysis/display (line 817) 
> gridWidth:
>     m000: 20
> 
> gridSpacing:
>     m000: 27
> 
> =====================
> 1/1 (1/1): m000 NULL000
> -------
> CELLMax
> @@@@@@@
> Reference to non-existent field 'CELLMax'.
> 
> Error in calciumImagingAnalysis/modelExtractSignalsFromMovie (line 289)
>                       saveID = {obj.extractionMethodStructSaveStr.(obj.signalExtractionMethod)};
> 
> Error in calciumImagingAnalysis/runPipeline (line 202)
>               obj.(thisFxn{1});
> 
> Error in calciumImagingAnalysis/display (line 817)
>           obj.runPipeline;
> @@@@@@@
> 
> errorList =
> 
>      1
> 
> =====================
> Error in the following folders: 1
> Re-run after checking below warning tips.
> =====================
> Warning:
> =====================
> Error during cell extraction with "modelExtractSignalsFromMovie". Some tips:
> - Make sure REGEXP for finding movie is correct.
> - Make sure folder has files in it and is accessible to MATLAB.
> - Try and avoid running cell extraction of extremely small movies (e.g. 100x100 movie with 25
> frames).
> - Make sure folder added with "modelAddNewFolders" points to an actual folder and not a file.
> - CNMF and CNMF-E: check that they are installed under "_external_programs" folder.
> - PCA-ICA: make sure there are MORE frames than PCs and ICs requested, else PCA-ICA will not run.
> - ROI: make sure you have run a previous cell-extraction method.
> =====================
>  
> > In calciumImagingAnalysis/modelExtractSignalsFromMovie/subfxnRunWarning (line 432)
>   In calciumImagingAnalysis/modelExtractSignalsFromMovie (line 427)
>   In calciumImagingAnalysis/runPipeline (line 202)
>   In calciumImagingAnalysis/display (line 817) 
> 
> 
> Run processing pipeline by typing below (or clicking link) into command window (no semi-colon!):
> obj
> >> 
bahanonu commented 3 years ago

@hsw28 hey! Yep, that's likely because you chose CELLMax instead of CNMF or PCA-ICA. e.g. select PCA-ICA as below, let me know if any of the subsequent steps are confusing or see https://bahanonu.github.io/calciumImagingAnalysis/pipeline_detailed/#extracting-cells-with-modelextractsignalsfrommovie.

image

hsw28 commented 3 years ago

Hi, sorry to bother you again! Two more questions:

  1. When will cellmax be available?
  2. I have a video where the cells are 'fainter' / less in focus. When I process it the program adds a bunch of speckled noise. Here is a pic from the video before processing and after processing: image image

Here are the parameters I am using. Thanks for any help! image image image

hsw28 commented 3 years ago

By process of elimination I found it introduces the noise at df/f0

bahanonu commented 3 years ago

hey! To your first question: hopefully soon, I can likely add you to the private repo if you'd like to try it out before then.

re: noise, there should generally not be noise added. See below for an explanation, let me know if have any follow-up questions.

Raw movie

For example, take one of the example movies in the CIAtah repository: 2014_04_01_p203_m19_check01.

A frame from the raw movie looks like: image

Applying a simple bandpass or highpass filter (to remove the low frequency background) leads to the below (keeping contrast/brightness the same as the raw movie image): image

However, if we adjust the contrast, we can now see some of the noise present in the higher frequency components of the raw movie: image

dF/F0

Now compare to dF/F0 of that same raw movie without any motion correction, etc. we see the below: image

However, if you adjust the contrast: image

bahanonu commented 3 years ago

@hsw28 Wanted to check that the above explanation made sense.

hsw28 commented 3 years ago

Sorry, I completely forgot to reply! Yes, it makes perfect sense, thank you! I have another likely very stupid question. I have done cell extraction etc for a video and i have a figure as such image

but I can't figure out (and again I am probably being super dumb here) how to get the traces for each cell and not just the 10 traces you can see on the side (zooming out does not work). I additionally would like the time that each cell "spikes" (either the beginning or peak of the calcium signal) but am unsure how to extract those without having the data for each trace (or maybe this is somehow done automatically and I am missing it). I read through the documentation on your website but it is still unclear to me.

And congrats on the hanna gray!

Thanks again!! I'm making great progress :)

hsw28 commented 3 years ago

nevermind I found it in 1_28_21_p000_m000_NULL000_cnmfeAnalysis.mat :)

hsw28 commented 3 years ago

also looking forward to your talk today at NU :)

hsw28 commented 3 years ago

Sorry another question-- when running cnmfe, in the settings file when it asks for

% Int: temporal downsampling factor
cnmfeOpts.tsub = ;

% Int: spatial downsampling factor
cnmfeOpts.ssub = ;

Do we put in the values we entered during pre-processing or is that if we want to do additional downsampling?

bahanonu commented 3 years ago

@hsw28 re: Hanna Gray, thanks!

Great to hear the cell extraction, etc. is working for you. I'll make that part of the ciatah guide clearer for where the outputs are located. Let me know if anything else is unclear during the processing steps.

For tsub and ssub, those are further spatiotemporal downsampling that CNMF(-e) will perform inside the algorithm to speed up processing, but will still give out spatial sources and activity traces that have the same dimensions as your pre-processed movie.

hsw28 commented 3 years ago

great, thank you!! and I am having one other issue with CNMF... I'm guessing I'm just doing something stupid, but I keep getting the following errors (pasting all output). I believe it is initially caused by 'Index in position 3 exceeds array bounds (must not exceed 2000).' which then triggers a whole other bunch of errors. This only happens with some processed videos and I can't figure out when/why-- it's probably obvious but ? thanks again!

!!!!!!!!!!!!!!!!!!!!!
Running: obj.modelExtractSignalsFromMovie
Warning: The DrawMode property will be removed in a future release. Use the SortMethod property
instead. 
> In inputdlg (line 255)
  In calciumImagingAnalysis/modelExtractSignalsFromMovie (line 101)
  In calciumImagingAnalysis/runPipeline (line 202)
  In calciumImagingAnalysis/display (line 817) 
Warning: The DrawMode property will be removed in a future release. Use the SortMethod property
instead. 
> In inputdlg (line 255)
  In calciumImagingAnalysis/modelExtractSignalsFromMovie/getAlgorithmOptions (line 901)
  In calciumImagingAnalysis/modelExtractSignalsFromMovie (line 147)
  In calciumImagingAnalysis/runPipeline (line 202)
  In calciumImagingAnalysis/display (line 817) 
*********************
*********************
Copying "/Users/Hannah/Programming/calciumImagingAnalysis-master/ciapkg/settings/cnmfeSettings.m" to
"private/settings/signal_extraction/cnmfeSettings_20210309_215807_Miniscope.m"

Close "cnmfeSettings_20210309_215807_Miniscope.m" file in Editor to continue!
Using settings file: private/settings/signal_extraction/cnmfeSettings_20210309_215807_Miniscope.m
Add _external_programs/cnmfe
=====================
1/1 (1/1): m000 NULL000
-------
CNMFE
saving temporary: /Volumes/fsmresfiles/Basic_Sciences/Phys/DisterhoftLab/Hannah_Wirtshafter/ca2+ videos/rat_1_28_21/2021_03_04/20_03_05/Miniscope/1_28_21_p000_m000_NULL000_cnmfeAnalysis.mat
Add _external_programs/cnmfe
**************
=====================
Running CNMF-e batch wrapper script
options:
                    nonCNMF: [1×1 struct]
                   runMerge: 1
    runRemoveFalsePositives: 1
         memory_size_to_use: 8
      memory_size_per_patch: 0.6000
                 patch_dims: [64 64]
               batch_frames: []
                       gSig: 3
                       gSiz: 10
                       ssub: 1
             with_dendrites: 1
               updateA_bSiz: 3
          spatial_algorithm: 'hals_thresh'
                       tsub: 1
                         Fs: 7.5000
                deconv_smin: -5
                    max_tau: 100
                         nk: 1
                   bg_model: 'ring'
                         nb: 1
                ring_radius: 18
                    bg_ssub: 3
                  merge_thr: 0.6500
                method_dist: 'max'
                       dmin: 5
                  dmin_only: 2
          merge_thr_spatial: [0.8000 0.4000 -Inf]
                          K: []
                   min_corr: 0.8000
                    min_pnr: 8
                         bd: 0
               use_parallel: 1
                  show_init: 1
                 center_psf: 1
               min_corr_res: 0.3000
                min_pnr_res: 3
            seed_method_res: 'auto'
                  update_sn: 1

options.nonCNMF:
    parallel: 1

The data has 202 X 202 pixels X 4000 frames. 
Loading all data (double precision) requires 1.216 GB RAM

The FOV is divided into 3 X 3 patches. 
Each patch has 67 X 67 pixels. 
It requires 0.298 GB RAM for loading data related to each patch. 

Finished reading images

-------- Loading --------
Data is being loaded and distributed into multiple small blocks for easy access.

Finished reading images
block( 1, 1)/(7, 7) done
block( 1, 2)/(7, 7) done
block( 1, 3)/(7, 7) done
block( 1, 4)/(7, 7) done
block( 1, 5)/(7, 7) done
block( 1, 6)/(7, 7) done
block( 1, 7)/(7, 7) done
block( 2, 1)/(7, 7) done
block( 2, 2)/(7, 7) done
block( 2, 3)/(7, 7) done
block( 2, 4)/(7, 7) done
block( 2, 5)/(7, 7) done
block( 2, 6)/(7, 7) done
block( 2, 7)/(7, 7) done
block( 3, 1)/(7, 7) done
block( 3, 2)/(7, 7) done
block( 3, 3)/(7, 7) done
block( 3, 4)/(7, 7) done
block( 3, 5)/(7, 7) done
block( 3, 6)/(7, 7) done
block( 3, 7)/(7, 7) done
block( 4, 1)/(7, 7) done
block( 4, 2)/(7, 7) done
block( 4, 3)/(7, 7) done
block( 4, 4)/(7, 7) done
block( 4, 5)/(7, 7) done
block( 4, 6)/(7, 7) done
block( 4, 7)/(7, 7) done
block( 5, 1)/(7, 7) done
block( 5, 2)/(7, 7) done
block( 5, 3)/(7, 7) done
block( 5, 4)/(7, 7) done
block( 5, 5)/(7, 7) done
block( 5, 6)/(7, 7) done
block( 5, 7)/(7, 7) done
block( 6, 1)/(7, 7) done
block( 6, 2)/(7, 7) done
block( 6, 3)/(7, 7) done
block( 6, 4)/(7, 7) done
block( 6, 5)/(7, 7) done
block( 6, 6)/(7, 7) done
block( 6, 7)/(7, 7) done
block( 7, 1)/(7, 7) done
block( 7, 2)/(7, 7) done
block( 7, 3)/(7, 7) done
block( 7, 4)/(7, 7) done
block( 7, 5)/(7, 7) done
block( 7, 6)/(7, 7) done
block( 7, 7)/(7, 7) done
loaded 4000 out of 4000 frames

The data has been saved into 
/Volumes/fsmresfiles/Basic_Sciences/Phys/DisterhoftLab/Hannah_Wirtshafter/ca2+ videos/rat_1_28_21/2021_03_04/20_03_05/Miniscope/_src_extrct/data_64_64_18.mat

-------- Done --------
estimating the nosie level for every pixel.......
@@@@@@@
Index in position 3 exceeds array bounds (must not exceed 2000).

Error in get_patch_data (line 85)
            Y((r0:r1)-block_rstart, (c0:c1)-block_cstart, :) = evalin(ws, tmp_str);

Error in Sources2D/estimate_noise (line 366)
                Ypatch = get_patch_data(mat_data, [r0, r1, c0, c1], frame_range, false);

Error in Sources2D/getReady (line 251)
                obj.P.sn = obj.estimate_noise();

Error in computeCnmfeSignalExtraction_batch (line 278)
            neuron.getReady(pars_envs);

Error in calciumImagingAnalysis/modelExtractSignalsFromMovie/runCNMFESignalFinder (line 1423)
            [cnmfeAnalysisOutput] = computeCnmfeSignalExtraction_batch(movieList{1},'options',cnmfeOptions);

Error in calciumImagingAnalysis/modelExtractSignalsFromMovie (line 364)
                        [cnmfOptions] = runCNMFESignalFinder();

Error in calciumImagingAnalysis/runPipeline (line 202)
                obj.(thisFxn{1});

Error in calciumImagingAnalysis/display (line 817)
            obj.runPipeline;
@@@@@@@
saving: /Volumes/fsmresfiles/Basic_Sciences/Phys/DisterhoftLab/Hannah_Wirtshafter/ca2+ videos/rat_1_28_21/2021_03_04/20_03_05/Miniscope/1_28_21_p000_m000_NULL000_cnmfeAnalysis.mat
@@@@@@@
Reference to non-existent field 'extractedImages'.

Error in calciumImagingAnalysis/modelExtractSignalsFromMovie/runCNMFESignalFinder (line 1446)
            subfxnSaveNwbFiles(cnmfeAnalysisOutput.extractedImages,{cnmfeAnalysisOutput.extractedSignals,cnmfeAnalysisOutput.extractedSignalsEst});

Error in calciumImagingAnalysis/modelExtractSignalsFromMovie (line 364)
                        [cnmfOptions] = runCNMFESignalFinder();

Error in calciumImagingAnalysis/runPipeline (line 202)
                obj.(thisFxn{1});

Error in calciumImagingAnalysis/display (line 817)
            obj.runPipeline;
@@@@@@@

ans =

     0

*********************
Deleting temporary folder: /Volumes/fsmresfiles/Basic_Sciences/Phys/DisterhoftLab/Hannah_Wirtshafter/ca2+ videos/rat_1_28_21/2021_03_04/20_03_05/Miniscope/_src_extrct
*********************

status =

  logical

   1

loading: private/data//database_processing_runtimes_20210309_164927_427.csv
Warning: The assignment added rows to the table, but did not assign values to all of the table's
existing variables. Those variables will extended with rows containing default values. 
> In tabular/subsasgnDot (line 458)
  In tabular/subsasgn (line 67)
  In calciumImagingAnalysis/modelExtractSignalsFromMovie/saveRunTimes (line 523)
  In calciumImagingAnalysis/modelExtractSignalsFromMovie (line 365)
  In calciumImagingAnalysis/runPipeline (line 202)
  In calciumImagingAnalysis/display (line 817) 
###
Getting movie info for 1\1: /Volumes/fsmresfiles/Basic_Sciences/Phys/DisterhoftLab/Hannah_Wirtshafter/ca2+ videos/rat_1_28_21/2021_03_04/20_03_05/Miniscope/proccc1_28_21_p000_m000_NULL000_strpRm_dsSpace_spFltBfReg_treg_crop_fxFrms_dfof_dsTime_1.h5
loading chunk | offset: 0  0  1 | block: 202  202    1
movie size: 0.15565Mb | 202  202 | single
checking movies: 100|
Elapsed time is 0.985510 seconds.
###
saving private/data//database_processing_runtimes_20210309_164927_427.csv
Elapsed time is 2346.742193 seconds.
#####################
loading files...
=====================
1/1 (1/1): m000 NULL000
loading: /Volumes/fsmresfiles/Basic_Sciences/Phys/DisterhoftLab/Hannah_Wirtshafter/ca2+ videos/rat_1_28_21/2021_03_04/20_03_05/Miniscope/1_28_21_p000_m000_NULL000_cnmfeAnalysis.mat
@@@@@@@
Reference to non-existent field 'extractedImages'.

Error in calciumImagingAnalysis/modelVarsFromFiles (line 297)
                    signalImages = double(cnmfeAnalysisOutput.extractedImages);

Error in calciumImagingAnalysis/modelExtractSignalsFromMovie (line 395)
                obj.modelVarsFromFiles();

Error in calciumImagingAnalysis/runPipeline (line 202)
                obj.(thisFxn{1});

Error in calciumImagingAnalysis/display (line 817)
            obj.runPipeline;
@@@@@@@
=====================
1/1: m000 NULL000
No region analysis to load!
                  rowSubP: 2
                  colSubP: 4
    onlyShowMapTraceGraph: 0
          mapTraceGraphNo: 43
                  figList: [2001 5001 4001 46]
             signalCutIdx: []
           signalCutXline: []
           movAvgFiltSize: 3
       medianFilterLength: 201
          incrementAmount: 0.1000
        filterShownTraces: 0
     scaleBarLengthMicron: 50
             cellOutlines: 1
     dilateOutlinesFactor: 0
       medianFilterImages: 'none'
    plotSignalsGraphColor: 'red'

=====================
1/1: m000 NULL000
Search: _cnmfeAnalysis.mat
using valid.CNMFE.auto identifications...
loading: /Volumes/fsmresfiles/Basic_Sciences/Phys/DisterhoftLab/Hannah_Wirtshafter/ca2+ videos/rat_1_28_21/2021_03_04/20_03_05/Miniscope/1_28_21_p000_m000_NULL000_cnmfeAnalysis.mat
@@@@@@@
Reference to non-existent field 'extractedImages'.

Error in calciumImagingAnalysis/modelGetSignalsImages (line 357)
            inputImages = double(cnmfeAnalysisOutput.extractedImages);

Error in calciumImagingAnalysis/viewObjmaps (line 156)
            [inputSignals, inputImages, signalPeaks, signalPeakIdx, valid, validType, inputSignals2] = modelGetSignalsImages(obj,'returnType','raw');

Error in calciumImagingAnalysis/modelExtractSignalsFromMovie (line 399)
                    obj.viewObjmaps('figList',[2000 5000 4000 45]+nInputFolders*signalExtractNo);

Error in calciumImagingAnalysis/runPipeline (line 202)
                obj.(thisFxn{1});

Error in calciumImagingAnalysis/display (line 817)
            obj.runPipeline;
@@@@@@@
###
Getting movie info for 1\1: /Volumes/fsmresfiles/Basic_Sciences/Phys/DisterhoftLab/Hannah_Wirtshafter/ca2+ videos/rat_1_28_21/2021_03_04/20_03_05/Miniscope/proccc1_28_21_p000_m000_NULL000_strpRm_dsSpace_spFltBfReg_treg_crop_fxFrms_dfof_dsTime_1.h5
loading chunk | offset: 0  0  1 | block: 202  202    1
movie size: 0.15565Mb | 202  202 | single
checking movies: 100|
Elapsed time is 0.406315 seconds.
###
###
Getting movie info for 1\1: /Volumes/fsmresfiles/Basic_Sciences/Phys/DisterhoftLab/Hannah_Wirtshafter/ca2+ videos/rat_1_28_21/2021_03_04/20_03_05/Miniscope/proccc1_28_21_p000_m000_NULL000_strpRm_dsSpace_spFltBfReg_treg_crop_fxFrms_dfof_dsTime_1.h5
loading chunk | offset: 0  0  1 | block: 202  202    1
movie size: 0.15565Mb | 202  202 | single
checking movies: 100|
-------
pre-allocating single NaN matrix...
-------
loading 1/1: /Volumes/fsmresfiles/Basic_Sciences/Phys/DisterhoftLab/Hannah_Wirtshafter/ca2+ videos/rat_1_28_21/2021_03_04/20_03_05/Miniscope/proccc1_28_21_p000_m000_NULL000_strpRm_dsSpace_spFltBfReg_treg_crop_fxFrms_dfof_dsTime_1.h5
loading movie as contiguous chunk: 0  0  0 | 202  202  500
loading chunk | offset: 0  0  0 | block: 202  202  500
movie size: 77.8274Mb | 202  202  500 | single
movie class: single
movie size: 202  202  500
x-dims: 202
y-dims: 202
z-dims: 500
movie size: 77.8274Mb | 202  202  500 | single
Elapsed time is 1.893200 seconds.
###
@@@@@@@
Undefined function or variable 'rMap'.

Error in calciumImagingAnalysis/viewObjmaps/subfxnDisplayMovie (line 387)
            movieFrameProc = cast(movieFrameProc,class(rMap));

Error in calciumImagingAnalysis/viewObjmaps (line 360)
                subfxnDisplayMovie()

Error in calciumImagingAnalysis/modelExtractSignalsFromMovie (line 399)
                    obj.viewObjmaps('figList',[2000 5000 4000 45]+nInputFolders*signalExtractNo);

Error in calciumImagingAnalysis/runPipeline (line 202)
                obj.(thisFxn{1});

Error in calciumImagingAnalysis/display (line 817)
            obj.runPipeline;
@@@@@@@
Warning: The DrawMode property will be removed in a future release. Use the SortMethod property
instead. 
> In suptitle (line 59)
  In calciumImagingAnalysis/viewObjmaps (line 369)
  In calciumImagingAnalysis/modelExtractSignalsFromMovie (line 399)
  In calciumImagingAnalysis/runPipeline (line 202)
  In calciumImagingAnalysis/display (line 817) 
Warning: The DrawMode property will be removed in a future release. Use the SortMethod property
instead. 
> In suptitle (line 59)
  In calciumImagingAnalysis/viewObjmaps (line 369)
  In calciumImagingAnalysis/modelExtractSignalsFromMovie (line 399)
  In calciumImagingAnalysis/runPipeline (line 202)
  In calciumImagingAnalysis/display (line 817) 
=====================
Successful ran the following folders: 1
=====================

Run processing pipeline by typing below (or clicking link) into command window (no semi-colon!):
obj
>> 
hsw28 commented 3 years ago

ok potential slight update-- that might have had something to do with the naming of my input movie file. but after seemingly making sure that was there I am still getting this set of errors. again with some files it works fine so im not sure what I'm messing up


!!!!!!!!!!!!!!!!!!!!!
Running: obj.modelExtractSignalsFromMovie
*********************
*********************
Copying "/Users/Hannah/Programming/calciumImagingAnalysis-master/ciapkg/settings/cnmfeSettings.m" to
"private/settings/signal_extraction/cnmfeSettings_20210309_234211_Miniscope.m"

Close "cnmfeSettings_20210309_234211_Miniscope.m" file in Editor to continue!
Using settings file: private/settings/signal_extraction/cnmfeSettings_20210309_234211_Miniscope.m
Add _external_programs/cnmfe
=====================
1/1 (1/1): m000 NULL000
-------
CNMFE
saving temporary: /Volumes/fsmresfiles/Basic_Sciences/Phys/DisterhoftLab/Hannah_Wirtshafter/ca2+ videos/rat_1_28_21/2021_03_04/20_03_05/Miniscope/1_28_21_p000_m000_NULL000_cnmfeAnalysis.mat
Add _external_programs/cnmfe
**************
=====================
Running CNMF-e batch wrapper script
options:
                    nonCNMF: [1×1 struct]
                   runMerge: 1
    runRemoveFalsePositives: 1
         memory_size_to_use: 8
      memory_size_per_patch: 0.6000
                 patch_dims: [64 64]
               batch_frames: []
                       gSig: 3
                       gSiz: 10
                       ssub: 3
             with_dendrites: 1
               updateA_bSiz: 3
          spatial_algorithm: 'hals_thresh'
                       tsub: 1
                         Fs: 7.5000
                deconv_smin: -5
                    max_tau: 100
                         nk: 1
                   bg_model: 'ring'
                         nb: 1
                ring_radius: 18
                    bg_ssub: 4
                  merge_thr: 0.6500
                method_dist: 'max'
                       dmin: 5
                  dmin_only: 2
          merge_thr_spatial: [0.8000 0.4000 -Inf]
                          K: []
                   min_corr: 0.8000
                    min_pnr: 8
                         bd: 0
               use_parallel: 1
                  show_init: 1
                 center_psf: 1
               min_corr_res: 0.3000
                min_pnr_res: 3
            seed_method_res: 'auto'
                  update_sn: 1

options.nonCNMF:
    parallel: 1

The data has 202 X 202 pixels X 4000 frames. 
Loading all data (double precision) requires 1.216 GB RAM

The FOV is divided into 3 X 3 patches. 
Each patch has 67 X 67 pixels. 
It requires 0.298 GB RAM for loading data related to each patch. 

Finished reading images

-------- Loading --------
Data is being loaded and distributed into multiple small blocks for easy access.

Finished reading images
block( 1, 1)/(7, 7) done
block( 1, 2)/(7, 7) done
block( 1, 3)/(7, 7) done
block( 1, 4)/(7, 7) done
block( 1, 5)/(7, 7) done
block( 1, 6)/(7, 7) done
block( 1, 7)/(7, 7) done
block( 2, 1)/(7, 7) done
block( 2, 2)/(7, 7) done
block( 2, 3)/(7, 7) done
block( 2, 4)/(7, 7) done
block( 2, 5)/(7, 7) done
block( 2, 6)/(7, 7) done
block( 2, 7)/(7, 7) done
block( 3, 1)/(7, 7) done
block( 3, 2)/(7, 7) done
block( 3, 3)/(7, 7) done
block( 3, 4)/(7, 7) done
block( 3, 5)/(7, 7) done
block( 3, 6)/(7, 7) done
block( 3, 7)/(7, 7) done
block( 4, 1)/(7, 7) done
block( 4, 2)/(7, 7) done
block( 4, 3)/(7, 7) done
block( 4, 4)/(7, 7) done
block( 4, 5)/(7, 7) done
block( 4, 6)/(7, 7) done
block( 4, 7)/(7, 7) done
block( 5, 1)/(7, 7) done
block( 5, 2)/(7, 7) done
block( 5, 3)/(7, 7) done
block( 5, 4)/(7, 7) done
block( 5, 5)/(7, 7) done
block( 5, 6)/(7, 7) done
block( 5, 7)/(7, 7) done
block( 6, 1)/(7, 7) done
block( 6, 2)/(7, 7) done
block( 6, 3)/(7, 7) done
block( 6, 4)/(7, 7) done
block( 6, 5)/(7, 7) done
block( 6, 6)/(7, 7) done
block( 6, 7)/(7, 7) done
block( 7, 1)/(7, 7) done
block( 7, 2)/(7, 7) done
block( 7, 3)/(7, 7) done
block( 7, 4)/(7, 7) done
block( 7, 5)/(7, 7) done
block( 7, 6)/(7, 7) done
block( 7, 7)/(7, 7) done
loaded 4000 out of 4000 frames

The data has been saved into 
/Volumes/fsmresfiles/Basic_Sciences/Phys/DisterhoftLab/Hannah_Wirtshafter/ca2+ videos/rat_1_28_21/2021_03_04/20_03_05/Miniscope/_src_extrct/data_64_64_18.mat

-------- Done --------
estimating the nosie level for every pixel.......
Time cost for estimating the nosie levels:  287.066 

Patch ( 1,  1) is done.  3 X  3 patches in total. 
Patch ( 3,  1) is done.  3 X  3 patches in total. 
Patch ( 1,  3) is done.  3 X  3 patches in total. 
Patch ( 2,  1) is done.  3 X  3 patches in total. 
Patch ( 1,  2) is done.  3 X  3 patches in total. 
Patch ( 3,  2) is done.  3 X  3 patches in total. 
Patch ( 2,  2) is done.  3 X  3 patches in total. 
Patch ( 2,  3) is done.  3 X  3 patches in total. 
Patch ( 3,  3) is done.  3 X  3 patches in total. 

-----------------UPDATE BACKGROUND---------------------------
Patch ( 1,  1) is done.  3 X  3 patches in total. 
Patch ( 1,  3) is done.  3 X  3 patches in total. 
Patch ( 3,  1) is done.  3 X  3 patches in total. 
Patch ( 1,  2) is done.  3 X  3 patches in total. 
Patch ( 3,  2) is done.  3 X  3 patches in total. 
Patch ( 2,  1) is done.  3 X  3 patches in total. 
Patch ( 2,  2) is done.  3 X  3 patches in total. 
Patch ( 2,  3) is done.  3 X  3 patches in total. 
Patch ( 3,  3) is done.  3 X  3 patches in total. 
Finished updating background using ring model.
-------------MERGE HIGHLY CORRELATED CLOSE-BY NEURONS----------

@@@@@@@
Error using corr (line 91)
Requires a data matrix X.

Error in Sources2D/merge_neurons_dist_corr (line 70)
C_corr = corr(C_')-eye(K);

Error in computeCnmfeSignalExtraction_batch (line 301)
            neuron.merge_neurons_dist_corr(show_merge);

Error in calciumImagingAnalysis/modelExtractSignalsFromMovie/runCNMFESignalFinder (line 1423)
            [cnmfeAnalysisOutput] = computeCnmfeSignalExtraction_batch(movieList{1},'options',cnmfeOptions);

Error in calciumImagingAnalysis/modelExtractSignalsFromMovie (line 364)
                        [cnmfOptions] = runCNMFESignalFinder();

Error in calciumImagingAnalysis/runPipeline (line 202)
                obj.(thisFxn{1});

Error in calciumImagingAnalysis/display (line 817)
            obj.runPipeline;
@@@@@@@
saving: /Volumes/fsmresfiles/Basic_Sciences/Phys/DisterhoftLab/Hannah_Wirtshafter/ca2+ videos/rat_1_28_21/2021_03_04/20_03_05/Miniscope/1_28_21_p000_m000_NULL000_cnmfeAnalysis.mat
@@@@@@@
Reference to non-existent field 'extractedImages'.

Error in calciumImagingAnalysis/modelExtractSignalsFromMovie/runCNMFESignalFinder (line 1446)
            subfxnSaveNwbFiles(cnmfeAnalysisOutput.extractedImages,{cnmfeAnalysisOutput.extractedSignals,cnmfeAnalysisOutput.extractedSignalsEst});

Error in calciumImagingAnalysis/modelExtractSignalsFromMovie (line 364)
                        [cnmfOptions] = runCNMFESignalFinder();

Error in calciumImagingAnalysis/runPipeline (line 202)
                obj.(thisFxn{1});

Error in calciumImagingAnalysis/display (line 817)
            obj.runPipeline;
@@@@@@@

ans =

     0

*********************
Deleting temporary folder: /Volumes/fsmresfiles/Basic_Sciences/Phys/DisterhoftLab/Hannah_Wirtshafter/ca2+ videos/rat_1_28_21/2021_03_04/20_03_05/Miniscope/_src_extrct
*********************

status =

  logical

   1

loading: private/data//database_processing_runtimes_20210309_233402_247.csv
Warning: The assignment added rows to the table, but did not assign values to all of the table's
existing variables. Those variables will extended with rows containing default values. 
> In tabular/subsasgnDot (line 458)
  In tabular/subsasgn (line 67)
  In calciumImagingAnalysis/modelExtractSignalsFromMovie/saveRunTimes (line 523)
  In calciumImagingAnalysis/modelExtractSignalsFromMovie (line 365)
  In calciumImagingAnalysis/runPipeline (line 202)
  In calciumImagingAnalysis/display (line 817) 
###
Getting movie info for 1\1: /Volumes/fsmresfiles/Basic_Sciences/Phys/DisterhoftLab/Hannah_Wirtshafter/ca2+ videos/rat_1_28_21/2021_03_04/20_03_05/Miniscope/proccc1_28_21_p000_m000_NULL000_strpRm_dsSpace_spFltBfReg_treg_crop_fxFrms_dfof_dsTime_1.h5
loading chunk | offset: 0  0  1 | block: 202  202    1
movie size: 0.15565Mb | 202  202 | single
checking movies: 100|
Elapsed time is 6.012158 seconds.
###
saving private/data//database_processing_runtimes_20210309_233402_247.csv
Elapsed time is 2998.697184 seconds.
#####################
loading files...
=====================
1/1 (1/1): m000 NULL000
No NWB files, checking for calciumImagingAnalysis files.
loading: /Volumes/fsmresfiles/Basic_Sciences/Phys/DisterhoftLab/Hannah_Wirtshafter/ca2+ videos/rat_1_28_21/2021_03_04/20_03_05/Miniscope/1_28_21_p000_m000_NULL000_cnmfeAnalysis.mat
@@@@@@@
Reference to non-existent field 'extractedImages'.

Error in calciumImagingAnalysis/modelVarsFromFiles (line 297)
                    signalImages = double(cnmfeAnalysisOutput.extractedImages);

Error in calciumImagingAnalysis/modelExtractSignalsFromMovie (line 395)
                obj.modelVarsFromFiles();

Error in calciumImagingAnalysis/runPipeline (line 202)
                obj.(thisFxn{1});

Error in calciumImagingAnalysis/display (line 817)
            obj.runPipeline;
@@@@@@@
=====================
1/1: m000 NULL000
No region analysis to load!
                  rowSubP: 2
                  colSubP: 4
    onlyShowMapTraceGraph: 0
          mapTraceGraphNo: 43
                  figList: [2001 5001 4001 46]
             signalCutIdx: []
           signalCutXline: []
           movAvgFiltSize: 3
       medianFilterLength: 201
          incrementAmount: 0.1000
        filterShownTraces: 0
     scaleBarLengthMicron: 50
             cellOutlines: 1
     dilateOutlinesFactor: 0
       medianFilterImages: 'none'
    plotSignalsGraphColor: 'red'

=====================
1/1: m000 NULL000
Search: _cnmfeAnalysis.mat
using auto identifications...
loading: /Volumes/fsmresfiles/Basic_Sciences/Phys/DisterhoftLab/Hannah_Wirtshafter/ca2+ videos/rat_1_28_21/2021_03_04/20_03_05/Miniscope/1_28_21_p000_m000_NULL000_cnmfeAnalysis.mat
@@@@@@@
Reference to non-existent field 'extractedImages'.

Error in calciumImagingAnalysis/modelGetSignalsImages (line 357)
            inputImages = double(cnmfeAnalysisOutput.extractedImages);

Error in calciumImagingAnalysis/viewObjmaps (line 156)
            [inputSignals, inputImages, signalPeaks, signalPeakIdx, valid, validType, inputSignals2] = modelGetSignalsImages(obj,'returnType','raw');

Error in calciumImagingAnalysis/modelExtractSignalsFromMovie (line 399)
                    obj.viewObjmaps('figList',[2000 5000 4000 45]+nInputFolders*signalExtractNo);

Error in calciumImagingAnalysis/runPipeline (line 202)
                obj.(thisFxn{1});

Error in calciumImagingAnalysis/display (line 817)
            obj.runPipeline;
@@@@@@@
###
Getting movie info for 1\1: /Volumes/fsmresfiles/Basic_Sciences/Phys/DisterhoftLab/Hannah_Wirtshafter/ca2+ videos/rat_1_28_21/2021_03_04/20_03_05/Miniscope/proccc1_28_21_p000_m000_NULL000_strpRm_dsSpace_spFltBfReg_treg_crop_fxFrms_dfof_dsTime_1.h5
loading chunk | offset: 0  0  1 | block: 202  202    1
movie size: 0.15565Mb | 202  202 | single
checking movies: 100|
Elapsed time is 0.050095 seconds.
###
###
Getting movie info for 1\1: /Volumes/fsmresfiles/Basic_Sciences/Phys/DisterhoftLab/Hannah_Wirtshafter/ca2+ videos/rat_1_28_21/2021_03_04/20_03_05/Miniscope/proccc1_28_21_p000_m000_NULL000_strpRm_dsSpace_spFltBfReg_treg_crop_fxFrms_dfof_dsTime_1.h5
loading chunk | offset: 0  0  1 | block: 202  202    1
movie size: 0.15565Mb | 202  202 | single
checking movies: 100|
-------
pre-allocating single NaN matrix...
-------
loading 1/1: /Volumes/fsmresfiles/Basic_Sciences/Phys/DisterhoftLab/Hannah_Wirtshafter/ca2+ videos/rat_1_28_21/2021_03_04/20_03_05/Miniscope/proccc1_28_21_p000_m000_NULL000_strpRm_dsSpace_spFltBfReg_treg_crop_fxFrms_dfof_dsTime_1.h5
loading movie as contiguous chunk: 0  0  0 | 202  202  500
loading chunk | offset: 0  0  0 | block: 202  202  500
movie size: 77.8274Mb | 202  202  500 | single
movie class: single
movie size: 202  202  500
x-dims: 202
y-dims: 202
z-dims: 500
movie size: 77.8274Mb | 202  202  500 | single
Elapsed time is 37.300241 seconds.
###
@@@@@@@
Undefined function or variable 'rMap'.

Error in calciumImagingAnalysis/viewObjmaps/subfxnDisplayMovie (line 387)
            movieFrameProc = cast(movieFrameProc,class(rMap));

Error in calciumImagingAnalysis/viewObjmaps (line 360)
                subfxnDisplayMovie()

Error in calciumImagingAnalysis/modelExtractSignalsFromMovie (line 399)
                    obj.viewObjmaps('figList',[2000 5000 4000 45]+nInputFolders*signalExtractNo);

Error in calciumImagingAnalysis/runPipeline (line 202)
                obj.(thisFxn{1});

Error in calciumImagingAnalysis/display (line 817)
            obj.runPipeline;
@@@@@@@
Warning: The DrawMode property will be removed in a future release. Use the SortMethod property
instead. 
> In suptitle (line 59)
  In calciumImagingAnalysis/viewObjmaps (line 369)
  In calciumImagingAnalysis/modelExtractSignalsFromMovie (line 399)
  In calciumImagingAnalysis/runPipeline (line 202)
  In calciumImagingAnalysis/display (line 817) 
=====================
Successful ran the following folders: 1
=====================

Run processing pipeline by typing below (or clicking link) into command window (no semi-colon!):
obj
>> 
hsw28 commented 3 years ago

Sorry for the 200 replies!! I got that working too but I'm not quite sure how haha. but surprise surprise I have another question. I ran cnmfe two times, using the same file. The parameters for cnmfe were all the same for both runs EXCEPT:

% Int: pixel, neuron diameter
cnmfeOpts.gSiz =

was 9 for one run and 10 for another. The only other difference was:

% Int: downsample background for a faster speed
cnmfeOpts.bg_ssub = 

was 2 for one run and 4 for the other. However, the run that had the diameter HIGHER (10) found more potential cells than the one with the lower diameter. Shouldnt it be the opposite? Or is it just not determinable bc the run with gSiz=9 might have had more merging?

I'm just trying to figure out the best parameters! thanks!!

bahanonu commented 3 years ago

@hsw28

hey! As a heads up, I've added support for one of our new cell-extraction algorithms EXTRACT (https://github.com/schnitzer-lab/EXTRACT-public) to CIAtah. The bioRxiv paper should be out soon. If you want to try it, would be a good comparison of results to CNMF-e. I'll be adding the new comparison GUI to make that easier as well soon.

I'll give you a heads up when CELLMax is out as well.

re: cell diameter question, to be clear, one run was gSiz = 9, bg_ssub = 4 and gSiz = 10, bg_ssub = 2? If the background downsampling was changed, this could alter the accuracy of estimating cells, especially those that overlap (hence if the diameter was larger but downsampling less, you might identify more cells).

Are you still getting the CNMF-e errors you saw previously or did you figure out a fix?

bahanonu commented 3 years ago

@hsw28 Pre-print here: https://www.biorxiv.org/content/10.1101/2021.03.24.436279v1.

hsw28 commented 3 years ago

Great, thank you! I will try it out. I have been using CNMF-e just because it doesn't require me to guess on number of cells haha. So I set the parameters wide and then hand screen after.

I'm not sure why the errors were occuring-- I think it might have been something to do with file names? Tbh I left it for a day and came back to it and didn't have an issue then so I'm not sure what I did differently. I was testing out running the same processed video with different CNMF-e parameters so I was repeatedly running it over the same data so I think something got weird with file name iterations.

Thanks for the link to the preprint! I haven't decided what method I think would be best yet... do you know any good reviews or discussions (even twitter threads) about people giving their reasoning for using different methods? Would be nice to get an outside perspective.

Also terrific talk at NU!

Thanks again!

bahanonu commented 3 years ago

Yep, EXTRACT (and CELLMax) don't require estimating cell numbers either, which comes in handy. Looking at the the name of your path

/Volumes/fsmresfiles/Basic_Sciences/Phys/DisterhoftLab/Hannah_Wirtshafter/ca2+ videos/rat_1_28_21/2021_03_04/20_03_05/Miniscope/_src_extrct/data_64_64_18.mat

It is possible that having a + in the path (ca2+ videos) is causing problems. Could rename to ca2_videos and re-try if running into issues. Let me take a look at this more later today or tomorrow and get back.

I'll get back about good discussions comparing the methods (hopefully people can do this more easily/quickly now that we are making wrapper tools), I think both the CELLMax and EXTRACT papers will have good discussions, etc. of strengths/weaknesses of each. I also outline/have a table of many of the prior methods here: https://bahanonu.com/brain/#c20181209.

Thanks! Glad you like it.

hsw28 commented 3 years ago

No, it wasnt the +, it was something in the individual file names-- i think i might have had files that i wasnt analyzing starting with the same beginning as files i meant to analyze, causing issues. Anyway seems ok for now!

I'll give EXTRACT a go (and cellmax when it's out!) and report back :) thanks again!

hsw28 commented 3 years ago

Hi, have you had any luck using ciatah with ffv1 compressed files (in windows)? would prefer not to have to convert every file before processing. thanks!!

hsw28 commented 3 years ago

actually got iit after installing the k-lite codec pack!

bahanonu commented 3 years ago

@hsw28
Great! I'll add a note about downloading codec packs to deal with additional formats, as has come up before for others.

hsw28 commented 3 years ago

:) yeah, tried a few different codec packs but this one instantly did the trick!

hsw28 commented 3 years ago

finicky question-- is it possible in modelPreprocessMovie to have the options be in a different order and a different set of defaults preselected? I always choose the same things and in the same order and so I would like them to be auto ordered and selected :) thanks!

hsw28 commented 3 years ago

Actually one more question-- if i have a folder with a large number of movies in it, I get this error: pre-allocating single ones matrix... @@@@@@@ Error using ones Requested 600x600x41574 (55.8GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information.

Do you have any suggestions to avoid this? Further downsampling or changing the order of the steps? Id of course ideally like to have one long session processed and analyzed in one go instead of splitting it into separate movies. Thanks!

bahanonu commented 3 years ago

Yep! Had considered adding such a feature, will make it so that you can save order and it'll persist even if close/open Matlab (with option to also reset to default).

If these are miniature microscope movies, you can likely downsample 2x in each dimension, see:

I'm working on updating the GUI pre-processing code so there is an option for chunked (process only segments of the movie at a time) or read-from-disk processing (as we've implemented in our new cell extraction algorithms) that will get around the memory issues.