-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbuildTemplate.pl
executable file
·71 lines (61 loc) · 2.65 KB
/
buildTemplate.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/perl
$utilitiesDirectory = "/mnt/data2/Avants/bin/3D/";
$imageDirectory = "/mnt/data2/PUBLIC/Data/Input/TedCareyUltrasound/high/G3 high/";
$outputDirectory = "/mnt/data1/tustison/Projects/UltrasoundRegistration/";
for $i ( 0..4 )
{
opendir( DIR, $imageDirectory );
@pngfiles = grep( /\.png$/, readdir(DIR) );
closedir( DIR );
$count = 0;
$template = "";
foreach $file( @pngfiles )
{
print "(" . $i . "): handling file " . $file . "\n";
if ( $count == 0 )
{
$template = $outputDirectory . "template.nii";
@args = ( "/mnt/data1/tustison/Utilities/bin/2D/float/ConvertImage",
$imageDirectory . $file, $template );
system( @args ) == 0 or die "system @args = failed: $?"
}
else
{
$movingFile = $outputDirectory . "moving" . $count . ".nii";
@args = ( "/mnt/data1/tustison/Utilities/bin/3D/float/ConvertImage",
$imageDirectory . $file, $movingFile );
system( @args ) == 0 or die "system @args = failed: $?";
$algorithm = $utilitiesDirectory . "SyMMN";
@args = ( $algorithm, "-f", $template,
"-m", $movingFile,
"-l", 0.25,
"-s", 3,
"-c", 3,
"-o", $outputDirectory . "output" . $count,
"-n", 5,
"-i", "41x41x41x31x7",
"-a", 0.001
);
system( @args ) == 0 or die "system @args = failed: $?";
}
$count = $count + 1;
}
@args = ( "rm", $outputDirectory . "*inversewarp*" );
system( @args ) == 0 or die "system @args = failed: $?";
@args = ( "rm", $outputDirectory . "templatewarp*" );
system( @args ) == 0 or die "system @args = failed: $?";
$algorithm = $utilitiesDirectory . "AverageImages";
@args = ( $algorithm, $outputDirectory . "templatewarpxvec.nii", 0,
$outputDirectory . "*warpxvec.nii" );
system( @args ) == 0 or die "system @args = failed: $?";
$algorithm = $utilitiesDirectory . "AverageImages";
@args = ( $algorithm, $outputDirectory . "templatewarpyvec.nii", 0,
$outputDirectory . "*warpyvec.nii" );
system( @args ) == 0 or die "system @args = failed: $?";
$algorithm = $utilitiesDirectory . "DiffeomorphicFitToDeformationField";
@args = ( $algorithm, 0, $outputDirectory . "templatewarp",
$outputDirectory . "template.nii",
$outputDirectory . "templateOut",
$outputDirectory . "template.nii", 15 );
system( @args ) == 0 or die "system @args = failed: $?";
}