diff --git a/code/preProcessTiles/preProcessTiles.m b/code/preProcessTiles/preProcessTiles.m index a18683e..4cd16d5 100644 --- a/code/preProcessTiles/preProcessTiles.m +++ b/code/preProcessTiles/preProcessTiles.m @@ -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, ... diff --git a/code/stitching/tileLoad.m b/code/stitching/tileLoad.m index d58e8f3..ecdf9a7 100644 --- a/code/stitching/tileLoad.m +++ b/code/stitching/tileLoad.m @@ -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, ...) @@ -50,7 +50,8 @@ % 3. optical section % 4. tile row % 5. tile column -% +% +% stagePos - structure containing stage positions in mm % % % EXAMPLES @@ -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 @@ -354,3 +366,4 @@ end %/COMMON + diff --git a/code/utils/readMetaData2Stitchit.m b/code/utils/readMetaData2Stitchit.m index df49cc9..86b301f 100644 --- a/code/utils/readMetaData2Stitchit.m +++ b/code/utils/readMetaData2Stitchit.m @@ -86,9 +86,6 @@ out = recipe2StitchIt(rawOut,fname); -% Add stage position data - - %------------------------------------------------------------------------ % Internal functions follow. This is just for tidiness. @@ -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 \ No newline at end of file diff --git a/code/visualisations/peekSection.m b/code/visualisations/peekSection.m index 25eea82..c6c8480 100644 --- a/code/visualisations/peekSection.m +++ b/code/visualisations/peekSection.m @@ -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);