Changeset 11837 for trunk/ippScripts/scripts/detrend_norm_calc.pl
- Timestamp:
- Feb 15, 2007, 2:23:33 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_norm_calc.pl (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_norm_calc.pl
r11831 r11837 31 31 32 32 # Parse command-line arguments 33 my ($det Id, # Detrend id33 my ($det_id, # Detrend id 34 34 $iter, # Iteration 35 35 $detType, # Detrend type 36 36 $workdir, # Working directory for output files 37 37 $dbname, # Database name 38 $no_update # Don't update the database? 38 $no_update, # Don't update the database? 39 $no_op, # Don't do operations 39 40 ); 40 41 GetOptions( 41 'det_id|d=s' => \$det Id,42 'det_id|d=s' => \$det_id, 42 43 'iteration|i=s' => \$iter, 43 44 'det_type|t=s' => \$detType, 44 45 'workdir|w=s' => \$workdir, 45 46 'dbname|d=s' => \$dbname,# Database name 46 'no-update' => \$no_update 47 'no-update' => \$no_update, 48 'no-op' => \$no_op, 47 49 ) or pod2usage( 2 ); 48 50 … … 50 52 pod2usage( -msg => "Required options --det_id --iteration --det_type", 51 53 -exitval => 3, 52 ) unless defined $det Id54 ) unless defined $det_id 53 55 and defined $iter 54 56 and defined $detType; … … 85 87 my @files; # The input files 86 88 { 87 my $command = "$dettool -processedimfile -det_id $det Id"; # Command to run89 my $command = "$dettool -processedimfile -det_id $det_id"; # Command to run 88 90 $command .= " -dbname $dbname" if defined $dbname; 89 91 my @command = split /\s+/, $command; … … 91 93 print "Running [$command]...\n"; 92 94 if (not run(\@command, \$stdin, \$stdout, \$stderr)) { 93 &my_die("Unable to perform dettool -processedimfile on detrend $det Id/$iter: $?",95 &my_die("Unable to perform dettool -processedimfile on detrend $det_id/$iter: $?", 94 96 $det_id, $iter, $PS_EXIT_SYS_ERROR); 95 97 } … … 115 117 116 118 my $norms; # MDC with normalisations 117 if (NORMALIZE()->{lc($detType)} ) {119 if (NORMALIZE()->{lc($detType)} and not $no_op) { 118 120 119 121 my %matrix; # Matrix of statistics as a function of exposures and classes 120 122 foreach my $file (@files) { 121 my $exp Tag = $file->{'exp_tag'}; # Exposure ID122 my $class Id = $file->{'class_id'}; # Class ID123 my $exp_tag = $file->{'exp_tag'}; # Exposure ID 124 my $class_id = $file->{'class_id'}; # Class ID 123 125 my $stat = $file->{STATISTIC()}; # Statistic of interest 124 126 125 127 # Create matrix elements 126 $matrix{$exp Tag} = {} if not defined $matrix{$expTag};127 $matrix{$exp Tag}->{$classId} = $stat;128 $matrix{$exp_tag} = {} if not defined $matrix{$exp_tag}; 129 $matrix{$exp_tag}->{$class_id} = $stat; 128 130 } 129 131 130 132 # Generate the input for ppNormCalc 131 133 my $normData; # Normalisation data 132 foreach my $exp Tag (keys %matrix) {133 $normData .= "$exp Tag\tMETADATA\n";134 foreach my $class Id (keys %{$matrix{$expTag}}) {135 $normData .= "\t" . $class Id . "\tF32\t" . $matrix{$expTag}->{$classId} . "\n";134 foreach my $exp_tag (keys %matrix) { 135 $normData .= "$exp_tag\tMETADATA\n"; 136 foreach my $class_id (keys %{$matrix{$exp_tag}}) { 137 $normData .= "\t" . $class_id . "\tF32\t" . $matrix{$exp_tag}->{$class_id} . "\n"; 136 138 } 137 139 $normData .= "END\n\n"; … … 157 159 my %classes; # List of unique classes 158 160 foreach my $file (@files) { 159 my $class Id = $file->{'class_id'}; # Class Id160 $classes{$class Id} = 1;161 my $class_id = $file->{'class_id'}; # Class Id 162 $classes{$class_id} = 1; 161 163 } 162 164 163 foreach my $class Id (keys %classes) {165 foreach my $class_id (keys %classes) { 164 166 my %mdValue; # Metadata value for this class id 165 $mdValue{name} = $class Id;167 $mdValue{name} = $class_id; 166 168 $mdValue{value} = 1.0; 167 169 push @$norms, \%mdValue; … … 176 178 my $normalisation = $normItem->{value}; # Normalisation for component 177 179 178 my $command = "$dettool -addnormalizedstat -det_id $det Id -iteration $iter -class_id $className ".180 my $command = "$dettool -addnormalizedstat -det_id $det_id -iteration $iter -class_id $className ". 179 181 "-norm $normalisation"; # Command to run 180 182 $command .= " -dbname $dbname" if defined $dbname; … … 199 201 200 202 warn($msg); 201 if ($det_id and $iter and $class_id andnot $no_update) {203 if ($det_id and $iter and not $no_update) { 202 204 my $command = "$dettool -addnormalizedstat -det_id $det_id -iteration $iter -code $exit_code"; 203 205 $command .= " -dbname $dbname" if defined $dbname;
Note:
See TracChangeset
for help on using the changeset viewer.
