diff --git a/src/toolbox_scs/routines/boz.py b/src/toolbox_scs/routines/boz.py index a7707e9692358d555d41d4de5f42270782f4b582..c15821c15228f8039e41a2468e7223852d722ee4 100644 --- a/src/toolbox_scs/routines/boz.py +++ b/src/toolbox_scs/routines/boz.py @@ -630,13 +630,14 @@ def inspect_histogram(arr, arr_dark=None, mask=None, extra_lines=False): # rois related function -def find_rois(data_mean, threshold): +def find_rois(data_mean, threshold, extended=False): """Find rois from 3 beams configuration. Inputs ------ data_mean: dark corrected average image threshold: threshold value to find beams + extended: boolean, True to define additional ASICS based rois Returns ------- @@ -655,17 +656,11 @@ def find_rois(data_mean, threshold): rightX = int(np.argmin(pX[128:192]) + 128) # along Y - lowY = int(np.argmax(pY[:64] > threshold)) # 1st occurrence returned - highY = int(np.argmax(pY[64:] < threshold) + 64) # 1st occ. returned + lowY = int(np.argmax(pY > threshold)) # 1st occurrence returned + highY = int(pY.shape[0] - np.argmax(pY[::-1] > threshold) - 1) # 1st occ. returned # define rois rois = {} - # baseline correction rois - for k in [0, 1, 2, 3]: - rois[f'b{k}'] = {'xl': k*64, 'xh': (k+1)*64, 'yl': 0, 'yh': lowY} - for k in [8, 9, 10, 11]: - rois[f'b{k}'] = {'xl': (k-8)*64, 'xh': (k+1-8)*64, - 'yl': highY, 'yh': 128} # beam roi rois['n'] = {'xl': lowX, 'xh': leftX, 'yl': lowY, 'yh': highY} @@ -675,24 +670,32 @@ def find_rois(data_mean, threshold): # saturation roi rois['sat'] = {'xl': lowX, 'xh': highX, 'yl': lowY, 'yh': highY} - # ASICs splitted beam roi - rois['0X'] = {'xl': lowX, 'xh': 1*64, 'yl': lowY, 'yh': 64} - rois['1X1'] = {'xl': 64, 'xh': leftX, 'yl': lowY, 'yh': 64} + if extended: + # baseline correction rois + for k in [0, 1, 2, 3]: + rois[f'b{k}'] = {'xl': k*64, 'xh': (k+1)*64, 'yl': 0, 'yh': lowY} + for k in [8, 9, 10, 11]: + rois[f'b{k}'] = {'xl': (k-8)*64, 'xh': (k+1-8)*64, + 'yl': highY, 'yh': 128} - rois['1X2'] = {'xl': leftX, 'xh': 2*64, 'yl': lowY, 'yh': 64} - rois['2X1'] = {'xl': 2*64, 'xh': rightX, 'yl': lowY, 'yh': 64} + # ASICs splitted beam roi + rois['0X'] = {'xl': lowX, 'xh': 1*64, 'yl': lowY, 'yh': 64} + rois['1X1'] = {'xl': 64, 'xh': leftX, 'yl': lowY, 'yh': 64} - rois['2X2'] = {'xl': rightX, 'xh': 3*64, 'yl': lowY, 'yh': 64} - rois['3X'] = {'xl': 3*64, 'xh': highX, 'yl': lowY, 'yh': 64} + rois['1X2'] = {'xl': leftX, 'xh': 2*64, 'yl': lowY, 'yh': 64} + rois['2X1'] = {'xl': 2*64, 'xh': rightX, 'yl': lowY, 'yh': 64} - rois['8X'] = {'xl': lowX, 'xh': 1*64, 'yl': 64, 'yh': highY} - rois['9X1'] = {'xl': 64, 'xh': leftX, 'yl': 64, 'yh': highY} + rois['2X2'] = {'xl': rightX, 'xh': 3*64, 'yl': lowY, 'yh': 64} + rois['3X'] = {'xl': 3*64, 'xh': highX, 'yl': lowY, 'yh': 64} - rois['9X2'] = {'xl': leftX, 'xh': 2*64, 'yl': 64, 'yh': highY} - rois['10X1'] = {'xl': 2*64, 'xh': rightX, 'yl': 64, 'yh': highY} + rois['8X'] = {'xl': lowX, 'xh': 1*64, 'yl': 64, 'yh': highY} + rois['9X1'] = {'xl': 64, 'xh': leftX, 'yl': 64, 'yh': highY} - rois['10X2'] = {'xl': rightX, 'xh': 3*64, 'yl': 64, 'yh': highY} - rois['11X'] = {'xl': 3*64, 'xh': highX, 'yl': 64, 'yh': highY} + rois['9X2'] = {'xl': leftX, 'xh': 2*64, 'yl': 64, 'yh': highY} + rois['10X1'] = {'xl': 2*64, 'xh': rightX, 'yl': 64, 'yh': highY} + + rois['10X2'] = {'xl': rightX, 'xh': 3*64, 'yl': 64, 'yh': highY} + rois['11X'] = {'xl': 3*64, 'xh': highX, 'yl': 64, 'yh': highY} return rois