Giter VIP home page Giter VIP logo

Comments (4)

ichristen avatar ichristen commented on June 12, 2024

Hmm. I think this is actually intended behavior. Looks like integer rounding to me, where the upper spots happened to be rounded up one in the (integer) computational k-space knm.

Internally, a grid is created in .make_rectangular_array() from x and y lists on each edge:

x_edge = (np.arange(array_shape[0]) - (array_shape[0] - 1) / 2)
x_edge = x_edge * array_pitch[0] + array_center[0]
y_edge = (np.arange(array_shape[1]) - (array_shape[1] - 1) / 2)
y_edge = y_edge * array_pitch[1] + array_center[1]

But then, the points generated from these edges are ceiled up.

self.spot_knm_rounded = np.ceil(shape / 2 + self.spot_knm.astype(np.float))
self.spot_knm_rounded = self.spot_knm_rounded.astype(np.int)

The fix is either to increase the resolution of k-space to be finer (and the off-by-one less noticeable), or choose array_shape and array_center more carefully to avoid undesirable rounding.

Rounding is going to happen no matter what, which is why this is intended behavior. I added a user info note in 7a84c9c.

from slmsuite.

tpr0p avatar tpr0p commented on June 12, 2024

I realized this would affect results of fourier calibration so I spent some more time thinking about it. I am proposing that we adopt the convention I declared here:

The x_edge and y_edge computation is fine because the results are floats with uniform pitch. I think spot_knm_rounded is funky due to the ceil. For example, say shape / 2 + self.spot_knm.astype(np.float)) has x coords 58.6, 64, 69.4: 58.6 is rounded up to 57, 64 stays, 69.4 is rounded up to 70, so the array isn't uniform anymore. You can prove by considering a few simple cases that, under the convention I proposed, two points equally spaced about zero (58.6 ~ -5.4) and (69.4 ~ 5.4) always end up an equal number of indices away from zero.

from slmsuite.

ichristen avatar ichristen commented on June 12, 2024

The ceil was intended to make the rounding explicit. The rounding has to occur no matter what, to generate a target image in computational k-space. I'm not sure if the proposed convention resolves the problem, as you're back to non-uniform pitch once you do more than three points in the example (e.g. five points). The heart of the issue was passing a non-integer knm pitch in the first place, I would argue, which is a user issue that we can (at best) warn about.

from slmsuite.

ichristen avatar ichristen commented on June 12, 2024

But after some discussion, around probably produces better results than ceil in the case of spot_knm_rounded, as this more accurately targets the positions of desired spots. See 2a958cc.

from slmsuite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.