Skip to content

antsBOLDNetworkAnalysis function and example #409

@DavidBarriere

Description

@DavidBarriere

Describe the bug
function : antsBOLDNetworkAnalysis doesnt work even in the example provided.

myimg <- antsImageRead(getANTsRData( "ch2" ), 3)
mylab <- antsImageRead(getANTsRData( "ch2a" ), 3)
boldfn <- getANTsRData( "pcasl" )
bold <- antsImageRead( boldfn , 4 )
avgbold <- getAverageOfTimeSeries( bold )
breg <- antsRegistration( avgbold, myimg, typeofTransform = c("AffineFast") )
warpedParcellation <- antsApplyTransforms( avgbold, mylab,
transformlist=breg$fwdtransforms, interpolator="NearestNeighbor" )
mask <- getMask( avgbold )
result <- antsBOLDNetworkAnalysis( bold=bold, mask=mask, warpedParcellation )

Erreur dans missing(k) || is.na(k) :
'length = 18' in coercion to 'logical(1)'

Probably because of splitNDImageToList function :
{
if (class(img) != "antsImage")
stop("Input is not antsImage.")
mydimv = dim(img)
mydim = img@dimension
if (img@dimension < 3)
stop("Input image dimensionality needs to be 3 or greater")
newimgs = list()
for (z in 1:mydimv[mydim]) {
if (mydim == 3)
newimgs[[z]] = makeImage(mydimv[-mydim], img[1:mydimv[1],
1:mydimv[2], z])
if (mydim == 4)
newimgs[[z]] = makeImage(mydimv[-mydim], img[1:mydimv[1],
1:mydimv[2], 1:mydimv[3], z])

}
direction = antsGetDirection(img)[-mydim, -mydim]
spacing = antsGetSpacing(img)[-mydim]
origin = antsGetOrigin(img)[-mydim]
for (im in newimgs) {
antsSetDirection(im, direction)
antsSetSpacing(im, spacing)
antsSetOrigin(im, origin)
}
return(newimgs)
}

When I test as follow I got the error :
**z=1
newimgs[[z]] = makeImage(mydimv[-mydim], img[1:mydimv[1],

  •                                          +                 1:mydimv[2], 1:mydimv[3], z])
    

Erreur dans missing(k) || is.na(k) :
'length = 18' in coercion to 'logical(1)'**

or here :
> img[1:mydimv[1],1:mydimv[2], 1:mydimv[3], z]
Erreur dans missing(k) || is.na(k) :
'length = 18' in coercion to 'logical(1)'

> toto=img[1:64,1:64, 1:18, ]
Erreur dans missing(k) || is.na(k) :
'length = 18' in coercion to 'logical(1)'

but works when I do this :
toto=img[1:64,1:64, , ]

A problem for switching between class 2 matrix ?

Thank you

David

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions