Index: ./src/csh/FIASCO Prereq: 1.23 *** /TOIL-U4/fiasco/Fiasco5.1/src/csh/FIASCO Thu Apr 4 14:21:56 2002 --- ./src/csh/FIASCO Mon Apr 15 17:48:54 2002 *************** *** 45,58 **** echo '#BEGINNING NEW ANALYSIS' >>& $LOGFILE setenv F_STARTDATE "`date`" echo '#'$F_STARTDATE $0 >>& $LOGFILE ! echo '$Id: FIASCO,v 1.23 2002/04/04 19:08:35 welling Exp $'\ >>& $LOGFILE echo '#'`whoami`' '`hostname` >>& $LOGFILE echo '#'$1' Processing' >>& $LOGFILE # FIASCO_VERSION number setenv FIASCO_VERSION 5.1 ! setenv FIASCO_PATCHLVL 2 echo "#FIASCO Version "$FIASCO_VERSION" patch "$FIASCO_PATCHLVL\ >>& $LOGFILE if ($1 == 'spiral') then --- 45,58 ---- echo '#BEGINNING NEW ANALYSIS' >>& $LOGFILE setenv F_STARTDATE "`date`" echo '#'$F_STARTDATE $0 >>& $LOGFILE ! echo '$Id: FIASCO,v 1.24 2002/04/15 21:20:56 welling Exp $'\ >>& $LOGFILE echo '#'`whoami`' '`hostname` >>& $LOGFILE echo '#'$1' Processing' >>& $LOGFILE # FIASCO_VERSION number setenv FIASCO_VERSION 5.1 ! setenv FIASCO_PATCHLVL 3 echo "#FIASCO Version "$FIASCO_VERSION" patch "$FIASCO_PATCHLVL\ >>& $LOGFILE if ($1 == 'spiral') then Index: ./src/csh/Makefile *** /TOIL-U4/fiasco/Fiasco5.1/src/csh/Makefile Thu Apr 4 14:21:56 2002 --- ./src/csh/Makefile Wed Apr 17 16:03:19 2002 *************** *** 29,35 **** awk '{ if (match($$0,/setenv SPLUS/)) { \ print "#"$$0; print "setenv SPLUS $(SPLUSEXE)"} \ else { print $0}} ' < fiasco.local_orig.csh > fiasco.local.csh ! chmod +x fiasco.local.csh -cp -f $(SCRIPTFILES) $B make_docs: --- 29,35 ---- awk '{ if (match($$0,/setenv SPLUS/)) { \ print "#"$$0; print "setenv SPLUS $(SPLUSEXE)"} \ else { print $0}} ' < fiasco.local_orig.csh > fiasco.local.csh ! chmod +x fiasco.local.csh $(SCRIPTFILES) -cp -f $(SCRIPTFILES) $B make_docs: Index: ./src/csh/color_by_phase.csh *** /TOIL-U4/fiasco/Fiasco5.1/src/csh/color_by_phase.csh Wed Apr 17 14:56:26 2002 --- ./src/csh/color_by_phase.csh Wed Apr 17 14:42:55 2002 *************** *** 0 **** --- 1,178 ---- + #! /bin/csh -ef + # color_by_phase.csh + #/************************************************************ + # * * + # * Permission is hereby granted to any individual or * + # * institution for use, copying, or redistribution of * + # * this code and associated documentation, provided * + # * that such code and documentation are not sold for * + # * profit and the following copyright notice is retained * + # * in the code and documentation: * + # * Copyright (c) 1998,1999 Department of Statistics, * + # * Carnegie Mellon University * + # * * + # * This program is distributed in the hope that it will * + # * be useful, but WITHOUT ANY WARRANTY; without even the * + # * implied warranty of MERCHANTABILITY or FITNESS FOR A * + # * PARTICULAR PURPOSE. Neither Carnegie Mellon University * + # * nor any of the authors assume any liability for * + # * damages, incidental or otherwise, caused by the * + # * installation or use of this software. * + # * * + # * CLINICAL APPLICATIONS ARE NOT RECOMMENDED, AND THIS * + # * SOFTWARE HAS NOT BEEN EVALUATED BY THE UNITED STATES * + # * FDA FOR ANY CLINICAL USE. * + # * * + # * * + # * Original programming by Bill Eddy * + # ************************************************************/ + # + echo '#'`date` $0 + echo '# $Id: color_by_phase.csh,v 1.4 2002/04/17 18:41:09 welling Exp $' + # + # This script generates a color image from a complex dataset, by + # using magnitude (as a fraction of min-max range) and phase as + # the hue and value of an HSV color triple, with saturation=1. + # The one argument is the name of a single complex image file. + # + + # Parse command line options + set args = `getopt bdrgp $*` + if ($#args < 2 ) then + echo "usage: " $0 '[-b -d -r -g -png] filename' + echo " -b brightens image" + echo " -d dims image" + echo " -r reverses black and white, blue and yellow, etc." + echo " -p produces PNG rather than postscript." + exit -1 + endif + set ropt = "" + set bopt = "" + set dopt = "" + set pngopt = "" + while ($#args > 1) + switch ( $args[1] ) + case '-b' : + set bopt = "-b" ; shift args; breaksw; + case '-d' : + set dopt = "-d" ; shift args; breaksw; + case '-r' : + set ropt = "-r" ; shift args; breaksw; + case '-p' : + set pngopt = "-png" ; shift args; breaksw; + case '--' : + shift args; breaksw; + endsw + if (junk${args[1]} == 'junk--') then + shift args; + break; + endif + end + if ($#args != 1) then + echo $0 ': only one filename permitted' + exit -1 + endif + set argv = $args + + # Get the root name, to construct output filename + if ($1:t == ".mri") then + set tailname = $1:t + set fname = $tailname:r + else + set fname = $1:t + endif + + # Grab some ancillary info from the .mri file + set type = \ + `mri_printfield -input $1 -field images.datatype -nofail` + set idtag = \ + `mri_printfield -input $1 -field images.scan.id -nofail` + + # Use the file name for first title + setenv F_PS_TITLE1 $1 + + # Use the ID tag as second title if available. + if (! ${?F_PS_TITLE2} && dummy$idtag != dummy ) then + setenv F_PS_TITLE2 "ID $idtag" + endif + + set vdim = `mri_printfield -input $1 -field images.extent.v` + set xdim = `mri_printfield -input $1 -field images.extent.x` + set ydim = `mri_printfield -input $1 -field images.extent.y` + set zdim = `mri_printfield -input $1 -field images.extent.z` + set tdim = `mri_printfield -input $1 -field images.extent.t -nofail` + if ( foo$tdim == foo ) set tdim = 1 + + if ( $vdim != 2 ) then + echo "Input file $1 is not complex!" + exit -1 + endif + + @ qdim = $xdim * $ydim * $zdim * $tdim + + # + # Make some scratch space, and go there. + # + if ( ${?F_TEMP} ) then + set tmpdir = ${F_TEMP}/color_by_phase_tmp_$$ + else + set tmpdir = ./color_by_phase_tmp_$$ + endif + if (! -e $tmpdir) mkdir $tmpdir + set homedir = `pwd` + if ( $1 =~ /* ) then + set input = $1 + else + set input = $homedir/$1 + endif + cd $tmpdir + + #Collect the undetermined options. + set allopts = "-n 0.0 -x 255.0 -mosaic -t -c -p $pngopt $ropt $bopt $dopt" + + mri_complex_to_scalar -m $input mags + mri_complex_to_scalar -p $input phase + + # If this is byte data, assume a range 0 to 255. Otherwise + # we rescale the range. + if ($type == "uint8") then + mri_rpn_math -o scaled_mags '$1,255,/' mags + else + mri_copy_dataset mags tmp1 + mri_remap -file tmp1 -order q -extents $qdim + mri_subsample -d q -e 1 -max tmp1 mag_max + mri_subsample -d q -e 1 -min tmp1 mag_min + mri_rpn_math -o scaled_mags '$1,$2,-,$3,$2,-,/' mags mag_min mag_max + endif + + # + # The following implements the HLS->RGB conversion from "Computer + # Graphics Principles and Practice" by Foley, van Dam, Feiner, + # and Hughes, chapter 13. + # + mri_rpn_math -o phase_zone '$1,0,2,pi,*,$1,0,>,if_keep,+,pi,/,3,*' phase + mri_rpn_math -o phase_int '$1,floor,5,min,0,max' phase_zone + mri_rpn_math -o phase_off '$1,$2,-' phase_zone phase_int + + mri_rpn_math -o p '0' scaled_mags phase_off + mri_rpn_math -o q '$1,1,$2,-,*' scaled_mags phase_off + mri_rpn_math -o t '$1,$2,*' scaled_mags phase_off + + mri_rpn_math -o r '$1,$4,$2,$2,$3,$1,$5,switch_6,255,*' \ + scaled_mags p q t phase_int + mri_rpn_math -o g '$2,$2,$3,$1,$1,$4,$5,switch_6,255,*' \ + scaled_mags p q t phase_int + mri_rpn_math -o b '$3,$1,$1,$4,$2,$2,$5,switch_6,255,*' \ + scaled_mags p q t phase_int + mri_paste -d v -out result r g b + + if ( foo$pngopt != foo ) then + mri_to_img -o $homedir/$fname.png $allopts result + else + mri_to_img -o $homedir/$fname.ps $allopts result + endif + + #clean up + cd $homedir + rm -r $tmpdir + Index: ./src/csh/despike_sampwise.csh *** /TOIL-U4/fiasco/Fiasco5.1/src/csh/despike_sampwise.csh Mon Apr 15 17:18:43 2002 --- ./src/csh/despike_sampwise.csh Tue Mar 19 19:35:55 2002 *************** *** 0 **** --- 1,99 ---- + #! /usr/bin/csh -exf + # despike_sampwise.csh + #/************************************************************ + # * * + # * Permission is hereby granted to any individual or * + # * institution for use, copying, or redistribution of * + # * this code and associated documentation, provided * + # * that such code and documentation are not sold for * + # * profit and the following copyright notice is retained * + # * in the code and documentation: * + # * Copyright (c) 1995 Department of Statistics, * + # * Carnegie Mellon University * + # * * + # * This program is distributed in the hope that it will * + # * be useful, but WITHOUT ANY WARRANTY; without even the * + # * implied warranty of MERCHANTABILITY or FITNESS FOR A * + # * PARTICULAR PURPOSE. Neither Carnegie Mellon University * + # * nor any of the authors assume any liability for * + # * damages, incidental or otherwise, caused by the * + # * installation or use of this software. * + # * * + # * CLINICAL APPLICATIONS ARE NOT RECOMMENDED, AND THIS * + # * SOFTWARE HAS NOT BEEN EVALUATED BY THE UNITED STATES * + # * FDA FOR ANY CLINICAL USE. * + # * * + # * * + # * Original programming by Bill Eddy * + # ************************************************************/ + # + echo '#'`date` $0 + echo '#$Id: despike_sampwise.csh,v 1.1 2002/03/20 00:35:12 welling Exp $' + + # + # spk_t0_cutoff is the cutoff threshold for image 0, in terms of + # (orig-smoothed)/(IQR) + # spk_t0_band is the smoother bandwidth used for image t0. + # + set spk_band = $F_DESPIKE_T0_BND + set spk_cutoff = $F_DESPIKE_T0_CUT + + # + # Make some of the parameters easier to remember + # + set q1 = $2 + set q3 = $3 + set result = $4 + set spike_count = $5 + + # + # We guess at where the spikes are by looking for rapid changes in + # magnitude, taking only the positive changes in this case. (Otherwise + # we end up picking up samples adjacent to the spike because of the + # smoothing operation). + # + mri_complex_to_scalar -m ${1} ${1}_m + mri_complex_to_scalar -u ${1} ${1}_p + mri_smooth -d p -b $spk_band ${1}_m ${1}_smooth_m + mri_rpn_math -o ${1}_trigger '$1,$2,-,$3,$4,-,/' ${1}_m ${1}_smooth_m $q3 $q1 + mri_destroy_dataset ${1}_smooth_m + mri_rpn_math -o ${1}_is_a_spike '$1,'$spk_cutoff',<' ${1}_trigger + mri_destroy_dataset ${1}_trigger + + # + # Through clever use of a triangular filter we happen to have handy, + # we'll produce a set of replacement values for the spikes which are + # the average of the two adjacent points. + # + mri_smooth -d p -b 2 -kernel triangular ${1}_m ${1}_triangle_m + mri_smooth -d p -b 2 -kernel triangular ${1}_p ${1}_triangle_p + mri_rpn_math -o ${1}_interp_m '$1,$2,0.5,*,-,2,*' ${1}_triangle_m ${1}_m + mri_destroy_dataset ${1}_triangle_m + mri_destroy_dataset ${1}_m + mri_rpn_math -o ${1}_interp_p '$1,$2,0.5,*,-,2,*' ${1}_triangle_p ${1}_p + mri_destroy_dataset ${1}_triangle_p + mri_destroy_dataset ${1}_p + + # + # Substitute these replacement values where appropriate + # + mri_rpn_math -o ${1}_r_interp '$1,$2,cos,*' \ + ${1}_interp_m ${1}_interp_p + mri_rpn_math -o ${1}_i_interp '$1,$2,sin,*' \ + ${1}_interp_m ${1}_interp_p + mri_destroy_dataset ${1}_interp_m + mri_destroy_dataset ${1}_interp_p + mri_paste -d v -out ${1}_interp ${1}_r_interp ${1}_i_interp + mri_destroy_dataset ${1}_r_interp + mri_destroy_dataset ${1}_i_interp + mri_interp -c -d v -e 2 ${1}_is_a_spike ${1}_is_a_spike_complex + mri_rpn_math -o $result '$1,$2,$3,if_keep' \ + ${1} ${1}_interp ${1}_is_a_spike_complex + mri_destroy_dataset ${1}_interp + mri_destroy_dataset ${1}_is_a_spike_complex + + # Produce spike count information + mri_subsample -sum -d p -e 1 ${1}_is_a_spike $spike_count + + # Clean up + mri_destroy_dataset ${1}_is_a_spike Index: ./src/csh/despike_timewise.csh *** /TOIL-U4/fiasco/Fiasco5.1/src/csh/despike_timewise.csh Mon Apr 15 17:18:50 2002 --- ./src/csh/despike_timewise.csh Tue Mar 19 19:35:55 2002 *************** *** 0 **** --- 1,112 ---- + #! /usr/bin/csh -exf + # despike_timewise.csh + #/************************************************************ + # * * + # * Permission is hereby granted to any individual or * + # * institution for use, copying, or redistribution of * + # * this code and associated documentation, provided * + # * that such code and documentation are not sold for * + # * profit and the following copyright notice is retained * + # * in the code and documentation: * + # * Copyright (c) 1995 Department of Statistics, * + # * Carnegie Mellon University * + # * * + # * This program is distributed in the hope that it will * + # * be useful, but WITHOUT ANY WARRANTY; without even the * + # * implied warranty of MERCHANTABILITY or FITNESS FOR A * + # * PARTICULAR PURPOSE. Neither Carnegie Mellon University * + # * nor any of the authors assume any liability for * + # * damages, incidental or otherwise, caused by the * + # * installation or use of this software. * + # * * + # * CLINICAL APPLICATIONS ARE NOT RECOMMENDED, AND THIS * + # * SOFTWARE HAS NOT BEEN EVALUATED BY THE UNITED STATES * + # * FDA FOR ANY CLINICAL USE. * + # * * + # * * + # * Original programming by Bill Eddy * + # ************************************************************/ + # + echo '#'`date` $0 + echo '#$Id: despike_timewise.csh,v 1.1 2002/03/20 00:35:12 welling Exp $' + + # + # spk_cutoff is the cutoff threshold (in terms of (mag-median)/(IQR)) + # for the body of the data (all but image 0) + set spk_cutoff = $F_DESPIKE_CUTOFF + + set tdim = `mri_printfield -input $1 -field images.extent.t` + @ median_offset = $tdim / 2 + @ q3_offset = $tdim / 4 + @ q1_offset = ( 3 * $tdim ) / 4 + + # + # Prepare median and quartiles for magnitude. + # + mri_complex_to_scalar -m ${1} ${1}_m + mri_permute -input ${1}_m -headerout ${1}_m_prm -order tvpscz + mri_remap -file ${1}_m_prm -order vtpscz + mri_sort ${1}_m_prm ${1}_m_sorted + mri_subset -d t -l 1 -s $median_offset ${1}_m_sorted ${1}_m_median + mri_subset -d t -l 1 -s $q1_offset ${1}_m_sorted ${1}_m_q1 + mri_subset -d t -l 1 -s $q3_offset ${1}_m_sorted ${1}_m_q3 + mri_destroy_dataset ${1}_m_sorted + mri_destroy_dataset ${1}_m_prm + + # + # Prepare median for phase + # We clip off the first image for special processing. + # + mri_complex_to_scalar -u ${1} ${1}_p + mri_permute -input ${1}_p -headerout ${1}_p_prm -order tvpscz + mri_destroy_dataset ${1}_p + mri_remap -file ${1}_p_prm -order vtpscz + mri_sort ${1}_p_prm ${1}_p_sorted + mri_subset -d t -l 1 -s $median_offset ${1}_p_sorted ${1}_p_median + mri_destroy_dataset ${1}_p_prm + mri_destroy_dataset ${1}_p_sorted + + # Reconstruct complex median for t != 0 + mri_remap -file ${1}_m_median -order vpsczt + mri_remap -file ${1}_m_q1 -order vpsczt + mri_remap -file ${1}_m_q3 -order vpsczt + mri_remap -file ${1}_p_median -order vpsczt + mri_rpn_math -o ${1}_r_median '$1,$2,cos,*' ${1}_m_median ${1}_p_median + mri_rpn_math -o ${1}_i_median '$1,$2,sin,*' ${1}_m_median ${1}_p_median + mri_paste -d v -out ${1}_median ${1}_r_median ${1}_i_median + mri_destroy_dataset ${1}_r_median + mri_destroy_dataset ${1}_i_median + + # + # A given sample is considered to be a spike if its "trigger" value + # (computed below) is larger than $spk_cutoff (defined above). + # + mri_rpn_math -o ${1}_trigger '$1,$2,-,$3,$4,-,/,abs' \ + ${1}_m ${1}_m_median ${1}_m_q3 ${1}_m_q1 + mri_destroy_dataset ${1}_m + mri_remap -file ${1}_trigger -order vpsczt + mri_rpn_math -o ${1}_is_a_spike '$1,'$spk_cutoff',<' ${1}_trigger + mri_destroy_dataset ${1}_trigger + + # + # By substituting for the spike points, we make filtered values. + # + mri_permute -input ${1}_is_a_spike -headerout ${1}_is_a_spike_tmp \ + -order pscztv + mri_paste -d v -out ${1}_is_a_spike_complex_tmp \ + ${1}_is_a_spike_tmp ${1}_is_a_spike_tmp + mri_destroy_dataset ${1}_is_a_spike_tmp + mri_permute -input ${1}_is_a_spike_complex_tmp \ + -headerout ${1}_is_a_spike_complex -order vpsczt + mri_destroy_dataset ${1}_is_a_spike_complex_tmp + mri_rpn_math -o ${2} '$1,$2,$3,if_keep' \ + ${1} ${1}_median ${1}_is_a_spike_complex + mri_destroy_dataset ${1}_median + mri_destroy_dataset ${1}_is_a_spike_complex + + # Produce spike count information + mri_subsample -sum -d p -e 1 ${1}_is_a_spike ${3} + + # Clean up + mri_destroy_dataset ${1}_is_a_spike + Index: ./src/csh/epi.despike.csh *** /TOIL-U4/fiasco/Fiasco5.1/src/csh/epi.despike.csh Mon Apr 15 17:18:24 2002 --- ./src/csh/epi.despike.csh Thu Apr 11 18:01:08 2002 *************** *** 0 **** --- 1,69 ---- + #! /usr/bin/csh -exf + # epi.despike.csh + #/************************************************************ + # * * + # * Permission is hereby granted to any individual or * + # * institution for use, copying, or redistribution of * + # * this code and associated documentation, provided * + # * that such code and documentation are not sold for * + # * profit and the following copyright notice is retained * + # * in the code and documentation: * + # * Copyright (c) 1995 Department of Statistics, * + # * Carnegie Mellon University * + # * * + # * This program is distributed in the hope that it will * + # * be useful, but WITHOUT ANY WARRANTY; without even the * + # * implied warranty of MERCHANTABILITY or FITNESS FOR A * + # * PARTICULAR PURPOSE. Neither Carnegie Mellon University * + # * nor any of the authors assume any liability for * + # * damages, incidental or otherwise, caused by the * + # * installation or use of this software. * + # * * + # * CLINICAL APPLICATIONS ARE NOT RECOMMENDED, AND THIS * + # * SOFTWARE HAS NOT BEEN EVALUATED BY THE UNITED STATES * + # * FDA FOR ANY CLINICAL USE. * + # * * + # * * + # * Original programming by Bill Eddy * + # ************************************************************/ + # + echo '#'`date` $0 + echo '#$Id: epi.despike.csh,v 1.2 2002/04/11 22:00:13 welling Exp $' + + # Find out some dimensions + set vdim = `mri_printfield -input $1 -field images.extent.v` + set xdim = `mri_printfield -input $1 -field images.extent.x` + set ydim = `mri_printfield -input $1 -field images.extent.y` + set zdim = `mri_printfield -input $1 -field images.extent.z` + set tdim = `mri_printfield -input $1 -field images.extent.t` + + @ pdim = ( $xdim * $ydim ) + + # Make a working copy, and give it the needed shape. + mri_type_convert -float $1 data/raw_samples + mri_remap -file data/raw_samples -order vpsczt \ + -extents ${vdim}:${pdim}:1:1:${zdim}:${tdim} + + # Despike the data by comparing across times. + despike_timewise.csh data/raw_samples data/samples_filtered data/spike_count + mri_destroy_dataset data/raw_samples + + # Produce an output dataset + mri_copy_dataset $1 $2 + mri_remap -file data/samples_filtered -order vxyzt \ + -extents ${vdim}:${xdim}:${ydim}:${zdim}:${tdim} + mri_copy_chunk -input data/samples_filtered -output $2 \ + -chunk images -to images -replace + mri_destroy_dataset data/samples_filtered + + # Produce summary information + if(! -d par) mkdir par + set step = `depath.csh $0` + echo '##Format: order:index_tz type:raw names:(spike_count)' \ + > par/$F_DESPIKE_PARMS + mri_rpn_math -o data/junk '0,$t,$z,$1,1,if_print_3' \ + data/spike_count >> par/$F_DESPIKE_PARMS + echo "$step par/${F_DESPIKE_PARMS}" >> $F_SUMM_INPUT + mri_destroy_dataset data/junk + mri_destroy_dataset data/spike_count + Index: ./src/csh/make_cine.csh *** /TOIL-U4/fiasco/Fiasco5.1/src/csh/make_cine.csh Wed Apr 17 14:56:09 2002 --- ./src/csh/make_cine.csh Mon Apr 15 19:57:47 2002 *************** *** 0 **** --- 1,188 ---- + #! /bin/csh -ef + # make_cine.csh + #/************************************************************ + # * * + # * Permission is hereby granted to any individual or * + # * institution for use, copying, or redistribution of * + # * this code and associated documentation, provided * + # * that such code and documentation are not sold for * + # * profit and the following copyright notice is retained * + # * in the code and documentation: * + # * Copyright (c) 1998,1999 Department of Statistics, * + # * Carnegie Mellon University * + # * * + # * This program is distributed in the hope that it will * + # * be useful, but WITHOUT ANY WARRANTY; without even the * + # * implied warranty of MERCHANTABILITY or FITNESS FOR A * + # * PARTICULAR PURPOSE. Neither Carnegie Mellon University * + # * nor any of the authors assume any liability for * + # * damages, incidental or otherwise, caused by the * + # * installation or use of this software. * + # * * + # * CLINICAL APPLICATIONS ARE NOT RECOMMENDED, AND THIS * + # * SOFTWARE HAS NOT BEEN EVALUATED BY THE UNITED STATES * + # * FDA FOR ANY CLINICAL USE. * + # * * + # * * + # * Original programming by Bill Eddy * + # ************************************************************/ + # + echo '#'`date` $0 + echo '# $Id: make_cine.csh,v 1.4 2002/04/15 23:57:12 welling Exp $' + # + # This script generates a cine loop from a (v)xyzt dataset. + # The one argument is the name of a single scalar dataset file. + # + + # Parse command line options + set args = `getopt bdrn:x: $*` + if ($#args < 2 ) then + echo "usage: " $0 '[-b -d -r -n min -x max] filename' + echo " -b brightens image" + echo " -d dims image" + echo " -r reverses black and white" + echo " -n min uses the given minimum value" + echo " -x max uses the given maximum value" + exit -1 + endif + set ropt = "" + set bopt = "" + set dopt = "" + set nopt = "" + set xopt = "" + while ($#args > 1) + switch ( $args[1] ) + case '-b' : + set bopt = "-b" ; shift args; breaksw; + case '-d' : + set dopt = "-d" ; shift args; breaksw; + case '-r' : + set ropt = "-r" ; shift args; breaksw; + case '-n' : + set nopt = "-n $args[2]" ; shift args; shift args; breaksw; + case '-x' : + set xopt = "-x $args[2]" ; shift args; shift args; breaksw; + case '--' : + shift args; breaksw; + endsw + if (junk${args[1]} == 'junk--') then + shift args; + break; + endif + end + if ($#args != 1) then + echo $0 ': only one filename permitted' + exit -1 + endif + set argv = $args + + # Check that the needed "convert" utility is present + if ( `test_in_subshell.csh which convert` ) then + echo ${0:t} ': The convert utility was needed but was not found!' + exit -1 + endif + + # Get the root name, to construct output filename + if ($1:t == ".mri") then + set tailname = $1:t + set fname = $tailname:r + else + set fname = $1:t + endif + + set vdim = `mri_printfield -input $1 -field images.extent.v -nofail` + if ( foo$vdim == foo ) set vdim = 1 + set xdim = `mri_printfield -input $1 -field images.extent.x` + set ydim = `mri_printfield -input $1 -field images.extent.y` + set zdim = `mri_printfield -input $1 -field images.extent.z` + set tdim = `mri_printfield -input $1 -field images.extent.t -nofail` + if ( foo$tdim == foo ) set tdim = 1 + + @ qdim = $xdim * $ydim * $zdim + + if ( $vdim != 1 ) then + echo "Input file $1 is not scalar!" + exit -1 + endif + + # + # Make some scratch space, and go there. + # + if ( ${?F_TEMP} ) then + set tmpdir = ${F_TEMP}/make_cine_tmp_$$ + else + set tmpdir = ./make_cine_tmp_$$ + endif + if (! -e $tmpdir) mkdir $tmpdir + set homedir = `pwd` + if ( $1 =~ /* ) then + set input = $1 + else + set input = $homedir/$1 + endif + cd $tmpdir + mkdir frames + + #We need the input range + + if ( `mri_printfield -input $input -field images.dimensions` == xyzt ) then + mri_permute -input $input -headerout ${fname}_p -order txyz + else + mri_permute -input $input -headerout ${fname}_p -order vtxyz + endif + mri_remap -file ${fname}_p -order tq -extents ${tdim}:${qdim} + mri_subsample -d t -e 1 -max ${fname}_p ${fname}_t + set missing_chunk = `mri_printfield -input ${fname}_t -field missing -nofail` + if ( ${#missing_chunk} != 0 ) then + mri_delete_chunk -dataset ${fname}_t -chunk missing + endif + mri_destroy_dataset ${fname}_p + mri_subsample -d q -e 1 -max ${fname}_t max + mri_subsample -d q -e 1 -min ${fname}_t min + + #Collect the undetermined options. + set allopts = "$nopt $xopt -png -mosaic $ropt $bopt $dopt" + + set t = 0 + + @ xlim = $xdim - 1 + @ ylim = $ydim - 1 + + echo "Generating $tdim frames..." + while ( $t < $tdim ) + echo -n "${t}... " + if ( ! ( $t % 10 ) && $t != 0 ) echo "" + mri_subset -d t -l 1 -s $t $input thistime + mri_rpn_math -o bright_image '$1,$2,-,$3,$2,-,/,sqrt' thistime min max + mri_rpn_math -o image_with_border \ + '$1,1,$x,0,==,$y,0,==,+,$x,'$xlim',==,+,$y,'$ylim',==,+,if_keep' \ + bright_image + # We have to jigger with the output file names to make sure they + # sort to the right order. This version will break if there are + # more than 10000 frames, but it should hold us for a while! + if ( $t < 10 ) then + set oname = frames/frame_000$t.png + else if ( $t < 100 ) then + set oname = frames/frame_00$t.png + else if ( $t < 1000 ) then + set oname = frames/frame_0$t.png + else + set oname = frames_frame_$t.png + endif + mri_to_img ${allopts} \ + -o ${oname} image_with_border + @ t = $t + 1 + end + echo "done" + + echo "Assembling mpeg..." + + cd frames + convert -scale 200%! frame_*.png ${homedir}/${fname}.mpg + + echo "Done." + + #clean up + cd $homedir + rm -r $tmpdir + Index: ./src/csh/make_phase_cine.csh *** /TOIL-U4/fiasco/Fiasco5.1/src/csh/make_phase_cine.csh Wed Apr 17 14:56:15 2002 --- ./src/csh/make_phase_cine.csh Wed Apr 17 14:41:48 2002 *************** *** 0 **** --- 1,178 ---- + #! /bin/csh -ef + # make_phase_cine.csh + #/************************************************************ + # * * + # * Permission is hereby granted to any individual or * + # * institution for use, copying, or redistribution of * + # * this code and associated documentation, provided * + # * that such code and documentation are not sold for * + # * profit and the following copyright notice is retained * + # * in the code and documentation: * + # * Copyright (c) 1998,1999 Department of Statistics, * + # * Carnegie Mellon University * + # * * + # * This program is distributed in the hope that it will * + # * be useful, but WITHOUT ANY WARRANTY; without even the * + # * implied warranty of MERCHANTABILITY or FITNESS FOR A * + # * PARTICULAR PURPOSE. Neither Carnegie Mellon University * + # * nor any of the authors assume any liability for * + # * damages, incidental or otherwise, caused by the * + # * installation or use of this software. * + # * * + # * CLINICAL APPLICATIONS ARE NOT RECOMMENDED, AND THIS * + # * SOFTWARE HAS NOT BEEN EVALUATED BY THE UNITED STATES * + # * FDA FOR ANY CLINICAL USE. * + # * * + # * * + # * Original programming by Bill Eddy * + # ************************************************************/ + # + echo '#'`date` $0 + echo '# $Id: make_phase_cine.csh,v 1.1 2002/04/13 01:26:39 welling Exp $' + # + # This script generates a cine loop from a (v)xyzt dataset. + # The one argument is the name of a single scalar dataset file. + # + + # Parse command line options + set args = `getopt bdr $*` + if ($#args < 2 ) then + echo "usage: " $0 '[-b -d -r] filename' + echo " -b brightens image" + echo " -d dims image" + echo " -r reverses black and white" + exit -1 + endif + set ropt = "" + set bopt = "" + set dopt = "" + set nopt = "" + set xopt = "" + while ($#args > 1) + switch ( $args[1] ) + case '-b' : + set bopt = "-b" ; shift args; breaksw; + case '-d' : + set dopt = "-d" ; shift args; breaksw; + case '-r' : + set ropt = "-r" ; shift args; breaksw; + case '--' : + shift args; breaksw; + endsw + if (junk${args[1]} == 'junk--') then + shift args; + break; + endif + end + if ($#args != 1) then + echo $0 ': only one filename permitted' + exit -1 + endif + set argv = $args + + # Check that the needed "convert" utility is present + if ( `test_in_subshell.csh which convert` ) then + echo ${0:t} ': The convert utility was needed but was not found!' + exit -1 + endif + + # Get the root name, to construct output filename + if ($1:t == ".mri") then + set tailname = $1:t + set fname = $tailname:r + else + set fname = $1:t + endif + + set vdim = `mri_printfield -input $1 -field images.extent.v -nofail` + if ( foo$vdim == foo ) set vdim = 1 + set xdim = `mri_printfield -input $1 -field images.extent.x` + set ydim = `mri_printfield -input $1 -field images.extent.y` + set zdim = `mri_printfield -input $1 -field images.extent.z` + set tdim = `mri_printfield -input $1 -field images.extent.t -nofail` + if ( foo$tdim == foo ) set tdim = 1 + + @ qdim = $xdim * $ydim * $zdim + + if ( $vdim != 2 ) then + echo "Input file $1 is not complex!" + exit -1 + endif + + # + # Make some scratch space, and go there. + # + if ( ${?F_TEMP} ) then + set tmpdir = ${F_TEMP}/make_phase_cine_tmp_$$ + else + set tmpdir = ./make_phase_cine_tmp_$$ + endif + if (! -e $tmpdir) mkdir $tmpdir + set homedir = `pwd` + if ( $1 =~ /* ) then + set input = $1 + else + set input = $homedir/$1 + endif + cd $tmpdir + mkdir frames + + #Collect the undetermined options. + set allopts = "-p $ropt $bopt $dopt" + + set t = 0 + + @ xlim = $xdim - 1 + @ ylim = $ydim - 1 + + #We need the maximum input magnitude + + mri_complex_to_scalar -m $input ${fname}_m + mri_permute -input ${fname}_m -headerout ${fname}_p -order vtxyz + mri_destroy_dataset ${fname}_m + mri_remap -file ${fname}_p -order tq -extents ${tdim}:${qdim} + mri_subsample -d t -e 1 -max ${fname}_p ${fname}_t + set missing_chunk = `mri_printfield -input ${fname}_t -field missing -nofail` + if ( foo${missing_chunk} != foo ) then + mri_delete_chunk -dataset ${fname}_t -chunk missing + endif + mri_destroy_dataset ${fname}_p + mri_subsample -d q -e 1 -max ${fname}_t max + + echo "Generating $tdim frames..." + while ( $t < $tdim ) + echo -n "${t}... " + if ( ! ( $t % 10 ) && $t != 0 ) echo "" + mri_subset -d t -l 1 -s $t $input thistime + mri_rpn_math -o tweaked_image \ + '$1,$2,0,$v,if_keep,$x,0,==,$y,0,==,+,$x,'$xlim',==,+,$y,'$ylim',==,+,if_keep' \ + thistime max + # We have to jigger with the output file names to make sure they + # sort to the right order. This version will break if there are + # more than 10000 frames, but it should hold us for a while! + if ( $t < 10 ) then + set oname = frames/frame_000$t.png + else if ( $t < 100 ) then + set oname = frames/frame_00$t.png + else if ( $t < 1000 ) then + set oname = frames/frame_0$t.png + else + set oname = frames_frame_$t.png + endif + color_by_phase.csh ${allopts} tweaked_image + mv tweaked_image.png ${oname} + @ t = $t + 1 + end + echo "done" + + echo "Assembling mpeg..." + + cd frames + convert -scale 200%! frame_*.png ${homedir}/${fname}.mpg + + echo "Done." + + #clean up + cd $homedir + rm -r $tmpdir + Index: ./src/imtops/mri_to_img.c *** /TOIL-U4/fiasco/Fiasco5.1/src/imtops/mri_to_img.c Wed Feb 13 19:01:14 2002 --- ./src/imtops/mri_to_img.c Tue Apr 16 14:30:46 2002 *************** *** 48,54 **** #define finite( foo ) isfinite( foo ) #endif ! static char rcsid[] = "$Id: mri_to_img.c,v 1.10 2000/12/05 20:13:44 welling Exp $"; /* Notes... */ --- 48,54 ---- #define finite( foo ) isfinite( foo ) #endif ! static char rcsid[] = "$Id: mri_to_img.c,v 1.13 2002/04/16 18:27:27 bakalj Exp $"; /* Notes... */ *************** *** 56,61 **** --- 56,67 ---- #define STR_SIZE 256 /* maximum size of strings */ #define DEFAULT_FORMAT IMG_PS + #define GRAY 1 + #define COLOR 3 + #define OPACITY 4 + #define RED 0 + #define GREEN 1 + #define BLUE 2 typedef enum { IMG_PS, IMG_PNG } ImgFormat; *************** *** 81,86 **** --- 87,93 ---- typedef struct img_info_struct { float* data; + int vdim; int xdim; int ydim; float min; *************** *** 148,197 **** char* dimstr; int zdim; int xdim; char* x_here; char* y_here; char* z_here; int fastblock; int slowblock; ! sprintf(keybuf,"%s.dimensions",chunk); /* array sizes checked earlier */ if (!mri_has(ds,keybuf)) { Error("%s: required tag <%s> missing!\n",progname,keybuf); return 0; } - dimstr= mri_get_string(ds,keybuf); ! x_here= strchr(dimstr,'x'); ! y_here= strchr(dimstr,'y'); ! z_here= strchr(dimstr,'z'); ! if (!x_here) { Error("%s: required x dimension is not present!\n",progname); return 0; } ! if (!y_here) { ! Error("%s: required x dimension is not present!\n",progname); return 0; } ! if (!z_here) { zdim= 1; } else zdim= safe_get_extent(ds,chunk,"z"); if (y_here != (x_here+1)) { Error("%s: dimensions x and y are not sequential!\n",progname); return 0; } if (z_here && (z_here != (y_here+1))) { Error("%s: dimensions x, y, z are not sequential!\n",progname); return 0; } xdim= safe_get_extent(ds,chunk,"x"); calc_sizes(ds, chunk, dimstr, "y", &fastblock, &slowblock); ! if (fastblock != xdim) { ! Error("%s: Need 1 value per pixel, found %d!\n", ! progname,fastblock/xdim); return 0; } if (!opts->all_times_flg && (slowblock != zdim)) { Error("%s: too many images!\n",progname); return 0; --- 155,221 ---- char* dimstr; int zdim; int xdim; + int vdim; char* x_here; char* y_here; char* z_here; + char* v_here; int fastblock; int slowblock; ! sprintf(keybuf,"%s.dimensions",chunk); /* chunk name size checked earlier */ if (!mri_has(ds,keybuf)) { Error("%s: required tag <%s> missing!\n",progname,keybuf); return 0; } ! dimstr= mri_get_string(ds,keybuf); ! if (!(x_here=strchr(dimstr, 'x'))) { Error("%s: required x dimension is not present!\n",progname); return 0; } ! ! if (!(y_here=strchr(dimstr, 'y'))) { ! Error("%s: required y dimension is not present!\n",progname); return 0; } ! ! if (!(z_here=strchr(dimstr, 'z'))) { zdim= 1; } else zdim= safe_get_extent(ds,chunk,"z"); + + if (!(v_here=strchr(dimstr, 'v'))) { + vdim= 1; + } + else vdim= safe_get_extent(ds,chunk,"v"); + + if (v_here && (x_here != (v_here+1))) { + Error("%s: dimension v must be before dimension x!\n",progname); + return 0; + } + if (y_here != (x_here+1)) { Error("%s: dimensions x and y are not sequential!\n",progname); return 0; } + if (z_here && (z_here != (y_here+1))) { Error("%s: dimensions x, y, z are not sequential!\n",progname); return 0; } + xdim= safe_get_extent(ds,chunk,"x"); + calc_sizes(ds, chunk, dimstr, "y", &fastblock, &slowblock); ! ! if (fastblock != vdim * xdim) { ! Error("%s: Need %d value(s) per pixel, found %d!\n", ! progname, vdim, fastblock/xdim); return 0; } + if (!opts->all_times_flg && (slowblock != zdim)) { Error("%s: too many images!\n",progname); return 0; *************** *** 201,208 **** } static ImageInfo* load_slice(MRI_Dataset* ds, const char* chunk, ! const int xdim, const int ydim, const int zdim, ! const int tdim, const int z, const int t) { ImageInfo* result; int imgSize; --- 225,233 ---- } static ImageInfo* load_slice(MRI_Dataset* ds, const char* chunk, ! const int vdim, const int xdim, const int ydim, ! const int zdim, const int tdim, const int z, ! const int t) { ImageInfo* result; int imgSize; *************** *** 215,227 **** if (!(result= (ImageInfo*)malloc(sizeof(ImageInfo)))) Abort("%s: unable to allocate %d bytes!\n",progname,sizeof(ImageInfo)); ! imgSize= xdim*ydim; if (!(result->data= (float*)malloc(imgSize*sizeof(float)))) Abort("%s: unable to allocate %d bytes!\n", progname,imgSize*sizeof(float)); result->xdim= xdim; result->ydim= ydim; inbuf= mri_get_chunk(ds, chunk, imgSize, (t*zdim + z)*imgSize, MRI_FLOAT); --- 240,253 ---- if (!(result= (ImageInfo*)malloc(sizeof(ImageInfo)))) Abort("%s: unable to allocate %d bytes!\n",progname,sizeof(ImageInfo)); ! imgSize= xdim*ydim*vdim; if (!(result->data= (float*)malloc(imgSize*sizeof(float)))) Abort("%s: unable to allocate %d bytes!\n", progname,imgSize*sizeof(float)); result->xdim= xdim; result->ydim= ydim; + result->vdim= vdim; inbuf= mri_get_chunk(ds, chunk, imgSize, (t*zdim + z)*imgSize, MRI_FLOAT); *************** *** 320,326 **** } static ImageInfo* load_mosaic(MRI_Dataset* ds, const char* chunk, ! const int xdim, const int ydim, const int zdim, const int tdim, const int t) { ImageInfo* result; --- 346,353 ---- } static ImageInfo* load_mosaic(MRI_Dataset* ds, const char* chunk, ! const int vdim, const int xdim, ! const int ydim, const int zdim, const int tdim, const int t) { ImageInfo* result; *************** *** 328,333 **** --- 355,361 ---- int imgSize; int i; int j; + int v; int ismall; int jsmall; int iblock; *************** *** 341,354 **** int range_valid; float* inbuf; /* Find the right decomposition */ factor= 1; ! while (factor*factor < zdim) { factor++; } if (!(result= (ImageInfo*)malloc(sizeof(ImageInfo)))) Abort("%s: unable to allocate %d bytes!\n",progname,sizeof(ImageInfo)); ! imgSize= factor*factor*xdim*ydim; if (!(result->data= (float*)malloc(imgSize*sizeof(float)))) Abort("%s: unable to allocate %d bytes!\n", progname,imgSize*sizeof(float)); --- 369,384 ---- int range_valid; float* inbuf; + /* Find the right decomposition */ factor= 1; ! while (factor*factor < zdim) { factor++;} if (!(result= (ImageInfo*)malloc(sizeof(ImageInfo)))) Abort("%s: unable to allocate %d bytes!\n",progname,sizeof(ImageInfo)); ! imgSize= factor*factor*xdim*ydim*vdim; ! if (!(result->data= (float*)malloc(imgSize*sizeof(float)))) Abort("%s: unable to allocate %d bytes!\n", progname,imgSize*sizeof(float)); *************** *** 356,367 **** result->xdim= xdimBig= factor*xdim; result->ydim= ydimBig= factor*ydim; iblock= jblock= 0; range_valid= 0; min= max= 0.0; for (z=0; zrange_valid) { --- 386,399 ---- result->xdim= xdimBig= factor*xdim; result->ydim= ydimBig= factor*ydim; + result->vdim= vdim; iblock= jblock= 0; range_valid= 0; min= max= 0.0; for (z=0; zrange_valid) { *************** *** 381,398 **** j= jblock*ydim + jsmall; for (ismall=0; ismalldata[(j*xdimBig)+i]= small->data[(jsmall*xdim) + ismall]; } } ! free_image(small); ! iblock++; ! if (iblock>=factor) { ! iblock= 0; ! jblock++; ! } } result->min= min; result->max= max; result->range_valid= range_valid; --- 413,433 ---- j= jblock*ydim + jsmall; for (ismall=0; ismalldata[(((j*xdimBig)+i)*vdim)+v]= small->data[(((jsmall*xdim) + ismall)*vdim)+v]; ! } } } ! free_image(small); ! iblock++; ! if (iblock>=factor) { ! iblock= 0; ! jblock++; ! } } + result->min= min; result->max= max; result->range_valid= range_valid; *************** *** 421,426 **** --- 456,482 ---- return c; } + static int get_color_image_byte( ImageInfo* img, const Options* opts, + const int i, const int j, const int color) + { + float datum; + int c; + + if (!(img->range_valid)) return 0; + + datum= img->data[(((((j*opts->subsa)*img->xdim) + (i*opts->subsa))*img->vdim) + color)]; + if (!finite(datum)) c= (opts->r_flg ? 255 : 0); + else { + c = (int)(((datum - img->min)/(img->max-img->min)) * 255.0) ; + } + if (c<0) c= 0; + if (c>255) c= 255; + + if (opts->r_flg) c= 255-c; + + return c; + } + static FILE* init_out( char* fname, Options* opts ) { FILE* fp= NULL; *************** *** 570,576 **** info_ptr->width= col_out + bar_width; info_ptr->height= row_out; ! info_ptr->color_type= PNG_COLOR_TYPE_GRAY; info_ptr->bit_depth= 8; info_ptr->gamma= opts->gamma; --- 626,640 ---- info_ptr->width= col_out + bar_width; info_ptr->height= row_out; ! ! switch (img->vdim) { ! case GRAY: ! info_ptr->color_type= PNG_COLOR_TYPE_GRAY; ! break; ! case COLOR: ! info_ptr->color_type= PNG_COLOR_TYPE_RGB; ! } ! info_ptr->bit_depth= 8; info_ptr->gamma= opts->gamma; *************** *** 619,625 **** png_write_info(png_ptr, info_ptr); ! if (!(row_ptr=(png_bytep)malloc(col_out+bar_width))) Abort("%s: unable to allocate %d bytes!\n",progname,col_out+bar_width); for (j=0; jvdim*col_out)+bar_width))) Abort("%s: unable to allocate %d bytes!\n",progname,col_out+bar_width); for (j=0; jr_flg)) barVal= 255-barVal; for (i=0; ir_flg)) barVal= 255-barVal; for (i=0; ivdim) { ! ! case GRAY: ! for (i=0; ivdim * i) + RED)] = ! get_color_image_byte(img, opts, i, j, RED); ! row_ptr[bar_width+((img->vdim * i) + GREEN)]= ! get_color_image_byte(img, opts, i, j, GREEN); ! row_ptr[bar_width+((img->vdim * i) + BLUE)]= ! get_color_image_byte(img, opts, i, j, BLUE); ! } ! } ! png_write_row(png_ptr, row_ptr); + } free(row_ptr); *************** *** 752,767 **** fprintf(fp,"%d %d translate\n %d %d scale\n",xorig,yorig,imwth,imht) ; fprintf(fp,"%d %d 8 [%d 0 0 %d 0 %d]\n", col_out, row_out, col_out, -row_out, row_out) ; ! fprintf(fp,"{currentfile picstr readhexstring pop} image\n\n"); ! cptr= outstr; ! for (j=0; j= sizeof(outstr)-2) { *cptr++= '\n'; *cptr++= '\0'; fputs(outstr, fp); --- 834,910 ---- fprintf(fp,"%d %d translate\n %d %d scale\n",xorig,yorig,imwth,imht) ; fprintf(fp,"%d %d 8 [%d 0 0 %d 0 %d]\n", col_out, row_out, col_out, -row_out, row_out) ; ! ! ! switch (img->vdim) { ! ! case GRAY: ! { ! fprintf(fp,"{currentfile picstr readhexstring pop} image\n\n"); ! cptr= outstr; ! for (j=0; j= sizeof(outstr)-2) { ! *cptr++= '\n'; ! *cptr++= '\0'; ! fputs(outstr, fp); ! cptr= outstr; ! } ! } ! } ! if (cptr>outstr) { ! *cptr++= '\n'; ! *cptr++= '\0'; ! fputs(outstr, fp); ! cptr= outstr; ! } ! } ! break; ! ! case COLOR: ! { ! int red, green, blue; ! fprintf(fp,"{currentfile picstr readhexstring pop} false 3 colorimage\n\n"); ! ! cptr= outstr; ! for (j=0; j= sizeof(outstr)-2) { ! *cptr++= '\n'; ! *cptr++= '\0'; ! fputs(outstr, fp); ! cptr= outstr; ! } ! green= get_color_image_byte( img, opts, i, j, GREEN ); ! *cptr++= hexcv[3*green]; ! *cptr++= hexcv[3*green + 1]; ! if (cptr-outstr >= sizeof(outstr)-2) { ! *cptr++= '\n'; ! *cptr++= '\0'; ! fputs(outstr, fp); ! cptr= outstr; ! } ! blue= get_color_image_byte( img, opts, i, j, BLUE ); ! *cptr++= hexcv[3*blue]; ! *cptr++= hexcv[3*blue + 1]; ! if (cptr-outstr >= sizeof(outstr)-2) { ! *cptr++= '\n'; ! *cptr++= '\0'; ! fputs(outstr, fp); ! cptr= outstr; ! } ! } ! } ! if (cptr>outstr) { *cptr++= '\n'; *cptr++= '\0'; fputs(outstr, fp); *************** *** 769,787 **** } } } ! if (cptr>outstr) { ! *cptr++= '\n'; ! *cptr++= '\0'; ! fputs(outstr, fp); ! cptr= outstr; ! } /* Finish the page */ fprintf(fp,"\n") ; fprintf(fp,"EndPage\n"); } - break; } } --- 912,925 ---- } } } ! /* Finish the page */ fprintf(fp,"\n") ; fprintf(fp,"EndPage\n"); + } } } *************** *** 799,805 **** char keybuf[STR_SIZE]; char outfilename[STR_SIZE]; ! int xdim, ydim, zdim, tdim; int z; int t; int junk; --- 937,943 ---- char keybuf[STR_SIZE]; char outfilename[STR_SIZE]; ! int xdim, ydim, zdim, vdim, tdim; int z; int t; int junk; *************** *** 887,892 **** --- 1025,1032 ---- #ifndef USE_PNG Abort("%s: this executable was compiled without PNG support!\n",argv[0]); #endif + if (!(opts.mosaic_flg==1)) + Warning(1, "%s: -png only supports mosaic, mosaic flag set to 1\n", argv[0]); opts.mosaic_flg= 1; if (opts.all_times_flg) Error("%s: -all flag incompatible with -png!\n",argv[0]); *************** *** 919,924 **** --- 1059,1067 ---- sprintf(keybuf,"%s.extent.z",chunk); if (mri_has(ds,keybuf)) zdim= mri_get_int(ds,keybuf); else zdim= 1; + sprintf(keybuf,"%s.extent.v",chunk); + if (mri_has(ds,keybuf)) vdim= mri_get_int(ds,keybuf); + else vdim= 1; sprintf(keybuf,"%s.dimensions",chunk); calc_sizes(ds, chunk, mri_get_string( ds, keybuf ), *************** *** 958,974 **** if (opts.mosaic_flg) { ImageInfo* img; char title3Buf[STR_SIZE]; ! pageLabel3= getenv("F_PS_TITLE3"); ! if (!pageLabel3) { ! sprintf(title3Buf,"%d Slices\n",zdim); ! pageLabel3= title3Buf; ! } ! img= load_mosaic(ds, chunk, xdim, ydim, zdim, tdim, t); ! adjust_bounds(img, &opts); ! do_page(creDate, prtDate, ! pageLabel1, pageLabel2, pageLabel3, img, ofile, &opts); ! free_image(img); } else { for (z=0; z 1 ) && !strcmp( argv[1], "-help" ) ) { --- 120,125 ---- *************** *** 142,147 **** --- 141,147 ---- m_flg= (cl_present("m") ? 1 : 0); p_flg= (cl_present("p") ? 1 : 0); u_flg= (cl_present("u") ? 1 : 0); + verbose_flg= cl_present("v"); /* Get filenames */ if (!cl_get("", "%s", infile)) { fprintf(stderr,"%s: Input file name not given.",progname); *************** *** 164,169 **** --- 164,172 ---- /*** End command-line parsing ***/ + /* Print version number */ + if (verbose_flg) Message( "# %s\n", rcsid ); + if (r_flg + i_flg + m_flg + p_flg + u_flg > 1) Abort("%s: two exclusive flags were used in the command line.\n",progname); if (r_flg + i_flg + m_flg + p_flg + u_flg == 0) m_flg= 1; *************** *** 264,270 **** mri_close_dataset( Input ); mri_close_dataset( Output ); ! Message( "# Image conversion complete.\n" ); exit(0); } --- 267,273 ---- mri_close_dataset( Input ); mri_close_dataset( Output ); ! if (verbose_flg) Message( "# Image conversion complete.\n" ); exit(0); } Index: ./src/mri_util/mri_complex_to_scalar_help.help *** /TOIL-U4/fiasco/Fiasco5.1/src/mri_util/mri_complex_to_scalar_help.help Wed Feb 13 19:01:22 2002 --- ./src/mri_util/mri_complex_to_scalar_help.help Thu Apr 4 20:05:14 2002 *************** *** 5,11 **** type float32. To run mri_complex_to_scalar use: ! mri_complex_to_scalar [-r|-i|-m|-p|-u] infile outfile or: mri_complex_to_scalar -help --- 5,11 ---- type float32. To run mri_complex_to_scalar use: ! mri_complex_to_scalar [-r|-i|-m|-p|-u] [-v] infile outfile or: mri_complex_to_scalar -help *************** *** 49,58 **** -p produces the unwound phase of the input dataset. Note that this operation is ambiguous; if the phase is changing rapidly ! the results may not be what was expected or desired. Only one of [-r|-i|-m|-p|-u] may be present at a time. The default is -m. *Arguments:infile infile --- 49,66 ---- -p produces the unwound phase of the input dataset. Note that this operation is ambiguous; if the phase is changing rapidly ! the results may not be what was expected or desired. Phase is ! unwound only over the first non-trial dimension. For example ! on a dataset with dimension order vtxyz the phase is unwound ! over the t dimension but starts fresh for each new x, y, or z. Only one of [-r|-i|-m|-p|-u] may be present at a time. The default is -m. + *Arguments:v + [-v] + + -v requests verbose operation. + *Arguments:infile infile Index: ./src/mri_util/mri_rpn_math.c *** /TOIL-U4/fiasco/Fiasco5.1/src/mri_util/mri_rpn_math.c Thu Apr 4 14:21:56 2002 --- ./src/mri_util/mri_rpn_math.c Mon Apr 8 21:56:13 2002 *************** *** 74,80 **** #define INITIAL_CODE_BLOCK_SIZE 100 #define KEYBUF_SIZE 512 ! static char rcsid[] = "$Id: mri_rpn_math.c,v 1.33 2002/04/04 18:56:54 welling Exp $"; typedef enum { OP_LOAD, OP_PLUS, OP_MINUS, OP_MULT, OP_DIV, OP_SQRT, OP_DUP, OP_SWAP, OP_POP, OP_CONST, OP_LN, OP_EXP, OP_ABS, --- 74,80 ---- #define INITIAL_CODE_BLOCK_SIZE 100 #define KEYBUF_SIZE 512 ! static char rcsid[] = "$Id: mri_rpn_math.c,v 1.34 2002/04/05 01:07:37 welling Exp welling $"; typedef enum { OP_LOAD, OP_PLUS, OP_MINUS, OP_MULT, OP_DIV, OP_SQRT, OP_DUP, OP_SWAP, OP_POP, OP_CONST, OP_LN, OP_EXP, OP_ABS, *************** *** 86,92 **** OP_CLOCK, OP_DIM, OP_IF_PRINT, OP_RANDOM, OP_SIN, OP_COS, OP_TAN, OP_ASIN, OP_ACOS, OP_ATAN, OP_MIN, OP_MAX, OP_ROT, OP_MISSING, OP_IS_FINITE, OP_ROUND, ! OP_FLOOR, OP_CEILING } Op; typedef struct instruction_struct { Op op; --- 86,92 ---- OP_CLOCK, OP_DIM, OP_IF_PRINT, OP_RANDOM, OP_SIN, OP_COS, OP_TAN, OP_ASIN, OP_ACOS, OP_ATAN, OP_MIN, OP_MAX, OP_ROT, OP_MISSING, OP_IS_FINITE, OP_ROUND, ! OP_FLOOR, OP_CEILING, OP_SWITCH } Op; typedef struct instruction_struct { Op op; *************** *** 456,463 **** } if (!matched) { if (!(strcmp(tok,"nan"))) { - inst->op= inst->op= OP_CONST; inst->param.f= log(-1.0); /* fprintf(stderr,"OP_CONST %g\n",inst->param.f); */ --- 456,473 ---- } if (!matched) { + if (!(strncasecmp(tok,"switch_",7))) { + char* tail= tok + 7; /* after rot_ */ + long count= atoi(tail); + inst->op= OP_SWITCH; + inst->param.l= count; + /*fprintf(stderr,"OP_SWITCH %d\n",(int)(inst->param.l));*/ + matched= 1; + } + } + + if (!matched) { if (!(strcmp(tok,"nan"))) { inst->op= OP_CONST; inst->param.f= log(-1.0); /* fprintf(stderr,"OP_CONST %g\n",inst->param.f); */ *************** *** 467,473 **** if (!matched) { if (!(strcmp(tok,"inf"))) { - inst->op= inst->op= OP_CONST; inst->param.f= -log(0.0); /* fprintf(stderr,"OP_CONST %g\n",inst->param.f); */ --- 477,482 ---- *************** *** 477,483 **** if (!matched) { if (!(strcmp(tok,"ninf"))) { - inst->op= inst->op= OP_CONST; inst->param.f= log(0.0); /* fprintf(stderr,"OP_CONST %g\n",inst->param.f); */ --- 486,491 ---- *************** *** 486,491 **** --- 494,508 ---- } if (!matched) { + if (!(strcmp(tok,"pi"))) { + inst->op= OP_CONST; + inst->param.f= M_PI; + /* fprintf(stderr,"OP_CONST %g\n",inst->param.f); */ + matched= 1; + } + } + + if (!matched) { if (*tok=='$') { int which_in= atoi(tok+1); if (which_in==0) { *************** *** 1457,1462 **** --- 1474,1501 ---- } break; + case OP_SWITCH: + { + int i; + long depth= abs(runner->param.l); + /*fprintf(stderr,"exec: OP_SWITCH %ld\n",runner->param.l);*/ + if (stack_top < stack_first+(depth*CHUNKSIZE)) + Abort("%s: stack underflow on switch_%ld!\n",progname, + runner->param.l); + for (i=0; idepth-1) + Abort("%s: stack underflow on switch_%ld with index %g = %ld!\n", + progname,depth,*(stack_top+i),which); + *(stack_top + i - depth*CHUNKSIZE)= + *(stack_top + i - (which+1)*CHUNKSIZE); + } + stack_top -= depth*CHUNKSIZE; + } + case OP_NOOP: /* do nothing */ /* fprintf(stderr,"exec: OP_NOOP\n"); */ break; *************** *** 1500,1508 **** progname= argv[0]; - /* Print version number */ - if (verbose_flg) Message( "# %s\n", rcsid ); - /* Check to see if help was requested */ if( ( argc > 1 ) && !strcmp( argv[1], "-help" ) ) { --- 1539,1544 ---- *************** *** 1532,1538 **** } } if (!cl_get("", "%s", infile)) { ! fprintf(stderr,"%s: Requred first input file name not given.\n",argv[0]); Help( "usage" ); exit(-1); } --- 1568,1574 ---- } } if (!cl_get("", "%s", infile)) { ! fprintf(stderr,"%s: Required first input file name not given.\n",argv[0]); Help( "usage" ); exit(-1); } *************** *** 1563,1568 **** --- 1599,1607 ---- /*** End command-line parsing ***/ + /* Print version number */ + if (verbose_flg) Message( "# %s\n", rcsid ); + if (verbose_flg && !script_from_file) Message("script: <%s>\n",script); /* Initialize the clock */ Index: ./src/mri_util/mri_rpn_math_help.help *** /TOIL-U4/fiasco/Fiasco5.1/src/mri_util/mri_rpn_math_help.help Wed Feb 13 19:01:22 2002 --- ./src/mri_util/mri_rpn_math_help.help Thu Apr 4 20:06:41 2002 *************** *** 6,12 **** element-by-element to the input datasets. mri_rpn_math [-o ofile] [-c chunk] [-r seed] [-f exprfl | expr ] ! infile1 [infile2 ...[infilen]] *Arguments --- 6,12 ---- element-by-element to the input datasets. mri_rpn_math [-o ofile] [-c chunk] [-r seed] [-f exprfl | expr ] ! [-v] infile1 [infile2 ...[infilen]] *Arguments *************** *** 90,95 **** --- 90,97 ---- exp e is raised to the power of the top element on stack; stack depth unchanged + pi the value pi (3.14159...) + sin,cos,tan, asin,acos,atan Sine, cosine, tangent, arcsin, arccos, and arctangent *************** *** 114,119 **** --- 116,130 ---- both equivalent to the "swap" operator. Stack depth is unchanged. + switch_2, switch_3, switch_4, ... + These operators implement a sort of "switch statement". + switch_n rounds the topmost element of the stack to the + nearest integer to produce a depth D. If D= n. + >,<,==, >=,<=,!= Compare top item on stack to next item down, and replace both items by 1.0 if the comparison is true, 0.0 otherwise.