Commit 58743562 authored by Thomas Vincent's avatar Thomas Vincent

apply image roi offset to maxipix correction

parent 402e806f
...@@ -949,6 +949,7 @@ class QSpaceConverter(object): ...@@ -949,6 +949,7 @@ class QSpaceConverter(object):
arg_list = (th_idx, arg_list = (th_idx,
entry_files, entry_files,
entries, entries,
image_roi_offset,
img_size, img_size,
output_f, output_f,
self.maxipix_correction, self.maxipix_correction,
...@@ -1237,6 +1238,7 @@ def _create_result_file(h5_fn, ...@@ -1237,6 +1238,7 @@ def _create_result_file(h5_fn,
def _to_qspace(th_idx, def _to_qspace(th_idx,
entry_files, entry_files,
entries, entries,
image_roi_offset,
img_size, img_size,
output_fn, output_fn,
maxipix_correction, maxipix_correction,
...@@ -1248,6 +1250,7 @@ def _to_qspace(th_idx, ...@@ -1248,6 +1250,7 @@ def _to_qspace(th_idx,
:param th_idx: :param th_idx:
:param entry_files: :param entry_files:
:param entries: :param entries:
:param image_roi_offset: Offset of detector image ROI (row, col)
:param img_size: :param img_size:
:param output_fn: :param output_fn:
:param bool maxipix_correction: :param bool maxipix_correction:
...@@ -1363,11 +1366,23 @@ def _to_qspace(th_idx, ...@@ -1363,11 +1366,23 @@ def _to_qspace(th_idx,
# Apply maxipix correction # Apply maxipix correction
if maxipix_correction: if maxipix_correction:
# TODO handle image ROI # Correction without image ROI, kept for readability
img[255:258] = img[255] / 3 # img[255:258] = img[255] / 3
img[258:261] = img[260] / 3 # img[258:261] = img[260] / 3
img[:, 255:258] = (img[:, 255] / 3)[:, None] # img[:, 255:258] = (img[:, 255] / 3)[:, None]
img[:, 258:261] = (img[:, 260] / 3)[:, None] # img[:, 258:261] = (img[:, 260] / 3)[:, None]
# Apply correction taking image ROI offset into account
# Skip correction if row/column with signal is outside ROI
row, column = image_roi_offset
if row < 255:
img[255-row:258-row] = img[255-row] / 3
if row <= 260:
img[max(0, 258-row):261-row] = img[260-row] / 3
if column < 255:
img[:, 255-column:258-column] = (img[:, 255-column] / 3)[:, None]
if column <= 260:
img[:, max(0, 258-column):261-column] = (img[:, 260-column] / 3)[:, None]
# Apply normalization # Apply normalization
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment