Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

speed bump in assembleCorrectedROITiff #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions assembleCorrectedROITiff.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,38 @@
numPX = roiGroup.rois(1,1).scanfields.pixelResolutionXY;
pixelResolution = mean(FOV./numPX);

% find size of final assembled FOV
strip=1; channel=1; frame=1;
stripTemp = roiData{1,strip}.imageData{1,channel}{1,frame}{1,1};
roiSize = size(stripTemp);
corr = returnScanOffset2(stripTemp,1); % find offset correction
stripTemp = fixScanPhase(stripTemp,corr,1); % fix scan phase
val = round(size(stripTemp,1)*0.03); % trim excess
stripTemp = stripTemp(val:end,7:138,:,:);

fullPXx = size(stripTemp,1); % final FOV x size (px)
fullPXy = size(stripTemp,2) * numROIs; % final FOV y size (px)

%% Assemble frames
imageData = [];
imageData = zeros(fullPXx, fullPXy, totalChannel,totalFrame, 'single');
for channel = 1:totalChannel
disp(['Assembling channel ' num2str(channel) ' of ' num2str(totalChannel) '...'])
frameTemp = [];

for strip = 1:numROIs

% Generate the time series of each ROI in the data
stripTemp = [];

stripTemp = zeros(roiSize(1), roiSize(2), 1, totalFrame, 'single');
for frame = 1:totalFrame
stripTemp = cat(4,stripTemp,single(roiData{1,strip}.imageData{1,channel}{1,frame}{1,1}));
stripTemp(:,:,1,frame) = single(roiData{1,strip}.imageData{1,channel}{1,frame}{1,1});
end
corr = returnScanOffset2(stripTemp,1); % find offset correction
stripTemp = fixScanPhase(stripTemp,corr,1); % fix scan phase
val = round(size(stripTemp,1)*0.03); % trim excess
stripTemp = stripTemp(val:end,7:138,:,:);

frameTemp = cat(2,frameTemp,stripTemp); % create each frame


yy = (strip-1)*fullPXy / numROIs+1:strip*fullPXy / numROIs; % y indices of current strip
imageData(:,yy,channel,:) = stripTemp;

end

imageData = single(cat(3,imageData,frameTemp));

end