Index: /branches/eam_branches/20091201/ippconfig/gpc1/ppImage.config
===================================================================
--- /branches/eam_branches/20091201/ippconfig/gpc1/ppImage.config	(revision 26775)
+++ /branches/eam_branches/20091201/ippconfig/gpc1/ppImage.config	(revision 26776)
@@ -24,6 +24,6 @@
 NOISEMAP                BOOL    FALSE          # Apply read noise map
 
-PATTERN		BOOL 	FALSE	# Do any pattern subtraction at all?
-PATTERN.SUBSET	METADATA	# List of chips and whether to do pattern subtraction
+PATTERN.ROW		BOOL 	FALSE	# Do any row pattern correction at all?
+PATTERN.ROW.SUBSET	METADATA	# List of chips and whether to do row pattern correction
 	XY01	BOOL	FALSE
 	XY02	BOOL	FALSE
@@ -283,4 +283,1042 @@
 END
 
+PATTERN.CELL		BOOL 	TRUE	# Do any cell pattern correction at all?
+PATTERN.CELL.SUBSET	METADATA	# List of chips and whether to do cell pattern correction
+	XY01	BOOL	FALSE
+	XY02	BOOL	FALSE
+	XY03	BOOL	FALSE
+	XY04	BOOL	FALSE
+	XY05	BOOL	FALSE
+	XY06	METADATA
+		xy00	BOOL	TRUE
+		xy01	BOOL	FALSE
+		xy02	BOOL	FALSE
+		xy03	BOOL	FALSE
+		xy04	BOOL	FALSE
+		xy05	BOOL	FALSE
+		xy06	BOOL	FALSE
+		xy07	BOOL	FALSE
+		xy10	BOOL	FALSE
+		xy11	BOOL	FALSE
+		xy12	BOOL	FALSE
+		xy13	BOOL	TRUE
+		xy14	BOOL	FALSE
+		xy15	BOOL	FALSE
+		xy16	BOOL	FALSE
+		xy17	BOOL	FALSE
+		xy20	BOOL	FALSE
+		xy21	BOOL	FALSE
+		xy22	BOOL	FALSE
+		xy23	BOOL	FALSE
+		xy24	BOOL	TRUE
+		xy25	BOOL	FALSE
+		xy26	BOOL	TRUE
+		xy27	BOOL	FALSE
+		xy30	BOOL	FALSE
+		xy31	BOOL	TRUE
+		xy32	BOOL	FALSE
+		xy33	BOOL	FALSE
+		xy34	BOOL	FALSE
+		xy35	BOOL	FALSE
+		xy36	BOOL	FALSE
+		xy37	BOOL	FALSE
+		xy40	BOOL	FALSE
+		xy41	BOOL	FALSE
+		xy42	BOOL	FALSE
+		xy43	BOOL	FALSE
+		xy44	BOOL	FALSE
+		xy45	BOOL	FALSE
+		xy46	BOOL	FALSE
+		xy47	BOOL	FALSE
+		xy50	BOOL	FALSE
+		xy51	BOOL	FALSE
+		xy52	BOOL	FALSE
+		xy53	BOOL	FALSE
+		xy54	BOOL	FALSE
+		xy55	BOOL	FALSE
+		xy56	BOOL	FALSE
+		xy57	BOOL	FALSE
+		xy60	BOOL	FALSE
+		xy61	BOOL	FALSE
+		xy62	BOOL	FALSE
+		xy63	BOOL	FALSE
+		xy64	BOOL	FALSE
+		xy65	BOOL	FALSE
+		xy66	BOOL	FALSE
+		xy67	BOOL	FALSE
+		xy70	BOOL	FALSE
+		xy71	BOOL	FALSE
+		xy72	BOOL	FALSE
+		xy73	BOOL	FALSE
+		xy74	BOOL	FALSE
+		xy75	BOOL	FALSE
+		xy76	BOOL	FALSE
+		xy77	BOOL	FALSE
+	END
+	XY10	BOOL	FALSE
+	XY11	BOOL	FALSE
+	XY12	BOOL	FALSE
+	XY13	BOOL	FALSE
+	XY14	METADATA
+		xy00	BOOL	FALSE
+		xy01	BOOL	FALSE
+		xy02	BOOL	FALSE
+		xy03	BOOL	FALSE
+		xy04	BOOL	FALSE
+		xy05	BOOL	FALSE
+		xy06	BOOL	FALSE
+		xy07	BOOL	FALSE
+		xy10	BOOL	FALSE
+		xy11	BOOL	FALSE
+		xy12	BOOL	FALSE
+		xy13	BOOL	FALSE
+		xy14	BOOL	FALSE
+		xy15	BOOL	FALSE
+		xy16	BOOL	FALSE
+		xy17	BOOL	FALSE
+		xy20	BOOL	FALSE
+		xy21	BOOL	FALSE
+		xy22	BOOL	FALSE
+		xy23	BOOL	FALSE
+		xy24	BOOL	FALSE
+		xy25	BOOL	FALSE
+		xy26	BOOL	FALSE
+		xy27	BOOL	FALSE
+		xy30	BOOL	FALSE
+		xy31	BOOL	FALSE
+		xy32	BOOL	FALSE
+		xy33	BOOL	FALSE
+		xy34	BOOL	FALSE
+		xy35	BOOL	FALSE
+		xy36	BOOL	FALSE
+		xy37	BOOL	FALSE
+		xy40	BOOL	FALSE
+		xy41	BOOL	FALSE
+		xy42	BOOL	FALSE
+		xy43	BOOL	FALSE
+		xy44	BOOL	FALSE
+		xy45	BOOL	FALSE
+		xy46	BOOL	FALSE
+		xy47	BOOL	FALSE
+		xy50	BOOL	FALSE
+		xy51	BOOL	FALSE
+		xy52	BOOL	FALSE
+		xy53	BOOL	FALSE
+		xy54	BOOL	FALSE
+		xy55	BOOL	FALSE
+		xy56	BOOL	FALSE
+		xy57	BOOL	TRUE
+		xy60	BOOL	FALSE
+		xy61	BOOL	FALSE
+		xy62	BOOL	FALSE
+		xy63	BOOL	FALSE
+		xy64	BOOL	FALSE
+		xy65	BOOL	FALSE
+		xy66	BOOL	FALSE
+		xy67	BOOL	FALSE
+		xy70	BOOL	FALSE
+		xy71	BOOL	FALSE
+		xy72	BOOL	TRUE
+		xy73	BOOL	FALSE
+		xy74	BOOL	TRUE
+		xy75	BOOL	TRUE
+		xy76	BOOL	FALSE
+		xy77	BOOL	TRUE
+	END
+	XY15	METADATA
+		xy00	BOOL	FALSE
+		xy01	BOOL	FALSE
+		xy02	BOOL	FALSE
+		xy03	BOOL	FALSE
+		xy04	BOOL	FALSE
+		xy05	BOOL	TRUE
+		xy06	BOOL	TRUE
+		xy07	BOOL	TRUE
+		xy10	BOOL	FALSE
+		xy11	BOOL	FALSE
+		xy12	BOOL	FALSE
+		xy13	BOOL	TRUE
+		xy14	BOOL	TRUE
+		xy15	BOOL	FALSE
+		xy16	BOOL	FALSE
+		xy17	BOOL	FALSE
+		xy20	BOOL	FALSE
+		xy21	BOOL	FALSE
+		xy22	BOOL	FALSE
+		xy23	BOOL	FALSE
+		xy24	BOOL	FALSE
+		xy25	BOOL	TRUE
+		xy26	BOOL	FALSE
+		xy27	BOOL	FALSE
+		xy30	BOOL	FALSE
+		xy31	BOOL	FALSE
+		xy32	BOOL	FALSE
+		xy33	BOOL	FALSE
+		xy34	BOOL	FALSE
+		xy35	BOOL	TRUE
+		xy36	BOOL	FALSE
+		xy37	BOOL	FALSE
+		xy40	BOOL	FALSE
+		xy41	BOOL	FALSE
+		xy42	BOOL	FALSE
+		xy43	BOOL	FALSE
+		xy44	BOOL	TRUE
+		xy45	BOOL	FALSE
+		xy46	BOOL	FALSE
+		xy47	BOOL	TRUE
+		xy50	BOOL	FALSE
+		xy51	BOOL	FALSE
+		xy52	BOOL	FALSE
+		xy53	BOOL	TRUE
+		xy54	BOOL	TRUE
+		xy55	BOOL	TRUE
+		xy56	BOOL	TRUE
+		xy57	BOOL	TRUE
+		xy60	BOOL	FALSE
+		xy61	BOOL	FALSE
+		xy62	BOOL	FALSE
+		xy63	BOOL	TRUE
+		xy64	BOOL	FALSE
+		xy65	BOOL	TRUE
+		xy66	BOOL	FALSE
+		xy67	BOOL	FALSE
+		xy70	BOOL	FALSE
+		xy71	BOOL	FALSE
+		xy72	BOOL	FALSE
+		xy73	BOOL	TRUE
+		xy74	BOOL	TRUE
+		xy75	BOOL	TRUE
+		xy76	BOOL	TRUE
+		xy77	BOOL	TRUE
+	END
+	XY16	METADATA
+		xy00	BOOL	FALSE
+		xy01	BOOL	FALSE
+		xy02	BOOL	FALSE
+		xy03	BOOL	FALSE
+		xy04	BOOL	FALSE
+		xy05	BOOL	FALSE
+		xy06	BOOL	FALSE
+		xy07	BOOL	TRUE
+		xy10	BOOL	FALSE
+		xy11	BOOL	FALSE
+		xy12	BOOL	FALSE
+		xy13	BOOL	FALSE
+		xy14	BOOL	FALSE
+		xy15	BOOL	FALSE
+		xy16	BOOL	FALSE
+		xy17	BOOL	FALSE
+		xy20	BOOL	FALSE
+		xy21	BOOL	FALSE
+		xy22	BOOL	FALSE
+		xy23	BOOL	FALSE
+		xy24	BOOL	FALSE
+		xy25	BOOL	FALSE
+		xy26	BOOL	FALSE
+		xy27	BOOL	FALSE
+		xy30	BOOL	FALSE
+		xy31	BOOL	FALSE
+		xy32	BOOL	FALSE
+		xy33	BOOL	FALSE
+		xy34	BOOL	FALSE
+		xy35	BOOL	FALSE
+		xy36	BOOL	FALSE
+		xy37	BOOL	FALSE
+		xy40	BOOL	FALSE
+		xy41	BOOL	FALSE
+		xy42	BOOL	FALSE
+		xy43	BOOL	FALSE
+		xy44	BOOL	FALSE
+		xy45	BOOL	FALSE
+		xy46	BOOL	FALSE
+		xy47	BOOL	TRUE
+		xy50	BOOL	FALSE
+		xy51	BOOL	FALSE
+		xy52	BOOL	FALSE
+		xy53	BOOL	FALSE
+		xy54	BOOL	FALSE
+		xy55	BOOL	FALSE
+		xy56	BOOL	FALSE
+		xy57	BOOL	FALSE
+		xy60	BOOL	FALSE
+		xy61	BOOL	FALSE
+		xy62	BOOL	FALSE
+		xy63	BOOL	FALSE
+		xy64	BOOL	FALSE
+		xy65	BOOL	FALSE
+		xy66	BOOL	FALSE
+		xy67	BOOL	FALSE
+		xy70	BOOL	FALSE
+		xy71	BOOL	FALSE
+		xy72	BOOL	FALSE
+		xy73	BOOL	FALSE
+		xy74	BOOL	FALSE
+		xy75	BOOL	FALSE
+		xy76	BOOL	FALSE
+		xy77	BOOL	FALSE
+	END
+	XY17	BOOL	FALSE
+	XY20	BOOL	FALSE
+	XY21	BOOL	FALSE
+	XY22	BOOL	FALSE
+	XY23	BOOL	FALSE
+	XY24	METADATA
+		xy00	BOOL	FALSE
+		xy01	BOOL	FALSE
+		xy02	BOOL	FALSE
+		xy03	BOOL	FALSE
+		xy04	BOOL	FALSE
+		xy05	BOOL	FALSE
+		xy06	BOOL	FALSE
+		xy07	BOOL	FALSE
+		xy10	BOOL	FALSE
+		xy11	BOOL	FALSE
+		xy12	BOOL	TRUE
+		xy13	BOOL	FALSE
+		xy14	BOOL	FALSE
+		xy15	BOOL	FALSE
+		xy16	BOOL	FALSE
+		xy17	BOOL	FALSE
+		xy20	BOOL	FALSE
+		xy21	BOOL	FALSE
+		xy22	BOOL	FALSE
+		xy23	BOOL	FALSE
+		xy24	BOOL	FALSE
+		xy25	BOOL	FALSE
+		xy26	BOOL	FALSE
+		xy27	BOOL	FALSE
+		xy30	BOOL	FALSE
+		xy31	BOOL	TRUE
+		xy32	BOOL	TRUE
+		xy33	BOOL	FALSE
+		xy34	BOOL	TRUE
+		xy35	BOOL	FALSE
+		xy36	BOOL	FALSE
+		xy37	BOOL	FALSE
+		xy40	BOOL	FALSE
+		xy41	BOOL	FALSE
+		xy42	BOOL	TRUE
+		xy43	BOOL	FALSE
+		xy44	BOOL	FALSE
+		xy45	BOOL	FALSE
+		xy46	BOOL	FALSE
+		xy47	BOOL	FALSE
+		xy50	BOOL	FALSE
+		xy51	BOOL	FALSE
+		xy52	BOOL	TRUE
+		xy53	BOOL	FALSE
+		xy54	BOOL	FALSE
+		xy55	BOOL	FALSE
+		xy56	BOOL	FALSE
+		xy57	BOOL	FALSE
+		xy60	BOOL	FALSE
+		xy61	BOOL	FALSE
+		xy62	BOOL	TRUE
+		xy63	BOOL	TRUE
+		xy64	BOOL	TRUE
+		xy65	BOOL	FALSE
+		xy66	BOOL	FALSE
+		xy67	BOOL	FALSE
+		xy70	BOOL	FALSE
+		xy71	BOOL	FALSE
+		xy72	BOOL	FALSE
+		xy73	BOOL	FALSE
+		xy74	BOOL	FALSE
+		xy75	BOOL	FALSE
+		xy76	BOOL	FALSE
+		xy77	BOOL	FALSE
+	END
+	XY25	METADATA
+		xy00	BOOL	FALSE
+		xy01	BOOL	TRUE
+		xy02	BOOL	FALSE
+		xy03	BOOL	FALSE
+		xy04	BOOL	FALSE
+		xy05	BOOL	TRUE
+		xy06	BOOL	FALSE
+		xy07	BOOL	FALSE
+		xy10	BOOL	FALSE
+		xy11	BOOL	FALSE
+		xy12	BOOL	FALSE
+		xy13	BOOL	FALSE
+		xy14	BOOL	TRUE
+		xy15	BOOL	FALSE
+		xy16	BOOL	FALSE
+		xy17	BOOL	TRUE
+		xy20	BOOL	FALSE
+		xy21	BOOL	FALSE
+		xy22	BOOL	TRUE
+		xy23	BOOL	FALSE
+		xy24	BOOL	TRUE
+		xy25	BOOL	TRUE
+		xy26	BOOL	FALSE
+		xy27	BOOL	FALSE
+		xy30	BOOL	FALSE
+		xy31	BOOL	FALSE
+		xy32	BOOL	FALSE
+		xy33	BOOL	FALSE
+		xy34	BOOL	FALSE
+		xy35	BOOL	FALSE
+		xy36	BOOL	TRUE
+		xy37	BOOL	FALSE
+		xy40	BOOL	FALSE
+		xy41	BOOL	FALSE
+		xy42	BOOL	FALSE
+		xy43	BOOL	FALSE
+		xy44	BOOL	FALSE
+		xy45	BOOL	TRUE
+		xy46	BOOL	TRUE
+		xy47	BOOL	TRUE
+		xy50	BOOL	FALSE
+		xy51	BOOL	FALSE
+		xy52	BOOL	FALSE
+		xy53	BOOL	TRUE
+		xy54	BOOL	FALSE
+		xy55	BOOL	FALSE
+		xy56	BOOL	FALSE
+		xy57	BOOL	FALSE
+		xy60	BOOL	FALSE
+		xy61	BOOL	FALSE
+		xy62	BOOL	FALSE
+		xy63	BOOL	FALSE
+		xy64	BOOL	TRUE
+		xy65	BOOL	FALSE
+		xy66	BOOL	FALSE
+		xy67	BOOL	FALSE
+		xy70	BOOL	FALSE
+		xy71	BOOL	FALSE
+		xy72	BOOL	FALSE
+		xy73	BOOL	FALSE
+		xy74	BOOL	FALSE
+		xy75	BOOL	FALSE
+		xy76	BOOL	TRUE
+		xy77	BOOL	FALSE
+	END
+	XY26	METADATA
+		xy00	BOOL	FALSE
+		xy01	BOOL	FALSE
+		xy02	BOOL	FALSE
+		xy03	BOOL	FALSE
+		xy04	BOOL	FALSE
+		xy05	BOOL	FALSE
+		xy06	BOOL	FALSE
+		xy07	BOOL	FALSE
+		xy10	BOOL	FALSE
+		xy11	BOOL	FALSE
+		xy12	BOOL	FALSE
+		xy13	BOOL	FALSE
+		xy14	BOOL	FALSE
+		xy15	BOOL	TRUE
+		xy16	BOOL	FALSE
+		xy17	BOOL	FALSE
+		xy20	BOOL	FALSE
+		xy21	BOOL	FALSE
+		xy22	BOOL	FALSE
+		xy23	BOOL	FALSE
+		xy24	BOOL	FALSE
+		xy25	BOOL	FALSE
+		xy26	BOOL	FALSE
+		xy27	BOOL	FALSE
+		xy30	BOOL	FALSE
+		xy31	BOOL	FALSE
+		xy32	BOOL	FALSE
+		xy33	BOOL	FALSE
+		xy34	BOOL	FALSE
+		xy35	BOOL	FALSE
+		xy36	BOOL	FALSE
+		xy37	BOOL	FALSE
+		xy40	BOOL	FALSE
+		xy41	BOOL	FALSE
+		xy42	BOOL	FALSE
+		xy43	BOOL	FALSE
+		xy44	BOOL	TRUE
+		xy45	BOOL	FALSE
+		xy46	BOOL	FALSE
+		xy47	BOOL	FALSE
+		xy50	BOOL	FALSE
+		xy51	BOOL	FALSE
+		xy52	BOOL	TRUE
+		xy53	BOOL	FALSE
+		xy54	BOOL	FALSE
+		xy55	BOOL	FALSE
+		xy56	BOOL	FALSE
+		xy57	BOOL	FALSE
+		xy60	BOOL	FALSE
+		xy61	BOOL	FALSE
+		xy62	BOOL	FALSE
+		xy63	BOOL	FALSE
+		xy64	BOOL	FALSE
+		xy65	BOOL	FALSE
+		xy66	BOOL	FALSE
+		xy67	BOOL	FALSE
+		xy70	BOOL	FALSE
+		xy71	BOOL	FALSE
+		xy72	BOOL	FALSE
+		xy73	BOOL	FALSE
+		xy74	BOOL	FALSE
+		xy75	BOOL	FALSE
+		xy76	BOOL	FALSE
+		xy77	BOOL	FALSE
+	END
+	XY27	BOOL	FALSE
+	XY30	BOOL	FALSE
+	XY31	BOOL	FALSE
+	XY32	BOOL	FALSE
+	XY33	BOOL	FALSE
+	XY34	METADATA
+		xy00	BOOL	FALSE
+		xy01	BOOL	FALSE
+		xy02	BOOL	FALSE
+		xy03	BOOL	FALSE
+		xy04	BOOL	FALSE
+		xy05	BOOL	FALSE
+		xy06	BOOL	FALSE
+		xy07	BOOL	FALSE
+		xy10	BOOL	FALSE
+		xy11	BOOL	FALSE
+		xy12	BOOL	FALSE
+		xy13	BOOL	FALSE
+		xy14	BOOL	FALSE
+		xy15	BOOL	FALSE
+		xy16	BOOL	FALSE
+		xy17	BOOL	FALSE
+		xy20	BOOL	FALSE
+		xy21	BOOL	FALSE
+		xy22	BOOL	FALSE
+		xy23	BOOL	FALSE
+		xy24	BOOL	FALSE
+		xy25	BOOL	FALSE
+		xy26	BOOL	FALSE
+		xy27	BOOL	FALSE
+		xy30	BOOL	FALSE
+		xy31	BOOL	FALSE
+		xy32	BOOL	FALSE
+		xy33	BOOL	FALSE
+		xy34	BOOL	FALSE
+		xy35	BOOL	FALSE
+		xy36	BOOL	FALSE
+		xy37	BOOL	FALSE
+		xy40	BOOL	FALSE
+		xy41	BOOL	FALSE
+		xy42	BOOL	FALSE
+		xy43	BOOL	FALSE
+		xy44	BOOL	FALSE
+		xy45	BOOL	FALSE
+		xy46	BOOL	FALSE
+		xy47	BOOL	TRUE
+		xy50	BOOL	FALSE
+		xy51	BOOL	FALSE
+		xy52	BOOL	FALSE
+		xy53	BOOL	FALSE
+		xy54	BOOL	FALSE
+		xy55	BOOL	TRUE
+		xy56	BOOL	FALSE
+		xy57	BOOL	FALSE
+		xy60	BOOL	FALSE
+		xy61	BOOL	FALSE
+		xy62	BOOL	FALSE
+		xy63	BOOL	FALSE
+		xy64	BOOL	TRUE
+		xy65	BOOL	FALSE
+		xy66	BOOL	TRUE
+		xy67	BOOL	FALSE
+		xy70	BOOL	FALSE
+		xy71	BOOL	FALSE
+		xy72	BOOL	TRUE
+		xy73	BOOL	TRUE
+		xy74	BOOL	TRUE
+		xy75	BOOL	FALSE
+		xy76	BOOL	TRUE
+		xy77	BOOL	TRUE
+	END
+	XY35	BOOL	FALSE
+	XY36	METADATA
+		xy00	BOOL	FALSE
+		xy01	BOOL	FALSE
+		xy02	BOOL	FALSE
+		xy03	BOOL	FALSE
+		xy04	BOOL	FALSE
+		xy05	BOOL	FALSE
+		xy06	BOOL	FALSE
+		xy07	BOOL	FALSE
+		xy10	BOOL	FALSE
+		xy11	BOOL	FALSE
+		xy12	BOOL	FALSE
+		xy13	BOOL	FALSE
+		xy14	BOOL	FALSE
+		xy15	BOOL	FALSE
+		xy16	BOOL	FALSE
+		xy17	BOOL	FALSE
+		xy20	BOOL	FALSE
+		xy21	BOOL	FALSE
+		xy22	BOOL	FALSE
+		xy23	BOOL	FALSE
+		xy24	BOOL	FALSE
+		xy25	BOOL	FALSE
+		xy26	BOOL	FALSE
+		xy27	BOOL	FALSE
+		xy30	BOOL	FALSE
+		xy31	BOOL	FALSE
+		xy32	BOOL	FALSE
+		xy33	BOOL	FALSE
+		xy34	BOOL	FALSE
+		xy35	BOOL	FALSE
+		xy36	BOOL	FALSE
+		xy37	BOOL	FALSE
+		xy40	BOOL	FALSE
+		xy41	BOOL	FALSE
+		xy42	BOOL	FALSE
+		xy43	BOOL	TRUE
+		xy44	BOOL	FALSE
+		xy45	BOOL	FALSE
+		xy46	BOOL	FALSE
+		xy47	BOOL	FALSE
+		xy50	BOOL	FALSE
+		xy51	BOOL	FALSE
+		xy52	BOOL	FALSE
+		xy53	BOOL	FALSE
+		xy54	BOOL	FALSE
+		xy55	BOOL	FALSE
+		xy56	BOOL	FALSE
+		xy57	BOOL	FALSE
+		xy60	BOOL	FALSE
+		xy61	BOOL	FALSE
+		xy62	BOOL	FALSE
+		xy63	BOOL	FALSE
+		xy64	BOOL	FALSE
+		xy65	BOOL	FALSE
+		xy66	BOOL	FALSE
+		xy67	BOOL	FALSE
+		xy70	BOOL	FALSE
+		xy71	BOOL	FALSE
+		xy72	BOOL	FALSE
+		xy73	BOOL	FALSE
+		xy74	BOOL	FALSE
+		xy75	BOOL	FALSE
+		xy76	BOOL	FALSE
+		xy77	BOOL	FALSE
+	END
+	XY37	METADATA
+		xy00	BOOL	FALSE
+		xy01	BOOL	FALSE
+		xy02	BOOL	FALSE
+		xy03	BOOL	FALSE
+		xy04	BOOL	FALSE
+		xy05	BOOL	FALSE
+		xy06	BOOL	FALSE
+		xy07	BOOL	FALSE
+		xy10	BOOL	FALSE
+		xy11	BOOL	FALSE
+		xy12	BOOL	FALSE
+		xy13	BOOL	FALSE
+		xy14	BOOL	FALSE
+		xy15	BOOL	FALSE
+		xy16	BOOL	FALSE
+		xy17	BOOL	FALSE
+		xy20	BOOL	FALSE
+		xy21	BOOL	FALSE
+		xy22	BOOL	FALSE
+		xy23	BOOL	FALSE
+		xy24	BOOL	FALSE
+		xy25	BOOL	FALSE
+		xy26	BOOL	FALSE
+		xy27	BOOL	FALSE
+		xy30	BOOL	FALSE
+		xy31	BOOL	FALSE
+		xy32	BOOL	FALSE
+		xy33	BOOL	FALSE
+		xy34	BOOL	FALSE
+		xy35	BOOL	FALSE
+		xy36	BOOL	FALSE
+		xy37	BOOL	TRUE
+		xy40	BOOL	FALSE
+		xy41	BOOL	FALSE
+		xy42	BOOL	FALSE
+		xy43	BOOL	TRUE
+		xy44	BOOL	FALSE
+		xy45	BOOL	FALSE
+		xy46	BOOL	FALSE
+		xy47	BOOL	TRUE
+		xy50	BOOL	FALSE
+		xy51	BOOL	FALSE
+		xy52	BOOL	FALSE
+		xy53	BOOL	FALSE
+		xy54	BOOL	FALSE
+		xy55	BOOL	FALSE
+		xy56	BOOL	FALSE
+		xy57	BOOL	FALSE
+		xy60	BOOL	TRUE
+		xy61	BOOL	FALSE
+		xy62	BOOL	TRUE
+		xy63	BOOL	TRUE
+		xy64	BOOL	FALSE
+		xy65	BOOL	FALSE
+		xy66	BOOL	FALSE
+		xy67	BOOL	FALSE
+		xy70	BOOL	TRUE
+		xy71	BOOL	FALSE
+		xy72	BOOL	TRUE
+		xy73	BOOL	TRUE
+		xy74	BOOL	FALSE
+		xy75	BOOL	TRUE
+		xy76	BOOL	TRUE
+		xy77	BOOL	FALSE
+	END
+	XY40	METADATA
+		xy00	BOOL	FALSE
+		xy01	BOOL	FALSE
+		xy02	BOOL	FALSE
+		xy03	BOOL	FALSE
+		xy04	BOOL	FALSE
+		xy05	BOOL	FALSE
+		xy06	BOOL	FALSE
+		xy07	BOOL	FALSE
+		xy10	BOOL	FALSE
+		xy11	BOOL	FALSE
+		xy12	BOOL	FALSE
+		xy13	BOOL	FALSE
+		xy14	BOOL	FALSE
+		xy15	BOOL	FALSE
+		xy16	BOOL	FALSE
+		xy17	BOOL	FALSE
+		xy20	BOOL	FALSE
+		xy21	BOOL	FALSE
+		xy22	BOOL	FALSE
+		xy23	BOOL	FALSE
+		xy24	BOOL	FALSE
+		xy25	BOOL	FALSE
+		xy26	BOOL	FALSE
+		xy27	BOOL	FALSE
+		xy30	BOOL	FALSE
+		xy31	BOOL	FALSE
+		xy32	BOOL	TRUE
+		xy33	BOOL	FALSE
+		xy34	BOOL	TRUE
+		xy35	BOOL	TRUE
+		xy36	BOOL	FALSE
+		xy37	BOOL	FALSE
+		xy40	BOOL	FALSE
+		xy41	BOOL	FALSE
+		xy42	BOOL	FALSE
+		xy43	BOOL	FALSE
+		xy44	BOOL	FALSE
+		xy45	BOOL	FALSE
+		xy46	BOOL	FALSE
+		xy47	BOOL	FALSE
+		xy50	BOOL	FALSE
+		xy51	BOOL	FALSE
+		xy52	BOOL	FALSE
+		xy53	BOOL	FALSE
+		xy54	BOOL	FALSE
+		xy55	BOOL	TRUE
+		xy56	BOOL	TRUE
+		xy57	BOOL	TRUE
+		xy60	BOOL	FALSE
+		xy61	BOOL	FALSE
+		xy62	BOOL	FALSE
+		xy63	BOOL	FALSE
+		xy64	BOOL	FALSE
+		xy65	BOOL	FALSE
+		xy66	BOOL	TRUE
+		xy67	BOOL	FALSE
+		xy70	BOOL	FALSE
+		xy71	BOOL	FALSE
+		xy72	BOOL	FALSE
+		xy73	BOOL	TRUE
+		xy74	BOOL	TRUE
+		xy75	BOOL	TRUE
+		xy76	BOOL	TRUE
+		xy77	BOOL	TRUE
+	END
+	XY41	BOOL	FALSE
+	XY42	BOOL	FALSE
+	XY43	METADATA
+		xy00	BOOL	FALSE
+		xy01	BOOL	FALSE
+		xy02	BOOL	FALSE
+		xy03	BOOL	FALSE
+		xy04	BOOL	FALSE
+		xy05	BOOL	FALSE
+		xy06	BOOL	FALSE
+		xy07	BOOL	FALSE
+		xy10	BOOL	FALSE
+		xy11	BOOL	FALSE
+		xy12	BOOL	FALSE
+		xy13	BOOL	FALSE
+		xy14	BOOL	FALSE
+		xy15	BOOL	FALSE
+		xy16	BOOL	FALSE
+		xy17	BOOL	FALSE
+		xy20	BOOL	FALSE
+		xy21	BOOL	FALSE
+		xy22	BOOL	FALSE
+		xy23	BOOL	FALSE
+		xy24	BOOL	FALSE
+		xy25	BOOL	FALSE
+		xy26	BOOL	FALSE
+		xy27	BOOL	TRUE
+		xy30	BOOL	FALSE
+		xy31	BOOL	FALSE
+		xy32	BOOL	FALSE
+		xy33	BOOL	FALSE
+		xy34	BOOL	FALSE
+		xy35	BOOL	FALSE
+		xy36	BOOL	FALSE
+		xy37	BOOL	TRUE
+		xy40	BOOL	FALSE
+		xy41	BOOL	FALSE
+		xy42	BOOL	FALSE
+		xy43	BOOL	FALSE
+		xy44	BOOL	FALSE
+		xy45	BOOL	FALSE
+		xy46	BOOL	FALSE
+		xy47	BOOL	FALSE
+		xy50	BOOL	FALSE
+		xy51	BOOL	FALSE
+		xy52	BOOL	FALSE
+		xy53	BOOL	FALSE
+		xy54	BOOL	TRUE
+		xy55	BOOL	FALSE
+		xy56	BOOL	FALSE
+		xy57	BOOL	FALSE
+		xy60	BOOL	FALSE
+		xy61	BOOL	TRUE
+		xy62	BOOL	FALSE
+		xy63	BOOL	FALSE
+		xy64	BOOL	FALSE
+		xy65	BOOL	FALSE
+		xy66	BOOL	FALSE
+		xy67	BOOL	TRUE
+		xy70	BOOL	FALSE
+		xy71	BOOL	FALSE
+		xy72	BOOL	FALSE
+		xy73	BOOL	FALSE
+		xy74	BOOL	FALSE
+		xy75	BOOL	TRUE
+		xy76	BOOL	FALSE
+		xy77	BOOL	FALSE
+	END
+	XY44	BOOL	FALSE
+	XY45	BOOL	FALSE
+	XY46	BOOL	FALSE
+	XY47	BOOL	FALSE
+	XY50	BOOL	FALSE
+	XY51	BOOL	FALSE
+	XY52	BOOL	FALSE
+	XY53	BOOL	FALSE
+	XY54	BOOL	FALSE
+	XY55	BOOL	FALSE
+	XY56	BOOL	FALSE
+	XY57	BOOL	FALSE
+	XY60	BOOL	FALSE
+	XY61	BOOL	FALSE
+	XY62	METADATA
+		xy00	BOOL	FALSE
+		xy01	BOOL	FALSE
+		xy02	BOOL	FALSE
+		xy03	BOOL	FALSE
+		xy04	BOOL	FALSE
+		xy05	BOOL	FALSE
+		xy06	BOOL	FALSE
+		xy07	BOOL	FALSE
+		xy10	BOOL	FALSE
+		xy11	BOOL	FALSE
+		xy12	BOOL	FALSE
+		xy13	BOOL	FALSE
+		xy14	BOOL	FALSE
+		xy15	BOOL	FALSE
+		xy16	BOOL	FALSE
+		xy17	BOOL	FALSE
+		xy20	BOOL	FALSE
+		xy21	BOOL	FALSE
+		xy22	BOOL	FALSE
+		xy23	BOOL	FALSE
+		xy24	BOOL	FALSE
+		xy25	BOOL	FALSE
+		xy26	BOOL	FALSE
+		xy27	BOOL	FALSE
+		xy30	BOOL	FALSE
+		xy31	BOOL	FALSE
+		xy32	BOOL	FALSE
+		xy33	BOOL	FALSE
+		xy34	BOOL	FALSE
+		xy35	BOOL	FALSE
+		xy36	BOOL	FALSE
+		xy37	BOOL	FALSE
+		xy40	BOOL	FALSE
+		xy41	BOOL	FALSE
+		xy42	BOOL	FALSE
+		xy43	BOOL	FALSE
+		xy44	BOOL	TRUE
+		xy45	BOOL	FALSE
+		xy46	BOOL	FALSE
+		xy47	BOOL	FALSE
+		xy50	BOOL	FALSE
+		xy51	BOOL	FALSE
+		xy52	BOOL	FALSE
+		xy53	BOOL	FALSE
+		xy54	BOOL	FALSE
+		xy55	BOOL	FALSE
+		xy56	BOOL	FALSE
+		xy57	BOOL	FALSE
+		xy60	BOOL	FALSE
+		xy61	BOOL	FALSE
+		xy62	BOOL	FALSE
+		xy63	BOOL	FALSE
+		xy64	BOOL	FALSE
+		xy65	BOOL	FALSE
+		xy66	BOOL	FALSE
+		xy67	BOOL	TRUE
+		xy70	BOOL	FALSE
+		xy71	BOOL	FALSE
+		xy72	BOOL	FALSE
+		xy73	BOOL	FALSE
+		xy74	BOOL	TRUE
+		xy75	BOOL	FALSE
+		xy76	BOOL	TRUE
+		xy77	BOOL	FALSE
+	END
+	XY63	BOOL	FALSE
+	XY64	BOOL	FALSE
+	XY65	BOOL	FALSE
+	XY66	BOOL	FALSE
+	XY67	BOOL	FALSE
+	XY71	BOOL	FALSE
+	XY72	METADATA
+		xy00	BOOL	FALSE
+		xy01	BOOL	FALSE
+		xy02	BOOL	FALSE
+		xy03	BOOL	FALSE
+		xy04	BOOL	FALSE
+		xy05	BOOL	FALSE
+		xy06	BOOL	FALSE
+		xy07	BOOL	FALSE
+		xy10	BOOL	FALSE
+		xy11	BOOL	FALSE
+		xy12	BOOL	FALSE
+		xy13	BOOL	FALSE
+		xy14	BOOL	FALSE
+		xy15	BOOL	FALSE
+		xy16	BOOL	FALSE
+		xy17	BOOL	FALSE
+		xy20	BOOL	FALSE
+		xy21	BOOL	FALSE
+		xy22	BOOL	FALSE
+		xy23	BOOL	FALSE
+		xy24	BOOL	FALSE
+		xy25	BOOL	FALSE
+		xy26	BOOL	FALSE
+		xy27	BOOL	FALSE
+		xy30	BOOL	FALSE
+		xy31	BOOL	FALSE
+		xy32	BOOL	FALSE
+		xy33	BOOL	FALSE
+		xy34	BOOL	FALSE
+		xy35	BOOL	FALSE
+		xy36	BOOL	FALSE
+		xy37	BOOL	FALSE
+		xy40	BOOL	FALSE
+		xy41	BOOL	FALSE
+		xy42	BOOL	FALSE
+		xy43	BOOL	FALSE
+		xy44	BOOL	FALSE
+		xy45	BOOL	FALSE
+		xy46	BOOL	FALSE
+		xy47	BOOL	FALSE
+		xy50	BOOL	FALSE
+		xy51	BOOL	FALSE
+		xy52	BOOL	FALSE
+		xy53	BOOL	FALSE
+		xy54	BOOL	FALSE
+		xy55	BOOL	FALSE
+		xy56	BOOL	FALSE
+		xy57	BOOL	FALSE
+		xy60	BOOL	FALSE
+		xy61	BOOL	FALSE
+		xy62	BOOL	FALSE
+		xy63	BOOL	FALSE
+		xy64	BOOL	FALSE
+		xy65	BOOL	FALSE
+		xy66	BOOL	FALSE
+		xy67	BOOL	FALSE
+		xy70	BOOL	FALSE
+		xy71	BOOL	FALSE
+		xy72	BOOL	FALSE
+		xy73	BOOL	FALSE
+		xy74	BOOL	FALSE
+		xy75	BOOL	FALSE
+		xy76	BOOL	FALSE
+		xy77	BOOL	TRUE
+	END
+	XY73	METADATA
+		xy00	BOOL	FALSE
+		xy01	BOOL	FALSE
+		xy02	BOOL	FALSE
+		xy03	BOOL	TRUE
+		xy04	BOOL	TRUE
+		xy05	BOOL	FALSE
+		xy06	BOOL	FALSE
+		xy07	BOOL	FALSE
+		xy10	BOOL	FALSE
+		xy11	BOOL	FALSE
+		xy12	BOOL	FALSE
+		xy13	BOOL	FALSE
+		xy14	BOOL	FALSE
+		xy15	BOOL	FALSE
+		xy16	BOOL	FALSE
+		xy17	BOOL	FALSE
+		xy20	BOOL	FALSE
+		xy21	BOOL	FALSE
+		xy22	BOOL	FALSE
+		xy23	BOOL	FALSE
+		xy24	BOOL	FALSE
+		xy25	BOOL	FALSE
+		xy26	BOOL	FALSE
+		xy27	BOOL	FALSE
+		xy30	BOOL	FALSE
+		xy31	BOOL	FALSE
+		xy32	BOOL	FALSE
+		xy33	BOOL	FALSE
+		xy34	BOOL	FALSE
+		xy35	BOOL	FALSE
+		xy36	BOOL	TRUE
+		xy37	BOOL	FALSE
+		xy40	BOOL	FALSE
+		xy41	BOOL	FALSE
+		xy42	BOOL	FALSE
+		xy43	BOOL	FALSE
+		xy44	BOOL	FALSE
+		xy45	BOOL	FALSE
+		xy46	BOOL	FALSE
+		xy47	BOOL	FALSE
+		xy50	BOOL	FALSE
+		xy51	BOOL	FALSE
+		xy52	BOOL	FALSE
+		xy53	BOOL	FALSE
+		xy54	BOOL	FALSE
+		xy55	BOOL	FALSE
+		xy56	BOOL	FALSE
+		xy57	BOOL	FALSE
+		xy60	BOOL	FALSE
+		xy61	BOOL	FALSE
+		xy62	BOOL	FALSE
+		xy63	BOOL	FALSE
+		xy64	BOOL	FALSE
+		xy65	BOOL	FALSE
+		xy66	BOOL	FALSE
+		xy67	BOOL	FALSE
+		xy70	BOOL	FALSE
+		xy71	BOOL	FALSE
+		xy72	BOOL	FALSE
+		xy73	BOOL	FALSE
+		xy74	BOOL	FALSE
+		xy75	BOOL	FALSE
+		xy76	BOOL	FALSE
+		xy77	BOOL	FALSE
+	END
+	XY74	BOOL	FALSE
+	XY75	BOOL	FALSE
+	XY76	BOOL	FALSE
+END
 
 TILTYSTREAK.BY.CLASS METADATA              # apply the 'tiltystreak' tool
@@ -415,6 +1453,7 @@
   FLAT             BOOL    TRUE            # Flat-field normalisation
   MASK             BOOL    TRUE            # Mask bad pixels
-  MASK.BURNTOOL      BOOL    TRUE            # Mask potential burntool trails
-  PATTERN          BOOL    TRUE            # Subtract pattern noise
+  MASK.BURNTOOL    BOOL    TRUE            # Mask potential burntool trails
+  PATTERN.ROW      BOOL    TRUE            # Row pattern correction
+  PATTERN.CELL	   BOOL	   TRUE		   # Cell pattern correction
   FRINGE           BOOL    FALSE           # Fringe subtraction
   BIN1.FITS        BOOL    TRUE            # Save 1st binned chip image?
@@ -1191,5 +2230,6 @@
   MASK             BOOL    TRUE            # Mask bad pixels
   FRINGE           BOOL    FALSE           # Fringe subtraction
-  PATTERN          BOOL    TRUE            # Subtract pattern noise
+  PATTERN.ROW      BOOL    TRUE            # Row pattern correction
+  PATTERN.CELL	   BOOL	   TRUE		   # Cell pattern correction
   BIN1.FITS        BOOL    TRUE            # Save 1st binned chip image?
   BIN2.FITS        BOOL    TRUE            # Save 2nd binned chip image?
@@ -1228,5 +2268,6 @@
   CROSSTALK.MEASURE  BOOL    TRUE            # Subtract model background?
   TILTYSTREAK.APPLY  BOOL    FALSE           # apply the 'tiltystreak' tool
-  PATTERN            BOOL    TRUE            # Subtract pattern noise
+  PATTERN.ROW        BOOL    TRUE            # Row pattern correction
+  PATTERN.CELL	     BOOL    TRUE	     # Cell pattern correction
   NOISEMAP           BOOL    TRUE            # Apply read noise map
 END
Index: /branches/eam_branches/20091201/ippconfig/recipes/ppImage.config
===================================================================
--- /branches/eam_branches/20091201/ippconfig/recipes/ppImage.config	(revision 26775)
+++ /branches/eam_branches/20091201/ippconfig/recipes/ppImage.config	(revision 26776)
@@ -18,6 +18,9 @@
 MASK.BURNTOOL      BOOL    FALSE           # Mask potential burntool trails
 VARIANCE.BUILD     BOOL    FALSE           # Build internal variance image
-PATTERN            BOOL    FALSE           # Fit and remove pattern noise?
-PATTERN.SUBSET	   METADATA
+PATTERN.ROW        BOOL    FALSE           # Row pattern correction
+PATTERN.ROW.SUBSET METADATA		   # Menu of chips and/or cells for row pattern correction
+END
+PATTERN.CELL       BOOL    FALSE           # Cell pattern correction
+PATTERN.CELL.SUBSET METADATA		   # Menu of chips and/or cells for cell pattern correction
 END
 FRINGE             BOOL    FALSE           # Fringe subtraction
@@ -90,10 +93,12 @@
 
 # Pattern subtraction options
-PATTERN.ORDER      S32     2               # Polynomial order
-PATTERN.ITER       S32     4               # Rejection iterations
-PATTERN.REJ        F32     2.5             # Rejection threshold
-PATTERN.THRESH     F32	   20.0		   # Ignore threshold
-PATTERN.MEAN       STR     SAMPLE_MEAN     # Statistic for mean
-PATTERN.STDEV      STR     SAMPLE_STDEV    # Statistic for standard deviation
+PATTERN.ROW.ORDER      S32     2               # Polynomial order for row pattern
+PATTERN.ROW.ITER       S32     4               # Rejection iterations for row pattern
+PATTERN.ROW.REJ        F32     2.5             # Rejection threshold for row pattern
+PATTERN.ROW.THRESH     F32     20.0            # Ignore threshold for row pattern
+PATTERN.ROW.MEAN       STR     SAMPLE_MEAN     # Statistic for mean for row pattern
+PATTERN.ROW.STDEV      STR     SAMPLE_STDEV    # Statistic for standard deviation for row pattern
+PATTERN.CELL.BG	       STR     ROBUST_MEDIAN   # Statistic for background for cell pattern
+PATTERN.CELL.MEAN      STR     SAMPLE_MEDIAN   # Statistic for mean for cell pattern
 
 # Fringe subtraction options
Index: /branches/eam_branches/20091201/ppImage/src/ppImage.h
===================================================================
--- /branches/eam_branches/20091201/ppImage/src/ppImage.h	(revision 26775)
+++ /branches/eam_branches/20091201/ppImage/src/ppImage.h	(revision 26776)
@@ -38,5 +38,6 @@
     bool doShutter;                     // Shutter correction
     bool doFlat;                        // Flat-field normalisation
-    bool doPattern;                     // Pattern noise subtraction
+    bool doPatternRow;                  // Row pattern correction
+    bool doPatternCell;                 // Cell pattern correction
     bool doFringe;                      // Fringe subtraction
     bool doPhotom;                      // Source identification and photometry
@@ -95,11 +96,13 @@
     float fringeKeep;                   // Fringe keep fraction
 
-    // Pattern noise subtraction
-    int patternOrder;                   // Polynomial order
-    int patternIter;                    // Clipping iterations
-    float patternRej;                   // Clipping threshold
-    float patternThresh;                // Ignore threshold
-    psStatsOptions patternMean;         // Statistic for mean
-    psStatsOptions patternStdev;        // Statistic for stdev
+    // Pattern correction
+    int patternRowOrder;                   // Polynomial order
+    int patternRowIter;                    // Clipping iterations
+    float patternRowRej;                   // Clipping threshold
+    float patternRowThresh;                // Ignore threshold
+    psStatsOptions patternRowMean;         // Statistic for mean
+    psStatsOptions patternRowStdev;        // Statistic for stdev
+    psStatsOptions patternCellBG;          // statistic for background
+    psStatsOptions patternCellMean;        // Statistic for mean
 
     int remnanceSize;                   // Size for remnance detection
Index: /branches/eam_branches/20091201/ppImage/src/ppImageDetrendPattern.c
===================================================================
--- /branches/eam_branches/20091201/ppImage/src/ppImageDetrendPattern.c	(revision 26775)
+++ /branches/eam_branches/20091201/ppImage/src/ppImageDetrendPattern.c	(revision 26776)
@@ -16,63 +16,93 @@
     pmCell *cell = NULL;
 
-    assert (options->doPattern); // do not call if not needed
-    assert (inputView->chip != -1);
-    assert (inputView->cell == -1);
-    assert (inputView->readout == -1);
-    bool status;
-    pmFPAfile *input = psMetadataLookupPtr(&status, config->files, "PPIMAGE.INPUT");
+    assert(options->doPatternRow || options->doPatternCell); // do not call if not needed
+    assert(inputView->chip != -1);
+    assert(inputView->cell == -1);
+    assert(inputView->readout == -1);
 
-    pmFPAview *view = pmFPAviewAlloc(0); // View for local processing
-    *view = *inputView;
+    if (options->doPatternRow) {
+        bool status;
+        pmFPAfile *input = psMetadataLookupPtr(&status, config->files, "PPIMAGE.INPUT");
+        pmFPAview *view = pmFPAviewAlloc(0); // View for local processing
+        *view = *inputView;
+        while ((cell = pmFPAviewNextCell(view, input->fpa, 1)) != NULL) {
+            if (!cell->process || !cell->file_exists) {
+                continue;
+            }
+            if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
+                ESCAPE("load failure for Cell");
+            }
 
-    while ((cell = pmFPAviewNextCell(view, input->fpa, 1)) != NULL) {
-        if (!cell->process || !cell->file_exists) {
-            continue;
-        }
-        if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
-            ESCAPE("load failure for Cell");
-        }
-
-        if (!cell->data_exists) {
-            continue;
-        }
-
-        if (cell->readouts->n > 1) {
-            psWarning ("Skipping Video Cell for ppImageDetrendPatternApply");
-            continue;
-        }
-
-        psMetadataItem *doPattern = pmConfigRecipeValueByView(config, RECIPE_NAME, "PATTERN.SUBSET",
-                                                              chip->parent, view); // Do we do pattern sub?
-        if (!doPattern || doPattern->type != PS_DATA_BOOL) {
-            ESCAPE("Unable to determine whether pattern matching should be applied.");
-        }
-        if (!doPattern->data.B) {
-            continue;
-        }
-
-        psLogMsg("ppImage", PS_LOG_INFO, "Performing pattern subtraction for %d,%d\n", view->chip, view->cell);
-
-        // process each of the readouts
-        pmReadout *readout;         // Readout from cell
-        while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
-            if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
-                ESCAPE("load failure for Readout");
-            }
-            if (!readout->data_exists) {
+            if (!cell->data_exists) {
                 continue;
             }
 
-            // perfore pattern correction
-            if (!pmPatternRow(readout, options->patternOrder, options->patternIter, options->patternRej,
-                              options->patternThresh, options->patternMean, options->patternStdev,
-                              options->maskValue, options->darkMask)) {
-                psFree(view);
-                return(false);
+            if (cell->readouts->n > 1) {
+                psWarning ("Skipping Video Cell for ppImageDetrendPatternApply");
+                continue;
+            }
+
+            psMetadataItem *doPattern = pmConfigRecipeValueByView(config, RECIPE_NAME, "PATTERN.ROW.SUBSET",
+                                                                  chip->parent, view); // Do pattern corr?
+            if (!doPattern || doPattern->type != PS_DATA_BOOL) {
+                ESCAPE("Unable to determine whether row pattern correction should be applied.");
+            }
+            if (!doPattern->data.B) {
+                continue;
+            }
+
+            psLogMsg("ppImage", PS_LOG_INFO, "Performing row pattern correction for %d,%d\n",
+                     view->chip, view->cell);
+
+            // process each of the readouts
+            pmReadout *readout;         // Readout from cell
+            while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
+                if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
+                    ESCAPE("load failure for Readout");
+                }
+                if (!readout->data_exists) {
+                    continue;
+                }
+
+                // Perform pattern correction
+                if (!pmPatternRow(readout, options->patternRowOrder, options->patternRowIter,
+                                  options->patternRowRej, options->patternRowThresh, options->patternRowMean,
+                                  options->patternRowStdev, options->maskValue, options->darkMask)) {
+                    psFree(view);
+                    return(false);
+                }
             }
         }
+        psFree(view);
     }
 
-    psFree(view);
+    if (options->doPatternCell) {
+        int numCells = chip->cells->n;       // Number of cells
+        psVector *tweak = psVectorAlloc(numCells, PS_TYPE_U8); // Tweak cell?
+        pmFPAview *view = pmFPAviewAlloc(0); // View for local processing
+        *view = *inputView;
+        for (int i = 0; i < chip->cells->n; i++) {
+            view->cell = i;
+            psMetadataItem *doPattern = pmConfigRecipeValueByView(config, RECIPE_NAME, "PATTERN.CELL.SUBSET",
+                                                                  chip->parent, view); // Do pattern sub?
+            if (!doPattern || doPattern->type != PS_DATA_BOOL) {
+                ESCAPE("Unable to determine whether cell pattern correction  should be applied.");
+            }
+            if (doPattern->data.B) {
+                tweak->data.U8[i] = 0xFF;
+            }
+        }
+
+        // Tweak the cells
+        if (!pmPatternCell(chip, tweak, options->patternCellBG, options->patternCellMean,
+                           options->maskValue, options->darkMask)) {
+            psFree(tweak);
+            psFree(view);
+            return false;
+        }
+        psFree(tweak);
+        psFree(view);
+    }
+
     return(true);
 }
Index: /branches/eam_branches/20091201/ppImage/src/ppImageLoop.c
===================================================================
--- /branches/eam_branches/20091201/ppImage/src/ppImageLoop.c	(revision 26775)
+++ /branches/eam_branches/20091201/ppImage/src/ppImageLoop.c	(revision 26776)
@@ -163,6 +163,6 @@
         }
 
-        // Apply the pattern noise correction
-        if (options->doPattern) {
+        // Apply the pattern correction
+        if (options->doPatternRow || options->doPatternCell) {
           if (!ppImageDetrendPatternApply(config,chip,view,options)) {
             ESCAPE("Unable to apply pattern corrections");
Index: /branches/eam_branches/20091201/ppImage/src/ppImageOptions.c
===================================================================
--- /branches/eam_branches/20091201/ppImage/src/ppImageOptions.c	(revision 26775)
+++ /branches/eam_branches/20091201/ppImage/src/ppImageOptions.c	(revision 26776)
@@ -32,5 +32,6 @@
     options->doShutter       = false;   // Shutter correction
     options->doFlat          = false;   // Flat-field normalisation
-    options->doPattern       = false;   // Pattern noise subtraction
+    options->doPatternRow    = false;   // Row pattern correction
+    options->doPatternCell   = false;   // Cell pattern correction
     options->doFringe        = false;   // Fringe subtraction
     options->doPhotom        = false;   // Source identification and photometry
@@ -90,12 +91,14 @@
     options->fringeKeep      = 1.0;     // Fringe keep fraction
 
-    // Pattern noise values
-
-    options->patternOrder    = 0;       // Polynomial order
-    options->patternIter     = 0;       // Clipping iterations
-    options->patternRej      = NAN;     // Clipping rejection threshold
-    options->patternThresh   = NAN;     // Threshold for ignoring pixels
-    options->patternMean     = PS_STAT_NONE; // Statistic for mean
-    options->patternStdev    = PS_STAT_NONE; // Statistic for standard deviation
+    // Pattern correction values
+
+    options->patternRowOrder    = 0;       // Polynomial order
+    options->patternRowIter     = 0;       // Clipping iterations
+    options->patternRowRej      = NAN;     // Clipping rejection threshold
+    options->patternRowThresh   = NAN;     // Threshold for ignoring pixels
+    options->patternRowMean     = PS_STAT_NONE; // Statistic for mean
+    options->patternRowStdev    = PS_STAT_NONE; // Statistic for standard deviation
+    options->patternCellBG      = PS_STAT_NONE; // Statistic for background
+    options->patternCellMean    = PS_STAT_NONE; // Statistic for mean
 
     // Remnance values
@@ -238,5 +241,6 @@
     options->doFringe = psMetadataLookupBool(NULL, recipe, "FRINGE");
     options->doShutter = psMetadataLookupBool(NULL, recipe, "SHUTTER");
-    options->doPattern = psMetadataLookupBool(NULL, recipe, "PATTERN");
+    options->doPatternRow = psMetadataLookupBool(NULL, recipe, "PATTERN.ROW");
+    options->doPatternCell = psMetadataLookupBool(NULL, recipe, "PATTERN.CELL");
 
     options->doStats = false;
@@ -250,14 +254,14 @@
     options->burntoolTrails = psMetadataLookupS32(&status, recipe, "BURNTOOL.TRAILS");
     psTrace("psModules.detrend", 7, "burntoolTrails: %d BURNTOOL.TRAILS: %d Status: %d\n",
-	    options->burntoolTrails,psMetadataLookupS32(&status,recipe,"BURNTOOL.TRAILS"),status);
+            options->burntoolTrails,psMetadataLookupS32(&status,recipe,"BURNTOOL.TRAILS"),status);
     if (!status) {
       psWarning("BURNTOOL.TRAILS not found in recipe: setting to default value.\n");
     }
-    
+
     // binned image options
     options->xBin1 = psMetadataLookupS32(&status, recipe, "BIN1.XBIN");
     if (!status) {
         psWarning("BIN1.XBIN not found in recipe: setting to default value.\n");
-	options->xBin1 = 4;
+        options->xBin1 = 4;
     }
     options->yBin1 = psMetadataLookupS32(&status, recipe, "BIN1.YBIN");
@@ -320,11 +324,13 @@
     options->fringeKeep = psMetadataLookupF32(NULL, recipe, "FRINGE.KEEP");
 
-    // Pattern noise
-    options->patternOrder = psMetadataLookupS32(NULL, recipe, "PATTERN.ORDER");
-    options->patternIter = psMetadataLookupS32(NULL, recipe, "PATTERN.ITER");
-    options->patternRej = psMetadataLookupF32(NULL, recipe, "PATTERN.REJ");
-    options->patternThresh = psMetadataLookupF32(NULL, recipe, "PATTERN.THRESH");
-    options->patternMean = psStatsOptionFromString(psMetadataLookupStr(NULL, recipe, "PATTERN.MEAN"));
-    options->patternStdev = psStatsOptionFromString(psMetadataLookupStr(NULL, recipe, "PATTERN.STDEV"));
+    // Pattern correction
+    options->patternRowOrder = psMetadataLookupS32(NULL, recipe, "PATTERN.ROW.ORDER");
+    options->patternRowIter = psMetadataLookupS32(NULL, recipe, "PATTERN.ROW.ITER");
+    options->patternRowRej = psMetadataLookupF32(NULL, recipe, "PATTERN.ROW.REJ");
+    options->patternRowThresh = psMetadataLookupF32(NULL, recipe, "PATTERN.ROW.THRESH");
+    options->patternRowMean = psStatsOptionFromString(psMetadataLookupStr(NULL, recipe, "PATTERN.ROW.MEAN"));
+    options->patternRowStdev = psStatsOptionFromString(psMetadataLookupStr(NULL, recipe, "PATTERN.ROW.STDEV"));
+    options->patternCellBG = psStatsOptionFromString(psMetadataLookupStr(NULL, recipe, "PATTERN.CELL.BG"));
+    options->patternCellMean = psStatsOptionFromString(psMetadataLookupStr(NULL, recipe, "PATTERN.CELL.MEAN"));
 
     // Remnance options
Index: /branches/eam_branches/20091201/psModules/src/detrend/pmPattern.c
===================================================================
--- /branches/eam_branches/20091201/psModules/src/detrend/pmPattern.c	(revision 26775)
+++ /branches/eam_branches/20091201/psModules/src/detrend/pmPattern.c	(revision 26776)
@@ -127,2 +127,142 @@
     return true;
 }
+
+
+
+
+bool pmPatternCell(pmChip *chip, const psVector *tweak, psStatsOptions bgStat, psStatsOptions cellStat,
+                   psImageMaskType maskVal, psImageMaskType maskBad)
+{
+    PS_ASSERT_PTR_NON_NULL(chip, false);
+    PS_ASSERT_VECTOR_NON_NULL(tweak, false);
+    PS_ASSERT_VECTOR_SIZE(tweak, chip->cells->n, false);
+    PS_ASSERT_VECTOR_TYPE(tweak, PS_TYPE_U8, false);
+
+    int numCells = tweak->n;            // Number of cells
+
+    psVector *mean = psVectorAlloc(numCells, PS_TYPE_F32); // Mean for each cell
+    psVector *meanMask = psVectorAlloc(numCells, PS_TYPE_VECTOR_MASK); // Mask for means
+    psVectorInit(mean, NAN);
+    psVectorInit(meanMask, 0);
+
+    // Mask bits
+    enum {
+        PM_PATTERN_IGNORE = 0x01,       // Ignore this cell
+        PM_PATTERN_TWEAK  = 0x02,       // Tweak this cell
+        PM_PATTERN_ERROR  = 0x04,       // Error in calculating background
+        PM_PATTERN_ALL    = 0xFF,       // All causes
+    };
+
+    // Count number of cells to tweak
+    int numTweak = 0;                   // Number of cells to tweak
+    int numIgnore = 0;                  // Number of cells to ignore
+    for (int i = 0; i < numCells; i++) {
+        pmCell *cell = chip->cells->data[i]; // Cell of interest
+        if (!cell || !cell->data_exists || !cell->process ||
+            cell->readouts->n == 0 || cell->readouts->n > 1 || !cell->readouts->data[0]) {
+            numIgnore++;
+            meanMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PM_PATTERN_IGNORE;
+            continue;
+        }
+        if (tweak->data.U8[i]) {
+            meanMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PM_PATTERN_TWEAK;
+            numTweak++;
+        }
+    }
+    if (numTweak == 0) {
+        // Nothing to do
+        psFree(mean);
+        psFree(meanMask);
+        return true;
+    }
+    if (numTweak >= numCells - numIgnore) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Cannot pattern-correct all cells within a chip.");
+        psFree(mean);
+        psFree(meanMask);
+        return false;
+    }
+
+    // Measure mean of each cell
+    // This is not really the perfect thing to do, which would be to take a common mean for the set of cells
+    // which aren't being tweaked (because some cells will be heavily masked, so shouldn't be weighted the
+    // same as pure cells), but it's simple and fast.
+    psStats *bgStats = psStatsAlloc(bgStat); // Statistics on background
+    psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator
+    for (int i = 0; i < numCells; i++) {
+        if (meanMask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PM_PATTERN_IGNORE) {
+            continue;
+        }
+        pmCell *cell = chip->cells->data[i]; // Cell of interest
+        pmReadout *ro = cell->readouts->data[0]; // Readout of interest
+
+        psStatsInit(bgStats);
+#if 1
+        if (!psImageBackground(bgStats, NULL, ro->image, ro->mask, maskVal, rng)) {
+            psWarning("Unable to measure background for cell %d\n", i);
+            psErrorClear();
+            meanMask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= PM_PATTERN_ERROR;
+            continue;
+        }
+#else
+        if (!psImageStats(bgStats, ro->image, ro->mask, maskVal)) {
+            psWarning("Unable to measure background for cell %d\n", i);
+            psErrorClear();
+            meanMask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= PM_PATTERN_ERROR;
+            continue;
+        }
+#endif
+        mean->data.F32[i] = psStatsGetValue(bgStats, bgStat);
+        if (!isfinite(mean->data.F32[i])) {
+            psWarning("Non-finite background for cell %d\n", i);
+            psErrorClear();
+            meanMask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= PM_PATTERN_ERROR;
+            continue;
+        }
+    }
+    psFree(bgStats);
+    psFree(rng);
+
+    psStats *cellStats = psStatsAlloc(cellStat); // Statistics on cells
+    if (!psVectorStats(cellStats, mean, NULL, meanMask, PM_PATTERN_ALL)) {
+        psError(PS_ERR_UNKNOWN, false, "Unable to calculate mean cell background.");
+        psFree(mean);
+        psFree(meanMask);
+        psFree(cellStats);
+        return false;
+    }
+
+    float background = psStatsGetValue(cellStats, cellStat); // Background value for chip
+    psFree(cellStats);
+    if (!isfinite(background)) {
+        psError(PS_ERR_UNKNOWN, false, "Non-finite mean cell background.");
+        psFree(mean);
+        psFree(meanMask);
+        return false;
+    }
+
+    psLogMsg("psModules.detrend", PS_LOG_DETAIL, "Mean chip background is %f", background);
+
+    for (int i = 0; i < numCells; i++) {
+        if (meanMask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PM_PATTERN_IGNORE) {
+            continue;
+        }
+        if (!(meanMask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PM_PATTERN_TWEAK)) {
+            continue;
+        }
+        pmCell *cell = chip->cells->data[i]; // Cell of interest
+        pmReadout *ro = cell->readouts->data[0]; // Readout of interest
+        if (meanMask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PM_PATTERN_ERROR) {
+            psImageInit(ro->image, NAN);
+            psBinaryOp(ro->mask, ro->mask, "|", psScalarAlloc(maskBad, PS_TYPE_IMAGE_MASK));
+            continue;
+        }
+        float correction = background - mean->data.F32[i]; // Correction to apply
+        psLogMsg("psModules.detrend", PS_LOG_DETAIL, "Correcting background of cell %d by %f", i, correction);
+        psBinaryOp(ro->image, ro->image, "+", psScalarAlloc(correction, PS_TYPE_F32));
+    }
+
+    psFree(mean);
+    psFree(meanMask);
+
+    return true;
+}
Index: /branches/eam_branches/20091201/psModules/src/detrend/pmPattern.h
===================================================================
--- /branches/eam_branches/20091201/psModules/src/detrend/pmPattern.h	(revision 26775)
+++ /branches/eam_branches/20091201/psModules/src/detrend/pmPattern.h	(revision 26776)
@@ -31,4 +31,15 @@
     );
 
+/// Fix the background on cells known to be troublesome
+bool pmPatternCell(
+    pmChip *chip,                       ///< Chip to correct
+    const psVector *tweak,              ///< U8 vector indicating whether to tweak the corresponding cell
+    psStatsOptions bgStat,              ///< Statistic to use for background measurement
+    psStatsOptions cellStat,            ///< Statistic to use for combination of cell background measurements
+    psImageMaskType maskVal,            ///< Mask value to use
+    psImageMaskType maskBad             ///< Mask value to give bad pixels
+    );
+
+
 /// @}
 #endif
