This repository has been archived by the owner. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deleted iterative shift correction and implemented cross correlation
- Loading branch information
1 parent
9fdec86
commit 9f5231e
Showing
4 changed files
with
119 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
function CellSortXCorr(nSubIm, nImages, m, n) | ||
% nSubIm = 10; | ||
% nImages = 1344; | ||
% m=14; | ||
% n=24; | ||
|
||
for k = m:n; | ||
% Compose image stack from filenames | ||
folder = sprintf('/storage/letz/Data/Data/Elisabeth_Abs/75EA/habituation/%u', k) | ||
if exist(folder) == 0 | ||
continue | ||
end | ||
folder_corr = '/storage/letz/Data/Data/Elisabeth_Abs/75EA/habituation/corrected'; | ||
|
||
file_image_red = [folder, 'ChanB_0001_0001_0001_0001.tif']; | ||
filePrefix_red = 'ChanB_0001_0001_0001_'; | ||
|
||
file_image_green = [folder, 'ChanA_0001_0001_0001_0001.tif']; | ||
filePrefix_green = 'ChanA_0001_0001_0001_'; | ||
|
||
filename_red = sprintf([folder,filesep,filePrefix_red,'%04u.tif'],1); | ||
im_red = imread(filename_red); | ||
|
||
filename_green = sprintf([folder,filesep,filePrefix_green,'%04u.tif'],1); | ||
im_green = imread(filename_green); | ||
|
||
%preallocate data variable | ||
allIm_red = zeros(size(im_red,1),size(im_red,2),nImages); | ||
%read tiffs | ||
for i = 1:nImages | ||
filename_red = sprintf([folder,filesep,filePrefix_red,'%04u.tif'],i); | ||
allIm_red(:,:,i) = readTiffNoStack(filename_red); | ||
end | ||
|
||
%preallocate data variable | ||
allIm_green = zeros(size(im_green,1),size(im_green,2),nImages); | ||
%read tiffs | ||
for i = 1:nImages | ||
filename_green = sprintf([folder,filesep,filePrefix_green,'%04u.tif'],i); | ||
allIm_green(:,:,i) = readTiffNoStack(filename_green); | ||
end | ||
|
||
|
||
[rs, cs] = medAlign(allIm_red, nSubIm, 50, -inf); | ||
|
||
registered = zeros(size(allIm_red,1),size(allIm_red,2),size(allIm_red,3), class(allIm_red)); | ||
parfor i = 1:nImages | ||
registered(:,:,i) = circshift(allIm_red(:,:,i),[rs(i),cs(i)]); | ||
end | ||
|
||
data = binning(registered,[1,1,2],'mean'); | ||
|
||
filename = sprintf([folder_corr,filesep,'red_%u.tiff'],k); | ||
for j=1:(nImages/2) | ||
imwrite(uint16(data(:,:,j)),filename, 'tiff','WriteMode','append'); | ||
end | ||
|
||
|
||
|
||
%align green channel with parameters from red alignment | ||
parfor i = 1:nImages | ||
registered(:,:,i) = circshift(allIm_green(:,:,i),[rs(i),cs(i)]); | ||
end | ||
|
||
data = binning(registered,[1,1,2],'mean'); | ||
|
||
filename = sprintf([folder_corr,filesep,'green_%u.tiff'],k); | ||
for j=1:(nImages/2) | ||
imwrite(uint16(data(:,:,j)),filename, 'tiff','WriteMode','append'); | ||
end | ||
|
||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
function data = readTiffNoStack(filename) | ||
t_g = Tiff(filename, 'r'); | ||
data = t_g.read(); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
fn = 'test.tif'; | ||
|
||
tic; | ||
|
||
for i=1:5000 | ||
data = readTiff(fn); | ||
end | ||
|
||
timeReadTiff = toc; | ||
|
||
tic; | ||
for i=1:5000 | ||
data = imread(fn); | ||
end | ||
|
||
timeImread = toc; | ||
|
||
|
||
tic; | ||
for i=1:5000 | ||
data = readTiffNoStack(fn); | ||
end | ||
|
||
timeNoStack = toc; | ||
|
||
tic; | ||
for i=1:5000 | ||
t_g = Tiff(fn, 'r'); | ||
data = t_g.read(); | ||
end | ||
|
||
timeNoStackNoFunction = toc; |