Script

Detect spot and change parameter along time

Publication ID: ICY-K5H2H9

Short Description

This scripts takes a time-sequence as input. Then it use the spot detector for each image separately, using a specific threshold computed with respect to time.

Versions

  • Version 1 • Released on: 2013-03-27 16:24:43
    Download
    Description:

    initial version

    importClass(Packages.icy.gui.dialog.MessageDialog)
    importClass(Packages.icy.sequence.Sequence)
    importClass(Packages.java.util.ArrayList)
    importClass(Packages.plugins.fab.spotDetector.detector.UDWTWavelet)
    importClass(Packages.icy.roi.ROI2DRectangle)
    importClass(java.awt.geom.Point2D)
     
    // creates a detector
    detector = new UDWTWavelet()
     
    // get the current sequence focused by the user
    sequence = getSequence()
    sequence.removeAllROI()
    // check if the sequence exists
    if ( sequence == null )
    {
            MessageDialog.showDialog("Please open a sequence first", MessageDialog.INFORMATION_MESSAGE );
            throw "no sequence"; // stops the script and say why
    }
    
    // loop over the image of a t sequence
    for ( frameNumber = 0 ; frameNumber < sequence.getSizeT() ; frameNumber++ )
    {
    	image = sequence.getImage( frameNumber , 0 ) // get image at t=0 and z=0
    	// create a temp sequence to perform the detection on it.
    
    	// This varies the threshold along time. In this example, at each frame the detector will become more and more sensitive
    	
    	parameterForScale2 = 100+frameNumber * 0.4
    	scaleParameters = [0, parameterForScale2] 
    
    	println("Time t=" + frameNumber );
    	println("Scale 2 parameter=" + parameterForScale2 );
    
    	tmpSequence = new Sequence();
    	tmpSequence.addImage( 0 , image );	
    	detector.detect(tmpSequence, false, false, scaleParameters)	
    	detectionResult = detector.getDetectionResult();
    
    	// get the number of detection
    	detectionSize = detectionResult.size();
    	println("Number of detection : " + detectionSize);
    
    	// display detection in original sequence as ROI
    
    	for (i = 0; i < detectionSize; i++) { // cycle over all the detections.
            	spot = detectionResult.get(i) // get the spot
    
     		// get mass center.
            	massCenter = spot.getMassCenter()
            	x = massCenter.x;
            	y = massCenter.y;
    
    		boxSize = 2;
            	roi = new ROI2DRectangle(
                    new Point2D.Double( x-boxSize , y-boxSize ),
                    new Point2D.Double( x+boxSize+1 , y+boxSize+1 ),
                    false ); // false: say to the system that the ROI is not in creation mode. 
              roi.setT(frameNumber)      
           	sequence.addROI(roi);
    	}
    
    
    }
     

Leave a Review