Opened 8 years ago

#32 new enhancement

MrsPrior.calculate_full_basis_set() could benefit from memoization

Reported by: flip Owned by:
Priority: minor Milestone:
Component: fitting Version:
Keywords: Cc: bsoher


MrsPrior.calculate_full_basis_set() is called often in Analysis. It's not horribly expensive, but since it's called so often its performance is worthy of attention.

This enhancement ticket isn't about the algorithm or the implementation but about the idea of memoization which is the concept of caching the output produced for a given set of inputs. ( As a user adjusts the PPM range in Analysis, Analysis calls calculate_full_basis_set(). If the change in PPM values include or exclude, say, one metab out of 20, the basis set for the 19 unchanged metabs is recalculated regardless. This is inefficient. If we could pull those values from a cache (lots of handwaving here), we wouldn't need to recalculate.

I'm out of my depth here since I don't know the science, but I'll add some more speculation. Is it possible to partially or wholly precalculate the basis set for a given metabolite and store those results in the database so that the calculation would not have to be done at runtime?

The heavy lifting in MrsPrior.calculate_full_basis_set() is done by util_voigt.calculate_generic_fid(). That uses a lot of dataset-specific properties (sweep width, acqdim, etc.), so it could be that its calculations are too dependent on these properties to calculate anything in advance. But it seems possible to me that some of the math might be independent of the dataset properties, and that could be done in advance and stored in the database and the dataset-specific math done at runtime.

Change History (0)

Note: See TracTickets for help on using tickets.