Skip to content

Commit

Permalink
tileLoad returns stage positions if required.
Browse files Browse the repository at this point in the history
  • Loading branch information
raacampbell committed May 12, 2020
1 parent c89379c commit 74bb94c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 23 deletions.
2 changes: 1 addition & 1 deletion code/preProcessTiles/preProcessTiles.m
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@
combFile=fullfile(sectionStatsDirName,'phaseStats_01.mat');
if length(sectionsToProcess)==1 && sectionsToProcess==0 && exist(combFile,'file')
fprintf('%s exists. Skipping this comb correction\n',combFile)
else
else
% load channel if needed
notLoaded = arrayfun(@(x) isempty(imStack{x,1}), combCorChans);
[imStack, tileIndex, loadError] = load_imstack(imStack, tileIndex, param, ...
Expand Down
19 changes: 16 additions & 3 deletions code/stitching/tileLoad.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [im,index]=tileLoad(coords,varargin)
function [im,index,stagePos]=tileLoad(coords,varargin)
% Load raw tile data as a stack for processing by StitchIt
%
% function [im,index]=tileLoad(coords,'Param1', Val1, 'Param2', Val2, ...)
Expand Down Expand Up @@ -50,7 +50,8 @@
% 3. optical section
% 4. tile row
% 5. tile column
%
%
% stagePos - structure containing stage positions in mm
%
%
% EXAMPLES
Expand Down Expand Up @@ -334,7 +335,18 @@
end



% get stage positions if requested
if nargout>2
stagePos=[];
posFname = fullfile(sectionDir,'tilePositions.mat');
if exist(posFname)
load(posFname,'positionArray')
stagePos.targetPos.X = positionArray(:,3);
stagePos.targetPos.Y = positionArray(:,4);
stagePos.actualPos.X = positionArray(:,5);
stagePos.actualPos.Y = positionArray(:,6);
end
end

%Calculate average filename from tile coordinates. We could simply load the
%image for one layer and one channel, or we could try odd stuff like averaging
Expand All @@ -354,3 +366,4 @@
end

%/COMMON

18 changes: 0 additions & 18 deletions code/utils/readMetaData2Stitchit.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@
out = recipe2StitchIt(rawOut,fname);


% Add stage position data


%------------------------------------------------------------------------
% Internal functions follow. This is just for tidiness.

Expand Down Expand Up @@ -124,18 +121,3 @@
if out.mosaic.sliceThickness<1
out.mosaic.sliceThickness = out.mosaic.sliceThickness*1E3;
end


function out = addStagePositions(recipeStruct,positionMatrix)
% Add stage position data associated with each tile to the recipe file
if ~isempty(raw.XPos)
out.stageLocations.requestedStep.X = raw.XPos(:,1); %What was the motion step requested by the microscope?
out.stageLocations.expected.X = cumsum(raw.XPos(:,1)); %Infer what the position shoudld be
out.stageLocations.reported.X = raw.XPos(:,2);
end

if ~isempty(raw.YPos)
out.stageLocations.requestedStep.Y = raw.YPos(:,1); %What was the motion step requested by the microscope?
out.stageLocations.expected.Y = cumsum(raw.YPos(:,1)); %Infer what the position shoudld be
out.stageLocations.reported.Y = raw.YPos(:,2);
end
2 changes: 1 addition & 1 deletion code/visualisations/peekSection.m
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
% if the images haven't been illumination-corrected for vignetting.
%tileIndex=flipud(tileIndex);


% Stitch using theoretical pixel positions
pixelPositions=ceil(gridPos2Pixels(tileIndex,[param.voxelSize.X,param.voxelSize.Y]));
stitchedImage = stitcher(im,pixelPositions);

Expand Down

0 comments on commit 74bb94c

Please sign in to comment.