Hi Mark,
Would I not be able to copy the sform from the original image to the cropped
image with fslcpgeom after the fact?
Thanks,
Matt.
-----Original Message-----
From: FSL - FMRIB's Software Library [mailto:[log in to unmask]] On Behalf
Of Mark Jenkinson
Sent: Thursday, August 19, 2010 1:35 AM
To: [log in to unmask]
Subject: Re: [FSL] Returning a Cropped Volume to Its Original Size
Hi Matt,
You can get the non-zero portion of your image (such that the
rejected parts contain only zeros) by running:
fslstats yourimage -w
The output is already in the format that fslroi takes.
You can also choose to just extract the z components
of it if you want to leave x and y the same.
As for putting the roi back into place, I would have
expected you to be able to do it with flirt as you
suggest but it seems that fslroi is not preserving
the sform/qform correctly. We will look into fixing
that. However, in the meantime you'll have to
make some flirt matrices manually. It is pretty
easy - if all you have is a shift in z then you'll
need a matrix like:
1 0 0 0
0 1 0 0
0 0 1 A
0 0 0 1
where A is the mm shift needed. So if your fslroi
call started with zmin of 5, and the z voxel dimension
(pixdim3) was 1.2 then the shift would be A=6.
Then you just run flirt as:
flirt -in croppedimage -ref originalimage -init shiftmatrix -
applyxfm -out restoredfovimage
All the best,
Mark
On 19 Aug 2010, at 02:54, Matt Glasser wrote:
> Lets say I need to crop a bunch of volumes to save on memory usage.
> I then take the mean of these and want to take this mean image back
> to the original FOV. What is the most straightforward way to do
> this? I had hoped I could do something with flirt -usesqform and
> just specify the correct reference volume, but it keeps putting my
> new image in the corner instead of in the center where it used to
> be. The mm coordinates of the image are not changing, just the
> voxel indices. Also, I am using some fairly complicated shell code
> to split the original mask image into slices along each dimension,
> test each slice for whether it is non-zero, and then use this to
> automatically specify the arguments for fslroi to do the original
> cropping. Is there a more straightforward way to do this
> automatically?
>
> Thanks,
>
> Matt.
|