1

When I run the script below on a DM EELS spectrum that already contains background and signal ROIs, it is ok if I don't show any images.

ImageDocument imdoc = GetFrontImageDocument() 
image i0 = ImageDocumentGetImage(imdoc,0)
image subt = eelssubtractpowerlawbackground(i0,800,900)

//image irrelevant = realimage("irrelevant",4,100,100)
//showimage(irrelevant)

But if I show any image after running the background subtraction command (activate the last 2 lines for example) the pre-existing ROIs on the initial image are changed (sig disappears and bckgd is moved to the new position).

This is despite i0 being in theory a new image, not part of the initial one.

Creating copies within the script and working on them appears in any case not to solve the problem.

More surprising is that if I first make a duplicate of the initial image and run the script on that, then close the new windows and the (modified) spectrum on which the script was run, then try and duplicate the initial image, the duplicate has the modified ROIs rather than its own. A second duplicate seems to be ok. I have no idea what's going on. Grateful for any ideas.

(The problem was initially part of a much bigger script in which I need to show images, I've reduced it to the essentials here). I'm using v2.3.2.

BmyGuest
  • 6,331
  • 1
  • 21
  • 35
Mike Walls
  • 11
  • 2

1 Answers1

0

I have tested your script on an EELS Spectrum with ROIs in GMS 2.3.3 and in GMS 3.2.2

GMS 2.3.3:

It does not seem to happen due to the ShowImage() but rather whenever the display of the image the last Background/Signal ROI was used on is refreshing its display. You get the same behavior when you run your script without the last two lines, but then click on another image (to select it) and then the spectrum again. And you get the same if you've used the background-subtraction ROI on a completely different image and then run the script. It messes up that last images' ROIs.

GMS 3.2.2: Doesn't show this. All is fine regardless what you do.


So, from these two tests I would conclude it is a bug in GMS 2.3 which has since been fixed.

The behaviour is indeed very odd, and I see nothing wrong with your code.

The bug seems to be that the command eelssubtractpowerlawbackground() messes with the settings of the last active signal-extracting ROIs, regardless on where they are placed on. It doesn't matter what the input image is. It seems to "reuse" these last ROIs.

Unfortunately, I don't know a good workaround for it.

Community
  • 1
  • 1
BmyGuest
  • 6,331
  • 1
  • 21
  • 35