Skip to content
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

Error in blmod_exp_startpars() when end of AIF contains zero values #11

Closed
pontusps opened this issue Jan 29, 2020 · 2 comments
Closed

Comments

@pontusps
Copy link
Contributor

Hi,

Love the package, keep up the good work!

I was playing around with fitting input functions, and I think I found a potential issue in blmod_exp_startpars(). When I have noisy data and get some negative values at the end of my AIF I would like to set them to zero. However, doing so means that line 20 bugs out, were it tries to do some fitting of the end of the AIF:

  exp3_mod <- lm(log(abs(activity)) ~ time, data = blood_exp_part3)

Produces

Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
NA/NaN/Inf in 'y'

I assume this is due to log(abs(0))producing -Inf. Perhaps any zero values inside blood_exp_part3 can be filtered out?

Here's a reproducible example (I think):

blooddata <- create_blooddata_bids(kinfitr::pbr28$jsondata[[1]])
blooddata <- bd_blood_dispcor(blooddata)
aif <- bd_getdata(blooddata, output = "AIF")
aif$aif[length(aif$aif)] <- 0

blood_fit <- blmod_exp(aif$time,
                       aif$aif,
                       Method = aif$Method, multstart_iter = 1)
@pontusps
Copy link
Contributor Author

pontusps commented Jan 30, 2020

Actually, I see now that the user don't even have to set negative values to zero themselves. The fun blmod_tidyinput called early in blmod_exp sets all negative values in the AIF to zero with line

blood$activity <- ifelse(blood$activity < 0, yes = 0, no = blood$activity)

meaning that if you have a single negative value at the end of the AIF, then blmod_exp_startpars will always error out at line 20.

@mathesong
Copy link
Owner

This is adddressed in PR #12 and fixed. Thanks so much for the contribution!

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

No branches or pull requests

2 participants