Ops call, Crop transform, throws null pointer exception


I’ve been unable to crop an Img from a 16-bit Grayscale 2D image using the following code. It throws a null pointer exception when I try to run a crop transform on the input Img.

I make a call earlier in the code to invoke UIService.show on the Img and it works fine.

The Rectangle is pulled from the RoI returned by the area selection tool in the UI. The coordinates match up exactly with what I’ve seen in the ImageJ toolbar.

Could I please have some pointers as to where to look next?

import java.awt.Rectangle;
import net.imglib2.FinalInterval;
import net.imglib2.img.Img;

public class BlotterPCA extends BlotterFunction{
	public Img run(Img input, Rectangle selection) {
		//Initialise interval 
		FinalInterval region = FinalInterval.createMinSize(selection.x,selection.y,
		//Call ui service to show input, works
		//Call Ops service to crop image along region specified, doesn't work
		return null;

I discovered that getOpsService() was returning a null pointer. Thank you to anyone who considered this question.