antsx / antsr Goto Github PK
View Code? Open in Web Editor NEWR interface to the ANTs biomedical image processing library
Home Page: https://antsx.github.io/ANTsR
License: Apache License 2.0
R interface to the ANTs biomedical image processing library
Home Page: https://antsx.github.io/ANTsR
License: Apache License 2.0
causes seg fault - likely type issue
library(ANTsR)
boldfn <- getANTsRData( "pcasl" )
bold <- antsImageRead( boldfn , 4 )
fixed<-getAverageOfTimeSeries( bold )
mask<-getMask( fixed )
antsMotionCalculation( bold, mask=mask, fixed=fixed, moreaccurate=0)
antsMotionCalculation( bold, mask=mask, fixed=fixed, moreaccurate=0)
kk<-antsMotionCalculation( bold, mask=mask, fixed=fixed, moreaccurate=0)
Wrap PrintHeader from ANTs into Rcpp.
I am using cropImage:
predlabel = cropImage(predlabel, predlabel, max(predlabel))
At this stage predlabel can be plotted, but it is already corrupt:
"> predlabel
antsImage
Pixel Type : float
Pixel Size :
Dimensions : 32x49x38
Voxel Spacing: 2x2x2
Origin : -93 138.1172 -82
Direction : 1 0 0 0 -1 0 0 0 1
��> predlabel[15,15,15]
index not inside the image : [14, 14, 14]
[1] NA"
After cropping, resampleImage is performed (within mrvnrfs, but I tried manually as well). There is no error but resampleImage produces a corrupt image, it cannot be plotted and getNeirghborhoodInMask is a matrix with 0 columns.
Cropping works fine if I use traditional code:
ttt2 = as.antsImage(as.array(predlabel)[20:80, 30:100, 1:84])
��> ttt2[15,15,15]
, , 1
[,1]
[1,] 0
plot(ttt2)
NULL
ttt3=resampleImage(ttt2, rep(4,3), 0, 1)
plot(ttt3)
NULL
needs work
Remove need for reference, just specify slices and axis.
Write wrapper testANTsRExample function to do stopifnot on examples.
The plot of an image with an overlay shows wrong displacement between the two. Initially I thought this is related to a double conversion antsImage->array->antsImage , but now it's clear that is happening in many other situations, perhaps even with original images. Saving the image and loading in itk-snap shows no displacement between images, so this is a specific problem of the plot function.
Started getting this earlier today on the master branch. But the file seems to exist
src/itkb/itkinst/include/ITK-4.8/itkAddImageFilter.h
src/itks/Modules/Filtering/ImageIntensity/include/itkAddImageFilter.h
Still, R CMD INSTALL ANTsR quickly fails with
antsImage.cpp:6:10: fatal error: 'itkAddImageFilter.h' file not found
^
1 error generated.
make: *** [antsImage.o] Error 1
ERROR: compilation failed for package ‘ANTsR’
labelsimage won't work, due to missing negation and calling missing object limg.
Goal: test ImageMath
for addtozero
:
from man:
addtozero : add image-b to image-a only over points where image-a has zero values
Reproducible example:
require(ANTsR)
require(testthat)
img1_array <- array(rep(2, 5*5), dim=c(5,5))
img1_array[1,2] <- 0
img1_array[2,3] <- 0
img1_array[2,2] <- 0
img1_array[3,3] <- 0
img1_array[4,3] <- 0
img1_array[4,3] <- 0
img1_array[4,4] <- 0
img1_array[4,3] <- 0
img1_array[5,1] <- 0
img2_array <- array(rep(2, 5*5), dim=c(5,5))
so:
> as.array(img1)
[,1] [,2] [,3] [,4] [,5]
[1,] 2 0 2 2 2
[2,] 2 0 0 2 2
[3,] 2 2 0 2 2
[4,] 2 2 0 0 2
[5,] 0 2 2 2 2
and:
> as.array(img2)
[,1] [,2] [,3] [,4] [,5]
[1,] 2 2 2 2 2
[2,] 2 2 2 2 2
[3,] 2 2 2 2 2
[4,] 2 2 2 2 2
[5,] 2 2 2 2 2
Moving on:
img1 <- as.antsImage(img1_array)
img2 <- as.antsImage(img2_array)
output <- antsImageClone(img2)
ImageMath(2, output, 'addtozero', img1, img2)
I would expect to get a homogenous array with 2s, but:
> as.array(output)
[,1] [,2] [,3] [,4] [,5]
[1,] 2 2 2.000000e+00 1.850677e-316 6.926506e-310
[2,] 2 2 2.000000e+00 3.127860e-316 4.940656e-324
[3,] 2 2 0.000000e+00 4.356597e-316 6.926506e-310
[4,] 2 2 4.431769e-321 1.037538e-321 6.926506e-310
[5,] 2 2 6.926606e-310 3.458460e-323 9.881313e-324
to check if casting could be a problem:
> img1@pixeltype
[1] "double"
> img2@pixeltype
[1] "double"
> output@pixeltype
[1] "double"
ImageMath.cxx:
else if( strcmp(operation.c_str(), "addtozero") == 0 && pix1 == 0 )
{
result = pix1 + pix2;
}
else if( strcmp(operation.c_str(), "addtozero") == 0 && pix1 != 0 )
{
result = pix1;
Ideas?
Arman
I don't want to add this as a direct pool request as it may break some code already, but I think you want do this for Ops in general (or at least Arith, Math, and Summary)
https://github.com/muschellij2/ANTsR/blob/master/R/antsImage_Operators.R
I'm not clear as to how you store logicals, and these may cause some problems. It is not as flexible as the operators you've implemented in that you cannot pass the … into as.antsImage (such as mask), but I think that can be added.
Also, you may want to define:
is.antsImage <- function(x){
inherits(x, 'antsImage')
}
or simply:
is.antsImage <- function(x){
is(x, 'antsImage')
}
in case someone extends your class.
see https://github.com/stnava/ANTsR/blob/master/DESCRIPTION#L4-L5
These should be synced. Also you might want to get rid of the date field since it's not necessary and it's easy to forget to update it.
Trying to complete the documentation for LabelClustersUniquely
, can anyone confirm my understanding based on the source code:
Where exactly have you used this before?
Hi, I am trying to get the affine transformation from a .mat file. I can import them via R.matlab::readMat()
and get a list containing $AffineTransform.float.3.3
(a 12x1 matrix) and a 3x1 matrix named $fixed
. Is there an easy way to combine this to a transform matrix (4x4 in my case)?
It looks like this:
$AffineTransform.float.3.3
[,1]
[1,] 1.05657983
[2,] 0.04566867
[3,] 0.03638180
[4,] -0.04745625
[5,] 0.99157244
[6,] -0.15884599
[7,] -0.01750578
[8,] 0.08629224
[9,] 1.02625072
[10,] -3.50945663
[11,] -185.69580078
[12,] 777.48010254
$fixed
[,1]
[1,] -1.3779984
[2,] 0.2889023
[3,] -1098.2500000
attr(,"header")
attr(,"header")$version
[1] "4"
attr(,"header")$endian
[1] "little"
The correct affine matrix (calculated from deformed pointsets using Morpho::computeTransform()
) would be:
[1,] 1.05657998 0.04566868 -0.03638175 -36.51162
[2,] -0.04745618 0.99157235 0.15884597 360.21133
[3,] 0.01750584 -0.08629226 1.02625079 806.26085
[4,] 0.00000000 0.00000000 0.00000000 1.00000
of which the upper-left 3x3 submatrix is (apart from the sign) equivalent to matrix(mat$AffineTransform.float.3.3[1:9],3,3,byrow = T)
Thanks
Stefan
works with + or -
temp = ConAvgDiff.t1[[k]] %>% iMath('Normalize') %>% - brainmask
doesn't work with * and /
temp = ConAvgDiff.t1[[k]] %>% iMath('Normalize') %>% * brainmask
Error: unexpected '*' in "temp = ConAvgDiff.t1[[k]] %>% iMath('Normalize') %>% *"
I am having this issue all the time. AntsImages are unusuable if saved in .R files and then reloaded.
For example, I load antsImages in workspace, save the workspace, and reload it again later. What happens is that antsImages seem to be there, but are compromised. If I try to use them R goes in segmentaiton fault.
There are two examples below, first I load an .R file, use mask from within it and R crashes. Second I remove mask and reload it again, and all works.
Is this a bug or antsImages S4 objects simply cannot be saved?
Welcome! Loading ANTsR...
ANTsR is loaded.
load(file="subjectdata.R")
mask
An object of class "antsImage"
Slot "pixeltype":
[1] "float"
Slot "dimension":
[1] 3
Slot "pointer":
<pointer: (nil)>
ls()
[1] "imageList" "mask" "mydata" "thick" "workfolder"
mat<-imagesToMatrix(imageList, mask)
*** caught segfault ***
address (nil), cause 'memory not mapped'
Traceback:
1: .Call("antsImage_RelationalOperators", e1, e2, region, operator, PACKAGE = "ANTsR")
2: mask > 0
3: mask > 0
4: which(mask > 0)
5: imagesToMatrix(imageList, mask)
Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection: q()
Selection: 3
Welcome! Loading ANTsR...
ANTsR is loaded.
load(file="subjectdata.R")
rm(mask)
mask<-antsImageRead('processing/smo_4_NormCortThick/mask.nii.gz', 3)
mat<-imagesToMatrix(imageList, mask)
I installed the latest ANTsR version from github and noticed that selecting any affine transform causes a segfault. I checked using the command line tool built in src/antb against an older version from 2014-09-29 that works:
old version (runs fine):
~/GIT/DEV/ANTSbuild/bin/antsRegistration -d 3 -m mattes[skull1.mha,skull2.mha,1,32,Regular,0.1] -t rigid[ 1.0 ] -c [1000x100x10,1e-8,20] -s 4x2x1vox -f 3x2x1 -u 1 -o [skull1.mha_fixed_skull1.mha_moving_custom,skull1.mha_fixed_skull1.mha_moving_custom_diff.nii.gz,skull1.mha_fixed_skull1.mha_moving_custom_inv.nii.gz]
new version:
~/GIT/DEV/ANTsR/src/antb/bin/antsRegistration -d 3 -m mattes[skull1.mha,skull2.mha,1,32,Regular,0.1] -t rigid[ 1.0 ] -c [1000x100x10,1e-8,20] -s 4x2x1vox -f 3x2x1 -u 1 -o [skull1.mha_fixed_skull1.mha_moving_custom,skull1.mha_fixed_skull1.mha_moving_custom_diff.nii.gz,skull1.mha_fixed_skull1.mha_moving_custom_inv.nii.gz]
fails with
All_Command_lines_OK
Using double precision for computations.
number of levels = 3
fixed image: skull1.mha
moving image: skull2.mha
Dimension = 3
Number of stages = 1
Use Histogram Matching true
Winsorize image intensities false
Lower quantile = 0
Upper quantile = 1
Stage 1 State
Image metric = Mattes
Fixed image = Image (0x3c44700)
RTTI typeinfo: itk::Image<double, 3u>
Reference Count: 2
Modified Time: 639
Debug: Off
Object Name:
Observers:
none
Source: (none)
Source output name: (none)
Release Data: Off
Data Released: False
Global Release Data: Off
PipelineMTime: 0
UpdateMTime: 448
RealTimeStamp: 0 seconds
LargestPossibleRegion:
Dimension: 3
Index: [0, 0, 0]
Size: [117, 157, 170]
BufferedRegion:
Dimension: 3
Index: [0, 0, 0]
Size: [117, 157, 170]
RequestedRegion:
Dimension: 3
Index: [0, 0, 0]
Size: [117, 157, 170]
Spacing: [1.5, 1.5, 1.5]
Origin: [-88.5114, -114.68, -157.958]
Direction:
1 0 0
0 1 0
0 0 1
IndexToPointMatrix:
1.5 0 0
0 1.5 0
0 0 1.5
PointToIndexMatrix:
0.666667 0 0
0 0.666667 0
0 0 0.666667
Inverse Direction:
1 0 0
0 1 0
0 0 1
PixelContainer:
ImportImageContainer (0x3c449c0)
RTTI typeinfo: itk::ImportImageContainer<unsigned long, double>
Reference Count: 1
Modified Time: 445
Debug: Off
Object Name:
Observers:
none
Pointer: 0x7f131f95b010
Container manages memory: true
Size: 3122730
Capacity: 3122730
Moving image = Image (0x3c48710)
RTTI typeinfo: itk::Image<double, 3u>
Reference Count: 2
Modified Time: 640
Debug: Off
Object Name:
Observers:
none
Source: (none)
Source output name: (none)
Release Data: Off
Data Released: False
Global Release Data: Off
PipelineMTime: 0
UpdateMTime: 637
RealTimeStamp: 0 seconds
LargestPossibleRegion:
Dimension: 3
Index: [0, 0, 0]
Size: [121, 148, 155]
BufferedRegion:
Dimension: 3
Index: [0, 0, 0]
Size: [121, 148, 155]
RequestedRegion:
Dimension: 3
Index: [0, 0, 0]
Size: [121, 148, 155]
Spacing: [1.5, 1.5, 1.5]
Origin: [-85.1487, -103.461, -145.826]
Direction:
1 0 0
0 1 0
0 0 1
IndexToPointMatrix:
1.5 0 0
0 1.5 0
0 0 1.5
PointToIndexMatrix:
0.666667 0 0
0 0.666667 0
0 0 0.666667
Inverse Direction:
1 0 0
0 1 0
0 0 1
PixelContainer:
ImportImageContainer (0x3c49c30)
RTTI typeinfo: itk::ImportImageContainer<unsigned long, double>
Reference Count: 1
Modified Time: 634
Debug: Off
Object Name:
Observers:
none
Pointer: 0x7f131e42d010
Container manages memory: true
Size: 2775740
Capacity: 2775740
Weighting = 1
Sampling strategy = regular
Number of bins = 32
Radius = 4
Sampling percentage = 0.1
Transform = Rigid
Gradient step = 1
Update field sigma (voxel space) = 0
Total field sigma (voxel space) = 0
Update field time sigma = 0
Total field time sigma = 0
Number of time indices = 0
Number of time point samples = 0
Registration using 1 total stages.
Stage 0
iterations = 1000x100x10
convergence threshold = 1e-08
convergence window size = 20
number of levels = 3
using the Mattes MI metric (number of bins = 32, weight = 1)
preprocessing: histogram matching the images
Shrink factors (level 1 out of 3): [3, 3, 3]
Shrink factors (level 2 out of 3): [2, 2, 2]
Shrink factors (level 3 out of 3): [1, 1, 1]
smoothing sigmas per level: [4, 2, 1]
regular sampling (percentage = 0.1)
Segmentation fault (core dumped)
Am I missing something?
Best
Stefan
@armaneshaghi - looks like we need several different options for travis builds
seems that , b/c of limited travis time, we can't do all at once ...
any ideas about how to approach this?
sort of a dual bug ... apply.antsImage gives you some junky header info and plot fails when it gets this - presumably actually cropImage fails ....
but quite nasty because of the segfault
tslice=apply.antsImage( img, c(1,3,4), mean )
plot(tslice)
ITK ExceptionObject caught !
itk::ExceptionObject (0x7faac52003c8)
Location: "unknown"
File: /Users/stnava/code/RLibs/ITKR/libs/include/ITK-4.8/itkImageBase.hxx
Line: 193
Description: itk::ERROR: Image(0x7faac3dbbe70): Bad direction, determinant is 0. Direction is -0 -1 0
0 0 0
0 0 1
libc++abi.dylib: terminating with uncaught exception of type Rcpp::exception: ITK exception caught
Abort trap: 6
MacBook-Pro:wetransfer-2bfbfc stnava$ plot(tslice)
-bash: syntax error near unexpected token `tslice'
First, I want to say thanks for so quickly resolving my last abpBrainExtraction issue, it worked. But, I used a crappy "tem" and "temmask" so I got a crappy brain mask. In an effort to fix this I am trying to use the MNI standard brain as the template and it's very good brain mask as the template mask. I used the code below:
ImageMath 3 close_MP1.nii.gz ClosestSimplifiedHeaderMatrix MP1.nii.gz
ImageMath 3 close_MNI.nii.gz ClosestSimplifiedHeaderMatrix MNInew.nii.gz
ImageMath 3 close_MNImask.nii.gz ClosestSimplifiedHeaderMatrix brainMask.niistruct<-antsImageRead("/Users/Bryson/Data/ANTsR_test/close_MP1.nii.gz")
struct<-abpN4(struct)
tem<-antsImageRead("/Users/Bryson/Data/ANTsR_test/close_MNI.nii.gz")
tem<-abpN4(tem)
temmask<-antsImageRead("/Users/Bryson/Data/ANTsR_test/close_MNImask.nii.gz")bm<-abpBrainExtraction(img=struct,tem=tem,temmask=temmask)
antsImageWrite(bm$bmask, "MP1bmask.nii.gz")
antsImageWrite(bm$brain, "MP1masked.nii.gz")
But the output I got looked more like a head-excluding mask than a brain-including mask.
I've attached the input and output files here:
https://drive.google.com/open?id=0B9oWACI5TJOEfm1KdzAxSG5IdlNZR3QyOEtGa3l2ZEVETHBUQXZyNDJGUGk5YXRNT2N4blk&authuser=0
Thanks again for your help!
this is from R 3.2
... to test examples by themselves, do the following
cd ANTsR # source dir
ln -s inst/extdata .
R
devtools::run_examples()
when you are done, be sure to remove the linked ext data
current findings:
i<-antsImageRead( getANTsRData('r16') , 2 )
iMath(i,"BlobDetector",100)
img<-antsImageRead( getANTsRData("r16"))
mask<-getMask( img )
mask2<-getMask( img )
mask<-iMath(mask,'ME',25)
print(paste( sum(mask2==1), sum(mask==1) ))
i added a test for this in iMathOps ...
seem to be ok .... though i did not look at the results visually. they at least build.
this last issue was resolved with an Imath documentation object
but this was removed for unknown reasons ... i undid this here:
so as not to avoid the variety of things that were breaking.
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>
Have a viewer (decided for MRIcron) that can be launched from R to view an antsImage.
@ntustison - the violators include
This is a really weird error. I want to use foreach loops with multiple processors. If I run a single loop I can capture the output and everything is fine. If I use more than one loop, the output is corrupt and R crashes. Here is the example:
img1 = antsImageRead(getANTsRData('r16'), 2)
img2 = antsImageRead(getANTsRData('r27'), 2)
temp=list(img1,img2)
library(foreach)
library(doMC)
registerDoMC(2)
output = foreach(i=1:1) %dopar% {
kmeansSegmentation(temp[[i]], 3, getMask(temp[[i]]))$segmentation
}
output
[[1]]
antsImage
Pixel Type : float
Pixel Size :
Dimensions : 256x256
Voxel Spacing: 1x1
Origin : 0 0
Direction : 1 0 0 1
output = foreach(i=1:2) %dopar% {
kmeansSegmentation(temp[[i]], 3, getMask(temp[[i]]))$segmentation
}
output
[[1]]
antsImage
Pixel Type : float
Pixel Size :
*** caught segfault ***
address (nil), cause 'memory not mapped'
Traceback:
1: .Call("antsImage_dim", x, PACKAGE = "ANTsR")
2: dim(object)
3: dim(object)
4: paste(dim(object), collapse = "x")
5: cat(" Dimensions :", paste(dim(object), collapse = "x"), "\n")
6: function (object) standardGeneric("show")(<S4 object of class "antsImage">)
7: function (object) standardGeneric("show")(<S4 object of class "antsImage">)
8: print.default(<S4 object of class "antsImage">)
9: print(<S4 object of class "antsImage">)
Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
We could get a DOI for ANTsR and make the whole software citable. Objections?
Step by step guide:
For example:
WarpImageMultiTransform()
Error in .Call("WarpImageMultiTransform", as.character(c(...))) :
"WarpImageMultiTransform" not resolved from current namespace (ANTsR)
I think this example is important because right now you can transform into a fixed space, perform operations, but you cannot go back into the moving space afterward.
gotta be under 100MB for cran
http://cran.r-project.org/doc/manuals/r-release/R-exts.html#Configure-and-cleanup
predlabel2 = predlabel*0
plot(predlabel2)
Error in if (window.img[1] == window.img[2]) window.img[1] <- min(x) :
missing value where TRUE/FALSE needed
Hi,
as I am mostly dealing with Volume and surface data, I momentarily am using a wrapper called antsTransformPoints* (it is an S3 function) calling the command line tool antsApplyTransformsToPoints to apply the transforms to point sets. It takes care of IJK to RAS transform and works on matrices and meshes of class "mesh3d". Would it be a big issue to implement this in ANTsR?
*) vert2points used from Morpho is simply
vert2points <- function (mesh) {
out <- t(mesh$vb[1:3, ])
return(out)
}
Best
Stefan
@ntustison , @bkandel , @dorianps, @jeffduda , @cookpa , @armaneshaghi, @muschellij2
hoping to work toward a CRAN submission for ANTsR - some updates on this topic:
i ran rd2roxygen and dealt with most of the issues. hopefully wont have
to do that again ... so, in the future, we should write documentation
using the roxygen2 style and just roxygenize() regularly.
a couple other changes
@muschellij2 - would appreciate any advice / help on this ....
some advice from wickham: http://www.rstudio.com/products/rpackages/devtools/
it's a very good page with strategies that will help with most of the issues we've had in the past ...
any thoughts appreciated.
@bkandel thought this is bug.
I have a crop mask with 7 slices (83:89), but crop is producing an image with 8 slices.
Get file here:
https://www.dropbox.com/s/ot4ponqk7j221n6/templateBrainMask.nii.gz?dl=0
Run:
brainmask=antsImageRead('templateBrainMask.nii.gz',3)
cropmask=brainmask*0
cropmask[1:192,1:256, 83:89] = 1
cropImage(brainmask,cropmask)
antsImage
Pixel Type : float
Pixel Size :
Dimensions : 192x256x8
Voxel Spacing: 0.9765625x0.9765625x1
Origin : -93 138.1172 1
Direction : 1 0 0 0 -1 0 0 0 1
In advance of the CRAN submission, it would be nice to pare down the functions to emphasize the core utility. Including functions in CRAN submissions implies a commitment to maintaining the function for the foreseeable future. Here is a list of functions that look to me like they either duplicate functionality or can be deleted:
maskImage
quantifySNPs (useful, but not sure it's suitable for ANTsR)
filterfMRIForNetworkAnalysis (overlap with frequencyFilterfMRI? is this still used?)
exemplarInpainting vs. basicInPainting -- why have both? Shouldn't we just have inPaint and have methods for exemplar and basic inpainting?
jointIntensityFusion and ""3D: Why have two functions for different dimensionalities?
renderNetwork and plotBasicNetwork: Can these be combined?
smoothImage -- I have always thought this should be part of iMath. Is there a consensus on this? Would this be too annoying?
visualizeBlob -- looks to me like it's been superseded by the various rendering functions.
Hi,
after your recent revamp, "-DVCL_CAN_STATIC_CONST_INIT_FLOAT=0" was dropped from
-PKG_CPPFLAGS. With this option added, everything builds fine again.
This requires to throw in an -fpermissive flag. Could you please readd this, or is there a reason for dropping it?
Best
Stefan
It would be extremely useful to have a function that can save the entire workspace in a single line. Right now is very difficult to keep track of what is a pointer and what is not, then save them separately, then write code again to load them on new session. A save-all function can take this burden away, create cleaner code with one-line saving, and offer to restart at different levels of a script. Of course, this should be complemented with a load function.
see discussion here:
it's not clear why this would happen but in the meantime you can try an install from the binary releases
or by cloning the repository and using R CMD INSTALL on the cloned repo.
@jeffduda
Issue emerged here: #42
Problem: assigning is performed on wrong slices, and may also contaminate other dimensions
Example:
3D file: https://www.dropbox.com/s/ot4ponqk7j221n6/templateBrainMask.nii.gz?dl=0
brainmask=antsImageRead('templateBrainMask.nii.gz',3)
cropmask=brainmask*0
cropmask[1:192,1:256, 83:89] = 1
plot(cropmask, axis=3, slices=82:90) # should show two black slices on the sides, but it doesn't
plot(cropmask, axis=3, slices=83:91) # this shows two black slices on the sides
Plus cropImage thinks there are 8 slices with some value = 1.
cropImage(brainmask,cropmask)
antsImage
Pixel Type : float
Pixel Size :
Dimensions : 192x256x8
Voxel Spacing: 0.9765625x0.9765625x1
Origin : -93 138.1172 1
Direction : 1 0 0 0 -1 0 0 0 1
antsImageRead/Write does currently not expand path (i.e. antsImageRead("~/myimage.nii.gz") leads to a segfault, the same is if the image to import does not exist.
An aesthetic issue:
Perhaps would be better to have consistent name for make, read, and write image. Maybe is better to have makeImage, readImage, writeImage.
One of the biggest issues when working with 1mm images is the huge matrix size obtained from a full brain 1mm neighborhood matrix with radius 4. The matrix can be 16gb or more.
To my understanding, with higher resolution the neaghboring voxels are increasingly less informative. What I need is not the immediate surrounding voxel layers but further out. The best would be to get i.e. 1st neighrbohood layer, 3rd layer, etc, thus skipping some neighborhood layers.
Would be great if this is achieved with a "step" parameter, or better if can be defined manually, like c(1,3,4) to get 1st layer + 3rd layer + 4th layer.
Let me know if this is not clear.
to run tests in a different repo
When I installed using
library(devtools)
install_github("ANTsR", "stnava")
the install worked fine on MacOSX 10.9.2, R 3.02.
Linux server didn't have CMake so tried the pre-compiled binaries, but didn't work. Install said it was fine, but when libraried in:
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/bst/student/jmuschel/R/x86_64-unknown-linux-gnu-library/3.0/ANTsR/libs/ANTsR.so':
Which I think is because of my version of Rcpp:
http://cran.r-project.org/web/packages/Rcpp/news.html
"Functions provided/used by Rcpp are now registered with R and instantiated by client package alleviating the new for explicit linking against libRcpp which is therefore no longer created."
Thanks a lot for bringing this functionality to R. During installation (Ubuntu 14.04; R 3.1.0) I noticed a couple of compiler errors:
e.g: error: ‘constexpr’ needed for in-class initialization of static data member ‘const float vnl_numeric_traits::one’ of non-integral type
To make the package compile successfully, I needed to set
CPPFLAGS=-fpermissive
in ~/.R/Makevars
Best
Stefan
Why can this not be installed using the "standard" github installer:
library(devtools)
install_github("ANTsR", "stnava")
?
I just installed ANTsR and the problem I am having is with abpBrainExtraction.
I enter the following commands in R in terminal:
struct<-antsImageRead("/Users/Bryson/Data/ANTsR_test/MPRAGE.nii.gz")
tem<-antsImageRead("/Users/Bryson/Data/ANTsR_test/bet.nii.gz")
temmask<-antsImageRead("/Users/Bryson/Data/ANTsR_test/bet_mask.nii.gz")bm<-abpBrainExtraction(img=struct,tem=tem,temmask=temmask)
And I get the following error:
Problem in arg list
see usage by calling antsApplyTransforms() w/o arguments
Error in thresholdImage(temmaskwarped, 0.5, 1) :
trying to get slot "dimension" from an object of a basic class ("numeric") with no slots
So I called antsApplyTransforms() w/o arguments, but it wasn't helpful to me:
antsApplyTransforms()
warpedimg<-antsApplyTransforms( fixed=img1 , moving=img2 ,
transformlist=list("my0GenericAffine.mat","my1Warp.nii.gz") )For full mode: use standard ants call as in antsApplyTransforms full mode ...
antsApplyTransforms("-d","2","-i","r64slice.nii.gz","-o","temp.nii.gz","-r","r16slice.nii.gz","-t","./Z0GenericAffine.mat")
for full help:
use .Call( "antsApplyTransforms", .int_antsProcessArguments( c(list("--help")) ), PACKAGE="ANTsR" );[1] 0
The "img" image is a MPRAGE from the ABIDE dataset.
The "tem" image is the bet brain extracted version of the same image(I wasn't sure what to put here).
And the "temmask" is the brain mask output from bet.
I've run the example in the manual and it runs fine. Also, I tried running abpBrainExtraction.R another time, and although it didn't give me good results (probably from a bad choice of the "tem" image), it did finish without errors. Any ideas on what I can do?
ANTsR will be "broken" for a while ... Being tired of this ongoing issue, I did the aggressive thing and removed imageMath and src/ImageMath.cpp and also updated the antstag s.t. ImageMath is not compiled in core. here are the current issues:
* checking R code for possible problems ... NOTE
aslCensoring : aslOutlierRejection: no visible global function
definition for ‘imageMath’
basicInPaint: no visible global function definition for ‘imageMath’
compcor: no visible global function definition for ‘imageMath’
getCentroids: no visible global function definition for ‘imageMath’
getTemplateCoordinates: no visible global function definition for
‘imageMath’
projectImageAlongAxis: no visible global function definition for
‘imageMath’
sliceTimingCorrection: no visible global function definition for
‘imageMath’
* checking Rd files ... OK
relating to:
ANTsR/R/aslCensoring.R: imageMath(4, diffs, "TimeSeriesSimpleSubtraction", asl)
ANTsR/R/basicInPaint.R: imageMath(img@dimension, temp, "MD", temp, 1)
ANTsR/R/basicInPaint.R: # imageMath(img@dimension,paintMaskUse,'GD',paintMask,1)
ANTsR/R/basicInPaint.R: imageMath(inpainted@dimension, inpainted, "FastMarchingExtension", speedimage,
ANTsR/R/compcor.R: imageMath(4, myoutfn, "CompCorrAuto", fmri, mask, ncompcor)
ANTsR/R/getCentroids.R: imageMath(imagedim, pointfile, "LabelStats", img, img, clustparam)
ANTsR/R/getTemplateCoordinates.R: imageMath(milab@dimension, pointfile, "LabelStats",
ANTsR/R/pairwiseImageDistanceMatrix.R: # broken !! metric <- capture.output(imageMath(dim, 'j', metrictype, i1,
ANTsR/R/projectImageAlongAxis.R: imageMath(imageND@dimension, downimg, "Project", imageND, axis, projtype)
ANTsR/R/sliceTimingCorrection.R: imageMath(4, corrected, "SliceTimingCorrection", fmri, sliceTime, interpolation,
ANTsR/R/sliceTimingCorrection.R: imageMath(4, corrected, "SliceTimingCorrection", fmri, sliceTime, interpolation,
ANTsR/R/sliceTimingCorrection.R: imageMath(4, corrected, "SliceTimingCorrection", fmri, sliceTime)
here is a commit that deals with some of these:
however it would be good to get the rest as well ...
@jeffduda a few pieces of functionality in iMath
@bkandel add x, y, z, t to labelStats ... the output is always 4D centroids ... e.g. in 2D it will contain x_i, y_i, 0, 0 ( or maybe NA, NA ) ....
the other issues should be self explanatory.
I tested the ANTs SmoothImage command and the ANTsR SmoothImage.R function, and I didn't get the same output results with a same sigma in input...
How could this be explained ?
I let you try with my 3D test image ("test.nii") :
http://we.tl/oNkfQirp39
Best regards,
Matthieu
Example:
img <- antsImageRead(getANTsRData('r16'),2)
img[,,]
Error en typeof(i) : el argumento "i" está ausente, sin valor por omisión
img[,1:20]
Error en typeof(i) : el argumento "i" está ausente, sin valor por omisión
img[1:20,]
[1] "'mask' provided is not of type 'logical'"
NULL
The activity should match that of R arrays, where img[, ,] should return all the values in the image.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.