nion-software / nionswift

Nion Swift is open source scientific image processing software integrating hardware control, data acquisition, visualization, processing, and analysis using Python. Nion Swift is easily extended using Python. It runs on Windows, Linux, and macOS.
http://nion.com/swift
GNU General Public License v3.0
46 stars 33 forks source link

Perform processing operations in calibrated units where possible #279

Open cmeyer opened 5 years ago

cmeyer commented 5 years ago

Processing operations requiring multiple inputs should have sensible result intensity units:

Processing operations requiring multiple inputs should also use common spatial reference frames:

For instance, calibrated subtraction...

Emails from 2019-07-02, AM, TL.

import numpy
from scipy.ndimage import shift
import uuid
from nion.data import xdata_1_0 as xd
shift_amount = (src2.xdata.dimensional_calibrations[0].offset - src1.xdata.dimensional_calibrations[0].offset) / src1.xdata.dimensional_calibrations[0].scale
shifted_data2 = shift(src2.data, shift_amount, order=1)
shifted_xdata2 = api.create_data_and_metadata(shifted_data2, intensity_calibration=src1.xdata.intensity_calibration, dimensional_calibrations=src1.xdata.dimensional_calibrations)
target.xdata =  shifted_xdata2 - src1.xdata
cmeyer commented 3 years ago

See also https://github.com/nion-software/niondata/blob/a0e1ee7580df5e6615bc76f5740a9be88b9d3cff/nion/data/Core.py#L2038-L2057

cmeyer commented 3 years ago

ND 2021-05-07:

if I add two images, the result will not be the sum of the images if either of the images has in intensity calibration.

So if I create a shifts image from an SI, any operation done to it will divide the data by the dispersion in user terms.

cmeyer commented 1 year ago

Also see ND 2021-06-14 email.