Commit 36c8df6f authored by Thomas Vincent's avatar Thomas Vincent

correct mask and center pixel with image roi offset

parent 6baf6029
......@@ -679,6 +679,9 @@ class QSpaceConverter(object):
raise ValueError('Invalid/missing center_chan value : {0}.'
''.format(center_chan))
# Load image ROI from first entry
image_roi_offset = first_param['image_roi_offset']
n_images = first_param['n_images']
if n_images is None or n_images == 0:
raise ValueError(
......@@ -696,8 +699,15 @@ class QSpaceConverter(object):
# Mask is empty, disable mask
mask = None
else:
if (image_roi_offset is not None and
image_roi_offset != (0, 0)):
# Apply image ROI to mask
row, column = image_roi_offset
mask = mask[row[0]:row[0]+img_size[0],
column[1]:column[1]+img_size[1]]
if mask.shape != img_size:
raise ValueError('Invalid mask size')
if (image_binning is not None and
not np.all(np.equal(image_binning, (1, 1)))):
raise ValueError(
......@@ -728,15 +738,21 @@ class QSpaceConverter(object):
n_xy = len(sample_indices)
print('Parameters :')
print('\t- beam energy : {0}'.format(beam_energy))
print('\t- center chan : {0}'.format(center_chan))
print('\t- chan per deg : {0}'.format(chan_per_deg))
print('\t- mask : {0}'.format(
print('\t- beam energy : {0}'.format(beam_energy))
print('\t- center channel : {0}'.format(center_chan))
print('\t- image roi offset : {0}'.format(image_roi_offset))
print('\t- channel per degree : {0}'.format(chan_per_deg))
print('\t- mask : {0}'.format(
'Yes' if mask is not None else 'No'))
print('\t- normalizer : {0}'.format(normalizer))
print('\t- img binning : {0}'.format(image_binning))
print('\t- medfilt dims : {0}'.format(medfilt_dims))
print('\t- qspace size : {0}'.format(qspace_dims))
print('\t- normalizer : {0}'.format(normalizer))
print('\t- img binning : {0}'.format(image_binning))
print('\t- medfilt dims : {0}'.format(medfilt_dims))
print('\t- qspace size : {0}'.format(qspace_dims))
# Offset center_chan with image roi offset if any
if image_roi_offset is not None:
center_chan = (center_chan[0] - image_roi_offset[0],
center_chan[1] - image_roi_offset[1])
# TODO : make this editable?
nx, ny, nz = qspace_dims
......@@ -1549,6 +1565,7 @@ def _get_all_params(data_h5f):
center_chans = []
chan_per_degs = []
angles = []
image_roi_offsets = []
with XsocsH5.XsocsH5(data_h5f, mode='r') as master_h5:
entries = master_h5.entries()
......@@ -1563,6 +1580,7 @@ def _get_all_params(data_h5f):
beam_energy = master_h5.beam_energy(entry=entry)
chan_per_deg = master_h5.chan_per_deg(entry=entry)
center_chan = master_h5.direct_beam(entry=entry)
image_roi_offset = master_h5.image_roi_offset(entry=entry)
angle = master_h5.positioner(entry, 'eta')
......@@ -1572,6 +1590,7 @@ def _get_all_params(data_h5f):
beam_energies.append(beam_energy)
chan_per_degs.append(chan_per_deg)
center_chans.append(center_chan)
image_roi_offsets.append(image_roi_offset)
angles.append(angle)
result = dict([(scan, dict(scans=entries[idx],
......@@ -1581,6 +1600,7 @@ def _get_all_params(data_h5f):
beam_energy=beam_energies[idx],
chan_per_deg=chan_per_degs[idx],
center_chan=center_chans[idx],
image_roi_offset=image_roi_offsets[idx],
angle=angles[idx]))
for idx, scan in enumerate(entries)])
return result
......
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