#!/usr/bin/env perl # # Compute the gyrification index of a cortical surface. Ideally, this should # be done in native space unless lsq6 or lsq7 linear registration is used. # Non-uniform scaling factors (lsq9 or lsq12) can change the index if compute # in Talairach. # # 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 /; # --- set the help & usage strings --- my $help = < 1, CLEANUP => 1 ); my $surface_native = $surface; if( defined $transform_xfm ) { $surface_native = "${tmpdir}/surface_native.obj"; my $inv_trans = "${tmpdir}/inv_trans.xfm"; &run( "xfminvert", $transform_xfm, $inv_trans ); &run( "transform_objects", $surface, $inv_trans, $surface_native ); } my $convex_hull = "${tmpdir}/convex_hull.obj"; &run( "convex_hull", $surface_native, $convex_hull ); my ($bla,$area_surface,$area_hull); ($bla,$area_surface) = split(' ',`measure_surface_area $surface_native`); ($bla,$area_hull) = split(' ',`measure_surface_area $convex_hull`); my $info; if( defined $label ) { $info = sprintf( "gyrification index %s: %5.3f\n", $label, ${area_surface}/${area_hull} ); } else { $info = sprintf( "gyrification index: %5.3f\n", ${area_surface}/${area_hull} ); } if( defined $info_file ) { open PIPE, ($append) ? ">>$info_file" : ">$info_file"; print PIPE $info; } else { print $info; } #Execute a system call. sub run { system(@_)==0 or die "Command @_ failed with status: $?"; }