% % % Track Plot Length 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::BPTrackPlotLength(%i) % % % % % % % Matlab::BPTrackPlotLength(%i) % % % % % % % Description: % % Plot the length of the track steps. % % function BPTrackPlotLength(aImarisApplicationID,aThreshold) % connect to Imaris Com interface if ~isa(aImarisApplicationID, 'COM.Imaris_Application') vImarisServer = actxserver('ImarisServer.Server'); vImarisApplication = vImarisServer.GetObject(aImarisApplicationID); else vImarisApplication = aImarisApplicationID; end % get the track vTrack = vImarisApplication.mFactory.ToTrack(vImarisApplication.mSurpassSelection); if ~vImarisApplication.mFactory.IsTrack(vTrack) msgbox('Please select a Track!'); return; end if nargin<2 vAnswer = inputdlg(['Step length below the threshold is considered ', ... 'as "pause" indicator. Please enter the threshold value:'],... 'Plot track length',... 1,{'0.4'}); if isempty(vAnswer), return; end; vThreshold = sscanf(char(vAnswer),'%f'); else vThreshold = aThreshold; end % get the spots and edges %vEdges = vTrack.GetEdges; vSpots = vTrack.GetSpots; [vSpotsXYZ,vSpotsTime,vSpotsRadius] = vSpots.Get; vSpotsXYZ = vSpotsXYZ'; vNumberOfSpots = length(vSpotsRadius); vTimeMin = min(vSpotsTime); vTimeMax = max(vSpotsTime); vSpotAtTime = zeros(1,vTimeMax-vTimeMin+1); vSpotAtTime(vSpotsTime-vTimeMin+1) = 1:vNumberOfSpots; vTime = sort(vSpotsTime); vSpotsIndex = vSpotAtTime(vTime-vTimeMin+1); vTimeLength = double(max(vTime(2:vNumberOfSpots)-vTime(1:vNumberOfSpots-1),1)); vStepLength = vSpotsXYZ(:,vSpotsIndex(2:vNumberOfSpots)) - ... vSpotsXYZ(:,vSpotsIndex(1:vNumberOfSpots-1)); vStepsSize = sqrt(sum( (vStepLength).^2 )) ./ vTimeLength; vPause = length(find(vStepsSize<=vThreshold)); vTimes = vTime(1:vNumberOfSpots-1)-vTimeMin+1; subplot(2,2,1) plot(vTimes,vStepsSize,'b-') hold on plot(vTimes,zeros(1,vNumberOfSpots-1)+vThreshold,'r-') hold off title(sprintf('Steps size of %s (total length = %.2f)',vTrack.mName,sum(vStepsSize))); xlabel(sprintf('Number of pause steps = %i (%.2f%%)',vPause,vPause/(vNumberOfSpots-1)*100)); ylabel('Step size [um]'); % finally plot the results vStrings = {'X','Y','Z'}; for vPlot = 1:3 subplot(2,2,vPlot+1) plot(vTimes,vStepLength(vPlot,:),'b-'); title([vStrings{vPlot}, '-Step size of ', vTrack.mName]); xlabel('Time'); ylabel('Step size [um]'); end