[MINC-users] nu_correct directory problems

Mishkin Derakhshan mishkind at gmail.com
Thu Jun 5 17:16:56 EDT 2008


Seems I found the problem.

chdir() in perl does not set the PWD environment variable, and I'm
assuming that is what nu_correct uses to determine where to write its
output files.

So what I thought might have been a bug at first, can be remedied with:

#! /usr/bin/perl
chdir("/mydir/");
$ENV{'PWD'} = "/mydir/";
system("nu_correct -iter 150 -stop 5e-05 -normalize_field
file_nu_0.mnc.gz file_nu_1.mnc");

unless there are other suggestions?


On Thu, Jun 5, 2008 at 5:05 PM, 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 I run this from the command line, ie.
> opus[~]$ cd /mydir
> opus[/mydir]$ nu_correct -iter 150 -stop 5e-05 -normalize_field
> file_nu_0.mnc.gz file_nu_1.mnc
>
> Then everything works fine.
>
> 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)
>
> The problem seems to be that the .imp file is getting saved to the
> directory I was in before I ran my perl script, and not to /mydir.
>
> I suspect this has something to do with using chdir() in perl, and to
> how nu_correct is calculating what its current directory.
>
> Any tips?
> thanks,
> mishkin
>
> opus[~]$ `which nu_correct` -version
> Program nu_correct, built from:
> Package MNI N3, version 1.10.1, compiled by rotor at ben
> (x86_64-unknown-linux-gnu) on 2007-11-07 at 11:54:01
>


More information about the MINC-users mailing list