diff --git a/notebooks/AGIPD/Characterize_AGIPD_Gain_FlatFields_Summary.ipynb b/notebooks/AGIPD/Characterize_AGIPD_Gain_FlatFields_Summary.ipynb
index e5705d14886ebc5234f282b9a887bead70205329..31bbb92df0ac33675e97b2b98e667ab09228a78c 100644
--- a/notebooks/AGIPD/Characterize_AGIPD_Gain_FlatFields_Summary.ipynb
+++ b/notebooks/AGIPD/Characterize_AGIPD_Gain_FlatFields_Summary.ipynb
@@ -19,17 +19,17 @@
     "metadata_folder = \"\"  # Directory containing calibration_metadata.yml when run by xfel-calibrate\n",
     "hist_file_template = \"hists_m{:02d}_sum.h5\"\n",
     "proc_folder = \"\" # Path to corrected image data used to create histograms and validation plots\n",
-    "raw_folder = \"/gpfs/exfel/exp/MID/202030/p900137/raw\"  # folder of raw data. This is used to save information of source data of generated constants, required\n",
-    "run = 449 # runs of image data used to create histograms\n",
+    "raw_folder = \"\"  # folder of raw data. This is used to save information of source data of generated constants, required\n",
+    "run = 38 # runs of image data used to create histograms\n",
     "\n",
-    "karabo_id = \"MID_DET_AGIPD1M-1\" # karabo karabo_id\n",
+    "karabo_id = \"SPB_DET_AGIPD1M-1\" # karabo karabo_id\n",
     "ctrl_source_template = '{}/MDL/FPGA_COMP' # path to control information\n",
-    "karabo_id_control = \"MID_EXP_AGIPD1M1\" # karabo-id for control device\n",
+    "karabo_id_control = \"SPB_IRU_AGIPD1M1\" # karabo-id for control device\n",
     "\n",
     "use_dir_creation_date = True # use the creation data of the input dir for database queries\n",
     "cal_db_interface = \"tcp://max-exfl-cal001:8015#8045\" # the database interface to use\n",
     "cal_db_timeout = 30000 # in milli seconds\n",
-    "local_output = True # output constants locally\n",
+    "local_output = False # output constants locally\n",
     "db_output = False # output constants to database\n",
     "\n",
     "# Fit parameters\n",
@@ -39,7 +39,7 @@
     "d0_lim = [10, 70] # hard limits for d0 value (distance between noise and first peak)\n",
     "gain_lim = [0.80, 1.2] # Threshold on gain in relative number. Contribute to BadPixel bit \"Gain_deviation\"\n",
     "\n",
-    "cell_range = [1,5] # range of cell to be considered, [0,0] for all\n",
+    "cell_range = [0,352] # range of cell to be considered, [0,0] for all\n",
     "pixel_range = [0,0,512,128] # range of pixels x1,y1,x2,y2 to consider [0,0,512,128] for all\n",
     "n_peaks_fit = 4 # Number of gaussian peaks to fit including noise peak\n",
     "\n",
@@ -586,6 +586,19 @@
     "orig = orig[cell_range[0]:cell_range[1], ...]"
    ]
   },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "# Get cell Ids from 1st train\n",
+    "run_data = RunDirectory(run_folder, include)\n",
+    "sel = run_data.select(f'{karabo_id}/DET/0CH0:xtdf', 'image.cellId')\n",
+    "tid0, cell = sel.train_from_index(0)\n",
+    "stacked_cells = stack_detector_data(cell, 'image.cellId')[0, :, 0]"
+   ]
+  },
   {
    "cell_type": "code",
    "execution_count": null,
@@ -594,10 +607,14 @@
    "source": [
     "# FIXME: mask bad pixels from median\n",
     "# mask = const_data['BadPixelsFF']\n",
-    "\n",
     "corrections = const_data['slopesFF'] # (16,shape[0],512,128) shape[0]= cell_range[1]-cell_range[0] /\n",
     "corrections = np.moveaxis(corrections, 1, 0) # (shape[0],16,512,128)\n",
     "rel_corr = corrections/np.nanmedian(corrections)\n",
+    "# this is needed if LitFrame is enabled in DAQ to avoid shape mismatch \n",
+    "# and correction of the right cells\n",
+    "if np.diff(cell_range)[0] == mem_cells:\n",
+    "    rel_corr = rel_corr[stacked_cells[0]:stacked_cells[-1]+1]\n",
+    "\n",
     "corrected = orig / rel_corr"
    ]
   },
@@ -817,6 +834,23 @@
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
    "version": "3.8.11"
+  },
+  "latex_envs": {
+   "LaTeX_envs_menu_present": true,
+   "autocomplete": true,
+   "bibliofile": "biblio.bib",
+   "cite_by": "apalike",
+   "current_citInitial": 1,
+   "eqLabelWithNumbers": true,
+   "eqNumInitial": 1,
+   "hotkeys": {
+    "equation": "Ctrl-E",
+    "itemize": "Ctrl-I"
+   },
+   "labels_anchors": false,
+   "latex_user_defs": false,
+   "report_style_numbering": false,
+   "user_envs_cfg": false
   }
  },
  "nbformat": 4,