Releases: mathesong/kinfitr
v0.9.0
Functionality additions mostly related to the development of the BIDS app, and some long-overdue convenience functions.
- In linear models with a
tstarIncludedFramesparameter, this is being deprecated in favour of two new arguments calledtstarandtstar_type. This allows specifying tstar either as the number of included frames from the end, or else as a number of minutes after which pseudo-equilibrium has been achieved. This is much simpler for datasets with different sets of frame times. - In all models, specifying subsets of frames to be included is modelling is simpler as there is a
timeStartEndandframeStartEndargument to decide upon - The
plyrdependencies have finally been expunged from the package and replaced withdplyr - The package has been updated so that it no longer raises warnings with the CRAN checks. It might soon be time to submit to CRAN.
- Weighting functions and decay correction allow custom half-life times for different radionuclides other than C11, O15 and F18
Next release probably to be expected reasonably soon as more things are added to the functions to allow the BIDS app to function.
v0.8.0
New release to describe a number of improvements to the package.
Modeling
feng_1tc_tac()is a model for fitting any old TAC. It is used for fitting the reference region with SiMBA reference tissue models, and can also be very helpful when combined with SRTM2 for modelling [11C]UCB-J to smooth out noisy CS TACs.- Added a
twotcm_irr()function for fitting the irreversible 2TC model, i.e. 2TC3k. - Added a
twotcm_macro()function for an alternative parameterisation of the 2TC focusing on macroparameters, where one has control over limits for K1, Vnd, BPp and k4, and can set Vnd, BPp or k4 to a predetermined value. - Fixed the issue with vB being considered as a fitted parameter when defined, which was causing incorrect AIC values. Thanks so much to Ronald Boellaard for bringing this to my attention!
Blood
- Whole blood data is now inferred for time points with plasma and no blood to accommodate datasets from research groups who collect mostly plasma measurements.
Plotting
- Fixed an issue with delay fitting when the TAC was also moved
- Added the ability to plot only one of the lines when plotting blooddata objects using the select_line input, which takes the same values as
bd_addfit()modeltype argument, i.e. BPR, Blood, AIF, parentFraction - BPR data is now inverted to PBR if it is too high and leaves the frame of the plot.
BIDS
- Added support for importing bloodstream outputs so that one can very simply load in the generated input objects from a whole study using
bloodstream_import_inputfunctions(), or AIF parameters usingbloodstream_import_aifpars() - Updated the BIDS parser
Changes to functionality
- The AIF models now automatically use a weighting function when fitted. This improves performance generally, but may cause slightly different fits. The old weights function can be selected using weightscheme=1.
kinfitr v0.7.0
I thought we needed a new release to take account of all the gradual improvements made over the last 18 months.
Firstly, thank you so much to everyone using the package! It always makes my day to hear that it's being used. I really appreciate your leaving a star on the repo, because it shows me who's actually using the package, because I can't see that otherwise. And please feel free to leave comments and suggestions in the issues: they're really helpful for fixing things, or for identifying new bugs.
BIDS Support
The PET BIDS standard is now incorporated into BIDS, and the paper is published! There were a few changes to the specification, and I've incorporated these into kinfitr. It should now be possible to import blood data automatically, with some heuristics for when things are missing. Please let me know if there are any other issues that you might come across based on any other changes which might have escaped my notice.
Pharmacokinetic models
Models
-
I have added the full reference tissue model (FRTM) as we were attempting to use it in another project. I would, however, advise caution with actually applying it, because our experience was that it was highly unstable even when its looser assumptions should have made it more stable. In fact, if you find applications where it works well and/or works better than other models, please get in touch.
-
Thanks to the contribution of @nakulrrraval , MRTM1 and MRTM2 now also provide additional output parameters when the relevant assumptions are met.
Weights
- I have added two more weighting functions, taking the number of different weighting functions to 9.
- I have also modified the default minimum weight for the weighting to 0.5 instead of 0.7. The latter just seems too high, and using 0 with almost all of the methods results in several TAC points being effectively ignored.
- I have also added the possibility of having a minimum weight which rises to the peak weight. This allows for very low weights in the very first few frames when they are very short, and then having a higher minimum weight value for the remainder of the PET measurement.
Blood modelling
Parent Fraction
-
I have corrected the integrated inverse gamma function. I had implemented a 2-parameter version of this model, which almost never produced optimal fits. From reading a little bit further, I see that the version of this model which is actually in use is a 3- or 4-parameter model, and this model performs substantially better.
-
I have added an integrated gamma function too. This is very similar to the previous model, except that it is based on the gamma, and not the inverse gamma, distribution.
-
I have also renamed the
hill_guomodmodel to thesigmoidmodel, as it is more frequently referred to in this manner.
AIF
- Thanks to @pontusps for spotting this, but there was previously a bug that if whole blood and raw plasma measurements were found, and there was a model fit to the blood-to-plasma ratio, then when fitting the AIF, the raw AIF values provided would be derived from the whole blood and the BPR model, rather than from the plasma values directly when available. This has now been fixed.
Tri-exponential model
-
I have improved the stability of the tri-exponential model. This model could easily fail in the absence of continuous autosampler data at the start. It should now fail less often.
-
I have also added the fact that this model is fitted both using multiple starting points, as well as our guessed starting points from our starting point estimation, since the latter could sometimes outperform the multiple starting points when there were not enough iterations. This selects whichever fit is best of the multstarts and the conventional fit.
kinfitr v0.6.0
This is a big release since the last one.
New BIDS Support
With the changes to the PET BIDS specification, I've incorporated those, and now BIDS data is ingested at a study level. There could still be some changes to the specification in the near future, and there could be a few things that need ironed out for strangely structured BIDS data, but it is certainly working for the current spec.
- The main change here is the
bids_parse_study()function, which parses a whole BIDS study
Blooddata changes
With the new BIDS spec, I've also updated the blooddata object to more closely represent it. I've also expanded upon the ability to extract data, and better compartmentalised these functions, as they were becoming impossible to maintain.
- create_blooddata_components is a little simpler, and now returns the new blooddata objects
bd_getdata()andbd_create_input()replacebd_getdata(), for extracting data from blooddata objects.bd_getdata()is for extracting single kinds of measures, and allows extraction of raw data, predicted data, or interpolated predicted databd_create_input()is for extracting input objects for use in kinetic modelling
- For backward compatibility, in case blooddata objects have been saved with a previous version of kinfitr, there is a
update_blooddata()function for updating to the new format. But some aspects of the new functionality are lost, so better to just create the blooddata objects afresh.
Model Updates
There are two new models, and some new functionality
New Models
- SRTM2, which can be fitted as either a 2 or 3-parameter model
- Linearised 2TCM, which can fit vB or ignore it.
Model Updates
- All linearised models can now be specified with the durations. This gives a theoretically more optimal method for integration, which should also be faster. The normal trapezoidal integration method, requiring only the mid time points are also available, and are still the default if durations are not provided.
- The models with double integrals now produce better parameter estimates, as there was an issue with the second integral. This applies to MA2 and lin2tcm.
Delay Fitting
I've been a little bit bothered by delay fitting for a while now, as you can fit it with the TCMs, but if the delay was clearly still wrong, but the rate constants were bending the curve into shape regardless, it could be hard to fix the delay other than playing with trial-and-error. From the Turku PET Tools pages, I saw that they use the linearised 2TCM and perform a grid search. I've pushed this idea into providing a whole RSS profile, so that we can see all the minima, and choose one that makes most sense, even if the model fit is less idea.
kinfitr::lin2tcm_inpshiftProfileprovides a figure with the log sum of weighted RSS, with the top 3 minima highlighted for better selection of the most appropriate inpshift value.
New Data
I've added a new dataset for testing reference region models which can be played with using data(simref). This is simulated data based on the PBR28 blood curves.
Improved Warnings
kinfitr will now warn if fitted parameters are equal to the upper or lower limits for nonlinear models. This is usually a sign either of bad parameter bounds, or of a bad fit. If the parameter estimates seem reasonable, best to alter the bounds. If they seem unreasonable, best to either try altering the starting values, or to try using multstart.
Misc
- Blood models: Tri-exponential model should be working better, and the spline method is now powered by GAMs, which improves its stability.
- Standard errors: More of the models provide SE estimates now, using the delta method to obtain values which take into consideration the relationships between coefficients for the models for which these are calculated from combinations of other outcomes.
- Unit conversion: From having fluffed unit conversions a few too many times, there's now a specified unit conversion function
unit_convert() - Weighting: There's also a method for calculating weights based on several different methods. I like the default best.
weights_create
kinfitr v0.4.0
There is now some data included in the package: data(pbr28). This dataset includes TACs, processed blood data, BIDS-style raw blood data, as well as a whole suite of blood processing tools and models. I have also added tests for most functions of the package, which has meant that I have caught out loads of bugs. I have added a Travis CI build for continuous integration.
Blooddata
-
Raw BIDS JSON data is now included in the pbr28 data object
-
Functions are included for setting up blooddata from BIDS sidecars, as well as from vectors
-
Functions for plotting blooddata
-
Functions for creating interpolated blooddata from raw blooddata
-
The ability to add fit objects, or model parameters, or fitted values to blooddata objects
-
Several metabolite models have been added
-
A spline-based blood model has been added
-
Tests have been added to check on a lot of these functions, but need some more work
tstarfinders
-
tstar finders can now be run without producing a file output.
-
vB has been added to several of these functions
Styling
- Have applied styler to implement tidyverse styling
Models
-
SRTM-V
-
2TCM1k
Fitting procedures
- In addition to nlsLM, there is now also nls.multstart integrated into all nonlinear fitting models. This allows for multiple starting parameters to be tried out and the best fitting model selected in case there is a possibility of running into a local minimum.
kinfitr 0.2.0
First release