diff --git a/fslstats.cc b/fslstats.cc index ee54aa805a4aa8708118ed21a3540816e3903a7a..a1ee921a7f617ed05438cb779cb2cc561549d963 100644 --- a/fslstats.cc +++ b/fslstats.cc @@ -224,14 +224,20 @@ int fmrib_main(int argc, char* argv[]) if (masks_used) cout << vol.min(mask) << " " << vol.max(mask) << " "; else cout << vol.min() << " " << vol.max() << " "; } else if (sarg=="-c") { - ColumnVector cog = vol[0].cog(); + ColumnVector cog(4); + // convert from fsl mm to voxel to sform coord + cog.SubMatrix(1,3,1,1) = vol[0].cog(); + cog(4) = 1.0; + if (vol[0].sform_code()!=NIFTI_XFORM_UNKNOWN) { + cog = vol[0].sform_mat() * (vol[0].sampling_mat()).i() * cog; + } cout << cog(1) << " " << cog(2) << " " << cog(3) << " " ; } else if (sarg=="-C") { - ColumnVector cog; - cog = vol[0].cog(); - cog(1) /= vol.xdim(); - cog(2) /= vol.ydim(); - cog(3) /= vol.zdim(); + ColumnVector cog(4); + // convert from fsl mm to voxel coord + cog.SubMatrix(1,3,1,1) = vol[0].cog(); + cog(4) = 1.0; + cog = (vol[0].sampling_mat()).i() * cog; cout << cog(1) << " " << cog(2) << " " << cog(3) << " " ; } else if (sarg=="-p") { float n;