\n";
$html .= "" .
"No. | " .
"ID | " .
"x-step | " .
"y-step | " .
"z-step | " .
"StxMaskErr | " .
"CSFcls | " .
"GMcls | " .
"WMcls | " .
"GMCortical | " .
"WMsurf | " .
"GMsurf | " .
"SRLeft | " .
"SRRight | " .
"SSLeft | " .
"SSRight | " .
"MeanCTLeft | " .
"MeanCTRight | " .
"MeanWM-T1 | " .
"StdDevWM-T1 | " .
"MeanGM-T1 | " .
"StdDevGM-T1 | " .
"GIleft | " .
"GIright | " .
"GIfull | " .
"
\n";
$html .= "
\n";
my $info = "# CIVET QC pipeline\n";
my $avg_stx_mask_error = 0.0;
my $stddev_stx_mask_error = 0.0;
my $count_stx_mask_error = 0;
my $avg_csf_cls = 0.0;
my $stddev_csf_cls = 0.0;
my $avg_gm_cls = 0.0;
my $stddev_gm_cls = 0.0;
my $avg_wm_cls = 0.0;
my $stddev_wm_cls = 0.0;
my $count_cls = 0.0;
my $avg_gm_cortical = 0.0;
my $stddev_gm_cortical = 0.0;
my $count_gm_cortical = 0.0;
my $avg_wm_surf = 0.0;
my $stddev_wm_surf = 0.0;
my $avg_gm_surf = 0.0;
my $stddev_gm_surf = 0.0;
my $count_gm_wm_surf = 0.0;
my $avg_surfreg_left = 0.0;
my $stddev_surfreg_left = 0.0;
my $count_surfreg_left = 0.0;
my $avg_surfreg_right = 0.0;
my $stddev_surfreg_right = 0.0;
my $count_surfreg_right = 0.0;
my $avg_surfsurf_left = 0.0;
my $stddev_surfsurf_left = 0.0;
my $count_surfsurf_left = 0.0;
my $avg_surfsurf_right = 0.0;
my $stddev_surfsurf_right = 0.0;
my $count_surfsurf_right = 0.0;
my $avg_meanct = 0.0;
my $stddev_meanct = 0.0;
my $count_meanct = 0.0;
my $count = 0;
foreach my $dsid (@dsids) {
$count++;
my $level = 0;
print "Processing subject $dsid...\n";
##### Create image object. #####
# depending on the two options your files can be in on target
# or there can be subdirs for every subject
my $Source_Base;
if ($sourceSubDir eq "noIdSubDir") {
$Source_Base = "${sourceDir}/";
} else {
$Source_Base = "${sourceDir}/${dsid}/";
}
my $image = MRI_Image->new( $version,
$Source_Base,
$target,
$prefix,
$dsid,
$inputType,
$correctPVE,
$maskType,
$interpMethod,
$headheight,
$MaskBloodVessels,
$N3Distance,
$N3Damping,
$lsqtype,
$surface,
\@thickness,
$ResampleSurfaces,
$MeanCurvature,
$Area_fwhm,
$Volume_fwhm,
$CombineSurfaces,
$VBM,
$VBM_fwhm,
$VBM_symmetry,
$VBM_cerebellum,
$animal,
$Template,
\$CIVETmodels{icbm152nl} );
# Column 1: subject id.
my $infoline = "$dsid ";
my $htmlline = "";
# Columns 2,3,4 : voxel sizes in native space
if( -e $image->{t1}{native} ) {
my $dx = `mincinfo -attvalue xspace:step $image->{t1}{native}`;
my $dy = `mincinfo -attvalue yspace:step $image->{t1}{native}`;
my $dz = `mincinfo -attvalue zspace:step $image->{t1}{native}`;
chomp( $dx ); chomp( $dy ); chomp( $dz );
$dx = abs($dx); $dy = abs($dy); $dz = abs($dz);
$infoline .= sprintf( "%5.2f %5.2f %5.2f ", abs($dx), abs($dy), abs($dz) );
if( abs($dx) >= 2.5 ) {
$htmlline .= ""; $level = max($level,$danger_level);
} elsif( abs($dx) >= 1.75 ) {
$htmlline .= " | "; $level = max($level,$warning_level);
} else {
$htmlline .= " | ";
}
$htmlline .= sprintf( "%5.2f", abs($dx) ) . " | ";
if( abs($dy) >= 2.5 ) {
$htmlline .= ""; $level = max($level,$danger_level);
} elsif( abs($dy) >= 1.75 ) {
$htmlline .= " | "; $level = max($level,$warning_level);
} else {
$htmlline .= " | ";
}
$htmlline .= sprintf( "%5.2f", abs($dy) ) . " | ";
if( abs($dz) >= 2.5 ) {
$htmlline .= ""; $level = max($level,$danger_level);
} elsif( abs($dx) >= 1.75 ) {
$htmlline .= " | "; $level = max($level,$warning_level);
} else {
$htmlline .= " | ";
}
$htmlline .= sprintf( "%5.2f", abs($dz) ) . " | ";
} else {
$infoline .= " 0 0 0 ";
$htmlline .= "0 | 0 | 0 | ";
$level = max($level,$incomplete_level);
}
# Column 5: Error in stereotaxic brain mask.
my $skull_mask = $image->{skull_mask_tal};
if( -e $skull_mask ) {
my $model_mask = "$CIVETmodels{icbm152nl}{RegLinDir}/$CIVETmodels{icbm152nl}{RegLinModel}_mask.mnc";
my $skull_mask_rsl = "${tmpdir}/skull_mask_rsl.mnc";
`mincresample -clobber -quiet -like $model_mask -nearest_neighbour $skull_mask $skull_mask_rsl`;
my $diff = "${tmpdir}/diff_mask_stx.mnc";
`minccalc -clobber -quiet -expression 'A[1]!=A[0]' $model_mask $skull_mask_rsl $diff`;
my $diff_volume;
chomp( $diff_volume = `mincstats -quiet -sum $diff` );
my $mask2_volume;
chomp( $mask2_volume = `mincstats -quiet -sum $model_mask` );
my $error = 100.0 * $diff_volume / $mask2_volume;
unlink( $skull_mask_rsl );
unlink( $diff );
if( $error < 20.0 ) { # exclude errors from avg and stddev
$avg_stx_mask_error += $error;
$stddev_stx_mask_error += $error*$error;
$count_stx_mask_error++;
}
$error = sprintf( "%5.2f", $error );
$infoline .= "$error ";
if( $error >= 20.0 ) {
$htmlline .= ""; $level = max($level,$danger_level);
} elsif( $error >= 10.0 ) {
$htmlline .= " | "; $level = max($level,$warning_level);
} else {
$htmlline .= " | ";
}
$htmlline .= $error . " | ";
} else {
$infoline .= " 0 ";
$htmlline .= "0 | ";
$level = max($level,$incomplete_level);
}
# Columns 6,7,8: percentages of CSF, GM, WM tissue in brain.
my $classify_qc = $image->{classify_qc};
if( -e $classify_qc ) {
open (IDFILE, $classify_qc);
my $idline = ;
$idline =~ /classified image CSF (.*)\% GM (.*)\% WM (.*)\%/;
my $csf = $1;
my $gm = $2;
my $wm = $3;
$infoline .= "$csf $gm $wm ";
close (IDFILE);
$avg_csf_cls += $csf;
$stddev_csf_cls += $csf*$csf;
$avg_gm_cls += $gm;
$stddev_gm_cls += $gm*$gm;
$avg_wm_cls += $wm;
$stddev_wm_cls += $wm*$wm;
$count_cls++;
if( $csf >= 50.0 || $csf <= 5.0 ) {
$htmlline .= ""; $level = max($level,$warning_level);
} else {
$htmlline .= " | ";
}
$htmlline .= $csf . " | ";
if( $gm >= 80.0 || $gm <= 15.0 ) {
$htmlline .= ""; $level = max($level,$warning_level);
} else {
$htmlline .= " | ";
}
$htmlline .= $gm . " | ";
if( $wm >= 80.0 || $wm <= 15.0 ) {
$htmlline .= ""; $level = max($level,$warning_level);
} else {
$htmlline .= " | ";
}
$htmlline .= $wm . " | ";
} else {
$infoline .= " 0 0 0 ";
$htmlline .= "0 | 0 | 0 | ";
$level = max($level,$incomplete_level);
}
# Column 9: Volume of gray matter inside the gray surface (cortical gray
# without sub-cortical).
my $cerebral_volume_qc = $image->{cerebral_volume};
if( -e $cerebral_volume_qc ) {
open (IDFILE, $cerebral_volume_qc);
my $idline = ;
my $idline = ; # need second line for cortical gray
close (IDFILE);
$idline =~ s/^\s+//;
my ($lbl, $gm) = split(/\s+/, $idline); chomp( $gm );
$gm /= 1000.0; # convert from mm^3 to cc
$infoline .= "$gm ";
$htmlline .= "" . $gm . " | ";
$count_gm_cortical++;
$avg_gm_cortical += $gm;
$stddev_gm_cortical += $gm*$gm;
} else {
$infoline .= "0 ";
$htmlline .= "0 | ";
$level = max($level,$incomplete_level);
}
# Columns 10,11: Error in wm surface and gm surface.
my $surface_qc = $image->{surface_qc};
if( -e $surface_qc ) {
open (IDFILE, $surface_qc);
my $idline = ;
$idline =~ /white surface \((.*)\%\), gray surface \((.*)\%\)/;
my $wm = $1;
my $gm = $2;
$infoline .= "$wm $gm ";
close (IDFILE);
$avg_gm_surf += $gm;
$stddev_gm_surf += $gm*$gm;
$avg_wm_surf += $wm;
$stddev_wm_surf += $wm*$wm;
$count_gm_wm_surf++;
if( $wm >= 20.0 ) {
$htmlline .= ""; $level = max($level,$danger_level);
} elsif( $wm >= 10.0 ) {
$htmlline .= " | "; $level = max($level,$warning_level);
} else {
$htmlline .= " | ";
}
$htmlline .= $wm . " | ";
if( $gm >= 20.0 ) {
$htmlline .= ""; $level = max($level,$danger_level);
} elsif( $gm >= 10.0 ) {
$htmlline .= " | "; $level = max($level,$warning_level);
} else {
$htmlline .= " | ";
}
$htmlline .= $gm . " | ";
} else {
$infoline .= " 100 100 ";
$htmlline .= "100 | 100 | ";
$level = max($level,$incomplete_level);
}
# Columns 12: number of self-intersections on resampled left mid surface
my $mid_rsl_left = $image->{mid_surface_rsl}{left};
if( -e $mid_rsl_left ) {
my @ret = `check_self_intersect $mid_rsl_left`;
my $left_inter = 0;
if( $ret[1] =~ m/self_intersecting/ ) { # little legacy typo
$ret[1] =~ /Number of self_intersecting triangles = (\d+)/;
$left_inter = $1;
} else {
$ret[1] =~ /Number of self-intersecting triangles = (\d+)/;
$left_inter = $1;
}
$infoline .= "$left_inter ";
if( $left_inter < 500 ) {
$avg_surfreg_left += $left_inter;
$stddev_surfreg_left += $left_inter*$left_inter;
$count_surfreg_left++;
}
if( $left_inter >= 500 ) {
$htmlline .= ""; $level = max($level,$danger_level);
} elsif( $left_inter >= 250 ) {
$htmlline .= " | "; $level = max($level,$warning_level);
} else {
$htmlline .= " | ";
}
$htmlline .= $left_inter . " | ";
} else {
$infoline .= " 0 ";
$htmlline .= "0 | ";
$level = max($level,$incomplete_level);
}
# Columns 13: number of self-intersections on resampled right mid surface
my $mid_rsl_right = $image->{mid_surface_rsl}{right};
if( -e $mid_rsl_right ) {
my @ret = `check_self_intersect $mid_rsl_right`;
my $right_inter = 0;
if( $ret[1] =~ m/self_intersecting/ ) { # little legacy typo
$ret[1] =~ /Number of self_intersecting triangles = (\d+)/;
$right_inter = $1;
} else {
$ret[1] =~ /Number of self-intersecting triangles = (\d+)/;
$right_inter = $1;
}
$infoline .= "$right_inter ";
if( $right_inter < 500 ) {
$avg_surfreg_right += $right_inter;
$stddev_surfreg_right += $right_inter*$right_inter;
$count_surfreg_right++;
}
if( $right_inter >= 500 ) {
$htmlline .= ""; $level = max($level,$danger_level);
} elsif( $right_inter >= 250 ) {
$htmlline .= " | "; $level = max($level,$warning_level);
} else {
$htmlline .= " | ";
}
$htmlline .= $right_inter . " | ";
} else {
$infoline .= " 0 ";
$htmlline .= "0 | ";
$level = max($level,$incomplete_level);
}
# Columns 14,15: number of surface-surface intersections between left/right wm-gm surfaces
foreach my $side ("left","right") {
my $gm = $image->{gray}{$side};
my $wm = $image->{cal_white}{$side};
if( -e $gm && -e $wm ) {
my $tmpobj = "${tmpdir}/surfsurf_${side}.obj";
my $tmptxt = "${tmpdir}/surfsurf_${side}.txt";
`objconcat $wm $gm none none $tmpobj none`;
`check_self_intersect $tmpobj $tmptxt`;
my @ret = split( / /, `wc -l $tmptxt` );
my $npoints = $ret[0]; chomp( $npoints ); $npoints /= 2;
`head -${npoints} $tmptxt > $tmpobj`;
`mv -f $tmpobj $tmptxt`;
`vertstats_math -const2 -0.001 0.001 -seg -old_style_file $tmptxt $tmptxt`;
@ret = `vertstats_stats $tmptxt |grep Sum`;
unlink( $tmptxt );
$ret[0] =~ / Sum: (.*)/;
my $num_inter = $1;
$infoline .= "$num_inter ";
if( $num_inter < 500 ) {
if( $side eq "left" ) {
$avg_surfsurf_left += $num_inter;
$stddev_surfsurf_left += $num_inter*$num_inter;
$count_surfsurf_left++;
} else {
$avg_surfsurf_right += $num_inter;
$stddev_surfsurf_right += $num_inter*$num_inter;
$count_surfsurf_right++;
}
}
if( $num_inter >= 500 ) {
$htmlline .= ""; $level = max($level,$danger_level);
} elsif( $num_inter >= 250 ) {
$htmlline .= " | "; $level = max($level,$warning_level);
} else {
$htmlline .= " | ";
}
$htmlline .= $num_inter . " | ";
} else {
$infoline .= " 0 ";
$htmlline .= "0 | ";
$level = max($level,$incomplete_level);
}
}
# Colums 16,17: mean cortical thickness for left,right hemispheres
foreach my $side ("left","right") {
my $meanct_file = $image->{lobe_thickness}{$side};
if( -e $meanct_file ) {
my $idline = `grep Total $meanct_file`;
chomp( $idline );
$idline =~ / Total (.*)/;
my $meanct = $1;
$infoline .= "$meanct ";
$htmlline .= "" . $meanct . " | ";
$avg_meanct += $meanct;
$stddev_meanct += $meanct*$meanct;
$count_meanct++;
} else {
$infoline .= " 0 ";
$htmlline .= "0 | ";
$level = max($level,$incomplete_level);
}
}
# Columns 18,19,20,21: T1 mean and stddev for WM and GM.
my $t1 = $image->{t1}{final};
# my $cls = $image->{cls_correct};
my $cls = "$image->{pve_prefix}\_disc.mnc";
my $mask = $image->{skull_mask_tal};
if( -e $t1 && -e $cls && -e $mask ) {
my $cls_masked = "${tmpdir}/cls_masked.mnc";
`minccalc -quiet -clobber -expression 'if(A[1]>0.5){A[0]}else{0}' $cls $mask $cls_masked`;
my $WMmean = `mincstats -quiet -mask $cls_masked -mask_binvalue 3 -mean $t1`;
my $WMsdev = `mincstats -quiet -mask $cls_masked -mask_binvalue 3 -stddev $t1`;
my $GMmean = `mincstats -quiet -mask $cls_masked -mask_binvalue 2 -mean $t1`;
my $GMsdev = `mincstats -quiet -mask $cls_masked -mask_binvalue 2 -stddev $t1`;
chomp( $WMmean );
chomp( $WMsdev );
chomp( $GMmean );
chomp( $GMsdev );
unlink( $cls_masked );
$infoline .= "$WMmean $WMsdev $GMmean $GMsdev ";
$htmlline .= "" . $WMmean . " | ";
$htmlline .= "" . $WMsdev . " | ";
$htmlline .= "" . $GMmean . " | ";
$htmlline .= "" . $GMsdev . " | ";
} else {
$infoline .= " 0 0 0 0 ";
$htmlline .= "0 | ";
$level = max($level,$incomplete_level);
}
# Columns 22: gyrification index for left hemisphere
my $gi_left = $image->{gyrification_index}{left};
if( -e $gi_left ) {
open (IDFILE, $gi_left);
my $idline = ;
$idline =~ /gyrification index gray: (.*)/;
my $gi = $1;
$infoline .= "$gi ";
close (IDFILE);
$htmlline .= "" . $gi . " | ";
} else {
$infoline .= " 0 ";
$htmlline .= "0 | ";
$level = max($level,$incomplete_level);
}
# Columns 23: gyrification index for right hemisphere
my $gi_right = $image->{gyrification_index}{right};
if( -e $gi_right ) {
open (IDFILE, $gi_right);
my $idline = ;
$idline =~ /gyrification index gray: (.*)/;
my $gi = $1;
$infoline .= "$gi ";
close (IDFILE);
$htmlline .= "" . $gi . " | ";
} else {
$infoline .= " 0 ";
$htmlline .= "0 | ";
$level = max($level,$incomplete_level);
}
# Columns 24: gyrification index for left+right hemispheres combined
my $gi_full = $image->{gyrification_index}{full};
if( -e $gi_full ) {
open (IDFILE, $gi_full);
my $idline = ;
$idline =~ /gyrification index gray: (.*)/;
my $gi = $1;
$infoline .= "$gi ";
close (IDFILE);
$htmlline .= "" . $gi . " | ";
} else {
$infoline .= " 0 ";
$htmlline .= "0 | ";
$level = max($level,$incomplete_level);
}
$infoline .= $dsid . "/thickness/" . basename( $image->{rms_rsl}{left} ) . " ";
$infoline .= $dsid . "/thickness/" . basename( $image->{rms_rsl}{right} ) . " ";
$infoline .= $dsid . "/surfaces/" . basename( $image->{surface_area_rsl}{left} ) . " ";
$infoline .= $dsid . "/surfaces/" . basename( $image->{surface_area_rsl}{right} ) . " ";
$infoline .= $dsid . "/surfaces/" . basename( $image->{surface_volume_rsl}{left} ) . " ";
$infoline .= $dsid . "/surfaces/" . basename( $image->{surface_volume_rsl}{right} ) . " ";
$infoline .= $dsid . "/surfaces/" . basename( $image->{rms_rsl}{asym_hemi} ) . " ";
$infoline .= "\n";
$info .= $infoline;
# Complete html line for global error good.
my $idcolourcode;
if( $level == $warning_level ) {
$idcolourcode = $warning;
} elsif( $level == $danger_level ) {
$idcolourcode = $danger;
} elsif( $level == $incomplete_level ) {
$idcolourcode = $incomplete;
} else {
$idcolourcode = $good;
}
$htmlline = "" .
"$dsid | " . $htmlline;
$htmlline = "" . "" . sprintf( "%4d", $count ) . " | " .
$htmlline . "
\n";
$html .= $htmlline;
open FILE, ">${qc_dir}/${dsid}.html";
print FILE "\n";
print FILE " |
\n";
print FILE " |
\n";
print FILE " |
\n";
print FILE " |
\n";
print FILE " |
\n";
print FILE "
\n";
close FILE;
}
# Line of averages and stddev on some fields.
$avg_stx_mask_error /= $count_stx_mask_error;
$avg_csf_cls /= $count_cls;
$avg_gm_cls /= $count_cls;
$avg_wm_cls /= $count_cls;
$avg_gm_cortical /= $count_gm_cortical;
$avg_gm_surf /= $count_gm_wm_surf if( $count_gm_wm_surf );
$avg_wm_surf /= $count_gm_wm_surf if( $count_gm_wm_surf );
$avg_surfreg_left /= $count_surfreg_left if( $count_surfreg_left );
$avg_surfreg_right /= $count_surfreg_right if( $count_surfreg_right );
$avg_surfsurf_left /= $count_surfsurf_left if( $count_surfsurf_left );
$avg_surfsurf_right /= $count_surfsurf_right if( $count_surfsurf_right );
$avg_meanct /= $count_meanct if( $count_meanct );
$html .= "
";
$html .= "" .
"Mean | | | | | " .
"" . sprintf( "%8.3f", $avg_stx_mask_error ) . " | " .
"" . sprintf( "%5.2f", $avg_csf_cls ) . " | " .
"" . sprintf( "%5.2f", $avg_gm_cls ) . " | " .
"" . sprintf( "%5.2f", $avg_wm_cls ) . " | " .
"" . sprintf( "%5.2f", $avg_gm_cortical ) . " | " .
"" . sprintf( "%5.2f", $avg_wm_surf ) . " | " .
"" . sprintf( "%5.2f", $avg_gm_surf ) . " | " .
"" . sprintf( "%5.2f", $avg_surfreg_left ) . " | " .
"" . sprintf( "%5.2f", $avg_surfreg_right ) . " | " .
"" . sprintf( "%5.2f", $avg_surfsurf_left ) . " | " .
"" . sprintf( "%5.2f", $avg_surfsurf_right ) . " | " .
"" . sprintf( "%5.2f", $avg_meanct ) . " | " .
"" . sprintf( "%5.2f", $avg_meanct ) . " | " .
" | | | | " .
" | | | " .
"
\n";
$stddev_stx_mask_error = sqrt( $stddev_stx_mask_error/$count_stx_mask_error -
$avg_stx_mask_error*$avg_stx_mask_error );
$stddev_csf_cls = sqrt( $stddev_csf_cls/$count_cls - $avg_csf_cls*$avg_csf_cls );
$stddev_gm_cls = sqrt( $stddev_gm_cls/$count_cls - $avg_gm_cls*$avg_gm_cls );
$stddev_wm_cls = sqrt( $stddev_wm_cls/$count_cls - $avg_wm_cls*$avg_wm_cls );
$stddev_gm_cortical = sqrt( $stddev_gm_cortical/$count_gm_cortical -
$avg_gm_cortical * $avg_gm_cortical );
$stddev_gm_surf = sqrt( $stddev_gm_surf/$count_gm_wm_surf -
$avg_gm_surf*$avg_gm_surf ) if( $count_gm_wm_surf );
$stddev_wm_surf = sqrt( $stddev_wm_surf/$count_gm_wm_surf -
$avg_wm_surf*$avg_wm_surf ) if( $count_gm_wm_surf );
$stddev_surfreg_left = sqrt( $stddev_surfreg_left/$count_surfreg_left -
$avg_surfreg_left*$avg_surfreg_left ) if( $count_surfreg_left );
$stddev_surfreg_right = sqrt( $stddev_surfreg_right/$count_surfreg_right -
$avg_surfreg_right*$avg_surfreg_right ) if( $count_surfreg_right );
$stddev_surfsurf_left = sqrt( $stddev_surfsurf_left/$count_surfsurf_left -
$avg_surfsurf_left*$avg_surfsurf_left ) if( $count_surfsurf_left );
$stddev_surfsurf_right = sqrt( $stddev_surfsurf_right/$count_surfsurf_right -
$avg_surfsurf_right*$avg_surfsurf_right ) if( $count_surfsurf_right );
$stddev_meanct = sqrt( $stddev_meanct/$count_meanct -
$avg_meanct*$avg_meanct ) if( $count_meanct );
$html .= "" .
"StdDev | | | | | " .
"" . sprintf( "%8.3f", $stddev_stx_mask_error ) . " | " .
"" . sprintf( "%5.2f", $stddev_csf_cls ) . " | " .
"" . sprintf( "%5.2f", $stddev_gm_cls ) . " | " .
"" . sprintf( "%5.2f", $stddev_wm_cls ) . " | " .
"" . sprintf( "%5.2f", $stddev_gm_cortical ) . " | " .
"" . sprintf( "%5.2f", $stddev_wm_surf ) . " | " .
"" . sprintf( "%5.2f", $stddev_gm_surf ) . " | " .
"" . sprintf( "%5.2f", $stddev_surfreg_left ) . " | " .
"" . sprintf( "%5.2f", $stddev_surfreg_right ) . " | " .
"" . sprintf( "%5.2f", $stddev_surfsurf_left ) . " | " .
"" . sprintf( "%5.2f", $stddev_surfsurf_right ) . " | " .
"" . sprintf( "%5.2f", $stddev_meanct ) . " | " .
"" . sprintf( "%5.2f", $stddev_meanct ) . " | " .
" | | | | " .
" | | | " .
"
\n";
$html .= "
";
# Do some scatter plots of the various fields.
open FILE, ">${qc_dir}/civet_${prefix}.glm";
$info =~ s/ +/ /g;
print FILE $info;
close FILE;
# ----------------------------------------------------------------------------------------------
open FILE, ">${qc_dir}/civet_${prefix}.gnu";
my $figure = 0;
$figure++;
print FILE "# Stereotaxic space brain masking error\n";
print FILE "clear\n";
print FILE "set grid\n";
print FILE "unset key\n";
print FILE "set title \"Stereotaxic space brain mask error\"\n";
print FILE "set xlabel \"Subjects\"\n";
print FILE "set ylabel \"Error %\"\n";
print FILE "set terminal png\n";
print FILE "set output \"${qc_dir}/StxMaskErr.png\"\n";
print FILE "plot \"${qc_dir}/civet_${prefix}.glm\" u 5 w po, $avg_stx_mask_error w li 2, " .
sprintf("%f",$avg_stx_mask_error-$stddev_stx_mask_error) . " w li 3, " .
sprintf("%f",$avg_stx_mask_error+$stddev_stx_mask_error) . " w li 3\n";
$html .= "