Skip to content

Loading different images in the same session #15

@RossBoylan

Description

@RossBoylan

Scenario

In the GUI load one image, work with it, then load another image, possibly with different dimensions or other attributes.

Or load repeated images without the GUI.

Check

The second image is set the same way it would have been if it were loaded first.

Concern

The second image might carry over some settings from the first, or be missing some settings.

Background

Because of these concerns, Karl initially recreated self.mybifs with each new image load. Ross changed this to rely more on copying. I (Ross) think the motivations were two-fold:

  1. Code reuse. bifs_gui.py doMap had code for creating a new bifs object based on an old one. I needed that same logic elsewhere, for scanning images to get an empirical prior. So I moved the logic to a separate function (in bifs.py, since there's nothing GUI specific in it).
  2. Performance: many fresh allocations used lots of memory and were slow (not sure about this one).

In particular, commit 47f9171 introduced this change, with the cautionary note

            # Reinitialize bifs object but keep current parameter setttings
            # RB: I refactored the parameter copying to the bifs object itself.
            # However, this means I set the parameters and then load the image file.
            # The original code loaded the image file and then set the parameters.
            # Since I don't understand why the reinitialization was necessary at all,
            # it's possible this change in sequence will break something.
            self.mybifs = self.mybifs.copy_params()

Extra Credit

Create one or more automated tests for these issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions