Skip to content

Commit

Permalink
Merge branch 'FABLE-3DXRD:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jadball authored Oct 17, 2024
2 parents 55c1548 + 4ec6bb8 commit 0896033
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 8 deletions.
20 changes: 17 additions & 3 deletions ImageD11/sinograms/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def import_all(self, scans=None, shape=None):
except:
logging.info("nnz not available. Segmentation done?")

def import_from_sparse(self, hname, scans=None):
def import_from_sparse(self, hname, scans=None, shape=None):
"""
hname = hdf5 file containing sparse pixels (and motors)
dataset = a dataset instance to import into
Expand All @@ -260,12 +260,26 @@ def import_from_sparse(self, hname, scans=None):
scans = list(hin["/"])
order = np.argsort([float(v) for v in scans if v.endswith(".1")])
self.scans = [scans[i] for i in order]
else:
self.scans = scans
self.masterfile = hname # hacky, motors come from the sparsefile
self.import_nnz_from_sparse() # must exist
self.import_motors_from_master()
self.shape = self.nnz.shape
# self.guess_shape() # fails with sparse
if shape is not None:
self.shape = shape
self.nnz = np.array(self.nnz).reshape(self.shape)
else:
self.shape = self.nnz.shape
self.omega = np.array(self.omega).reshape(self.shape)
self.dty = np.array(self.dty).reshape(self.shape)
if len(scans) == 1 and self.shape[0]>1:
file_nums = np.arange(self.shape[0]*self.shape[1]).reshape(self.shape)
self.scans = [
"%s::[%d:%d]" % (self.scans[0], row[0], row[-1] + 1)
for row in file_nums
]

self.guessbins()

def import_scans(self, scans=None, hname=None):
Expand Down Expand Up @@ -525,7 +539,7 @@ def get_monitor(self, name="fpico6"):
lo, hi = [int(v) for v in slc[1:-1].split(":")]
mon = hin[snum]["measurement"][name][lo:hi]
else:
mon = hin[snum]["measurement"][name][:]
mon = hin[scan]["measurement"][name][:]
monitor.append(mon)
self.monitor = np.concatenate(monitor).reshape(self.shape)
return self.monitor
Expand Down
11 changes: 8 additions & 3 deletions ImageD11/sinograms/roi_iradon.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,13 @@ def correct_recon_central_zingers(recon, radius=25):


def run_iradon(sino, angles, pad=20, shift=0,
workers=1, mask=None,
apply_halfmask=False, mask_central_zingers=False, central_mask_radius=25):
workers=1,
mask=None,
apply_halfmask=False,
mask_central_zingers=False,
central_mask_radius=25,
filter_name='hamming',
):
"""Applies an iradon to a sinogram, with an optional pad
Calculates scaled-up output size from pad value
Applies projection shifts of shift
Expand All @@ -550,7 +555,7 @@ def run_iradon(sino, angles, pad=20, shift=0,
mask=mask,
output_size=outsize,
projection_shifts=np.full(sino.shape, shift),
filter_name='hamming',
filter_name=filter_name,
interpolation='linear',
workers=workers)

Expand Down
15 changes: 13 additions & 2 deletions ImageD11/sinograms/sinogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ def build_sinogram(self, columns=('omega',)):
# intensity weighted sums
angs = {}
for name in columns:
if name == 'sum_intensity':
continue
angs[name] = np.zeros((npks, NY), 'f')
ImageD11.cImageD11.put_incr64(angs[name], adr, self.cf_for_sino[name] * sig )
sinoangles = angs['omega'] .sum(axis=1) / sino.sum(axis=1)
Expand All @@ -172,7 +174,13 @@ def build_sinogram(self, columns=('omega',)):
self.ssino = self.sino[order].T
self.proj_scale = self.proj_scale[order]
if len(columns)>1:
self.angle_wt_sinos = { name : angs[name][order].T for name in columns }
self.angle_wt_sinos = { name : angs[name][order].T
for name in columns
if name != 'sum_intensity'
}
if 'sum_intensity' in columns:
self.angle_wt_sinos['sum_intensity'] = sino[order].T
self.hits = hits
self.hkle = pkindices[:, order] # dims are [ (h,k,l,sign(eta)) , nprojections ]

def update_lab_position_from_peaks(self, cf_4d, grain_label):
Expand Down Expand Up @@ -252,7 +260,10 @@ def recon(self,
iradon -> ImageD11.sinograms.roi_iradon.run_iradon
{ pad=20, shift=0, workers=1, mask=None,
apply_halfmask=False, mask_central_zingers=False, central_mask_radius=25 }
apply_halfmask=False,
mask_central_zingers=False,
central_mask_radius=25,
filter_name='hamming'}
mlem : ImageD11.sinograms.roi_iradon.run_mlem
{ mask=None, pad=20, shift=0, workers=1, niter=20, apply_halfmask=False,
mask_central_zingers=False, central_mask_radius=25 }
Expand Down

0 comments on commit 0896033

Please sign in to comment.