File: BrainWeb2.experiment.R

package info (click to toggle)
insighttoolkit 3.20.1%2Bgit20120521-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 80,652 kB
  • sloc: cpp: 458,133; ansic: 196,223; fortran: 28,000; python: 3,839; tcl: 1,811; sh: 1,184; java: 583; makefile: 430; csh: 220; perl: 193; xml: 20
file content (81 lines) | stat: -rw-r--r-- 3,197 bytes parent folder | download | duplicates (4)
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
72
73
74
75
76
77
78
79
80
81
imagePath <- "/share/work/data/brainweb" ;
binPath <- "/share/bin-linux/insight/bin" ;
validationRoot <- "/share/work/src/Insight/Validation/StatisticalClustering" ;
scriptPath <- getwd() ;
iteration <- 4000 ;
parametersMutationScales <- c(1, 2) ;
noiseLevels = c(3, 9) ; 
imageSets <- list() ; 
imageSets[[1]] <- c("brainweb.T1.1mm.3.0.mhd",
                    "brainweb.PD.1mm.3.0.mhd") ;
imageSets[[2]] <- c("brainweb.T1.1mm.9.0.mhd",
                    "brainweb.PD.1mm.9.0.mhd") ;
classMask <- "phantom_discrete.mhd" ;

kdTreeBucketSize = 100 ;

for ( i in 1:length(noiseLevels) )
  {
    for ( j in 1:length(parametersMutationScales) )
      {
                                        # prepare common command arguments for EM & GOF
        imageFiles <- paste(imagePath, "/", imageSets[[i]], sep="") ;
        paramFile <- paste(validationRoot, "/Inputs/BrainWeb/", noiseLevels[i], "pn.params.",
                       parametersMutationScales[j], "ext.dat", sep="") ;
        maskFile <- paste(imagePath, "/", classMask, sep="") ;

        options.files <- "--images" ;

        for ( k in 1:length(imageFiles) )
          {
            options.files <- paste(options.files, imageFiles[k]) ;
          }

        options.maskfile <- paste("--mask", maskFile) ;
        
        options.parameters <- paste("--parameters", paramFile) ;

        options.iteration <- paste("--iteration", iteration) ;

                                        # prepare the command arguments for EM
        resultfile <- paste(validationRoot, "/Results/BrainWeb2.EM.", noiseLevels[i], "pn.",
                         parametersMutationScales[j], "ext.dat", sep="") ;

        options.resultfile <- paste("--result", resultfile) ;
        
        options <- paste(options.files, options.maskfile,
                         options.parameters,
                         options.resultfile, 
                         options.iteration) ;
        
                                        #run EM experiment
        command <- paste(binPath, "/ExpectationMaximizationBrainWebValidationApp", sep="") ;
        command <- paste(command, options) ;
        if ( file.access(resultfile, mode=0) == -1 )
          {
            print(command) ;
            system(command) ;
          }
                                        # prepare the command arguments for Kmeans
        resultfile <- paste(validationRoot, "/Results/BrainWeb2.Kmeans.", noiseLevels[i], "pn.",
                         parametersMutationScales[j], "ext.dat", sep="") ;

        options.resultfile <- paste("--result", resultfile) ;

        options.bucketsize <- paste("--bucket-size", kdTreeBucketSize) ;
        options <- paste(options.files, options.maskfile,
                         options.parameters, options.resultfile,
                         options.iteration, options.bucketsize) ;
        
                                        #run GOF experiment
        command <- paste(binPath, "/KdTreeBasedKmeansBrainWebValidationApp", sep="") ;
        command <- paste(command, options) ;
        if ( file.access(resultfile, mode=0) == -1 )
          {
            print(command) ;
            system(command) ;
          }
      }
  }