#! /usr/bin/env perl # # Compute the percentages of classified CSF, WM, GM. # # Note: This is for the whole head, including brain stem and cerebellum, # so not ideal to represent the WM and GM we want. # # Claude Lepage - claude@bic.mni.mcgill.ca # # Copyright Alan C. Evans # Professor of Neurology # McGill University # use strict; use warnings "all"; use Getopt::Tabular; use File::Basename; use File::Temp qw/ tempdir /; my($Help, $Usage, $me); my $transform_xfm = undef; $me = &basename($0); $Help = < 1, CLEANUP => 1 ); if( ( $mask ne "none" ) and ( -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`; $cls = $cls_masked; } my $csf_vol; chomp( $csf_vol = `mincstats -quiet -count -mask $cls -mask_binvalue 1 $cls` ); my $gm_vol; chomp( $gm_vol = `mincstats -quiet -count -mask $cls -mask_binvalue 2 $cls` ); my $wm_vol; chomp( $wm_vol = `mincstats -quiet -count -mask $cls -mask_binvalue 3 $cls` ); my $total_vol = $csf_vol + $gm_vol + $wm_vol; my $csf_pct = 100.0 * $csf_vol / $total_vol; my $gm_pct = 100.0 * $gm_vol / $total_vol; my $wm_pct = 100.0 * $wm_vol / $total_vol; if( defined $info_file ) { open PIPE, ">$info_file"; print PIPE sprintf( "classified image CSF %5.2f%% GM %5.2f%% WM %5.2f%%\n", $csf_pct, $gm_pct, $wm_pct ); close PIPE; } else { print sprintf( "classified image CSF %5.2f%% GM %5.2f%% WM %5.2f%%\n", $csf_pct, $gm_pct, $wm_pct ); }