Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
%% Paramters
%input file
inFileGren = 'D:\data\BelenTestData\Out\complete_g.tif';
inFileRed = 'D:\data\BelenTestData\Out\complete_g.tif';
%oiutput file
outFileGreen = 'D:\data\BelenTestData\Out\complete_g_Grealigned.tif';
outFileRed = 'D:\data\BelenTestData\Out\complete_g_Rrealigned.tif';
%Apply Gaussian Filter before correction?
bGaussian = 0;
%reference channels
referenceChannel = 1; %1: red, 0: green
numShiftCorrections = 1;
nSubIm = 200;%number of subImages for med align
numImages = 50; %number of images that will be meaned for global shift correction
%% Load data and perform correction
data_r = loadtiff(inFileRed);
data_g = loadtiff(inFileGren);
for j = 1:numShiftCorrections
if referenceChannel
referenceChannelData = data_r;
else
referenceChannelData = data_g;
end
if bGaussian
for f=1:size(referenceChannelData,3)
referenceChannelData(:,:,f) = imgaussfilt(referenceChannelData(:,:,f),2);
end
end
%Med Align
[rs, cs] = medAlign(referenceChannelData, nSubIm, 50, -inf);
%shift red and green channel
%waitbar(j/numShiftCorrections, wb, 'Performing Med Align..');
for i = 1:size(data_g,3)
data_r(:,:,i) = circshift(data_r(:,:,i),[rs(i),cs(i)]);
data_g(:,:,i) = circshift(data_g(:,:,i),[rs(i),cs(i)]);
end
end
%% Exort Data
saveastiff(data_r, outFileRed);
saveastiff(data_g, outFileGreen);