[MINC-users] mnc2nii, orientation of nii file
Soren Christensen
sorench at gmail.com
Sun Mar 11 06:54:05 EST 2007
Hi Andrew,
Thanks for that, will try out but I might just stick with doing the
"radiologicalisation" in FSL to keep the MINC file correct.
After some thinking I think I understand that radiological is a display issue.
I guess there is a mapping from voxels coordinates to real world
coordinates and then there is a mapping onto the display on top of
that (determining if we see the data radiologically or
neurologically). It seems the two mappings are often lumped together
leading to a lot of confusion.
Thanks for the help!
Soren
On 3/11/07, Andrew Janke <a.janke at gmail.com> wrote:
> Hi Soren,
>
> <soapbox>
> Radio vs Neuro _should_ be something that concerns display of an image only.
> Certain other packages think differently... :)
> </soapbox>
>
> MINC will never allow you to "flip" data about in a file unless you
> specificaly transform it or do some dodgy tricks as will be
> illustrated in the file I am attaching!
>
> What you are doing with the -xdirection is to flip the voxel data
> about and _also_ flip the step direction, so the data ends up the same
> as what it was.
>
> That all said, use the script below (that I call volflip) to achieve
> what you want. (I think I turned attachments off on this list)
>
>
> a
>
>
> ----- cut here ----
>
> #! /usr/bin/env perl
> #
> # Andrew Janke - rotor at cmr.uq.edu.au
> # Center for Magnetic Resonance
> # The University of Queensland
> # http://www.cmr.uq.edu.au/~rotor
> #
> # Copyright Andrew Janke, The University of Queensland.
> # Permission to use, copy, modify, and distribute this software and its
> # documentation for any purpose and without fee is hereby granted,
> # provided that the above copyright notice appear in all copies. The
> # author and the University of Queensland make no representations about the
> # suitability of this software for any purpose. It is provided "as is"
> # without express or implied warranty.
>
> use strict;
> use warnings "all";
> use Getopt::Tabular;
> use File::Basename;
> use File::Temp qw/ tempdir /;
>
> my($Help, $Usage, $me);
> my(@opt_table, %opt, $infile, $outfile, @args, $tmpdir);
>
> $me = &basename($0);
> %opt = (
> 'verbose' => 0,
> 'clobber' => 0,
> 'fake' => 0,
> 'direction' => 'x',
> );
>
> $Help = <<HELP;
> | $me flips a volume about its centre (volume not world) there
> | are far easier ways to flip a volume about its world centre
> | than this.
> |
> | Problems or comments should be sent to: rotor\@cmr.uq.edu.au
> HELP
>
> $Usage = "Usage: $me [options] <infile.mnc> <outfile.mnc>\n".
> " $me -help to list options\n\n";
>
> @opt_table = (
> ["-verbose", "boolean", 0, \$opt{verbose},
> "be verbose" ],
> ["-clobber", "boolean", 0, \$opt{clobber},
> "clobber existing check files" ],
> ["-fake", "boolean", 0, \$opt{fake},
> "do a dry run, (echo cmds only)" ],
>
> ["-x", "const", 'x', \$opt{direction},
> "flip volume in x-plane (default)" ],
> ["-y", "const", 'y', \$opt{direction},
> "flip volume in y-plane" ],
> ["-z", "const", 'z', \$opt{direction},
> "flip volume in z-plane" ],
> );
>
> # check args
> &Getopt::Tabular::SetHelp($Help, $Usage);
> &GetOptions(\@opt_table, \@ARGV) || exit 1;
> die $Usage if($#ARGV != 1);
> $infile = shift(@ARGV);
> $outfile = shift(@ARGV);
>
> # check for files
> die "$me: Couldn't find input file: $infile\n" if (!-e $infile);
> if(-e $outfile && !$opt{clobber}){
> die "$me: $outfile exists, -clobber to overwrite\n";
> }
>
> # make tmpdir
> $tmpdir = &tempdir( "$me-XXXXXXXX", TMPDIR => 1, CLEANUP => 1 );
>
> my($step);
>
> # get file start and step info
> chomp($step = `mincinfo -attvalue $opt{direction}space:step $infile`);
>
> # first make sure we don't get bitten by slice normalisation
> &do_cmd('mincreshape', '-clobber',
> '-normalize',
> $infile, "$tmpdir/nrm.mnc");
> # reshape
> &do_cmd('mincreshape', '-clobber',
> '-dimsize', "$opt{direction}space=-1",
> ($step > 0) ? "-$opt{direction}direction" :"+$opt{direction}direction",
> "$tmpdir/nrm.mnc", "$tmpdir/res.mnc");
>
> # create template image and copy data
> &do_cmd('cp', '-f', "$tmpdir/nrm.mnc", $outfile);
> &do_cmd('minccopy', "$tmpdir/res.mnc", $outfile);
>
>
> sub do_cmd {
> print STDOUT "@_\n" if $opt{verbose};
> if(!$opt{fake}){
> system(@_) == 0 or die;
> }
> }
>
>
>
> --- fin ---
>
>
> On 3/11/07, Soren Christensen <sorench at gmail.com> wrote:
> > Hi,
> > I have a coronal MRI that are have re-oriented to x,y,z data-order
> > with all posetive stepsizes as described by Andrew on
> > http://brainbody.nottingham.ac.uk/users/wiki/pmwiki.php?n=MincUsersGroup.FAQDataFormats
> >
> > The directional cosines are othogonal, posetive and increasing in the
> > size of the dimension (eg 1,0,0 for x).
> >
> > When I run mnc2nii the resulting nifti files comes out as neurological.
> > I'd like it to be radiological since FSL seems to not be completely
> > independent of the voxel data storage order.
> >
> > Is there something I can do to make mnc2nii output it radiologically?
> > I thought that reshaping with -xdirection might work but it doesn't.
> >
> > Alternatively I guess I could change the nii file order+orienteation
> > using the FSL tools but I'd like to understand why it does not seem
> > possible with mnc2nii.
> >
> > Thanks
> > Soren
> > _______________________________________________
> > MINC-users at bic.mni.mcgill.ca
> > http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users
> >
>
>
> --
> Andrew Janke (a.janke at gmail.com || http://a.janke.googlepages.com/)
> Canberra->Australia +61 (402) 700 883
> _______________________________________________
> MINC-users at bic.mni.mcgill.ca
> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users
>
More information about the MINC-users
mailing list