Short Description
Crop a sequence and copy the source ROI in the cropped sequence.Versions
-
Version 1 • Released on: 2014-01-22 14:11:21DownloadDescription:
initial version
123456789101112131415161718192021222324252627282930313233343536373839404142434445importClass(Packages.icy.type.point.Point5D)importClass(Packages.icy.main.Icy)importClass(Packages.icy.sequence.SequenceUtil)// 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 readsequence = getSequence();// define the ROI for the croproiToUse = null;// try to find which ROI to useif ( sequence.getSelectedROI() != null ){// get selected ROIroiToUse = sequence.getSelectedROI();}else{// take the 1st ROIroiToUse = 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 sequenceIcy.getMainInterface().addSequence( croppedSequence );// get a copy of the ROIroiCopy = roiToUse.getCopy();if ( roiCopy.canSetPosition() ) // check if the ROI manage the setPosition method{//Set the new 5d positionroiCopy.setPosition5D( new Point5D.Double( 0 ,0 ,0 ,0 ,0 ) );}// add the final ROI to the cropped sequencecroppedSequence.addROI( roiCopy, false );