% % % Merge Spot 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::BPSpotsMerge(%i) % % % % % % % Matlab::BPSpotsMerge(%i) % % % % % % % Description: % % Merge all the spots objects that are in the same folder in a single % spots object. % % function BPSpotsMerge(aImarisApplicationID) % connect to Imaris Com interface if ~isa(aImarisApplicationID, 'COM.Imaris_Application') vImarisServer = actxserver('ImarisServer.Server'); vImarisApplication = vImarisServer.GetObject(aImarisApplicationID); else vImarisApplication = aImarisApplicationID; end % the user has to create a scene with some spots vSurpassScene = vImarisApplication.mSurpassScene; if isequal(vSurpassScene, []) msgbox('Please create some Spots in the Surpass scene!'); return; end % get the spots vSpots = vImarisApplication.mFactory.ToSpots(vImarisApplication.mSurpassSelection); if ~vImarisApplication.mFactory.IsSpots(vSpots) msgbox('Please select some Spots!'); return; end vMergedSpotsXYZ = []; vMergedSpotsT = []; vMergedSpotsR = []; vNumberOfSpots = 0; vProgressDisplay = waitbar(0,'Merging spots'); vParentGroup = vSpots.GetParent; vNumberOfChildren = vParentGroup.GetNumberOfChildren; for vChildIndex = 1:vNumberOfChildren vDataItem = vParentGroup.GetChild(vChildIndex - 1); if vImarisApplication.mFactory.IsSpots(vDataItem) [vSpotsXYZ,vSpotsTime,vSpotsRadius] = vDataItem.Get; vMergedSpotsXYZ = [vMergedSpotsXYZ; vSpotsXYZ]; vMergedSpotsT = [vMergedSpotsT, vSpotsTime]; vMergedSpotsR = [vMergedSpotsR, vSpotsRadius]; vDataItem.mVisible = false; vNumberOfSpots = vNumberOfSpots+1; end waitbar(vChildIndex/vNumberOfChildren) end close(vProgressDisplay); vMergedSpots = vImarisApplication.mFactory.CreateSpots; vMergedSpots.Set(vMergedSpotsXYZ, vMergedSpotsT, vMergedSpotsR); vMergedSpots.mName = sprintf('Spots Merged [%i items]', vNumberOfSpots); vMergedSpots.SetColor(0.0, 1.0, 0.0, 0.0); vParentGroup.AddChild(vMergedSpots);