Giter Site home page Giter Site logo

bmorris3 / shampoo Goto Github PK

View Code? Open in Web Editor NEW
19.0 4.0 11.0 6.66 MB

An open source digital holographic microscopy toolkit in Python.

Home Page: http://shampoo.readthedocs.org/en/latest/

Python 97.35% Shell 2.65%
holography python microscopy open-source numerical-reconstruction

shampoo's Introduction

shampoo's People

Contributors

bmorris3 avatar bsipocz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

shampoo's Issues

Missing feature: magnification

The current implementation of shampoo doesn't account for the magnification of the main objective, so the propagation distances aren't correct.

The propagation distance should be divided by the square of the MO's magnification, which I've been told is usually 19-20 for shampoo.

Error with shampoo.test()

I run shampoo.test() and get an error. Could someone help me fix this problem?
It says TypeError: 'float' object cannot be interpreted as an index
image
image

Reconstruction of non-square holograms raises error

Reconstructing holograms with shape that is non-square yields a ValueError from the Hologram.apodize method.

Below is a script that reproduces the error, using data from the repository

import numpy as np
import os.path
from shampoo import Hologram

FILEPATH = 'USAF_test.tif'

if __name__ == '__main__':

    hologram = Hologram.from_tif(FILEPATH)
    original_shape = hologram.hologram.shape
    print('Image shape is square: {}'.format(original_shape))

    reshaped_data = np.resize(hologram.hologram, new_shape = (original_shape[0], original_shape[1] - 10))
    reshaped_hologram = Hologram(reshaped_data)
    print('New shape is not square: {}'.format(reshaped_data.shape))

    reconstructed = reshaped_hologram.reconstruct(propagation_distance = 0.03865)

This is a problem because some Allied Vision cameras have a resolution of 2550 x 2548

Error Installing SHAMPOO

I downloaded git and performed the first two commands successfully (cloning the git repository then cd shampoo), however the third "install" command produces the following error:

Shamu@NadeauLab-DHM MINGW64 ~/shampoo (master)
$ python setup.py install
Initializing astropy_helpers submodule with: git submodule update --init -- astropy_helpers
Freezing version number to shampoo\version.py
running install
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

[Errno 13] Permission denied: 'C:\\Program Files\\Anaconda3\\Lib\\site-packages\\test-easy-install-10176.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

C:\Program Files\Anaconda3\Lib\site-packages\

Perhaps your account does not have write access to this directory? If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account. If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.

For information on other options, you may wish to consult the
documentation at:

https://setuptools.readthedocs.io/en/latest/easy_install.html

Please make the appropriate changes for your system and try again.

I am the administrator on my Windows 10 pc, so I don't understand why it did not work.
Any Ideas?

Thanks,
-Marwan

Is the picture specific?

when i try run the demo use fro my picture, the error is coming. of course, I have modified some parameters. for example, wavelength、dx and dy ...
so, Can you provide some photo collections? or explain the specific format of the input picture.
thank you very much,Your code has a great help for me .

Raise warning if pyfftw not installed

To encourage people to use pyfftw, which can be 2x faster than scipy's FFT implementation, let's raise a warning when pyfftw is unavailable and shampoo falls back to scipy's FFT.

Efficiency: calculate G only on mask

Suggestion from @jkentwallace: Currently, the Fourier transform of the impulse response function G, calculated in Hologram.fourier_trans_of_impulse_resp_func operates on the whole FT(hologram) matrix, but we only need to compute it on the non-zero portions of the Fourier mask.

Modify this line to compute the mask only on the portions that are non-zero in the Fourier mask.

Feature request: adjustable Fourier mask attribute

In the weekly telecon, @LaurentRDC requested, and @jkentwallace seconded the request, to:

  1. Make a more general interface to the Fourier mask, such that the mask is an attribute that can be edited, and reconstructions repeated with the updated mask.

  2. Save the raw Fourier mask within the HDF5 archive, so that reconstructions are reproducible.

Efficiency: switch to using fftshift method

The current implementation of shift_peak uses numpy.roll to shift the FT spectrum on two axes, one at a time. This might be inefficient compared to the purpose-built scipy method for this task, scipy.fftpack.fftshift.

Wherever shift_peak is used, let's swap it for scipy.fftpack.fftshift and ifftshift – or numpy.fft.fftshift, whichever is most efficient.

MNT: Stop using ci-helpers in appveyor.yml

To whom it may concern,

If you are using https://github.com/astropy/ci-helpers in your appveyor.yml , please know that the Astropy project has dropped active development/support for Appveyor CI. If it still works, good for you, because we did not remove the relevant files (yet). But if it ever stops working, we have no plans to fix anything for Appveyor CI. Please consider using native Windows support other CI, e.g., Travis CI (see https://docs.travis-ci.com/user/reference/windows/). We apologize for any inconvenience caused.

If this issue is opened in error or irrelevant to you, feel free to close. Thank you.

xref astropy/ci-helpers#464

ModuleNotFoundError

I ran the shampoo.test() when the shampoo installation completed in linux,a issue named "Module Not FoundError :No module named 'astropy.tests.pytest_plugins'",why?how should i deal with it?

HDF5 Storage of ReconstructedWave object

This has been discussed extensively, and Brett suggested the following hierarchy:

/t0000/hologram
/t0000/wavelength0/intensity
/t0000/wavelength0/phase
/t0000/wavelength0/fourier_mask
/t0000/wavelength1/intensity
/t0000/wavelength1/phase
/t0000/wavelength1/fourier_mask

/t0001/hologram
/t0001/wavelength0/intensity
/t0001/wavelength0/phase
/t0001/wavelength0/fourier_mask
...

Let's discuss the practical implementation of this in this issue.

Docs wishlist

Talking with @gshowalt, we isolated some places where the documentation could be fleshed out more. Let's make a list here of the docs we would like to have.

  • tutorial showing reconstructions at multiple time steps.

RuntimeWarning: invalid value encountered in sqrt np.sqrt(1.0 - first_term - second_term))

This is my first attempt at using shampoo. I am getting the following error with the USAF_test.tif in the repo:

\Anaconda3\lib\site-packages\shampoo-0.1.dev156-py3.5.egg\shampoo\reconstruction.py:419: RuntimeWarning: invalid value encountered in sqrt
np.sqrt(1.0 - first_term - second_term))

The code I am using is here:

from shampoo import Hologram
import matplotlib.pyplot as plt

hologram_path = 'C:\\Users\\xxxxx\\Desktop\\usaf_sqt.tiff'
propagation_distance = 0.03685  # m
h = Hologram.from_tif(hologram_path, wavelength=470e-6, dx=3.5e-6, dy=3.5e-6)
wave = h.reconstruct(propagation_distance)
fig, ax = wave.plot()
fig.suptitle("USAF Target")
fig.tight_layout()
plt.show()

I have tried my own .tif and I get the same result. I have also tried modifying the propagation_distance, wavelength and dx,dy variables, but I get the same problem.

Inefficient pyfftw implementation: order of magnitude speedups possible!

@jkentwallace @LaurentRDC – I've begun doing some profiling, and I'm looking to see where the bottlenecks are. In this test I'm reconstructing the USAF test target example file at one propagation distance:

screen shot 2016-11-24 at 10 35 35 am

49% of the runtime is spent within the pyfftw module's Fourier transform, which confirms that the secondary optimizations like doing arithmetic on masked arrays are probably secondary in importance to figuring out how to do FFTs more efficiently. Reading up on pyfftw, it looks like there's a very specific way to uses it that allows for the speedups that I expected.

In simple comparison with scipy's FFT, my current implementation with pyfftw is almost an order of magnitude slower for reconstructing a single hologram – I'm going to need to spend some time understanding this issue. If you'd like to see how much quicker shampoo could be going simply by switching to scipy's FFT temporarily, comment out this block of imports and replace it with only the scipy import line.

The next slowest step is the phase unwrapping, which is being done in C wrapped in Python with this algorithm: reference, source code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.