#!/bin/csh -f source /star/etc/login >& /dev/null source /star/etc/cshrc >& /dev/null kappa >& /dev/null if (`alias kappa` == "") then echo "" echo "Fatal: Initialization error of kappa environment" echo "" exit endif set kap = $KAPPA_DIR set argv = `echo "$argv" | sed s/":"/" "/g` if ($#argv < 4) set argv = "help" if ($argv[1] =~ *"help"* || $argv[1] == "-h") then echo "" echo "Use: sp_bsl file order v1:v2 [[v3:v4] ...]" echo " e.g. 'sp_bsl myfile 1 -300:-100 100:300 ...'" echo "" echo "Note: the boundaries must be in increasing order!" echo "" exit endif set infile = $argv[1] set infile = `echo "$infile" | cut -d\. -f1` set infile = "${infile}.sdf" shift argv if !(-e "$infile") then echo "" echo "Fatal: file $infile not found" echo "" exit endif echo "" echo "Remove baseline from file ${infile}:" # ---------------------------------------------------------------------- # Remove Polynomial Baseline # FIT_BSL: set order = $argv[1] shift argv if ( `echo "$#argv%2" | bc` == 1 ) then echo "Use: sp_bsl file order v1:v2 [[v3:v4] ...]" exit endif set parts = `echo "$argv" | sed s/":"/" "/g` set regions = "" @ ii = 1 while ($ii <= $#parts) if ($ii > 1) set regions = "${regions}," if ("${parts[$ii]}" =~ *'.'*) then set regions = "${regions}${parts[$ii]}" else set regions = "${regions}${parts[$ii]}." endif @ ii ++ end unset parts set regions = `echo "$regions" | sed s/" "/","/g` set fpb_par = "${order} ${regions}" set base = `echo $infile | sed s/.sdf//` set basefile = ${base}_bsl.sdf set outfile = ${base}_rembsl.sdf # # Use mfittrend twice because the 'sub' option apparently looses the # variance (at the moment) # echo "Regions: '${regions}'" ${kap}/mfittrend in=$infile axis=3 order=${order} out=$basefile \ ranges='"'${regions}'"' variance=false subtract=false ${kap}/mfittrend in=$infile axis=3 order=${order} out=$outfile \ ranges='"'${regions}'"' variance=false subtract=true if (-e "${basefile}") then echo "The fitted baseline has been saved in file:" echo " '${basefile}'" # ${kap}/sub ${infile} ${basefile} ${outfile} if (-e "${outfile}") then echo "The baselines subtracted cube has been saved in:" echo " '${outfile}'" else echo "ERROR: subtraction of the baseline failed" endif else echo "ERROR: the baseline fit failed" endif endif echo ""