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

Infinite loop #84

Closed milesOIST closed 2 years ago

milesOIST commented 2 years ago

I tried to use the ciatah signalSorter function as specified here. However, I got an loop error.

It gives this warning at the start.

Warning: File: computeSignalSnr.m Line: 148 Column: 5 The temporary variable 'loopMean' will be cleared at the beginning of each iteration of the parfor-loop. If 'loopMean' is used before it is set, a runtime error will occur. For more information, see Parallel for Loops in MATLAB, "Uninitialized Temporaries". In signalSorter (line 413)

Then keeps repeating this error until it is stopped.

@@@@@@@ Index exceeds the number of array elements (2).

Error in compareSignalToMovie (line 101) nPoints = options.inputMovieDims(3);

Error in signalSorter>viewMontage (line 2505) croppedPeakImages = compareSignalToMovie(inputMovie, inputImage, thisTrace,'getOnlyPeakImages',1,'waitbarOn',0,'extendedCrosshairs',2,'crossHairVal',maxValMovie*options.crossHairPercent,'outlines',1,'signalPeakArray',signalPeakArray,'cropSize',cropSizeLength,'addPadding',1,'outlineVal',NaN,'xCoords',xCoords,'yCoords',yCoords,'inputDatasetName',options.inputDatasetName,'inputMovieDims',options.inputMovieDims,'hdf5Fid',options.hdf5Fid,'keepFileOpen',options.keepFileOpen);

Error in signalSorter>chooseSignals (line 986) [objCutImagesCollection{i}, ~] = viewMontage(options.inputMovie,thisImage,options,thisTrace,[signalPeakIdx{i}],minValMovie,maxValMovie,options.cropSizeLength,i,1);

Error in signalSorter (line 603) [choices, safeExit] = chooseSignals(options,1:nSignals, inputImages,inputSignals,objMap, valid, inputStr,tmpDir,sessionID,signalPeakIdx,signalSnr,inputImagesThres,inputImageSizes,peakOutputStat,ROItraces,imgStats,inputSignalSignal,inputSignalNoise,inputImagesBoundaryIndices,signalPeakIdxOriginal,signalPeaksOriginal,instructionStr); @@@@@@@ @@@@@@@ Index exceeds the number of array elements (0).

Error in signalSorter>chooseSignals (line 1046) title(['imageCorr = ' num2str(round(peakOutputStat.outputMeanImageCorrs(i)*sigDig)/sigDig) 10 'Press Y to go to last sorted signal.'],'FontSize',options.fontSize,'Interpreter','tex');

Error in signalSorter (line 603) [choices, safeExit] = chooseSignals(options,1:nSignals, inputImages,inputSignals,objMap, valid, inputStr,tmpDir,sessionID,signalPeakIdx,signalSnr,inputImagesThres,inputImageSizes,peakOutputStat,ROItraces,imgStats,inputSignalSignal,inputSignalNoise,inputImagesBoundaryIndices,signalPeakIdxOriginal,signalPeaksOriginal,instructionStr); @@@@@@@ 0 0 cellmap type: max @@@@@@@ Index exceeds the number of array elements (0).

Error in signalSorter>chooseSignals (line 1279) ' | imageCorr = ' num2str(round(peakOutputStat.outputMeanImageCorrs(i)*sigDig)/sigDig) ',' num2str(peakOutputStat.outputMeanImageCorrs2(i))...

Error in signalSorter (line 603) [choices, safeExit] = chooseSignals(options,1:nSignals, inputImages,inputSignals,objMap, valid, inputStr,tmpDir,sessionID,signalPeakIdx,signalSnr,inputImagesThres,inputImageSizes,peakOutputStat,ROItraces,imgStats,inputSignalSignal,inputSignalNoise,inputImagesBoundaryIndices,signalPeakIdxOriginal,signalPeaksOriginal,instructionStr); @@@@@@@ All warnings have the state 'off'. calculating movie min/max... finding centroids... Finding cell neighbors: 10|100 Done assigning neighbor IDs...

ans =

'Frame 1/4000'

@@@@@@@

bahanonu commented 2 years ago

Is this after running EXTRACT? Could you provide the following (will make it easier to debug):

milesOIST commented 2 years ago

Thanks for the quick response.

Matlab 2020b.

% EXTRACT output is stored in a structure called "output"

% Some configurations for the external cell checker iopts.inputMovie = M; % movie associated with traces iopts.valid = 'neutralStart'; % all choices start out gray or neutral to not bias user iopts.cropSizeLength = 20; % region, in px, around a signal source for transient cut movies (subplot 2) iopts.cropSize = 20; % see above iopts.medianFilterTrace = 0; % whether to subtract a rolling median from trace iopts.subtractMean = 0; % whether to subtract the trace mean iopts.backgroundGood = [208,229,180]/255; iopts.backgroundBad = [244,166,166]/255; iopts.backgroundNeutral = repmat(230,[1 3])/255;

% Run the external cell checker [inputImagesSorted, inputSignalsSorted, choices] = signalSorter(output.spatial_weights, output.temporal_weights', 'options',iopts);

the file is called output, which is a struct containing: spatial_weights which are 512x512x10 single. temporal_weights which are 4000x10 single info a struct config a struct

bahanonu commented 2 years ago

Great, thanks for the additional info. And I assume M is a matrix of size 512x512x4000?

Would you mind giving me a link to the MAT-file containing the outputs? I want to make sure the activity traces or spatial filters look okay then can get back on anything to change.

milesOIST commented 2 years ago

Yes, 512x512x4000 Here is the original file and the output from EXTRACT. https://filesender2.oist.jp/filesender/?s=download&token=f5d68055-5bcd-42c2-b233-0b51f5c85e52

bahanonu commented 2 years ago

Did a fresh download of the ciatah github repo and loaded the movie/EXTRACT output, the signalSorter interface loads fine for me in MATLAB 2020b on Windows 10 sans those errors, see below.

image

As a side note, checking the movie around transients for the example cell in the signalSorter GUI above, appeared that EXTRACT was missing cells (e.g. green circled below). Might be worth reducing cellfind_min_snr or similar parameters to find these cells.

image

This agrees with what I subsequently saw in a quick PCA-ICA analysis of the data via ciatah.

image

bahanonu commented 2 years ago

@123miles Got a notification of your message but don't see it here. Can change HDF5 extension to .h5 or .hdf5 and CIAtah should read it fine.

milesOIST commented 2 years ago

It worked! Apparently it is cap sensitive as changing from .HDF5 to .hdf5 worked.

milesOIST commented 2 years ago

I have managed to get it working in some contexts. But when I tried using code on the ciatah readme, I get the same looping error as before. I tried updating ciatah and forcing new downloads. I saw that there is an error with cvx_setup.m. I tried looking in external_programs as suggested, but there was no cvx_rd file. When I searched using Everything app I found an empty zip file in the Recycling Bin. I wonder if this is causing an issue. Is there somewhere I can download this file? I couldn't see a place to directly download cvx_rd on github.

bahanonu commented 2 years ago

To help with debugging, could you provide the commands you input that are causing the issue to arise? Also, what operating system are you on?

re: cvx, that shouldn't be causing the issue as it is only for CNMF. However, you can download it at http://web.cvxr.com/cvx/cvx-rd.zip then extract it to _external_programs if running ciapkg.io.loadDependencies is not working to download it.

milesOIST commented 2 years ago

Solved it! I had to change the processed movie regular expression and raw movie regular expression in the main GUI box (black background with buttons). I had been just setting these in the pop-up windows that come up when you load a video or method, but apparently that seems to result in a clash at some point and cause the looping error.

Thanks for the link. That's loading well now.