[MINC-users] nu_correct directory problems

Andrew Janke a.janke at gmail.com
Thu Jun 5 17:16:44 EDT 2008


Hi Mishkin,

On Fri, Jun 6, 2008 at 7:05 AM, Mishkin Derakhshan <mishkind at gmail.com> wrote:
> Hi,
> I am trying to call nu_correct from perl:
> ie.
> #! /usr/bin/perl
> chdir("/mydir/");
> system("nu_correct -iter 150 -stop 5e-05 -normalize_field
> file_nu_0.mnc.gz file_nu_1.mnc");
>
> If however, I do this:
> opus[~]$ ./perlscript.pl
>
> Then I always get the same error:
> Cannot open .imp file: file_nu_1.imp
> nu_correct: crashed while running nu_estimate_np_and_em (termination status=512)

You are right that the chdir/system interaction is biting you (I
think). My first suggestion is why use chdir?  It typically makes
things more fragile.  Why not just this:

   system("nu_correct -iter 150 -stop 5e-05 -normalize_field \
      $indir/file_nu_0.mnc.gz $indir/file_nu_1.mnc");

You may also be being bitten by the .gz on the file but I dont think
so.  My other suggestion (which will not be causing the problem) is to
use system as an array, this tends to work better with filenames with
spaces in them.  ie:

   system("nu_correct", '-iter', 150,
      '-stop', 5e-05,
      '-normalize_field',
      "$indir/file_nu_0.mnc.gz", "$indir/file_nu_1.mnc") == 0 or die
"I tried but couldnt\n";

I have also added a check for the status of the command


a


More information about the MINC-users mailing list