Skip to content

Commit

Permalink
Fix bug with specifying frame in frelon seg gui
Browse files Browse the repository at this point in the history
  • Loading branch information
jadball authored Sep 26, 2024
1 parent ac28b5a commit 3eb8107
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions ImageD11/nbGui/segmenter_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,18 @@ def chooseframe(self, counter):
ds = self.dset
if self.scan is None:
self.scan = ds.scans[len(ds.scans)//2]
if self.idx is not None:
return
# Locate a busy image to look at
with h5py.File(ds.masterfile,'r') as hin:
ctr = ds.detector+counter
if self.scan.find("::") > -1: # 1.1::[10000:12000] etc
lo, hi = [int(v) for v in self.scan[:-1].split("[")[1].split(":")]
self.scan = self.scan.split("::")[0]
roi1 = hin[self.scan]['measurement'][ctr][lo:hi]
self.idx = np.argmax(roi1) + lo
else: # "1.1"
roi1 = hin[self.scan]['measurement'][ctr][:]
self.idx = np.argmax(roi1)
if self.idx is None:
# Locate a busy image to look at
with h5py.File(ds.masterfile,'r') as hin:
ctr = ds.detector+counter
if self.scan.find("::") > -1: # 1.1::[10000:12000] etc
lo, hi = [int(v) for v in self.scan[:-1].split("[")[1].split(":")]
self.scan = self.scan.split("::")[0]
roi1 = hin[self.scan]['measurement'][ctr][lo:hi]
self.idx = np.argmax(roi1) + lo
else: # "1.1"
roi1 = hin[self.scan]['measurement'][ctr][:]
self.idx = np.argmax(roi1)
print("Using frame", self.idx, "from scan", self.scan)
with h5py.File(self.dset.masterfile, 'r') as h5In:
self.raw_image = h5In[self.scan + '/measurement/' + ds.detector][self.idx].astype('uint16')
Expand Down Expand Up @@ -230,4 +229,4 @@ def update_image(self, threshold, smoothsigma, bgc, minpx, m_offset_thresh, m_ra
def getopts(self):
opts = { name: self.options[name] for name in ('bgfile','maskfile','threshold','smoothsigma','bgc','minpx','m_offset_thresh','m_ratio_thresh') }
print("options = ",repr(opts))
return opts
return opts

1 comment on commit 3eb8107

@haixing0a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi James,
Just to give you some feedbacks about your very new updates on the notebook.
Seen with user measurement data, found two small issues:

  1. in the indexing notebook, we have to do:
    cf_4d.parameters.loadparameters(par_file)
    cf_4d.updateGeometry()

before ucell = ImageD11.unitcell.unitcell_from_parameters(cf_4d.parameters)

It seems cf_4d = ds.get_cf_4d() does not get parameters. Probably this is because ds does not contain parameters any more.

  1. in the sinogram_map notebook:
    write_h5(ds.grainsfile, grainsinos, overwrite_grains=False) currently has a different key from the old version which uses "write_grains_too" ?
    So I guess the notebook needs to be updated to the new key name.

Cheers,
Haixing

Please sign in to comment.