From 6d66ecb294798421bedb09f260dae746e83b3f4e Mon Sep 17 00:00:00 2001 From: jmmanley Date: Tue, 21 Jun 2022 18:00:57 -0400 Subject: [PATCH 1/2] optimize assembleCorrectedROITiff - get rid of all the cat() --- assembleCorrectedROITiff.m | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/assembleCorrectedROITiff.m b/assembleCorrectedROITiff.m index f4030ad..88a371d 100644 --- a/assembleCorrectedROITiff.m +++ b/assembleCorrectedROITiff.m @@ -12,27 +12,40 @@ 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 = []; + frameTemp = zeros(fullPXx, fullPXy / numROIs, 1, totalFrame, 'single'); for strip = 1:numROIs % Generate the time series of each ROI in the data - stripTemp = []; + + stripTemp = zeros(roiSize(1), roiSize(2), 1, totalFrame); 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; + frameTemp(:,yy,1,:) = stripTemp; end - imageData = single(cat(3,imageData,frameTemp)); - + imageData(:,:,channel,:) = frameTemp; end \ No newline at end of file From e3d21bd38a92a30f51ac01605b4e111d79c739c3 Mon Sep 17 00:00:00 2001 From: jmmanley Date: Fri, 17 Feb 2023 10:08:09 -0500 Subject: [PATCH 2/2] change imageData to single --- assembleCorrectedROITiff.m | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/assembleCorrectedROITiff.m b/assembleCorrectedROITiff.m index 88a371d..f1a6c22 100644 --- a/assembleCorrectedROITiff.m +++ b/assembleCorrectedROITiff.m @@ -28,12 +28,12 @@ imageData = zeros(fullPXx, fullPXy, totalChannel,totalFrame, 'single'); for channel = 1:totalChannel disp(['Assembling channel ' num2str(channel) ' of ' num2str(totalChannel) '...']) - frameTemp = zeros(fullPXx, fullPXy / numROIs, 1, totalFrame, 'single'); + for strip = 1:numROIs % Generate the time series of each ROI in the data - stripTemp = zeros(roiSize(1), roiSize(2), 1, totalFrame); + stripTemp = zeros(roiSize(1), roiSize(2), 1, totalFrame, 'single'); for frame = 1:totalFrame stripTemp(:,:,1,frame) = single(roiData{1,strip}.imageData{1,channel}{1,frame}{1,1}); end @@ -42,10 +42,8 @@ val = round(size(stripTemp,1)*0.03); % trim excess stripTemp = stripTemp(val:end,7:138,:,:); - yy = (strip-1)*fullPXy / numROIs+1:strip*fullPXy / numROIs; - frameTemp(:,yy,1,:) = stripTemp; - + yy = (strip-1)*fullPXy / numROIs+1:strip*fullPXy / numROIs; % y indices of current strip + imageData(:,yy,channel,:) = stripTemp; + end - - imageData(:,:,channel,:) = frameTemp; end \ No newline at end of file