Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
added a script for import, alignement and export of stack data
  • Loading branch information
MPIBR-vollrathf committed Apr 24, 2018
1 parent 0e4bed4 commit c49d196
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions realignementScript.m
@@ -0,0 +1,50 @@
%% 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);

0 comments on commit c49d196

Please sign in to comment.