#!/usr/bin/perl use strict; use warnings; use File::Find::Rule; use NEURO qw(print_help get_pair load_study achtung shit_done); use Data::Dump qw(dump); use File::Basename qw(basename); my $net_path; @ARGV = ("-h") unless @ARGV; while (@ARGV and $ARGV[0] =~ /^-/) { $_ = shift; last if /^--$/; if (/^-path/) {$net_path = shift;} if (/^-h/) { print_help $ENV{'PIPEDIR'}.'/doc/dti_metrics.hlp'; exit;} } my $study = shift; $net_path = "out" unless $net_path; unless ($study) { print_help $ENV{'PIPEDIR'}.'/doc/dti_metrics.hlp'; exit;} my %std = load_study($study); my $w_dir=$std{'WORKING'}; my $data_dir=$std{'DATA'}; my @dti_fas = find(file => 'name' => "*_dti_FA.nii.gz", in => $w_dir); my %csv; my $ofile = $data_dir."/".$study."_dti_thresholds_".$net_path.".csv"; open OF, ">$ofile"; print OF "Threshold"; my %pollos; foreach my $dti (sort @dti_fas){ (my $a,my $subject) = $dti =~ /(\w{1,4})(\d{1,6})_dti_FA/; my $name = $a.$subject; my $img_path = $w_dir.'/'.$name.'_probtrack_'.$net_path.'/fdt_paths.nii.gz'; if(-f $img_path){ $pollos{$name} = $dti; print OF ";$name"; } } print OF "\n"; for (my $thr = 0.05; $thr<1; $thr+=0.05){ print OF "$thr"; print "$thr\n"; foreach my $pollo (sort keys %pollos){ my $img_path = $w_dir.'/'.$pollo.'_probtrack_'.$net_path.'/fdt_paths.nii.gz'; my $order = $ENV{'PIPEDIR'}.'/bin/track2mask.sh '.$img_path.' '.$thr; system($order); my $mask_path = $w_dir.'/'.$pollo.'_probtrack_'.$net_path.'/fdt_paths_mask.nii.gz'; $order = "fslstats ".$pollos{$pollo}." -k ".$mask_path." -M -S"; (my $mean, my $std) = map{/(\d+\.\d*)\s*(\d+\.\d*)/} qx/$order/; print OF ";$mean"; } print OF "\n"; } close OF; achtung basename($ENV{_}), $ofile, $study;