8000 First draft of deconvolution revisited by AnnaWiniwarter · Pull Request #181 · ixdat/ixdat · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

First draft of deconvolution revisited #181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Aug 7, 2024
Merged

First draft of deconvolution revisited #181

merged 39 commits into from
Aug 7, 2024

Conversation

AnnaWiniwarter
Copy link
Contributor
@AnnaWiniwarter AnnaWiniwarter commented Jul 8, 2024

changes made by Anna from the original PR by Kevin:
*) some syntax fixes to adjust for changes made to ixdat overall (up to 0.2.8)
*) remove the class DecoMeasurement and put the related methods directly into the ECMSMeasurement class. renamed some of the methods so they are more aligned with ixdat conventions
*) Change the name "Kernel" to "ECMSImpulseResponse". Might be the correct mathematical term, but I found it confusing (especially since Python also has Kernels)
*) Tried to remove the differentiation between whether an "ECMSImpulseResponse" is from a measurement or modelled, as they are both essentially just a tuple of (time, value). I think some is still left

There are some unfinished methods, which are not priority for me at the minute, but I'm not sure if it's necessary to wait for them to be finished and polished before merging.
Eventually, 'deconvolution' will be one 'modifier' (or how did we call it?) among many, but I wanted to get this running and available for others earlier than this major overhaul.
What do you think @ScottSoren?
I know that NEXT_CHANGES.rst is still missing - will provide if merge makes sense already.

@AnnaWiniwarter AnnaWiniwarter requested a review from ScottSoren July 8, 2024 18:46
@AnnaWiniwarter AnnaWiniwarter marked this pull request as draft July 8, 2024 18:46
@AnnaWiniwarter
Copy link
Contributor Author

I really don't get why the CI checks are STILL failing. running black doesnt do anything, checking with flake8 shows nothing. I really tried! :(

@matenestor
Copy link
Member
matenestor commented Jul 9, 2024

@AnnaWiniwarter CI complains about reformatting the ixdat/src/ixdat/techniques/ms.py file. On your PC it's not changing?

@AnnaWiniwarter
Copy link
Contributor Author

@matenestor it changed some files before (see the various commits I made) but does nothing now:
image
(ignore my typo please :) )

Copy link
Member
@ScottSoren ScottSoren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! I can see it's not quite finished. I've made some comments which might help. Some things will move according to the Calculator structure in #182 . Do you think it's best to finish #182 first, or this PR first?

A request: Make a demo script in the development_scripts/ folder with some okay-to-share sample data, so that I can test it out.

#TODO:need to understand if this is actually necessary
impulse_response (ImpulseResponse): impulse response object from model/data
mol (str): molecule
F_mol (CalPoint): spectro_inlets_calibration CalPoint object
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The data_snippet should inherit all of the original measurement's Calculators including siq or native MS calculators, so you should be able to drop this argument and instead just require that the original measurement has a Calculator for mol and use grab_flux.

).calc_impulse_response_from_data(tspan=tspan, tspan_bg=tspan_bg)
return impulse_response

def deconvolute_for_tspans(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also be a method of the Calculator (ie, the ECMSImpulseResponse.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leaving this unresolved since it's a not for you rather than me

@AnnaWiniwarter
Copy link
Contributor Author

Hi @ScottSoren, thanks for the thourough feedback! I'll get working on it.

Just one reply here:

Do you think it's best to finish #182 first, or this PR first?
YES I think that would be best (as you also write later on in the comments).

@AnnaWiniwarter
Copy link
Contributor Author
AnnaWiniwarter commented Jul 26, 2024

@ScottSoren Please review my revisions. :)

I still need to add NEXT_CHANGES.rst

@AnnaWiniwarter AnnaWiniwarter marked this pull request as ready for review July 26, 2024 13:28
Copy link
Member
@ScottSoren ScottSoren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @AnnaWiniwarter , this is a review just of the Demo script. The rest will follow.

The demo script is beautiful: reads like a tutorial. I've therefore allowed myself a bit of perfectionism in the comments, the few places where it's not quite clear, and to solicit your thoughts. Further improving it as a tutorial could be a long comment explaining that there's a "compare experimental impulse responses" section followed by a "deconvolute with modelled impulse response" section.

The one change in src that I had to make before it could run on my computer is np.trapezoid --> np.trapz. Not sure in what version trapezoid is a thing but trapz seems much more robust to me.

Copy link
Member
@ScottSoren ScottSoren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the rest of the review! Really nice with the classmethods!
I think there's some things that can be deleted now that they are covered in classmethods. And there are a bunch of unresolved comments from my earlier reviews.

impulse_response # no need to recalculate if these parameters fit
)
else:
# re-calculate the impulse response
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will have to disappear.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean?

Copy link
Member
@ScottSoren ScottSoren Aug 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I hadn't understood it, but do now.
I guess it can't disappear, because you do need a kernel and t_kernel that match the timespan requested. But if you can generate a new ECMSImpulseResponse object using only the info in the previous one and the desired time vector, then kernel and t_kernel are not the defining characteristics of an ECMSImpulseResponse. There should be a method ECMSImpulseResponse.grab_kernel_for_t() that does this when called from the original object, avoiding the need to make a second one.
I'll do this when merging with [calculators].

@AnnaWiniwarter
Copy link
Contributor Author

The one change in src that I had to make before it could run on my computer is np.trapezoid --> np.trapz. Not sure in what version trapezoid is a thing but trapz seems much more robust to me.

As mentioned today, I used trapezoid as I got following deprecation warning after updating numpy (to vs 2.0.0)

DeprecationWarning: `trapz` is deprecated. Use `trapezoid` instead, or one of the numerical integration functions in `scipy.integrate`.
  return np.trapz(v, t)

(Now that I realise they updated to vs 2.0.0 it makes sense that there's such a big change)

Anyway, I changed it all back to trapz, we can update across all of ixdat at a later stage

@AnnaWiniwarter
Copy link
Contributor Author

@ScottSoren
I've now resolved all your new comments, should be ready for merge. I really dont get why it's still failing checks. On my computer, flake8 doesnt find anything, black doesnt change anything. Also, it complains about ms.py, a file I dont think I touched at all on this branch. Hope you can solve it.

Copy link
Member
@ScottSoren ScottSoren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make a commit getting it to pass checks and then merge. We've left a few unresolved comments to resolve when merging with calculators (#182).

@ScottSoren
Copy link
Member

What was failing checks earlier is here (the != --> is not had already been updated on main): 5d36ac8

Anyway, all good now, except those comments left to resolve with #182. Merging! :)

@ScottSoren ScottSoren merged commit 8d82784 into main Aug 7, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0