Index: trunk/ppImage/src/Makefile.am
===================================================================
--- trunk/ppImage/src/Makefile.am	(revision 20410)
+++ trunk/ppImage/src/Makefile.am	(revision 20419)
@@ -1,5 +1,3 @@
-bin_PROGRAMS = ppImage ppFocus
-
-noinst_PROGRAMS = ppTest
+bin_PROGRAMS = ppImage
 
 noinst_HEADERS = \
@@ -16,4 +14,5 @@
 	ppImageOptions.c \
 	ppImageDetrendReadout.c \
+	ppImageDetrendRecord.c \
 	ppImageDetrendNonLinear.c \
 	ppImageDetrendFringe.c \
@@ -33,38 +32,4 @@
 	ppImageMemory.c
 
-ppFocus_CFLAGS = $(PPIMAGE_CFLAGS) $(PPSTATS_CFLAGS) $(PSASTRO_CFLAGS) $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
-ppFocus_LDFLAGS = $(PPIMAGE_LIBS) $(PSASTRO_LIBS) $(PPSTATS_LIBS) $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
-ppFocus_SOURCES = \
-	ppFocus.c \
-	ppFocusArguments.c \
-	ppFocusParseCamera.c \
-	ppFocusGetFWHM.c \
-	ppFocusFitFWHM.c \
-	ppImageLoop.c \
-	ppImageCleanup.c \
-	ppImageOptions.c \
-	ppImageDetrendReadout.c \
-	ppImageDetrendNonLinear.c \
-	ppImageDetrendFringe.c \
-	ppImageRebinReadout.c \
-	ppImageMosaic.c \
-	ppImagePhotom.c \
-	ppImageAstrom.c \
-	ppImageAddstar.c \
-	ppImageStatsOutput.c \
-	ppImagePixelStats.c \
-	ppImageMetadataStats.c \
-	ppImageReplaceBackground.c \
-	ppImageDefineFile.c \
-	ppImageSetMaskBits.c \
-	ppImageFileCheck.c \
-	ppImageVersion.c \
-	ppImageMemory.c
-
-ppTest_CFLAGS = $(PPIMAGE_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
-ppTest_LDFLAGS = $(PPIMAGE_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
-ppTest_SOURCES = \
-	ppTest.c
-
 CLEANFILES = *~
 
Index: trunk/ppImage/src/ppImage.h
===================================================================
--- trunk/ppImage/src/ppImage.h	(revision 20410)
+++ trunk/ppImage/src/ppImage.h	(revision 20419)
@@ -125,4 +125,12 @@
 pmReadout* ppImageDetrendSelectFirst(pmCell *cell, char *name, bool doThis);
 
+// Record which detrend file was used for the detrending
+bool ppImageDetrendRecord(
+    pmCell *cell,                       // Cell of interest
+    const pmConfig *config,             // Configuration
+    const ppImageOptions *options,      // Processing options
+    const pmFPAview *view               // View to cell
+    );
+
 bool ppImageRebinChip (pmConfig *config, pmFPAview *view, ppImageOptions *options, char *outName);
 bool ppImageRebinReadout (pmReadout *output, pmReadout *input, pmFPAfile *outFile, ppImageOptions *options);
Index: trunk/ppImage/src/ppImageDetrendRecord.c
===================================================================
--- trunk/ppImage/src/ppImageDetrendRecord.c	(revision 20419)
+++ trunk/ppImage/src/ppImageDetrendRecord.c	(revision 20419)
@@ -0,0 +1,55 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "ppImage.h"
+
+static void detrendRecord(
+    bool doThis,                        // Are we supposed to do this?
+    psMetadata *target,                 // Target metadata
+    const pmConfig *config,             // Configuration
+    const pmFPAview *view,              // View to cell
+    const char *filename,               // Name of file
+    const char *name,                   // Name in header
+    const char *desc                    // Description
+    )
+{
+    psAssert(config, "Need configuration");
+    psAssert(view, "Need view to cell");
+    psAssert(name, "Need file name");
+
+    if (!doThis) {
+        return;
+    }
+
+    pmFPAfile *file = psMetadataLookupPtr(NULL, config->files, filename); // File of interest
+    psAssert(file, "Should be there");
+
+    if (target) {
+        psMetadataAddStr(target, PS_LIST_TAIL, name, 0, desc, file->filename);
+    }
+
+    pmCell *input = pmFPAfileThisCell(config->files, view, "PPIMAGE.INPUT"); // File we're processing
+    psAssert(input, "Should be there");
+    pmHDU *hdu = pmHDUFromCell(input);  // HDU for cell
+    psMetadataAddStr(hdu->header, PS_LIST_TAIL, name, PS_META_DUPLICATE_OK, desc, basename(file->filename));
+
+    return;
+}
+
+
+bool ppImageDetrendRecord(pmCell *cell, const pmConfig *config, const ppImageOptions *options,
+                          const pmFPAview *view)
+{
+    psMetadata *detrend = psMetadataAlloc(); // Detrend information
+    psMetadataAddMetadata(cell->analysis, PS_LIST_TAIL, "DETREND", 0, "Detrend information", detrend);
+    detrendRecord(options->doMask, detrend, config, view, "PPIMAGE.MASK", "DETREND.MASK", "Mask filename");
+    detrendRecord(options->doBias, detrend, config, view, "PPIMAGE.BIAS", "DETREND.BIAS", "Bias filename");
+    detrendRecord(options->doDark, detrend, config, view, "PPIMAGE.DARK", "DETREND.DARK", "Dark filename");
+    detrendRecord(options->doShutter, detrend, config, view, "PPIMAGE.SHUTTER", "DETREND.SHUTTER",
+                  "Shutter correction filename");
+    detrendRecord(options->doFlat, detrend, config, view, "PPIMAGE.FLAT", "DETREND.FLAT", "Flat filename");
+    detrendRecord(options->doFringe, detrend, config, view, "PPIMAGE.FRINGE", "DETREND.FRINGE",
+                  "Fringe filename");
+    return true;
+}
Index: trunk/ppImage/src/ppImageLoop.c
===================================================================
--- trunk/ppImage/src/ppImageLoop.c	(revision 20410)
+++ trunk/ppImage/src/ppImageLoop.c	(revision 20419)
@@ -95,4 +95,8 @@
                     ESCAPE("Unable to detrend readout");
                 }
+            }
+
+            if (cell->data_exists) {
+                ppImageDetrendRecord(cell, config, options, view);
             }
         }
