mathesong / kinfitr

kinfitr: PET Kinetic Modelling Using R
Other
33 stars 7 forks source link

Bug in blmod_exp, unused argument (startpars) #10

Closed pontusps closed 4 years ago

pontusps commented 4 years ago

Hi,

Great package, I really enjoy using it.

I was playing around with fitting input functions and I think i discovered a bug in the blmod_exp function.

blooddata <- create_blooddata_bids(kinfitr::pbr28$jsondata[[1]])
blooddata <- bd_blood_dispcor(blooddata)
aif <- bd_getdata(blooddata, output = "AIF")
blood_fit <- blmod_exp(aif$time,
                       aif$aif,
                       Method = aif$Method, multstart_iter = 1)

Works as intended. However, when you define starting parameters yourself, then it buggs out:

startpars <- blood_fit$par
blood_fit2 <- blmod_exp(aif$time,
                       aif$aif,
                       Method = aif$Method, multstart_iter = 1, start  = startpars)

Produces: Error in purrr::map(startvals, ~(.x - abs(.x 0.5))) : object 'startvals' not found*

I think startvals never gets defined when the user supply inputarg start, but then the code calls on startvals at a later point anyways (e.g. line 16 and 25).

Hope it can be solved whenever you have the time! 😃

mathesong commented 4 years ago

Thanks for the issue! This is definitely a bug. I'll look into this asap.

mathesong commented 4 years ago

Thanks for bringing this up. This is now resolved in https://github.com/mathesong/kinfitr/commit/d11d003c2314d7e3ee146f2d77e72c966bde3e8d .