TrimmingImages - MRC CBU Imaging Wiki

Please enter your password of your account at the remote wiki below.
/!\ You should trust both wikis because the password could be read by the particular administrators.

Clear message
location: TrimmingImages

Trimming images

This utility allows you to knock bottom and top planes off an image, while preserving the information any any .mat file the associated with the image.You will need a couple of matlab functions - http://imaging.mrc-cbu.cam.ac.uk/scripts/trim_img.m, and http://imaging.mrc-cbu.cam.ac.uk/scripts/takeblock.m; you should download these to a directory on your matlab path.

Display the image in SPM. Click on the "World space" item at the bottom right of the screen to select voxel space. The image is displayed in it's voxel dimensions. The bottom image panel shows the image with X going from left to right, and Y from top to bottom; the top left shows X left to right, Z top to bottom, and the top right shows Y going from left to right, Z going from top to bottom. Check which of the VOXEL dimensions you want to trim in; then click on the images to find the lowest plane in this direction you want to keep, and the highest plane you want to keep; you can get the plane from the voxel coordinates in the box in the lower left middle of the window.

Worked example; here is a structural image displayed in the SPM display window that needs trimming. It has a .mat file that has reoriented it to neurological orientation.

Click here to view page in pdf format Here is the same image, displayed in Voxel space (see bottom right);

Click here to view page in pdf format You can see that the Z direction in world coordinates (bottom to top), has become the Y direction in voxel coordinates - as the bottom panel goes from bottom to top in the voxel Y direction, and it shows the top-bottom direction of the brain. I have clicked on the top plane (in voxel space) that I want to keep. You may be able to see in the "Crosshair position", "vx" box, that this corresponds to voxel 193.8 in the Y direction. I will then click just below the top of the head on the same panel; this will correspond to ~16 in Y voxel coordinates. Thus: dimension to trim is Y, bottom plane to keep is 16, and top plane to keep is 194. Now run

trim_img

from the matlab prompt. Select the image you want to trim, select the dimension you want to to trim in, and enter the top and bottom planes you want to keep. Wait a while, and a new image is created with an appropriate .mat file, and a "tb_" prefix.Matthew Brett 17/10/02