Skip to content

Commit

Permalink
all settings in place. this refs #33
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanBilheux committed Jul 29, 2024
1 parent 0d52dc3 commit dcaf14d
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 219 deletions.
9 changes: 7 additions & 2 deletions __code/laminography_event_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,16 @@ class LaminographyEventHandler:

_proj_mlog = None

def __init__(self, parent=None):
def __init__(self, parent=None, batch_mode=False):
self.parent = parent

self.z_top, self.z_bottom = list(self.parent.z_range_selection.result)
self._proj_mlog = self.parent.proj_mlog[self.z_top: self.z_bottom, :, :]
if batch_mode:
proj_mlog = self.parent.proj_raw
else:
proj_mlog = self.parent.proj_mlog
self._proj_mlog = proj_mlog[self.z_top: self.z_bottom, :, :]

[self.nbr_angles, self.nbr_row, self.nbr_col] = np.shape(self._proj_mlog)

def set_settings(self):
Expand Down
36 changes: 28 additions & 8 deletions __code/laminographyui_batch_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,37 @@ def define_parameters(self):
self.display_section_title(name='Crop')
self.crop_embedded(batch_mode=True)

self.display_section_title(name='Filtering')
self.display_section_title(name='Filtering #1')
self.gamma_filtering_options()

self.display_section_title(name='Beam fluctuation')
o_beam = BeamFluctuationCorrection(parent=self)
o_beam.beam_fluctuation_correction_option()
o_beam.apply_select_beam_fluctuation(batch_mode=True)

self.display_section_title(name='Tilt calculation')
self.tilt_correction_options()

self.display_section_title(name='Filtering #2')
self.filter_options()

self.display_section_title(name='Ring removal')
self.ring_removal_options()

self.display_section_title(name="Range of slices to reconstruct")
self.select_range_of_slices(batch_mode=True)

self.display_section_title(name="Define laminography parameters")
self.laminography_settings(batch_mode=True)

def run_reconstruction_in_batch_mode(self):
# create json config
# launch command
pass





def tilt_correction_options(self):
o_tilt = Tilt(parent=self)
o_tilt.display_batch_options()
Expand Down Expand Up @@ -323,9 +343,9 @@ def remove_negative_values_option(self):
description="Remove negative values")
display(self.remove_negative_ui)

def apply_filter_options(self):
def apply_filter_options(self, batch_mode=False):
# self.strikes_removal()
self.remove_negative_values()
self.remove_negative_values(batch_mode=batch_mode)

def remove_negative_values(self):
o_filter = Filters(parent=self)
Expand Down Expand Up @@ -394,16 +414,16 @@ def running_reconstruction_test(self):
self.o_test_reco.retrieving_parameters()
self.o_test_reco.running_reconstruction_test()

def select_range_of_slices(self):
def select_range_of_slices(self, batch_mode=False):
o_select = SelectZRange(parent=self)
o_select.select_range_of_slices()
o_select.select_range_of_slices(batch_mode=batch_mode)

def display_reconstruction_test(self):
pass

# Laminography
def laminography_settings(self):
self.o_event_laminography_settings = LaminographyEventHandler(parent=self)
def laminography_settings(self, batch_mode=False):
self.o_event_laminography_settings = LaminographyEventHandler(parent=self, batch_mode=batch_mode)
self.o_event_laminography_settings.set_settings()

def run_laminography(self):
Expand Down
9 changes: 7 additions & 2 deletions __code/workflow/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@

class Filters(Parent):

def remove_negative_values(self):
def remove_negative_values(self, batch_mode=False):
"""remove all the intensity that are below 0"""
if self.parent.remove_negative_ui.value:
if batch_mode:
flag = True
else:
flag = self.parent.remove_negative_ui.value

if flag:
self.parent.proj_mlog[self.parent.proj_mlog < 0] = 0
print(" Removed negative values!")
else:
Expand Down
23 changes: 18 additions & 5 deletions __code/workflow/select_z_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,22 @@

class SelectZRange(Parent):

def select_range_of_slices(self):
list_images = self.parent.proj_tilt_corrected
integrated_image = np.mean(list_images, axis=0)
def select_range_of_slices(self, batch_mode=False):

if batch_mode:
integrated_image = self.parent.integrated_proj_min
else:
list_images = self.parent.proj_tilt_corrected
integrated_image = np.mean(list_images, axis=0)
height, width = np.shape(integrated_image)
max_value = np.max(integrated_image)

z_top = self.parent.crop_roi[2] if self.parent.crop_roi[2] else 0
z_bottom = self.parent.crop_roi[3] if self.parent.crop_roi[3] else height - 1

def plot_z_range(top, bottom):
def plot_z_range(top, bottom, vmin, vmax):
fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(5, 5))
ax.imshow(integrated_image)
ax.imshow(integrated_image, vmin=vmin, vmax=vmax)

ax.axhline(top, color='blue', linestyle='--')
ax.axhline(bottom, color='red', linestyle='--')
Expand All @@ -35,5 +40,13 @@ def plot_z_range(top, bottom):
max=height - 1,
value=z_bottom,
continuous_update=False),
vmin=widgets.IntSlider(min=0,
max=max_value,
value=0,
continuous_update=False),
vmax=widgets.IntSlider(min=0,
max=max_value,
value=max_value,
continuous_update=False)
)
display(self.parent.z_range_selection)
Loading

0 comments on commit dcaf14d

Please sign in to comment.