LiberTEM / LiberTEM

Open pixelated STEM framework
https://libertem.github.io/LiberTEM/
GNU General Public License v3.0
112 stars 68 forks source link

COM analysis yields a blank result when the ROI doesn't include the frame center. #139

Closed uellue closed 6 years ago

uellue commented 6 years ago

I was trying a COM analysis on individual diffraction spots of the Glasgow data set.

What happened: I get a blank, black result frame when the ROI doesn't include the frame center. The bug described in #138 seems to be triggered when the border of the ROI is going through the frame center. It works when the frame center is inside the ROI.

What I'd expect to happen: COM analysis works independent of the ROI within the frame.

sk1p commented 6 years ago

Did you get blank results for all channels? Or only magnitude?

uellue commented 6 years ago

Did you get blank results for all channels? Or only magnitude?

Yes, all channels. But it only happens on the Glasgow data set. The EMPAD BiFeO3 works.

Parameter Value
path C:\Users\weber\ownCloud\Projects\Open Pixelated STEM framework\Data\3rd-Party Datasets\Glasgow\10 um 110.blo
type BLO
name Glasgow: Ian MacLaren, Shane McCartan
tileshape (1,8,144,144)
shape (90,121,144,144)

I confirmed that it is really the center of the frame that matters. If I shift the ROI only slightly to include or not include the center, the display changes dramatically from colorful to all-black after re-calculating.

PS: Awesome, I can copy & paste the "Info" table of the dataset and it keeps the table formatting!

sk1p commented 6 years ago

Why this is happening: the dataset has areas (the very bottom left) that are completely free of intensity outside of the transmitted beam, which results in a divide by zero -> both min and max for normalization are inf.

uellue commented 6 years ago

Hm, that makes sense. What would be the most correct behavior for this case? Can we somehow just ignore inf values for the color scale? Should we have a specific display for inf or nan pixels, such as white, black, grey, ...?

sk1p commented 6 years ago

For center-of-mass, I would set the value to the reference center, which results in a zero-length vector and thus a neutral representation in the field visualization (and a zero in magnitude). I think this is the expected results in the case of center of mass with all weights equal to zero.

For the general case, we should discuss this in #128 I think.

uellue commented 6 years ago

Confirmed fixed, thank you! :-) 👍