This assumes that at least images and point sets are passed in - segmentation images are optional. The indexing of point sets will be whichSimulation by whichPoint by dimensionality (e.g. 10 x 25 x 3 for 10 simulations of point sets with 25 points in 3D.

generateDiskPointAndSegmentationData(
  inputImageList,
  pointsetList,
  segmentationImageList,
  segmentationNumbers,
  selector,
  maskIndex,
  smoothHeatMaps = 0,
  numpynames,
  cropping = NULL,
  numberOfSimulations = 16,
  referenceImage = NULL,
  transformType = "rigid",
  noiseModel = "additivegaussian",
  noiseParameters = c(0, 0.002),
  sdSimulatedBiasField = 5e-04,
  sdHistogramWarping = 5e-04,
  sdAffine = 0.2
)

Arguments

inputImageList

list of lists of input images to warp. The internal list sets contains one or more images (per subject) which are assumed to be mutually aligned. The outer list contains multiple subject lists which are randomly sampled to produce output image list.

pointsetList

list of matrices containing point sets where each matrix is of size n-points by dimensionality matching to input segmentation/image data (optional)

segmentationImageList

of segmentation images corresponding to the input image list (optional)

segmentationNumbers

the integer list of values in the segmentation to model

selector

subsets the input lists (eg to define train test splits)

maskIndex

the entry within the list of lists that contains a mask

smoothHeatMaps

numeric greater than zero will cause method to return heatmaps. the value passed here also sets the smoothing parameter passed to smoothImage in pixel/voxel space.

numpynames

the names of the numpy on disk files should include something with the word pointset. Also: the string segmentation if using segmentations and the string mask if using maskIndex and something with the word coordconv if using CC. should include something with the word heatmaps if using heatmaps.

cropping

a vector of size 1 plus image dimensionality where the first parameter indicates which landmark to target and the trailing parameters define the size of the cropping patch. e.g. c(2,32,32,64) would crop a box of size 32 by 32 by 64 around landmark 2.

numberOfSimulations

number of output images/pointsets. Default = 10.

referenceImage

defines the spatial domain for all output images. If the input images do not match the spatial domain of the reference image, we internally resample the target to the reference image. This could have unexpected consequences. Resampling to the reference domain is performed by testing using antsImagePhysicalSpaceConsistency then calling resampleImageToTarget upon failure.

transformType

one of the following options c( "translation", "rigid", "scaleShear", "affine" ). Non-invertible models will not work with point sets.

noiseModel

one of the following options c( "additivegaussian", "saltandpepper", "shot", "speckle" )

noiseParameters

'additivegaussian': c( mean, standardDeviation ), 'saltandpepper': c( probability, saltValue, pepperValue) , 'shot': scale, 'speckle': standardDeviation. Note that the standard deviation, scale, and probability values are max values and are randomly selected in the range [0, noise_parameter]. Also, the "mean", "saltValue" and pepperValue" are assumed to be in the intensity normalized range of [0, 1].

sdSimulatedBiasField

Characterize the standard deviation of the amplitude.

sdHistogramWarping

Determines the strength of the bias field.

sdAffine

Determines the amount of transformation based change

Value

list of array

Author

Avants BB

Examples

library( reticulate ) library( ANTsR ) library( ANTsRNet ) library( surgeRy ) image1 <- antsImageRead( getANTsRData( "r16" ) ) image2 <- antsImageRead( getANTsRData( "r27" ) ) segmentation1 <- thresholdImage( image1, "Otsu", 3 ) segmentation11 = thresholdImage( segmentation1, 1, 1 ) segmentation12 = thresholdImage( segmentation1, 2, 2 ) segmentation13 = thresholdImage( segmentation1, 3, 3 ) segmentation11[1:128,1:256]=0 segmentation12[1:256,1:180]=0 segmentation13[1:256,1:128]=0 segmentation1 = segmentation11 + segmentation12* 2 + segmentation13 * 3 segmentation2 <- thresholdImage( image2, "Otsu", 3 ) segmentation21 = thresholdImage( segmentation2, 1, 1 ) segmentation22 = thresholdImage( segmentation2, 2, 2 ) segmentation23 = thresholdImage( segmentation2, 3, 3 ) segmentation21[1:128,1:256]=0 segmentation22[1:256,1:180]=0 segmentation23[1:256,1:128]=0 segmentation2 = segmentation21 + segmentation22* 2 + segmentation23 * 3 pts1 = getCentroids( segmentation1 )[,1:2] pts2 = getCentroids( segmentation2 )[,1:2] plist = list( pts1, pts2) ilist = list( list( image1 ), list( image2 ) ) slist = list( segmentation1, segmentation2 ) npn = paste0(tempfile(), c('i.npy','pointset.npy','heatmap.npy','coordconv.npy','segmentation.npy') ) temp1 = generateDiskPointAndSegmentationData( ilist, plist, slist, segmentationNumbers = 1:3, numpynames = npn ) temp2 = generateDiskPointAndSegmentationData( ilist, plist, segmentationNumbers = 1:3, numpynames = npn, smoothHeatMaps = 3 ) temp = generateDiskPointAndSegmentationData( ilist, plist, slist, segmentationNumbers = 1:3, numpynames = npn, smoothHeatMaps = 3 ) locimg=as.antsImage( temp$images[1,,,1] ) locseg=as.antsImage( temp$segmentation[1,,,3] ) locseg2=as.antsImage( temp$segmentation[2,,,3] ) locimg2=as.antsImage( temp$images[2,,,1] ) # layout(matrix(1:4,nrow=1)) # plot(locimg,locseg) # plot(locimg,as.antsImage( temp$heatmaps[1,,,3])) # plot(locimg2,locseg2) # plot(locimg2,as.antsImage( temp$heatmaps[2,,,3])) print(getCentroids( thresholdImage(as.antsImage( temp$heatmaps[1,,,1]),0.5,1) ))
#> x y z t #> [1,] 159 133 0 0
print(getCentroids( thresholdImage(as.antsImage( temp$heatmaps[1,,,3]),0.5,1) ))
#> x y z t #> [1,] 127 164 0 0
print(temp$points[1,1,])
#> [1] 159.3520 132.8819
print(temp$points[1,3,])
#> [1] 126.5328 163.7855
mm = makePointsImage( temp$points[1,,], getMask( locimg ) ) mm2 = makePointsImage( temp$points[2,,], getMask( locimg2 ) ) gg1 = thresholdImage(as.antsImage( temp$heatmaps[1,,,1]),0.5,1) %>% antsCopyImageInfo2(ri(1)) gg2 = thresholdImage(as.antsImage( temp$heatmaps[1,,,2]),0.5,1) %>% antsCopyImageInfo2(ri(1)) gg3 = thresholdImage(as.antsImage( temp$heatmaps[1,,,3]),0.5,1) %>% antsCopyImageInfo2(ri(1)) # plot( locimg, mm ) # plot( locimg, gg1*1+gg2*2+gg3*3 )