begin Version 6.0
authorA.M. Thurnherr <athurnherr@yahoo.com>
Wed, 29 Oct 2014 19:23:31 +0000
changeset 8 248fef05e79d
parent 7 f7b4692ad805
child 9 1a7983cbb82a
begin Version 6.0
ANTSlib
ants.pl
antsio.pl
--- a/ANTSlib
+++ b/ANTSlib
@@ -1,35 +1,36 @@
 #!/usr/bin/perl
 #======================================================================
-#                    A N T S L I B 
+#                    L I B / A N T S L I B 
 #                    doc: Wed May 16 06:19:16 2012
-#                    dlm: Wed May 16 06:28:16 2012
+#                    dlm: Wed Oct 29 19:22:45 2014
 #                    (c) 2012 A.M. Thurnherr
-#                    uE-Info: 11 36 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 35 42 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
 #	May 16, 2012: - created for V5.0
+#	Oct 29, 2014: - made it work again for V6
 
-($ANTSlib) = ($0 =~ m{^(.*)/[^/]*$});
+($ANTSLIB) = ($0 =~ m{^(.*)/[^/]*$});
 
-require "$ANTSlib/ants.pl";
-require "$ANTSlib/libCPT.pl";
-require "$ANTSlib/libEOS83.pl";
-require "$ANTSlib/libGM.pl";
-require "$ANTSlib/libLADCP.pl";
-require "$ANTSlib/libNODC.pl";
-require "$ANTSlib/libPOSIX.pl";
-require "$ANTSlib/libRWalk.pl";
-require "$ANTSlib/libWOCE.pl";
-require "$ANTSlib/libWOCE_oldstyle.pl";
-require "$ANTSlib/libconv.pl";
-require "$ANTSlib/libfuns.pl";
-require "$ANTSlib/libgamma.pl";
-require "$ANTSlib/libstats.pl";
-require "$ANTSlib/libtides.pl";
-require "$ANTSlib/libubtest.pl";
-require "$ANTSlib/libvec.pl";
+require "$ANTSLIB/ants.pl";
+require "$ANTSLIB/libCPT.pl";
+require "$ANTSLIB/libEOS83.pl";
+require "$ANTSLIB/libGM.pl";
+require "$ANTSLIB/libLADCP.pl";
+require "$ANTSLIB/libNODC.pl";
+require "$ANTSLIB/libPOSIX.pl";
+require "$ANTSLIB/libRWalk.pl";
+require "$ANTSLIB/libWOCE.pl";
+require "$ANTSLIB/libWOCE_oldstyle.pl";
+require "$ANTSLIB/libconv.pl";
+require "$ANTSLIB/libfuns.pl";
+require "$ANTSLIB/libgamma.pl";
+require "$ANTSLIB/libstats.pl";
+require "$ANTSLIB/libtides.pl";
+require "$ANTSLIB/libubtest.pl";
+require "$ANTSLIB/libvec.pl";
 
-chomp($about = `sed -n '/^description =/s/description = //p' $ANTSlib/.hg/hgrc`);
-print(STDERR "$about installed in $ANTSlib\n");
+chomp($about = `sed -n '/^description =/s/description = //p' $ANTSLIB/.hg/hgrc`);
+printf(STDERR "$about (\$antsLibVersion = %.1f) installed in $ANTSLIB\n",$antsLibVersion);
 exit(0);
--- a/ants.pl
+++ b/ants.pl
@@ -1,10 +1,10 @@
 #!/usr/bin/perl
 #======================================================================
-#                    A N T S . P L 
+#                    L I B / A N T S . P L 
 #                    doc: Fri Jun 19 14:01:06 1998
-#                    dlm: Mon Sep 24 12:41:50 2012
+#                    dlm: Wed Oct 29 19:21:12 2014
 #                    (c) 1998 A.M. Thurnherr
-#                    uE-Info: 25 76 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 21 8 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -13,10 +13,13 @@
 #  Jul  5, 2006: - removed `basename`
 #  Jul 19, 2006: - added error if exec($ANTS_PERL) fails
 #  Sep 24, 2012: - added support for $ANTSLIB
+#  Oct 19, 2014: - added $antsLibVersion
 
 exec($ENV{ANTS_PERL},$0,@ARGV),die("$ENV{ANTS_PERL}: $!")
     if (defined($ENV{ANTS_PERL}) && $^X ne $ENV{ANTS_PERL});
 
+$antsLibVersion = 6.0;    
+
 if (defined($ANTSLIB)) {							# new style (V5)
 	require "$ANTSLIB/antsusage.pl";
 	require "$ANTSLIB/antsio.pl";
--- a/antsio.pl
+++ b/antsio.pl
@@ -2,9 +2,9 @@
 #======================================================================
 #                    A N T S I O . P L 
 #                    doc: Fri Jun 19 19:22:51 1998
-#                    dlm: Wed Oct 10 12:36:29 2012
+#                    dlm: Wed Oct 29 16:12:46 2014
 #                    (c) 1998 A.M. Thurnherr
-#                    uE-Info: 598 0 NIL 0 0 70 2 2 4 NIL ofnI
+#                    uE-Info: 202 73 NIL 0 0 70 2 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -197,9 +197,11 @@
 #	May 24: 2011: - BUG: forgot '$' in a variable (where???)
 #	Jul 28, 2011: - disabled adding of new deps on -D
 #	Apr 11, 2012: - improved layout-change error message
-#	Apr 26, 2012: - BUG: antsFileScanParam() was not properly anchored (%start_date matched %BT.start_date)
+#	Apr 26, 2012: - BUG: antsFileScanParam() was not properly anchored (%start_date matched
+#						 %BT.start_date)
+#	Oct 29, 2014: - implemented abbreviated Layout and %PARAM definitions
 
-# NOTES:
+# GENERAL NOTES:
 #	- %P was named without an ants-prefix because associative arrays
 #	  are rare (and perl supports multiple name spaces for the
 #	  different variable types) and to facilitate its use in
@@ -207,6 +209,15 @@
 #	- copying of embedded (i.e. not appearing at start) headers is
 #	  required e.g. for subsample -i ... | list %some-param
 
+# ABBREVIATED LAYOUT & PARAM DEFINITIONS
+#	- # definition [definition [...]]
+#	- definition := field_name | %PARAM_def
+#	- field_name := {string}
+#	- %PARAM_def := string{string|num}
+#	- implemented in October 2014 in order to make ANTS format easier to use for others
+#	- abbreviated and full headers must not be used together
+#	- abbreviated field definitions are additive (rather than replacing, as in the full headers)
+
 # $antsIngoreInputParams:
 #	- is eval'ed first time antsIn() is called (usually while parsing header)
 #	- if it evaluates to TRUE, all input %PARAMS are ignored (even if it would
@@ -308,12 +319,23 @@
 
 #----------------------------------------------------------------------
 
+sub def_abbrev($)
+{
+	my($def) = @_;
+	if ($def =~ /^\{(\w+)\}$/) {
+		push(@Layout,$1);
+	} else {
+		my($name,$val) = ($def =~ /(\w+)\{([^\}]+)\}/);
+		$P{$name} = $val;
+	}
+}
+
 sub antsReCompile()								# re-compile with funs
 { eval '
 
 sub antsIn()
 {
-	my(@Layout);
+	local(@Layout);
 	undef(@Layout);								# needed, but unclear why
 
 	undef($antsNewFile);						# assume no new file
@@ -415,8 +437,14 @@
 			do {
 				push(@Layout,$1 eq "" ? undef : $1);
 			} while ($\' =~ m/ \{([^\}]*)\}/);
+		} elsif (/^# (\{\w+\}|\w+\{[^\}]+\})+/) {		# ABBREVIATED DEFINITIONS
+			my($match) = $1; my($rem) = $\';
+			do {
+				def_abbrev($match);
+				($match,$rem) = ($rem =~ /(\{\w+\}|\w+\{[^\}]+\})(.*)/);
+			} while ($match);
 		}
-
+				
 		if (!($opt_Q || $antsNoHeaderCopy) && /^#ANTS#/) {	# handle headers
 			if (defined($antsHeadersPrinted)) {		# embedded headers
 # The following is somewhat subtle because it must prevent embedded