Skip to content

Commit

Permalink
Add example images and usage example
Browse files Browse the repository at this point in the history
  • Loading branch information
raacampbell committed Aug 14, 2018
1 parent ba20a01 commit 138500c
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.DS_Store
53 changes: 41 additions & 12 deletions @hilospeckle/hilospeckle.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
end

properties (Hidden)
doVectorisedCamOTF=true
verbose = false
padded %boolean - true if images were padded
impLo %The "Lo" image
Expand All @@ -65,6 +66,13 @@
return
end

try
gpuDevice
catch
obj.doGPU=false;
fprintf('Disabling GPU acceleration: no device found\n')
end

obj.uniformIm = uniformIm;
obj.speckleIm = speckleIm;
obj.runHiLo;
Expand Down Expand Up @@ -183,24 +191,45 @@ function showResults(obj)



function pixel = createCameraOTF(~, imWidth, imHeight)
function pixel = createCameraOTF(obj, imWidth, imHeight)
% Tested and produces something that looks plausible
pixel = ones(imHeight, imWidth);


X = (2 * (1:imWidth) - imWidth) * pi / imWidth;
Y = (2 * (1:imHeight) - imHeight) * pi / imHeight;

if obj.doVectorisedCamOTF %Faster but doesn't yield exactly the same answer as the loop
[xx,yy] = meshgrid(X,Y);

pixel=sin(xx) .* sin(yy) ./ (xx .* yy);

f=(xx == 0 & yy ~= 0);
t = sin(yy(f))./yy(f);
pixel(f)=t;

f=(xx ~= 0 & yy == 0);
t = sin(xx(f))./xx(f);
pixel(f)=t;

f=(xx == 0 & yy == 0);
pixel(f)=1;

pixel(pixel<0) = 0;
return
end

pixel = ones(imHeight, imWidth,'single');
for x = 1:imWidth
for y = 1:imHeight

x1 = (2 * x - imWidth) * pi / imWidth;
y1 = (2 * y - imHeight) * pi / imHeight;

if x1 ~= 0 && y1 ~= 0
pixel(y,x) = sin(x1) * sin(y1) / x1 / y1;
if X(x) ~= 0 && Y(y) ~= 0
pixel(y,x) = sin(X(x)) * sin(Y(y)) / (X(x) * Y(y));

elseif x1 == 0 && y1 ~= 0
pixel(y,x) = sin(y1) / y1;
elseif X(x) == 0 && Y(y) ~= 0
pixel(y,x) = sin(Y(y)) / Y(y);

elseif x1 ~= 0 && y1 == 0
pixel(y,x) = sin(x1) / x1;
elseif X(x) ~= 0 && Y(y) == 0
pixel(y,x) = sin(X(x)) / X(x);
%otherwise it's a one
end

Expand All @@ -213,7 +242,7 @@ function showResults(obj)


function pixel = createImagingOTF(obj, numericalAperture, wavelengthInNM, sizeX, sizeY)
% Tested but tends to yield zero arrays
% Tested and seem to yield something meaningful
BandWidth = 2 * numericalAperture / (wavelengthInNM * 1E-9);
scaleUnits = obj.magnification / (obj.pixelSize * 1E-6) / BandWidth;

Expand Down
10 changes: 8 additions & 2 deletions @hilospeckle/runHiLo.m
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,15 @@ function runHiLo(obj)

obj.impLo = obj.impLo .* obj.eta;
obj.HiloFinal(:,:,ii) = obj.impLo + obj.impHi;

end %for ii = 1:size(obj.uniformIm,3)
obj.HiloFinal(obj.HiloFinal<0)=0;
obj.HiloFinal = uint16(obj.HiloFinal/max(obj.HiloFinal(:))*2^16);
fprintf('\nCompleted in %0.1f s\n', toc)
T=toc;
if T<2
fprintf('\nCompleted in %0.3f s\n', T)
else
fprintf('\nCompleted in %0.1f s\n', T)
end

end % hilo
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

This is a very basic MATLAB implementation of the HiLo algorithm for structured illumination.

## Usage
```
H=hilospeckle(ImageUniform, ImageSpeckle); %Run and show result image
clf, imagesc(H.HiloFinal), axis equal off %re-plot result image
%Change a setting and re-run
H.targetThickness=4;
H.runHiLo
H.showResults
%Swap the speckle image with the unform image and re-run to compare with above
H.speckleIm = H.uniformIm;
H.runHiLo
figure
H.showResults
```


###
References
Expand Down
Binary file added example_images/HiLo_ImageJ_result_image.tif
Binary file not shown.
21 changes: 21 additions & 0 deletions example_images/Readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

HiLo_ImageJ_result_image.tiff was produced the by the HiLo ImageJ plugin using the "uniform_image" and "structured_speckle_image" with settings:


Camera gain: 0.15
Readout noise: 1.64
Magnification: 40
Pixel size: 22.2
Illumination wavelength: 488
Detection wavelength: 520
Illumination NA: 0.30
Detection NA: 0.40

Depth field multiplier: 2.0
HiLo weighting: 3.0



The image shows GFP-labeled neurons in a mouse cortex slice and comes from the Mertz lab home page: http://biomicroscopy.bu.edu/resources/4

These images can be used to validate the output of the MATLAB code with respect to that produced by ImageJ.
Binary file added example_images/structured_speckle_image.tif
Binary file not shown.
Binary file added example_images/uniform_image.tif
Binary file not shown.

0 comments on commit 138500c

Please sign in to comment.