% % % Smooth time Function for Imaris % % Copyright Bitplane AG 2006 % % % Installation: % % - Copy this file into the XTensions folder in the Imaris installation directory. % - You will find this function in the Image Processing menu % % % % % Matlab::BPSmoothTime(%i) % % % % % % Description: % % Smooth the intensity of each voxel along the time dimension using a % gaussian filter. % % function BPSmoothTime(aImarisApplicationID, aSigma, aChannelIndex) % connect to Imaris Com interface if ~isa(aImarisApplicationID, 'COM.Imaris_Application') vImarisServer = actxserver('ImarisServer.Server'); vImarisApplication = vImarisServer.GetObject(aImarisApplicationID); else vImarisApplication = aImarisApplicationID; end vImarisApplication.DataSetPushUndo('Smooth Time'); % get the data set vImarisDataSet = vImarisApplication.mDataSet.Clone; vChannelIndex = 1; for vChannelId = 1:vImarisDataSet.mSizeC if vImarisApplication.GetChannelVisibility(vChannelId-1) == true vChannelIndex = vChannelId; break; end end if nargin<3 vSigma = 1; vAnswer = inputdlg({'Channel','Filter Width'}, 'Smooth Time', ... 1, {num2str(vChannelIndex),num2str(vSigma)}); if isempty(vAnswer) return; else vChannelIndex = str2double(char(vAnswer(1))); vSigma = str2double(char(vAnswer(2))); end else vChannelIndex = aChannelIndex; vSigma = aSigma; end vImageProcessing = vImarisApplication.mImageProcessing; vNumberOfTimePoints = vImarisDataSet.mSizeT; vNumberOfSlices = vImarisDataSet.mSizeZ; vProgressDisplay = waitbar(0,'Smoothing Time'); % prepare the dataset vDataSet = vImarisApplication.mFactory.CreateDataSet; vDataSet.Create(vImarisDataSet.mType, vImarisDataSet.mSizeX, vImarisDataSet.mSizeY, ... vNumberOfTimePoints, 1, 1); vDataSet.mExtendMinX = 0; vDataSet.mExtendMinY = 0; vDataSet.mExtendMinZ = 0; % gaussian filter does not operate along X and Y axis vDataSet.mExtendMaxX = 5000*vImarisDataSet.mSizeX; vDataSet.mExtendMaxY = 5000*vImarisDataSet.mSizeY; vDataSet.mExtendMaxZ = vNumberOfTimePoints; for vSlice = 1:vNumberOfSlices % sets the time slices in the Z dimension for vTime = 1:vNumberOfTimePoints vDataSet.SetDataSlice(vImarisDataSet.GetDataSlice(vSlice-1, vChannelIndex-1, vTime-1), ... vTime-1, 0, 0); end %vImageSlice = GaussFilter1D(vImageSlice,3,vSigma,0); vDataSet = vImageProcessing.GaussFilterDataSet(vDataSet, vSigma); % filtered image is returned and saved at the different time % coordinates for vTime = 1:vNumberOfTimePoints vImarisDataSet.SetDataSlice(vDataSet.GetDataSlice(vTime-1, 0, 0), ... vSlice-1, vChannelIndex-1, vTime-1); end waitbar(vSlice/vNumberOfSlices) end close(vProgressDisplay); vImarisApplication.mDataSet = vImarisDataSet;