r97: Converted Scanner and Projections to C++
[ctsim.git] / cgi-bin / ctsim.cgi.in
index 6b0da4833601b1a57a6bf13482e72ddb62430a0f..898aa89f1450186bc5c291fe714225929ed038d0 100755 (executable)
@@ -22,7 +22,7 @@ CGI::ReadParse(\%in);
 
 # Incoming variables 
 #   Phantom_Name, Phantom_Nx, Phantom_Ny, Phantom_NSample
 
 # Incoming variables 
 #   Phantom_Name, Phantom_Nx, Phantom_Ny, Phantom_NSample
-#   RS_NDet, RS_NRot, RS_NRay, RS_RotAngle,
+#   PJ_NDet, PJ_NRot, PJ_NRay, PJ_RotAngle,
 #   IR_Nx, IR_Ny, IR_Filter, IR_Filter_Param
 
 my $error = "";
 #   IR_Nx, IR_Ny, IR_Filter, IR_Filter_Param
 
 my $error = "";
@@ -35,13 +35,13 @@ $error .= "Phantom name must not be blank<br>" if ($Phantom_Name eq "");
 $error .= "Phantom NX and NY must be between 5 and 1024<br>" if ($Phantom_Nx < 5 || $Phantom_Nx > 1024 || $Phantom_Ny < 5 || $Phantom_Ny > 1024);
 $error .= "Phantom NSample must be between 1 and 10<br>" if ($Phantom_NSample < 1 || $Phantom_NSample > 10);
 
 $error .= "Phantom NX and NY must be between 5 and 1024<br>" if ($Phantom_Nx < 5 || $Phantom_Nx > 1024 || $Phantom_Ny < 5 || $Phantom_Ny > 1024);
 $error .= "Phantom NSample must be between 1 and 10<br>" if ($Phantom_NSample < 1 || $Phantom_NSample > 10);
 
-my $RS_NDet = FilterToNumber($in{'RS_NDet'});
-my $RS_NRot = FilterToNumber($in{'RS_NRot'});
-my $RS_NRay = FilterToNumber($in{'RS_NRay'});
-my $RS_RotAngle = FilterToNumber($in{'RS_RotAngle'});
-$error .= "Raysum NDet must be between 5 and 1800<br>" if ($RS_NDet < 5 || $RS_NDet > 1800);
-$error .= "Raysum NRot must be between 5 and 2048<br>" if ($RS_NRot < 5 || $RS_NRot > 2048);
-$error .= "Raysum RotAngle must be between 0.1 and 2<br>" if ($RS_RotAngle < 0.1 || $RS_RotAngle > 2);
+my $PJ_NDet = FilterToNumber($in{'PJ_NDet'});
+my $PJ_NRot = FilterToNumber($in{'PJ_NRot'});
+my $PJ_NRay = FilterToNumber($in{'PJ_NRay'});
+my $PJ_RotAngle = FilterToNumber($in{'PJ_RotAngle'});
+$error .= "Projection NDet must be between 5 and 1800<br>" if ($PJ_NDet < 5 || $PJ_NDet > 1800);
+$error .= "Projection NRot must be between 5 and 2048<br>" if ($PJ_NRot < 5 || $PJ_NRot > 2048);
+$error .= "Projection RotAngle must be between 0.1 and 2<br>" if ($PJ_RotAngle < 0.1 || $PJ_RotAngle > 2);
 
 #my $IR_Nx = FilterToNumber($in{'IR_Nx'});
 #my $IR_Ny = FilterToNumber($in{'IR_Ny'});
 
 #my $IR_Nx = FilterToNumber($in{'IR_Nx'});
 #my $IR_Ny = FilterToNumber($in{'IR_Ny'});
@@ -74,38 +74,38 @@ $error .= "IR Filter Parameter must be between 0 and 1<br>" if ($IR_Filter_Param
 my $tmpid = $$;
 my $auto_window_img = "std0.1";
 my $auto_window_diff = "std1";
 my $tmpid = $$;
 my $auto_window_img = "std0.1";
 my $auto_window_diff = "std1";
-my $auto_window_rs = "full";
+my $auto_window_pj = "full";
 my $logfile = "$::jobdir/ctsim.log";
 
 my $result_fname = "$::datadir/result-$tmpid.html";
 my $phantom_fname = "$::datadir/phantom-$tmpid.if";
 my $logfile = "$::jobdir/ctsim.log";
 
 my $result_fname = "$::datadir/result-$tmpid.html";
 my $phantom_fname = "$::datadir/phantom-$tmpid.if";
-my $rs_fname = "$::datadir/rs-$tmpid.rs";
+my $pj_fname = "$::datadir/pj-$tmpid.pj";
 my $ir_fname = "$::datadir/ir-$tmpid.if";
 my $ir_fname = "$::datadir/ir-$tmpid.if";
-my $rs_if_fname = "$::datadir/rs-$tmpid.if";
+my $pj_if_fname = "$::datadir/pj-$tmpid.if";
 my $diff_fname = "$::datadir/diff-$tmpid.if";
 my $phantom_png = "$::datadir/phantom-$tmpid.png";
 my $ir_png = "$::datadir/ir-$tmpid.png";
 my $diff_fname = "$::datadir/diff-$tmpid.if";
 my $phantom_png = "$::datadir/phantom-$tmpid.png";
 my $ir_png = "$::datadir/ir-$tmpid.png";
-my $rs_png = "$::datadir/rs-$tmpid.png";
+my $pj_png = "$::datadir/pj-$tmpid.png";
 my $diff_png = "$::datadir/diff-$tmpid.png";
 
 my $result_url = "$::url_datadir/result-$tmpid.html";
 my $phantom_png_url = "$::url_datadir/phantom-$tmpid.png";
 my $ir_png_url = "$::url_datadir/ir-$tmpid.png";
 my $diff_png = "$::datadir/diff-$tmpid.png";
 
 my $result_url = "$::url_datadir/result-$tmpid.html";
 my $phantom_png_url = "$::url_datadir/phantom-$tmpid.png";
 my $ir_png_url = "$::url_datadir/ir-$tmpid.png";
-my $rs_png_url = "$::url_datadir/rs-$tmpid.png";
+my $pj_png_url = "$::url_datadir/pj-$tmpid.png";
 my $diff_png_url = "$::url_datadir/diff-$tmpid.png";
 
 my $ctrec_ver = "$::bindir/ctrec";
 my $diff_png_url = "$::url_datadir/diff-$tmpid.png";
 
 my $ctrec_ver = "$::bindir/ctrec";
-my $phm2rs_ver = "$::bindir/phm2rs";
+my $phm2pj_ver = "$::bindir/phm2pj";
 my $phm2if_ver = "$::bindir/phm2if";
 my $diff_ver = "$::bindir/if-2";
 $ctrec_ver = "/opt/lam/bin/mpirun N N $::lamrundir/ctrec-lam" if $MPI;
 my $phm2if_ver = "$::bindir/phm2if";
 my $diff_ver = "$::bindir/if-2";
 $ctrec_ver = "/opt/lam/bin/mpirun N N $::lamrundir/ctrec-lam" if $MPI;
-$phm2rs_ver = "/opt/lam/bin/mpirun N N $::lamrundir/phm2rs-lam" if $MPI;
+$phm2pj_ver = "/opt/lam/bin/mpirun N N $::lamrundir/phm2pj-lam" if $MPI;
 $phm2if_ver = "/opt/lam/bin/mpirun N N $::lamrundir/phm2if-lam" if $MPI;
 
 my $gp_cmd = "$phm2if_ver $phantom_fname $Phantom_Nx $Phantom_Ny --phantom $Phantom_Name --nsample $Phantom_NSample";
 $phm2if_ver = "/opt/lam/bin/mpirun N N $::lamrundir/phm2if-lam" if $MPI;
 
 my $gp_cmd = "$phm2if_ver $phantom_fname $Phantom_Nx $Phantom_Ny --phantom $Phantom_Name --nsample $Phantom_NSample";
-my $rs_cmd = "$phm2rs_ver $rs_fname $RS_NDet $RS_NRot --phantom $Phantom_Name --nray $RS_NRay --rotangle $RS_RotAngle";
-my $rs_if_cmd = "$::bindir/rs2if $rs_fname $rs_if_fname";
-my $ir_cmd = "$ctrec_ver $rs_fname $ir_fname $IR_Nx $IR_Ny --filter $IR_Filter --filter-param $IR_Filter_Param --interp $IR_Interp --backproj $IR_Backproj";
+my $pj_cmd = "$phm2pj_ver $pj_fname $PJ_NDet $PJ_NRot --phantom $Phantom_Name --nray $PJ_NRay --rotangle $PJ_RotAngle";
+my $pj_if_cmd = "$::bindir/pj2if $pj_fname $pj_if_fname";
+my $ir_cmd = "$ctrec_ver $pj_fname $ir_fname $IR_Nx $IR_Ny --filter $IR_Filter --filter-param $IR_Filter_Param --interp $IR_Interp --backproj $IR_Backproj";
 my $diff_cmd = "$diff_ver $phantom_fname $ir_fname $diff_fname --comp";
 
 my $window_options = "--auto $auto_window_img";
 my $diff_cmd = "$diff_ver $phantom_fname $ir_fname $diff_fname --comp";
 
 my $window_options = "--auto $auto_window_img";
@@ -118,7 +118,7 @@ if ($Disp_Max ne 'auto') {
 
 my $png1_cmd = "$::bindir/if2img $phantom_fname $phantom_png $window_options --stats --format png";
 my $png2_cmd = "$::bindir/if2img $ir_fname $ir_png $window_options --stats --format png";
 
 my $png1_cmd = "$::bindir/if2img $phantom_fname $phantom_png $window_options --stats --format png";
 my $png2_cmd = "$::bindir/if2img $ir_fname $ir_png $window_options --stats --format png";
-my $png3_cmd = "$::bindir/if2img $rs_if_fname $rs_png --auto $auto_window_rs --stats --format png";
+my $png3_cmd = "$::bindir/if2img $pj_if_fname $pj_png --auto $auto_window_pj --stats --format png";
 my $png4_cmd = "$::bindir/if2img $diff_fname $diff_png --auto $auto_window_diff --stats --format png";
 
 my $title = "CT Simulation Results";
 my $png4_cmd = "$::bindir/if2img $diff_fname $diff_png --auto $auto_window_diff --stats --format png";
 
 my $title = "CT Simulation Results";
@@ -130,7 +130,7 @@ $out .= "<H1>$title</H1><HR>\n";
 
 if ($opt_d) {
     $out .= "<H2>Commands</H2>\n";
 
 if ($opt_d) {
     $out .= "<H2>Commands</H2>\n";
-    $out .= "$gp_cmd<br>\n$rs_cmd<br>\n$rs_if_cmd<br>\n$ir_cmd<br>\n$diff_cmd<br>\n$png1_cmd<br>\n$png2_cmd<br>\n" .
+    $out .= "$gp_cmd<br>\n$pj_cmd<br>\n$pj_if_cmd<br>\n$ir_cmd<br>\n$diff_cmd<br>\n$png1_cmd<br>\n$png2_cmd<br>\n" .
             "$png3_cmd<br>\n$png4_cmd<br>\n";
 }
 
             "$png3_cmd<br>\n$png4_cmd<br>\n";
 }
 
@@ -141,21 +141,21 @@ if ($error ne "") {
     $out .= "<i>$error</i>";
 } else {
   my $gp_out;
     $out .= "<i>$error</i>";
 } else {
   my $gp_out;
-  my $rs_out;
-  my $rs_if_out;
+  my $pj_out;
+  my $pj_if_out;
   my $ir_out;
   my $diff_out;
   my $png_gp_out;
   my $png_ir_out;
   my $ir_out;
   my $diff_out;
   my $png_gp_out;
   my $png_ir_out;
-  my $png_rs_out;
+  my $png_pj_out;
   my $png_diff_out;
   $gp_out = `$gp_cmd`;
   if (-s $phantom_fname) {
   my $png_diff_out;
   $gp_out = `$gp_cmd`;
   if (-s $phantom_fname) {
-    $rs_out .= `$rs_cmd`;
+    $pj_out .= `$pj_cmd`;
     $png_gp_out .= `$png1_cmd`;
     $png_gp_out .= `$png1_cmd`;
-    if (-s $rs_fname) {
-      $rs_if_out .= `$rs_if_cmd`;
-      $png_rs_out .= `$png3_cmd`;
+    if (-s $pj_fname) {
+      $pj_if_out .= `$pj_if_cmd`;
+      $png_pj_out .= `$png3_cmd`;
       $ir_out .= `$ir_cmd`;
       if (-s $ir_fname) {
        $png_ir_out .= `$png2_cmd`;
       $ir_out .= `$ir_cmd`;
       if (-s $ir_fname) {
        $png_ir_out .= `$png2_cmd`;
@@ -165,7 +165,7 @@ if ($error ne "") {
     }
   }
 
     }
   }
 
-  $cmdout = "$gp_cmd\n $gp_out $rs_cmd\n $rs_out $rs_if_cmd\n $rs_if_out $ir_cmd\n $ir_out $diff_cmd\n $diff_out $png1_cmd\n $png_gp_out $png2_cmd\n $png_ir_out $png3_cmd\n $png_rs_out $png4_cmd\n $png_diff_out";
+  $cmdout = "$gp_cmd\n $gp_out $pj_cmd\n $pj_out $pj_if_cmd\n $pj_if_out $ir_cmd\n $ir_out $diff_cmd\n $diff_out $png1_cmd\n $png_gp_out $png2_cmd\n $png_ir_out $png3_cmd\n $png_pj_out $png4_cmd\n $png_diff_out";
   if (open(LOGFILE,">> $logfile")) {
     flock(LOGFILE,LOCK_EX);
     seek(LOGFILE, 0, 2);
   if (open(LOGFILE,">> $logfile")) {
     flock(LOGFILE,LOCK_EX);
     seek(LOGFILE, 0, 2);
@@ -182,17 +182,17 @@ if ($error ne "") {
   }
   my $png_gp_out_html = $png_gp_out;
   my $png_ir_out_html = $png_ir_out;
   }
   my $png_gp_out_html = $png_gp_out;
   my $png_ir_out_html = $png_ir_out;
-  my $png_rs_out_html = $png_rs_out;
+  my $png_pj_out_html = $png_pj_out;
   my $png_diff_out_html = $png_diff_out;
   $png_gp_out_html =~ s/\n/<br>/gms;
   $png_ir_out_html =~ s/\n/<br>/gms;
   my $png_diff_out_html = $png_diff_out;
   $png_gp_out_html =~ s/\n/<br>/gms;
   $png_ir_out_html =~ s/\n/<br>/gms;
-  $png_rs_out_html =~ s/\n/<br>/gms;
+  $png_pj_out_html =~ s/\n/<br>/gms;
   $png_diff_out_html =~ s/\n/<br>/gms;
   $out .= "<TABLE><TR><TD>Phantom Image</TD><TD>Reconstructed Image</TD></TR>\n";
   $out .= "<TR><TD><IMG SRC=\"$phantom_png_url\"><br><FONT SIZE=1>$png_gp_out</FONT></TD>\n";
   $out .= "<TD><IMG SRC=\"$ir_png_url\"><br><FONT SIZE=1>$png_ir_out</FONT></TD></TR>\n";
   $png_diff_out_html =~ s/\n/<br>/gms;
   $out .= "<TABLE><TR><TD>Phantom Image</TD><TD>Reconstructed Image</TD></TR>\n";
   $out .= "<TR><TD><IMG SRC=\"$phantom_png_url\"><br><FONT SIZE=1>$png_gp_out</FONT></TD>\n";
   $out .= "<TD><IMG SRC=\"$ir_png_url\"><br><FONT SIZE=1>$png_ir_out</FONT></TD></TR>\n";
-  $out .= "<TR><TD>Raysum Sinusoid</TD><TD>Phantom/Reconst Error</TD></TR>\n";
-  $out .= "<TR><TD><IMG SRC=\"$rs_png_url\"><br><FONT SIZE=1>$png_rs_out</FONT></TD>\n";
+  $out .= "<TR><TD>Projection Sinusoid</TD><TD>Phantom/Reconst Error</TD></TR>\n";
+  $out .= "<TR><TD><IMG SRC=\"$pj_png_url\"><br><FONT SIZE=1>$png_pj_out</FONT></TD>\n";
   $out .= "<TD><IMG SRC=\"$diff_png_url\"><br><FONT SIZE=2>$diff_out</FONT><br><FONT SIZE=1>$png_diff_out</FONT></TD></TR>\n";
   $out .= "</TABLE>";
   $out .= "Execution time: $execution_time seconds\n";
   $out .= "<TD><IMG SRC=\"$diff_png_url\"><br><FONT SIZE=2>$diff_out</FONT><br><FONT SIZE=1>$png_diff_out</FONT></TD></TR>\n";
   $out .= "</TABLE>";
   $out .= "Execution time: $execution_time seconds\n";
@@ -227,10 +227,10 @@ if (open(JOBFILES,"> $::jobdir/$tmpid"))
     print JOBFILES "Phantom_Nx=$Phantom_Nx\n";
     print JOBFILES "Phantom_Ny=$Phantom_Nx\n";
     print JOBFILES "Phantom_NSample=$Phantom_NSample\n";
     print JOBFILES "Phantom_Nx=$Phantom_Nx\n";
     print JOBFILES "Phantom_Ny=$Phantom_Nx\n";
     print JOBFILES "Phantom_NSample=$Phantom_NSample\n";
-    print JOBFILES "RS_NDet=$RS_NDet\n";
-    print JOBFILES "RS_NRot=$RS_NRot\n";
-    print JOBFILES "RS_NRay=$RS_NRay\n";
-    print JOBFILES "RS_RotAngle=$RS_RotAngle\n";
+    print JOBFILES "PJ_NDet=$PJ_NDet\n";
+    print JOBFILES "PJ_NRot=$PJ_NRot\n";
+    print JOBFILES "PJ_NRay=$PJ_NRay\n";
+    print JOBFILES "PJ_RotAngle=$PJ_RotAngle\n";
     print JOBFILES "IR_Nx=$IR_Nx\n";
     print JOBFILES "IR_Ny=$IR_Ny\n";
     print JOBFILES "IR_Interp=$IR_Interp\n";
     print JOBFILES "IR_Nx=$IR_Nx\n";
     print JOBFILES "IR_Ny=$IR_Ny\n";
     print JOBFILES "IR_Interp=$IR_Interp\n";
@@ -240,7 +240,7 @@ if (open(JOBFILES,"> $::jobdir/$tmpid"))
     print JOBFILES "Disp_Min=$Disp_Min\n";
     print JOBFILES "Disp_Max=$Disp_Max\n";
     print JOBFILES "MPI=$MPI\n";
     print JOBFILES "Disp_Min=$Disp_Min\n";
     print JOBFILES "Disp_Max=$Disp_Max\n";
     print JOBFILES "MPI=$MPI\n";
-    print JOBFILES "Files=$result_fname,$phantom_fname,$rs_fname,$ir_fname,$phantom_png,$ir_png,$rs_if_fname,$rs_png\n" if ($error eq "");
+    print JOBFILES "Files=$result_fname,$phantom_fname,$pj_fname,$ir_fname,$phantom_png,$ir_png,$pj_if_fname,$pj_png\n" if ($error eq "");
     printf JOBFILES "cmdout=$cmdout\n";
     flock(JOBFILES,LOCK_UN);
     close JOBFILES;
     printf JOBFILES "cmdout=$cmdout\n";
     flock(JOBFILES,LOCK_UN);
     close JOBFILES;