#!/usr/bin/perl -w #--------------------------------------------------------------------------- #@COPYRIGHT : # Copyright 1996, John G. Sled, # McConnell Brain Imaging Centre, # Montreal Neurological Institute, McGill University. # Permission to use, copy, modify, and distribute this # software and its documentation for any purpose and without # fee is hereby granted, provided that the above copyright # notice appear in all copies. The author and McGill University # make no representations about the suitability of this # software for any purpose. It is provided "as is" without # express or implied warranty. #---------------------------------------------------------------------------- #$RCSfile: sharpen_volume.in,v $ #$Revision: 1.1 $ #$Author: bert $ #$Date: 2003/04/16 14:29:34 $ #$State: Exp $ #--------------------------------------------------------------------------- # ------------------------------ MNI Header ---------------------------------- #@NAME : sharpen_volume #@INPUT : #@OUTPUT : #@RETURNS : #@DESCRIPTION: modifies intensities so as to produce a sharper histogram #@METHOD : #@GLOBALS : #@CALLS : #@CREATED : February 28, 1996 #@MODIFIED : #----------------------------------------------------------------------------- use MNI::Startup qw(nocputimes); use MNI::Spawn; use MNI::FileUtilities; use Getopt::Tabular; &Initialize; &Spawn(['volume_hist', '-bins', $bins, '-auto_range', '-mask', $mask_volume, $source_volume, "$base_name.hist", '-clobber', '-text', '-select', 1, '-quiet', @window_option]); $min_bin = 0; $max_bin = 1; open(FILE, "$base_name.hist"); while() { if(/domain: +([-e\d\.]+) +([-e\d\.]+)/) { $min_bin = $1; $max_bin = $2; } } close(FILE); &Spawn(['sharpen_hist', '-clobber', @blur_option, '-fwhm', $filter_fwhm, '-noise', $noise_level, '-quiet', '-range', $min_bin, $max_bin, "$base_name.hist", "$base_name.sharp"]); &Spawn(['minclookup', '-continuous', '-range', $min_bin, $max_bin, '-clobber', '-lookup_table', "$base_name.sharp", $source_volume, $output_volume]); (defined $save_histogram) && &Spawn("cp $base_name.hist $save_histogram"); # ------------------------------ MNI Header ---------------------------------- #@NAME : &Initialize #@INPUT : none #@OUTPUT : none #@RETURNS : #@DESCRIPTION: #@METHOD : #@GLOBALS : #@CALLS : #@CREATED : #@MODIFIED : #----------------------------------------------------------------------------- sub Initialize { $Version = '1.10'; $LongVersion = 'Package MNI N3, version 1.10, compiled by nicks@minerva (x86_64-unknown-linux-gnu) on 2010-02-20 at 17:32:37'; $Usage = < fwhm of blur in histogram (default .2)"], ["-noise", "float", 1, \$noise_level, " noise threshold for deconvolution"], ["-bins", "integer", 1, \$bins, " specify number of bins in histogram (default 200)"], ["-blur|-deblur", "boolean", undef, \$blur_flag, "use blurring. -deblur: skip deblurring step."], ["-parzen|-noparzen", "boolean", undef, \$window_flag, "use Parzen window when estimating intensity distribution"], ["-save_histogram", "string", 1, \$save_histogram, "keep uncorrected histogram"]); my (@reducedARGV); GetOptions(\@args_table, \@ARGV, \@reducedARGV) || exit 1; if (@reducedARGV != 3) { print STDERR "Leftover args: @reducedARGV\n" if @reducedARGV; print STDERR $Usage; die "Incorrect number of arguments\n"; } ($mask_volume, $source_volume, $output_volume) = @reducedARGV; # check whether $output_volume can be over written ((-e $output_volume) && ! $Clobber) && (die("Clobber option not given. Cannot overwrite file:" ." $output_volume\n")); ($output_volume =~ ?^([\S]+).mnc?) && ($base_name = $1) || die "sharpen_volume failed: output volume does not appear to be" ." a minc volume.\n"; @blur_option = $blur_flag ? ('-blur') : (); @window_option = $window_flag ? ('-window') : (); # Set global variables for calling various programs MNI::Spawn::SetOptions (strict => 2); RegisterPrograms([qw(volume_hist sharpen_hist minclookup cp)]); }