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

antsAverageImages error #35

Closed
dorianps opened this issue Mar 24, 2015 · 6 comments
Closed

antsAverageImages error #35

dorianps opened this issue Mar 24, 2015 · 6 comments
Assignees

Comments

@dorianps
Copy link
Collaborator

It doesn't seem the variable "template" is needed for anything.

average = antsAverageImages(trn.imgCon, normalize = T)
Error: object 'template' not found

function (imageList, normalize = FALSE)
{
avg <- imageList[[1]] * 0
for (i in imageList) {
if (normalize) {
i <- i/mean(i)
}
template <- template + i
}
avg <- avg/length(imageList)
return(avg)
}
<environment: namespace:ANTsR>

@bkandel bkandel self-assigned this Mar 24, 2015
@dorianps
Copy link
Collaborator Author

Corrected:

antsAverageImages = function (imageList, normalize = FALSE)
{
avg <- imageList[[1]] * 0
for (i in imageList) {
if (normalize) {
i <- i/mean(i)
}
avg <- avg + i
}
avg <- avg/length(imageList)
return(avg)
}

@bkandel bkandel closed this as completed Mar 24, 2015
@bkandel
Copy link
Collaborator

bkandel commented Mar 24, 2015

If the help file for this function had a reproducible example, this bug would have been caught automatically by Travis.

@stnava
Copy link
Member

stnava commented Mar 24, 2015

agreed - the example should be added

brian

On Tue, Mar 24, 2015 at 10:22 AM, bkandel notifications@github.com wrote:

If the help file for this function had a reproducible example, this bug
would have been caught automatically by Travis.


Reply to this email directly or view it on GitHub
#35 (comment).

@dorianps
Copy link
Collaborator Author

Normalization step was missing in fix above:

antsAverageImages = function (imageList, normalize = FALSE)
{
avg <- imageList[[1]] * 0
for (i in imageList) {
if (normalize) {
i <- i/mean(i)
}
avg <- avg + i
}
avg <- avg/length(imageList)
if (normalize) avg = avg %>% iMath('Normalize')
return(avg)
}

@bkandel
Copy link
Collaborator

bkandel commented Mar 24, 2015

The fix I pushed took care of this: 3e97beb

@dorianps
Copy link
Collaborator Author

Good, cause mine above is not good enough, needed another fix.

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

3 participants