hyperspy / rosettasciio

Python library for reading and writing scientific data format
https://hyperspy.org/rosettasciio
GNU General Public License v3.0
44 stars 26 forks source link

Problem with sum spectra for bruker M4 tonado .BCF file #290

Open Divyadeep00 opened 2 weeks ago

Divyadeep00 commented 2 weeks ago
import hyperspy.api as hs

import scipy
# Load your data (replace with actual data loading code)
data = hs.load('MS-1b_S.bcf')
data= data[4]
data.plot()
roi = hs.roi.RectangularROI(left=110, right=125, top=55, bottom=65)

s_roi = roi.interactive(data, recompute_out_event=None, color='C1')
s_roi = roi(data)
roi_sum = hs.interactive(s_roi.sum, recompute_out_event=None)
roi_sum.plot()

I am using above code to view the spectrum at my roi, while doing so, I encounter a flat XRF spectra shown in image image

both orange and red are nearly (even when they overlap) the default eds signal navigator gives a spectrum but the sum plot is giving a flat signal, is it a but or I am doing something wrong.

ericpre commented 2 weeks ago

By any chance, do you have any NaN in your data? If so, you should use https://hyperspy.org/hyperspy-doc/dev/reference/api.signals/BaseSignal.html#hyperspy.api.signals.BaseSignal.nansum

Divyadeep00 commented 2 weeks ago

but if the reason is the NaN value than default view eds viewer should also show flat, but it is showing signals

ericpre commented 2 weeks ago

No, the default pointer doesn't take the sum.

Divyadeep00 commented 2 weeks ago

but the provided image both have same pixel, size, default pointer is giving values but sum pointer not, as you can see in the provided image also.

Divyadeep00 commented 2 weeks ago

image in this image both pixcel is overlap

ericpre commented 2 weeks ago

Have you tried to use nansum instead of sum as suggested above? e.g. try to adapt your example above to use roi_sum = hs.interactive(s_roi.nansum, recompute_out_event=None).