tjof2 / pgure-svt Goto Github PK
View Code? Open in Web Editor NEWSingular value thresholding for denoising time-resolved microscopy
Home Page: https://tjof2.github.io/pgure-svt/
License: GNU General Public License v3.0
Singular value thresholding for denoising time-resolved microscopy
Home Page: https://tjof2.github.io/pgure-svt/
License: GNU General Public License v3.0
Parallelization over frames / frame blocks would be better than the current inner-loop implementation.
Offending line no. 77 in noise.hpp
- robust means and variance arrays are sometimes too small compared to the number of patches resulting from the quadtree segmentation:
// Perform quadtree decomposition of frames
// to generate patches for noise estimation
int maxVsize = (Nx/size)*(Ny/size);
arma::vec means = -1 * arma::ones<arma::vec>(T*maxVsize);
arma::vec vars = -1 * arma::ones<arma::vec>(T*maxVsize);
Current "fix" on line 84 doesn't always help - still get an Armadillo error on some noise estimation problems. Thanks to @bm424 for reminding me.
Especially for HyperSpy wrapper.
Overhaul of much of the code to improve maintenance, as well as add new features and enhance performance on larger images.
The main change will be switching from standalone executable to a Python-wrapped library, thus removing need to maintain LibTIFF support and I/O functions, and easier parameter checking than currently. A compiled library can then be distributed with the next release.
Task list
Currently the Python wrapper only returns the denoised image sequence. It would be good to return the noise estimates as well as the optimized threshold.
I am trying to compile on OSX following the installation instruction and running into the following error when running make
in the build directory.
...
[ 50%] Building CXX object CMakeFiles/pguresvt.dir/src/lib-PGURE-SVT.cpp.o
/Users/grr/pgure-svt-0.3.3/src/lib-PGURE-SVT.cpp:57:10: fatal error: 'omp.h'
file not found
#include <omp.h>
^
1 error generated.
...
I'm not an expert in compiling, but have gathered that OSX is using clang and not gcc for compiling, but I'm not exactly sure how to get around this issue.
Currently set to one pixel (for accuracy) which is fine for small frame sizes, but problematic in terms of both memory and performance for larger frames (512x512 etc.) - should have an option to reduce the overlap.
Along with a "OSError: [WinError -529697949] Windows Error 0xe06d7363" output in the notebook. Anyway, seems to be the c++ code failing, not the python, so its a good bit less transparent.
On every few image series I have been denoising I have gotten this error in the jupyther notebook terminal window. Have not really been a problem, except now with the latest batch of really good data, almost half the series are failing, so I have to get it fixed.
Previously it seems to have come from 1) some series with corrupt data at late frames (recording error), while 2) some recordings I cannot find anything wrong with, where some it works if I rerun, while others never work. These latest, though seems to be mostly of the 2) type.
Any idea how to attack it?
edit: OSError
Aiming for April 30th.
Often sample drift is a big problem in time-resolved microscopy. Although the PGURE-SVT algorithm can deal with small shifts through the use of the ARPS motion estimation step, it would be good to "pre-align" the image sequence with single pixel accuracy* to help reduce any issues.
Easiest way is to use cross-correlation.
*sub-pixel accuracy would mean interpolation, which is problematic for low SNR images
Code currently fails to deal with non-square images.
i.e. missing the appropriate MSVCRT.dll
etc.
Current HyperSpy wrapper was written for an old version - needs updating to work with v1.1.
Currently untested on OSX.
The Python version offers the ability to control the number of threads used when OpenMP is enabled, through the parameter num_threads
.
This is not enabled in the standalone version.
e.g. the example test
pgure-svt/pguresvt/tests/test_pguresvt.py
Lines 18 to 44 in 4511672
seems to return non-deterministic results each time (hence the pytest.mark.xfail()
). Unclear of cause at the moment.
Noise estimation currently supports images up to 1024x1024 pixels, since PGURE-SVT was designed for small images.
Probably worth supporting larger images e.g. from a K2 camera.
It would be good to package pgure-svt on conda-forge.
The HyperSpy wrapper is quite out-of-date with https://github.com/hyperspy/hyperspy - noting here that it should be updated.
@bm424 can you investigate this please? Possibly something to do with latest version of HyperSpy using Python 3?
Enable importing of HDF5 files as well as TIFF stacks (will require libhdf5 linking).
Currently PGURE-SVT acts on the full image sequence. However, there are cases e.g. in an aligned/registered image sequence where certain regions of the frame should not be included in the denoising, as they are not part of the field of view.
Currently the only way to deal with this is to crop the full image sequence to the correct size, but this loses information in other frames. Adding a masking feature would be useful.
In the absence of a robust PCA approach using multiple SVT iterations and an l1-norm, a simple method for detecting hot pixels in CCD data needs to be implemented.
When building using conda-build, the example of README.md
raises an error:
import numpy as np
from pguresvt import pguresvt
# Example dataset has dimensions (nx, ny, T),
# in this case a 128x128px video with 25 frames
X = np.random.randn(128, 128, 25)
# Initialize the algorithm
# with default parameters
svt = pguresvt.SVT()
# Run the algorithm on the data X
svt.denoise(X)
error:
error: Mat::operator(): index out of boundsMat::operator(): index out of bounds
terminate called after throwing an instance of 'std::logic_error'
terminate called recursively
what(): Mat::operator(): index out of bounds
The test suite works fine.
Currently the Python wrapper converts the data to np.uint16
- but the C++ does support different types. Supporting float and double would be a good start.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.