Skip to content

Commit

Permalink
Fix #988. Add a radial profile menu item to Fourier processing sub-menu.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmeyer committed Nov 8, 2023
1 parent 8612ad1 commit 27e8f6f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
14 changes: 14 additions & 0 deletions nion/swift/DocumentController.py
Original file line number Diff line number Diff line change
Expand Up @@ -4693,6 +4693,19 @@ def invoke(self, context: Window.ActionContext) -> Window.ActionResult:
return self.invoke_processing(context, context.model.get_projection_new)


class RadialProfileAction(ProcessingAction):
action_id = "processing.radial_profile"
action_name = _("Radial Profile")

def execute(self, context: Window.ActionContext) -> Window.ActionResult:
context = typing.cast(DocumentController.ActionContext, context)
return self.execute_processing(context, context.model.get_radial_profile_new)

def invoke(self, context: Window.ActionContext) -> Window.ActionResult:
context = typing.cast(DocumentController.ActionContext, context)
return self.invoke_processing(context, context.model.get_radial_profile_new)


class RebinAction(ProcessingAction):
action_id = "processing.rebin"
action_name = _("Rebin")
Expand Down Expand Up @@ -4966,6 +4979,7 @@ def is_enabled(self, context: Window.ActionContext) -> bool:
Window.register_action(PickAverageAction())
Window.register_action(PickSumAction())
Window.register_action(ProjectionSumAction())
Window.register_action(RadialProfileAction())
Window.register_action(RebinAction())
Window.register_action(ResampleAction())
Window.register_action(ResizeAction())
Expand Down
5 changes: 5 additions & 0 deletions nion/swift/model/DocumentModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2573,6 +2573,8 @@ def _get_builtin_processing_descriptions(cls) -> typing.Dict[str, typing.Any]:
line_profile_in_region = {"name": "line_region", "type": "line", "params": {"label": _("Line Profile")}}
vs["line-profile"] = {"title": _("Line Profile"), "expression": "xd.line_profile(xd.absolute({src}.element_xdata) if {src}.element_xdata.is_data_complex_type else {src}.element_xdata, line_region.vector, line_region.line_width)",
"sources": [{"name": "src", "label": _("Source"), "regions": [line_profile_in_region]}]}
vs["radial-profile"] = {"title": _("Radial Profile"), "expression": "xd.radial_profile({src}.display_xdata)",
"sources": [{"name": "src", "label": _("Source"), "requirements": [requirement_2d]}]}
vs["filter"] = {"title": _("Filter"), "expression": "xd.real(xd.ifft({src}.filtered_xdata))",
"sources": [{"name": "src", "label": _("Source"), "requirements": [requirement_2d]}]}
vs["sequence-register"] = {"title": _("Shifts"), "expression": "xd.sequence_squeeze_measurement(xd.sequence_measure_relative_translation({src}.xdata, {src}.xdata[numpy.unravel_index(0, {src}.xdata.navigation_dimension_shape)], 100))",
Expand Down Expand Up @@ -2733,6 +2735,9 @@ def get_subtract_region_average_new(self, display_item: DisplayItem.DisplayItem,
def get_line_profile_new(self, display_item: DisplayItem.DisplayItem, data_item: DataItem.DataItem, crop_region: typing.Optional[Graphics.Graphic]=None, line_region: typing.Optional[Graphics.Graphic]=None) -> typing.Optional[DataItem.DataItem]:
return self.__make_computation("line-profile", [(display_item, data_item, crop_region)], {"src": [line_region]})

def get_radial_profile_new(self, display_item: DisplayItem.DisplayItem, data_item: DataItem.DataItem, crop_region: typing.Optional[Graphics.Graphic]=None) -> typing.Optional[DataItem.DataItem]:
return self.__make_computation("radial-profile", [(display_item, data_item, crop_region)])

def get_fourier_filter_new(self, display_item: DisplayItem.DisplayItem, data_item: DataItem.DataItem, crop_region: typing.Optional[Graphics.Graphic]=None) -> typing.Optional[DataItem.DataItem]:
display_data_item = display_item.data_item
if display_data_item and display_item:
Expand Down
4 changes: 4 additions & 0 deletions nion/swift/resources/changes.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
{
"version": "Unreleased",
"notes": [
{
"issues": ["https://github.com/nion-software/nionswift/issues/988"],
"summary": "Add a radial profile menu item to Fourier processing sub-menu."
},
{
"summary": "Expand About Box to include release notes and recent changes."
},
Expand Down
4 changes: 4 additions & 0 deletions nion/swift/resources/menu_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,10 @@
"type": "item",
"action_id": "processing.cross_correlate"
},
{
"type": "item",
"action_id": "processing.radial_profile"
},
{
"type": "item",
"action_id": "processing.fourier_filter"
Expand Down

0 comments on commit 27e8f6f

Please sign in to comment.