diff --git a/cal_tools/cal_tools/agipdlib.py b/cal_tools/cal_tools/agipdlib.py
index 5650700d968c53f7094d4986a74face5dc089a68..3438769e6508db7ede72eb0188974431fffdca83 100644
--- a/cal_tools/cal_tools/agipdlib.py
+++ b/cal_tools/cal_tools/agipdlib.py
@@ -54,7 +54,8 @@ class AgipdCorrections:
                  h5_data_path="INSTRUMENT/SPB_DET_AGIPD1M-1/DET/{}CH0:xtdf/",
                  h5_index_path="INDEX/SPB_DET_AGIPD1M-1/DET/{}CH0:xtdf/",
                  do_rel_gain=True, chunk_size_idim=512, il_mode=False,
-                 cal_det_instance="AGIPD1M1", karabo_data_mode=False):
+                 cal_det_instance="AGIPD1M1", karabo_data_mode=False,
+                 force_hg_if_below=None):
         """
         Initialize an AgipdCorrections Class
 
@@ -80,6 +81,9 @@ class AgipdCorrections:
             writing data out
         :param il_mode: set to true if AGIPD data is interlaced (pre-Nov 2017 data)
         :param karabo_data_mode: set to true to use data iterated with karabo data
+        :param force_hg_if_below: set to a value different to None/0 to force a pixels
+                                  gain to high, if the pixel value is below the given
+                                  value after high gain offset subtraction.
         """
         self.agipd_base = h5_data_path.format(channel)
         self.idx_base = h5_index_path.format(channel)
@@ -115,6 +119,7 @@ class AgipdCorrections:
         self.il_mode = il_mode
         self.cal_det_instance = cal_det_instance
         self.karabo_data_mode = karabo_data_mode
+        self.force_hg_if_below = force_hg_if_below
 
     def get_iteration_range(self):
         """Returns a range expression over which to iterate in chunks
@@ -794,6 +799,10 @@ class AgipdCorrections:
         gain[ga > t0[cellid, ...]] = 1
         # exceeding also second threshold means data is low gain
         gain[ga > t1[cellid, ...]] = 2
+        
+        # force into high gain if requested
+        if self.force_hg_if_below is not None and self.force_hg_if_below > 0:
+            gain[(im - self.offset[cellid, ...,0]) < self.force_hg_if_below] = 0
 
         # check if any data has zero standard deviation, and mark this in
         # the bad pixel maks
diff --git a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb
index f53ea15e8fa88273bd4de502c14149f165deddbc..d0b696711733400fe8527095e00a2e6348d5d72a 100644
--- a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb
+++ b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb
@@ -13,22 +13,22 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 9,
+   "execution_count": 1,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2019-01-11T09:27:55.381275Z",
-     "start_time": "2019-01-11T09:27:55.317063Z"
+     "end_time": "2019-02-12T14:30:10.801940Z",
+     "start_time": "2019-02-12T14:30:10.732217Z"
     },
     "collapsed": false
    },
    "outputs": [],
    "source": [
     "in_folder = \"/gpfs/exfel/exp/SPB/201801/p002108/raw/\" # the folder to read data from, required\n",
-    "run = 410 # runs to process, required\n",
-    "out_folder =  \"/gpfs/exfel/data/scratch/haufs/test/\"  # the folder to output to, required\n",
+    "run = 334 # runs to process, required\n",
+    "out_folder =  \"/gpfs/exfel/exp/SPB/201801/p002108/proc/reproc/no_rel_gain_blc_fix_indices_forced_gain/\"  # the folder to output to, required\n",
     "calfile =  \"/gpfs/exfel/data/scratch/haufs/agipd_on_demand/agipd_store.h5\" # path to calibration file. Leave empty if all data should come from DB\n",
     "sequences =  [-1] # sequences to correct, set to -1 for all, range allowed\n",
-    "mem_cells = 176 # memory cells in data\n",
+    "mem_cells = 128 # memory cells in data\n",
     "interlaced = False # whether data is in interlaced layout\n",
     "overwrite = True # set to True if existing data should be overwritten\n",
     "no_relative_gain = True # do not do relative gain correction\n",
@@ -54,6 +54,7 @@
     "chunk_size_idim = 32  # chunking size of imaging dimension, adjust if user software is sensitive to this.\n",
     "creation_date_offset = \"00:00:00\" # add an offset to creation date, e.g. to get different constants\n",
     "instrument = \"SPB\"  # the instrument the detector is installed at, required\n",
+    "force_hg_if_below = 0 # set to a value other than 0 to force a pixel into high gain if it's high gain offset subtracted value is below this threshold\n",
     "\n",
     "def balance_sequences(in_folder, run, sequences, sequences_per_node):\n",
     "    import glob\n",
@@ -79,23 +80,31 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 10,
+   "execution_count": 2,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2019-01-11T09:27:55.899528Z",
-     "start_time": "2019-01-11T09:27:55.748845Z"
+     "end_time": "2019-02-12T14:30:12.069998Z",
+     "start_time": "2019-02-12T14:30:10.804460Z"
     },
     "collapsed": false
    },
    "outputs": [
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "/home/haufs/calkarabo/karabo/extern/lib/python3.4/importlib/_bootstrap.py:321: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\n",
+      "  return f(*args, **kwds)\n"
+     ]
+    },
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
       "Connecting to profile noDB\n",
-      "Using 2018-10-23 06:05:21.207336 as creation time\n",
-      "Working in IL Mode: False. Actual cells in use are: 176\n",
-      "Outputting to /gpfs/exfel/data/scratch/haufs/test//r0410\n",
+      "Using 2018-10-22 23:12:12.894488 as creation time\n",
+      "Working in IL Mode: False. Actual cells in use are: 128\n",
+      "Outputting to /gpfs/exfel/exp/SPB/201801/p002108/proc/reproc/no_rel_gain_blc_fix_indices_forced_gain//r0334\n",
       "Detector in use is SPB_DET_AGIPD1M-1\n"
      ]
     }
@@ -186,11 +195,11 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 11,
+   "execution_count": 3,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2019-01-11T09:27:56.435155Z",
-     "start_time": "2019-01-11T09:27:56.388218Z"
+     "end_time": "2019-02-12T14:30:12.092645Z",
+     "start_time": "2019-02-12T14:30:12.071720Z"
     },
     "collapsed": true
    },
@@ -246,11 +255,11 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 12,
+   "execution_count": 4,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2019-01-11T09:27:56.889297Z",
-     "start_time": "2019-01-11T09:27:56.830345Z"
+     "end_time": "2019-02-12T14:30:12.132514Z",
+     "start_time": "2019-02-12T14:30:12.094044Z"
     },
     "collapsed": false
    },
@@ -309,11 +318,10 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 13,
+   "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2019-01-11T09:27:57.944770Z",
-     "start_time": "2019-01-11T09:27:57.901437Z"
+     "start_time": "2019-02-12T13:30:10.738Z"
     },
     "collapsed": false
    },
@@ -322,7 +330,7 @@
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "Processing a total of 32 sequence files in chunks of 32\n"
+      "Processing a total of 48 sequence files in chunks of 32\n"
      ]
     },
     {
@@ -330,40 +338,56 @@
       "text/latex": [
        "\\begin{tabular}{rlrl}\n",
        "\\hline\n",
-       "   \\# & module   &   \\# module & file                                                                     \\\\\n",
+       "   \\# & module   &   \\# module & file                                                                      \\\\\n",
        "\\hline\n",
-       "   0 & Q1M1     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD00-S00000.h5 \\\\\n",
-       "   1 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD00-S00001.h5 \\\\\n",
-       "   2 & Q1M2     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD01-S00000.h5 \\\\\n",
-       "   3 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD01-S00001.h5 \\\\\n",
-       "   4 & Q1M3     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD02-S00000.h5 \\\\\n",
-       "   5 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD02-S00001.h5 \\\\\n",
-       "   6 & Q1M4     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD03-S00000.h5 \\\\\n",
-       "   7 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD03-S00001.h5 \\\\\n",
-       "   8 & Q2M1     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD04-S00000.h5 \\\\\n",
-       "   9 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD04-S00001.h5 \\\\\n",
-       "  10 & Q2M2     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD05-S00000.h5 \\\\\n",
-       "  11 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD05-S00001.h5 \\\\\n",
-       "  12 & Q2M3     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD06-S00000.h5 \\\\\n",
-       "  13 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD06-S00001.h5 \\\\\n",
-       "  14 & Q2M4     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD07-S00000.h5 \\\\\n",
-       "  15 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD07-S00001.h5 \\\\\n",
-       "  16 & Q3M1     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD08-S00000.h5 \\\\\n",
-       "  17 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD08-S00001.h5 \\\\\n",
-       "  18 & Q3M2     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD09-S00000.h5 \\\\\n",
-       "  19 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD09-S00001.h5 \\\\\n",
-       "  20 & Q3M3     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD10-S00000.h5 \\\\\n",
-       "  21 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD10-S00001.h5 \\\\\n",
-       "  22 & Q3M4     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD11-S00000.h5 \\\\\n",
-       "  23 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD11-S00001.h5 \\\\\n",
-       "  24 & Q4M1     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD12-S00000.h5 \\\\\n",
-       "  25 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD12-S00001.h5 \\\\\n",
-       "  26 & Q4M2     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD13-S00000.h5 \\\\\n",
-       "  27 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD13-S00001.h5 \\\\\n",
-       "  28 & Q4M3     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD14-S00000.h5 \\\\\n",
-       "  29 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD14-S00001.h5 \\\\\n",
-       "  30 & Q4M4     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD15-S00000.h5 \\\\\n",
-       "  31 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw/r0410/RAW-R0410-AGIPD15-S00001.h5 \\\\\n",
+       "   0 & Q1M1     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD00-S00000.h5 \\\\\n",
+       "   1 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD00-S00001.h5 \\\\\n",
+       "   2 &          &          2 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD00-S00002.h5 \\\\\n",
+       "   3 & Q1M2     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD01-S00000.h5 \\\\\n",
+       "   4 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD01-S00001.h5 \\\\\n",
+       "   5 &          &          2 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD01-S00002.h5 \\\\\n",
+       "   6 & Q1M3     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD02-S00000.h5 \\\\\n",
+       "   7 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD02-S00001.h5 \\\\\n",
+       "   8 &          &          2 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD02-S00002.h5 \\\\\n",
+       "   9 & Q1M4     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD03-S00000.h5 \\\\\n",
+       "  10 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD03-S00001.h5 \\\\\n",
+       "  11 &          &          2 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD03-S00002.h5 \\\\\n",
+       "  12 & Q2M1     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD04-S00000.h5 \\\\\n",
+       "  13 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD04-S00001.h5 \\\\\n",
+       "  14 &          &          2 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD04-S00002.h5 \\\\\n",
+       "  15 & Q2M2     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD05-S00000.h5 \\\\\n",
+       "  16 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD05-S00001.h5 \\\\\n",
+       "  17 &          &          2 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD05-S00002.h5 \\\\\n",
+       "  18 & Q2M3     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD06-S00000.h5 \\\\\n",
+       "  19 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD06-S00001.h5 \\\\\n",
+       "  20 &          &          2 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD06-S00002.h5 \\\\\n",
+       "  21 & Q2M4     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD07-S00000.h5 \\\\\n",
+       "  22 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD07-S00001.h5 \\\\\n",
+       "  23 &          &          2 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD07-S00002.h5 \\\\\n",
+       "  24 & Q3M1     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD08-S00000.h5 \\\\\n",
+       "  25 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD08-S00001.h5 \\\\\n",
+       "  26 &          &          2 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD08-S00002.h5 \\\\\n",
+       "  27 & Q3M2     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD09-S00000.h5 \\\\\n",
+       "  28 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD09-S00001.h5 \\\\\n",
+       "  29 &          &          2 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD09-S00002.h5 \\\\\n",
+       "  30 & Q3M3     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD10-S00000.h5 \\\\\n",
+       "  31 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD10-S00001.h5 \\\\\n",
+       "  32 &          &          2 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD10-S00002.h5 \\\\\n",
+       "  33 & Q3M4     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD11-S00000.h5 \\\\\n",
+       "  34 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD11-S00001.h5 \\\\\n",
+       "  35 &          &          2 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD11-S00002.h5 \\\\\n",
+       "  36 & Q4M1     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD12-S00000.h5 \\\\\n",
+       "  37 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD12-S00001.h5 \\\\\n",
+       "  38 &          &          2 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD12-S00002.h5 \\\\\n",
+       "  39 & Q4M2     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD13-S00000.h5 \\\\\n",
+       "  40 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD13-S00001.h5 \\\\\n",
+       "  41 &          &          2 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD13-S00002.h5 \\\\\n",
+       "  42 & Q4M3     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD14-S00000.h5 \\\\\n",
+       "  43 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD14-S00001.h5 \\\\\n",
+       "  44 &          &          2 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD14-S00002.h5 \\\\\n",
+       "  45 & Q4M4     &          0 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD15-S00000.h5 \\\\\n",
+       "  46 &          &          1 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD15-S00001.h5 \\\\\n",
+       "  47 &          &          2 & /gpfs/exfel/exp/SPB/201801/p002108/raw//r0334/RAW-R0334-AGIPD15-S00002.h5 \\\\\n",
        "\\hline\n",
        "\\end{tabular}"
       ],
@@ -403,7 +427,7 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "start_time": "2019-01-11T08:28:49.990Z"
+     "start_time": "2019-02-12T13:30:10.746Z"
     },
     "collapsed": false
    },
@@ -414,27 +438,18 @@
      "text": [
       "Running 32 tasks parallel\n",
       "INDEX/SPB_DET_AGIPD1M-1/DET/0CH0:xtdf/\n",
-      "Offset was injected on: 2018-10-21 20:55:02+02:00\n",
-      "Noise was injected on: 2018-10-21 20:55:02+02:00\n",
-      "BadPixelsDark was injected on: 2018-10-21 20:55:02+02:00\n",
-      "ThresholdsDark was injected on: 2018-10-21 20:55:02+02:00\n",
-      "(27776,) 27775\n",
-      "Offet medians are [4957. 7500. 7724.]\n",
-      "Threshold medians are [6268.75 7083.5 ]\n",
+      "Offset was injected on: 2018-10-22 22:24:16+02:00\n",
+      "Noise was injected on: 2018-10-22 22:24:16+02:00\n",
+      "BadPixelsDark was injected on: 2018-10-22 22:24:16+02:00\n",
+      "ThresholdsDark was injected on: 2018-10-22 22:24:16+02:00\n",
+      "(28544,) 28543\n",
+      "Offet medians are [5094. 7641. 7866.]\n",
+      "Threshold medians are [6414.5  7233.75]\n",
       "After reading from file: \n",
-      "Offet medians are [4957.         7397.23876953 7724.        ]\n",
-      "Gain medians are [  0.9968053  33.925804  152.13365  ]\n",
-      "Threshold medians are [6268.75 7083.5 ]\n",
-      "Initialized constants\n",
-      "Iterated\n",
-      "Iterated\n",
-      "Iterated\n",
-      "Iterated\n",
-      "Iterated\n",
-      "Iterated\n",
-      "Iterated\n",
-      "Iterated\n",
-      "Iterated\n"
+      "Offet medians are [5094.         7529.09924316 7866.        ]\n",
+      "Gain medians are [  0.9956078  33.962654  152.29889  ]\n",
+      "Threshold medians are [6414.5  7233.75]\n",
+      "Initialized constants\n"
      ]
     }
    ],
@@ -444,7 +459,7 @@
     "def correct_module(max_cells, do_rel_gain, index_v, CHUNK_SIZE, total_sequences, sequences_qm, \n",
     "                   bins_gain_vs_signal, bins_signal_low_range, bins_signal_high_range,\n",
     "                   bins_dig_gain_vs_signal, max_pulses, dbparms, fileparms, nodb, chunk_size_idim,\n",
-    "                   special_opts, il_mode, loc, dinstance, inp):\n",
+    "                   special_opts, il_mode, loc, dinstance, force_hg_if_below, inp):\n",
     "    import numpy as np\n",
     "    import copy\n",
     "    import h5py\n",
@@ -510,7 +525,7 @@
     "                                      il_mode=il_mode, raw_fmt_version=index_v, \n",
     "                                      h5_data_path=\"INSTRUMENT/{}/DET/{{}}CH0:xtdf/\".format(loc),\n",
     "                                      h5_index_path=\"INDEX/{}/DET/{{}}CH0:xtdf/\".format(loc),\n",
-    "                                      cal_det_instance=dinstance)\n",
+    "                                      cal_det_instance=dinstance, force_hg_if_below=force_hg_if_below)\n",
     "        \n",
     "        blc_noise, blc_noise_threshold, blc_hist, match_asics, corr_asic_diag, melt_snow = special_opts\n",
     "        agipd_corr.baseline_corr_using_noise = blc_noise\n",
@@ -599,7 +614,7 @@
     "        p = partial(correct_module, max_cells, do_rel_gain, index_v, CHUNK_SIZE, total_sequences,\n",
     "                    sequences_qm, bins_gain_vs_signal, bins_signal_low_range, bins_signal_high_range,\n",
     "                    bins_dig_gain_vs_signal, max_pulses, dbparms, fileparms, nodb, chunk_size_idim,\n",
-    "                    special_opts, il_mode, loc, dinstance)\n",
+    "                    special_opts, il_mode, loc, dinstance, force_hg_if_below)\n",
     "         \n",
     "        r = view.map_sync(p, inp)\n",
     "        \n",