'Remove Section' GUI implementation#54
Conversation
src/misc.jl
Outdated
| results.yfit = g | ||
|
|
||
| # pick indices from xfit that are closest to the measured x values | ||
| closest_indices = [findmin(abs.(results.xfit .- x))[2] for x in results.x] |
There was a problem hiding this comment.
This is a nice solution, but the results would not be 100% accurate, since the different x values might not match. We could instead use the original K matrix (as opposed to the one made right above) and compute Kf-g again for the residuals? That seems a bit more elegant and would give the most accurate residuals.
There was a problem hiding this comment.
I've added the original ker_struct from the 1D invert method into the results. Calculating the residuals (as in the finding_alpha method, using g-Kf with g and K from the kernel struct) with the unchanged f leaves the residuals unchanged. However, changing f does give seemingly incorrect results. It's likely I'm just misunderstanding how ker_struct is used.
(even more seemingly incorrect than the last)
The following 2 are the plots of Kf, using the old and new K.
There was a problem hiding this comment.
The values in the kernel structure sometimes are compressed by singular value decomposition to make the inversion faster and remove a bit of noise. I imagine that may introduce some confusion, since if the data is compressed, g will have a different size compared to x or y.
This is also why the x axis in the residuals uses "index" instead of time.
That's a bit confusing without looking at your code. Could you push it please?
|
Just tried the code on my machine, it works fine, well done! Also, I was thinking one more thing; |
|
That sounds like a good idea, I will work on this. In the current code there is no feature to find the integral of |
Great. Perhaps we could also use the Of course, let me know if this, or anything else is unclear. |
|
Got it, sounds good. Thanks! |
|
Hi @aris-mav, I think I've figured out the issue. I have used Plotting Looking closely at the first index, having left Original residuals plot, Updated residuals plot, Using the updated method also gives sensible results when removing sections, unlike the original method, where residuals are very large initially and then quickly go to zero. |
|
That looks good, @louob20! Just one thing, as mentioned in a previous comment, it would be good if the |
|
Would you please enable “Allow edits from maintainers"? |
So you have to apply the filter to the function only when you want to plot it? |
That's what I was thinking, that would be consistent with the 2D case and it would preserve the original information. |
|
@aris-mav I believe that last commit was all, if you would like to run the code before merging |
|
It seems that the filter selection function still updates the residuals and the yfit directly on the structure. |
|
I have changed it, should be good now. |
| @@ -132,6 +132,7 @@ Run the GUI to plot the 1D inversion results and select peaks you want to label. | |||
| """ | |||
| function Makie.plot(res::NMRInversions.inv_out_1D) | |||
|
|
|||
There was a problem hiding this comment.
Maybe the most elegant and consistent way to handle this would be following the same approach as the 2D case:
Add a filter field to the results struct, which can be a vector with 0's in the deleted region and 1's everywhere else.
Then, each time before plotting, we can plot filter .* f instead of f, K *( filter .* f ) .- yfit instead of r etc.
If so, the delete_range! function can be modified to delete_range(r::NMRInversions.inv_out_1D) (or another suitable name), and it can return the values above which need to be plotted, instead of modifying the original structure. This way, the original information is preserved, and the new information is computed in-place using the 'filter' field.
Can't think of a better way, but keen to hear your opinion as well.
There was a problem hiding this comment.
Basically the delete button would only modify the filter field, and the reset button would turn it back to 1's.
src/misc.jl
Outdated
| results.yfit = g | ||
|
|
||
| # pick indices from xfit that are closest to the measured x values | ||
| closest_indices = [findmin(abs.(results.xfit .- x))[2] for x in results.x] |
There was a problem hiding this comment.
The values in the kernel structure sometimes are compressed by singular value decomposition to make the inversion faster and remove a bit of noise. I imagine that may introduce some confusion, since if the data is compressed, g will have a different size compared to x or y.
This is also why the x axis in the residuals uses "index" instead of time.
That's a bit confusing without looking at your code. Could you push it please?
|
Good job @louob20 ! |




Appears to work, but please do check that this gives the desired results
I'm also unsure how to format the buttons in a nicer manner