Index: trunk/ppImage/src/ppImage.h
===================================================================
--- trunk/ppImage/src/ppImage.h	(revision 13970)
+++ trunk/ppImage/src/ppImage.h	(revision 14000)
@@ -14,8 +14,69 @@
 #include "psphot.h"
 #include "psastro.h"
-#include "ppImageOptions.h"
+#include "ppStats.h"
 
 #define RECIPE_NAME "PPIMAGE"           // Name of the recipe to use
 #define TIMERNAME "ppImage"             // Name of timer
+
+// Options for ppImage processing
+typedef struct {
+    bool doMask;                        // Mask bad pixels
+    psMaskType maskValue;               // apply this bit-mask to choose masked bits
+    psMaskType satMask;                 // Mask value to give saturated pixels
+    psMaskType badMask;                 // Mask value to give bad pixels
+    psMaskType flatMask;                // Mask value to give bad flat pixels
+    psMaskType blankMask;               // Mask value to give blank pixels
+
+    bool doBias;                        // Bias subtraction
+    bool doDark;                        // Dark subtraction
+    bool doShutter;                     // Shutter correction
+    bool doFlat;                        // Flat-field normalisation
+    bool doFringe;                      // Fringe subtraction
+    bool doPhotom;                      // Source identification and photometry
+    bool doAstromChip;                  // per-chip Astrometry
+    bool doAstromMosaic;                // full-mosaic Astrometry
+    bool doAddstar;                     // add results to object database?
+
+    bool doOverscan;                    // Overscan subtraction
+    pmOverscanOptions *overscan;        // Overscan options
+
+    bool doNonLin;                      // Non-linearity correction
+    psDataType nonLinearType;
+    psMetadataItem *nonLinearData;
+    void *nonLinearSource;
+
+    bool doStats;
+
+    bool BaseFITS;
+    bool ChipFITS;
+    bool FPA1FITS;
+    bool FPA2FITS;
+
+    bool Bin1FITS;
+    bool Bin1JPEG;
+    int xBin1, yBin1;
+
+    bool Bin2FITS;
+    bool Bin2JPEG;
+    int xBin2, yBin2;
+
+    float fringeRej;                    // Fringe rejection limit
+    int fringeIter;                     // Fringe iterations
+    float fringeKeep;                   // Fringe keep fraction
+} ppImageOptions;
+
+// Cells to be used in the detrend
+typedef struct {
+    pmCell *input;                      // The input cell, to be operated upon
+    pmCell *mask;                       // The bad pixel mask
+    pmCell *bias;                       // The bias correction
+    pmCell *dark;                       // The dark correction
+    pmCell *flat;                       // The flat-field correction
+} ppImageDetrend;
+
+ppImageOptions *ppImageOptionsAlloc(void);
+
+// Determine the processing options
+ppImageOptions *ppImageOptionsParse(pmConfig *config);
 
 // Get the configuration
@@ -35,9 +96,12 @@
 
 bool ppImageDetrendBias(pmReadout *inputReadout, pmReadout *bias, pmReadout *dark, ppImageOptions *options);
-bool ppImageDetrendMask(pmReadout *input, pmReadout *mask);
 
 bool ppImageDetrendNonLinear(pmReadout *input, ppImageOptions *options);
 bool ppImageDetrendNonLinearLookup(pmReadout *input, psMetadataItem *dataItem);
 bool ppImageDetrendNonLinearPolynomial(pmReadout *input, psMetadataItem *dataItem);
+
+bool ppImageDetrendCell(ppImageDetrend *detrend, ppImageOptions *options, pmConfig *config);
+bool ppImageDetrendBias(pmReadout *inputReadout, pmReadout *bias, pmReadout *dark, ppImageOptions *options);
+pmReadout* ppImageDetrendSelectFirst(pmCell *cell, char *name, bool doThis);
 
 bool ppImageRebinChip (pmConfig *config, pmFPAview *view, char *outName);
@@ -69,5 +133,52 @@
 
 // write stats to output file 
-bool ppImageStatsOutput (pmConfig *config, pmFPA *fpa, const ppImageOptions *options);
+bool ppImageStatsOutput (pmConfig *config, const ppImageOptions *options);
+
+
+// Measure fringes
+bool ppImageDetrendFringeMeasure(pmReadout *readout, // Readout to measure
+                                 pmCell *fringe, // Fringe cell (each readout is a different component)
+				 const bool isResidual,
+                                 const ppImageOptions *options // Options
+    );
+
+// Solve the fringe system
+bool ppImageDetrendFringeSolve(pmChip *scienceChip, // Chip with science
+                               const pmChip *refChip, // Chip with reference fringes
+			       const bool isResidual,
+                               const ppImageOptions *options // Options
+    );
+
+// Generate fringe frame
+bool ppImageDetrendFringeGenerate(pmCell *science, // Science cell
+                                  pmCell *fringes, // Fringe cell, one readout per fringe component
+				  const ppImageOptions *options // Options
+    );
+
+
+bool ppImageDetrendFringeApply (pmConfig *config, // config
+				pmChip *chip, // science chip
+				const pmFPAview *inputView, // current view
+				const ppImageOptions *options // options
+    );
+
+/// Return short version information
+psString ppImageVersion(void);
+
+/// Return long version information
+psString ppImageVersionLong(void);
+
+/// Update the metadata with version information for all dependencies
+void ppImageVersionMetadata(psMetadata *metadata ///< Metadata to update with version information
+    );
+
+
+// calculate stats, including MD5
+bool ppImagePixelStats (pmConfig *config, const ppImageOptions *options, const pmFPAview *inputView);
+
+// calculate stats from headers and concepts
+bool ppImageMetadataStats (pmConfig *config, const ppImageOptions *options);
+
+void ppImageFileCheck (pmConfig *config);
 
 #endif
