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

Crop and keep ROI

by fab / Fabrice de Chaumont

Crop a sequence and copy the source ROI in the cropped sequence.

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

// this script takes a sequence as input, crop it with a ROI,
// and then copy the original ROI and put it at (0,0) location.
// remark: some null-tests are not performed like checking if a sequence exists, if it has ROIs...
// I did not put them to create a light script, easy to read

sequence = getSequence();

// define the ROI for the crop
roiToUse = null;

// try to find which ROI to use
if ( sequence.getSelectedROI() != null )
	// get selected ROI
	roiToUse = sequence.getSelectedROI();
	// take the 1st ROI
	roiToUse = sequence.getROIs().get( 0 );

// test is a ROI hab been found.
if ( roiToUse == null ) throw "CropScript: At least 1 ROI is needed for this operation.";

// crop the sequence.
croppedSequence = SequenceUtil.getSubSequence( sequence, roiToUse );

// display the sequence
Icy.getMainInterface().addSequence( croppedSequence );

// get a copy of the ROI
roiCopy = roiToUse.getCopy();

if ( roiCopy.canSetPosition() ) // check if the ROI manage the setPosition method
	//Set the new 5d position
	roiCopy.setPosition5D( new Point5D.Double( 0 ,0 ,0 ,0 ,0 ) );

// add the final ROI to the cropped sequence
croppedSequence.addROI( roiCopy, false );

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

Icy script publication Id : P9S3H3