Preprocessing: Spatial filtering - bahanonu/ciatah GitHub Wiki
https://bahanonu.github.io/ciatah/
Please use the online documentation website going forward:Movie Filtering
This page documents different functions in the repository variable for filtering (spatial high/low/bandpass) movies to remove neuropil, cells, or other features.
options.freqLow = 1;
options.freqHigh = 4;
inputMovie = normalizeMovie(single(inputMovie),'normalizationType','lowpassFFTDivisive','freqLow',options.freqLow,'freqHigh',options.freqHigh,'waitbarOn',1,'bandpassMask','gaussian');
Images from unit test
Main filtering functions.
Below is a screen grab from a random frame using all the filtering functions. A nice way to quickly see the many differences between each functions filtering.
Test function filtering
This is currently only for the Matlab fft, but I'll see about expanding to others.
unitNormalizeMovie;
Matlab test function
- I've also added the ability to test the parameter space of the Matlab fft, use the below command.
testMovieFFT = normalizeMovie(testMovie,'normalizationType','matlabFFT_test','secondaryNormalizationType','lowpassFFTDivisive','bandpassMask','gaussian','bandpassType','lowpass');
- Should get a movie output similar to the below, where there is the original movie, the FFT movie, the original/FFT movie, and the dfof of original/FFT movie.
Matlab test function movie output
Similar to above, showing results when using lowpassFFTDivisive
normalization (matlab divide by lowpass before registering
in modelPreprocessMovie
and viewMovieRegistrationTest
functions) with freqLow = 0
and freqHigh
set to 1
, 4
, and 20
. This corresponds to removing increasingly smaller features from the movie.
ImageJ test function
To test the ImageJ FFT and determine the best parameters for a given set of movies, run the following function on a test movie matrix:
inputMovieTest = normalizeMovie(inputMovie,'normalizationType','imagejFFT_test');
The output should look like the below:
Common Issues
A list of some common issues.
Dark halos around cells
If the spatial filter is not properly configured then dark halos will appear around high SNR cells, potentially obscuring nearby, low SNR cells.
https://github.com/schnitzer-lab/miniscope_analysis/pull/30
-
FYI, for 4x downsampled movies,
highFreq
parameter of 4 (which corresponds to afspecial
gaussian with std of 4) produces the closest results to ImageJProcess->FFT->Bandpass Filter...
with inputs offilter_large=10000 filter_small=80 suppress=None tolerance=5
(the current default innormalizeMovie
). -
Example frame from ImageJ and Matlab FFTs.
-
Distribution of pixel differences between ImageJ and Matlab FFT movies.
-
This matches the filter that ImageJ says it uses, which is fairly close to the Matlab filter.
Example video: 2015_11_25_p384_m610_openfield01
- Below is an example comparison using the following Matlab commands to produce the filtered inputs:
testMovieFFT = normalizeMovie(testMovie,'normalizationType','lowpassFFTDivisive','freqHigh',7);
testMovieFFTImageJ = normalizeMovie(testMovie,'normalizationType','imagejFFT');
diffMovie = testMovieFFT-testMovieFFTImageJ ;
- With some tweaking of the
freqHigh
and other parameters, should hopefully be able to get closer to macheps and say that the two are identical for our purposes.
- This is the histogram of the difference movie (Matlab - ImageJ). Notice most of the values are centered around zero with stdev ~0.2% df/f.