Need help or advice ? Come to the Icy club ! - Every Wenesday morning from 9h30 to 12h30 - Francois Jacob Building - Main hall - Pasteur
Register

Detect spot and change parameter along time

by fab / Fabrice de Chaumont

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.

version 1 (last version):

download to use and modify in Icy. How do I use scripts ? A Problem ? ask the community.
Changelog for this version: 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);
	}


}
 

This script has no documentation. A Problem ? ask the community.



Icy script publication Id : K5H2H9