Index: trunk/ppSub/src/ppSubArguments.c
===================================================================
--- trunk/ppSub/src/ppSubArguments.c	(revision 13593)
+++ trunk/ppSub/src/ppSubArguments.c	(revision 13713)
@@ -152,4 +152,19 @@
 }
 
+// Add a single filename to the arguments as an array, so that it can be used with pmFPAfileBindFromArgs, etc
+static void fileList(const char *file, // The symbolic name for the file
+                     const char *name, // The name of the file
+                     const char *comment, // Description of the file
+                     pmConfig *config // Configuration
+    )
+{
+    psArray *files = psArrayAlloc(1); // Array with file names
+    files->data[0] = psStringCopy(name);
+    psMetadataAddArray(config->arguments, PS_LIST_TAIL, file, 0, comment, files);
+    psFree(files);
+    return;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 bool ppSubArguments(int argc, char *argv[], pmConfig *config)
@@ -187,18 +202,26 @@
     }
 
-    psArray *files = psArrayAlloc(1);   // Array with file names
-    files->data[0] = psStringCopy(argv[1]);
-    psMetadataAddArray(config->arguments, PS_LIST_TAIL, "INPUT", 0, "Name of the input image", files);
-    psFree(files);
-    files = psArrayAlloc(1);
-    files->data[0] = psStringCopy(argv[2]);
-    psMetadataAddArray(config->arguments, PS_LIST_TAIL, "REF", 0, "Name of the reference image", files);
-    psFree(files);
+    fileList("INPUT", argv[1], "Name of the input image",     config);
+    fileList("REF",   argv[2], "Name of the reference image", config);
     psMetadataAddStr(config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "Name of the output image", argv[3]);
 
-    valueArgStr(config, arguments, "-inmask",    "INPUT.MASK",    config->arguments);
-    valueArgStr(config, arguments, "-inweight",  "INPUT.WEIGHT",  config->arguments);
-    valueArgStr(config, arguments, "-refmask",   "REF.MASK",      config->arguments);
-    valueArgStr(config, arguments, "-refweight", "REF.WEIGHT",    config->arguments);
+    const char *inMask = psMetadataLookupStr(NULL, arguments, "-inmask"); // Name of input mask
+    if (inMask && strlen(inMask) > 0) {
+        fileList("INPUT.MASK", inMask, "Name of the input mask image", config);
+    }
+    const char *inWeight = psMetadataLookupStr(NULL, arguments, "-inweight"); // Name of input weight
+    if (inWeight && strlen(inWeight) > 0) {
+        fileList("INPUT.WEIGHT", inWeight, "Name of the input weight image", config);
+    }
+
+    const char *refMask = psMetadataLookupStr(NULL, arguments, "-refmask"); // Name of reference mask
+    if (refMask && strlen(refMask) > 0) {
+        fileList("REF.MASK", refMask, "Name of the reference mask image", config);
+    }
+    const char *refWeight = psMetadataLookupStr(NULL, arguments, "-refweight"); // Name of reference weight
+    if (refWeight && strlen(refWeight) > 0) {
+        fileList("REF.WEIGHT", refWeight, "Name of the reference weight image", config);
+    }
+
     valueArgStr(config, arguments, "-stat",      "STATS",         config->arguments);
 
