Skip to content

Commit 0b7842d

Browse files
authored
ENH: Expose number of atropos iterations. (#326)
* ENH: Expose number of atropos iterations. * ENH: Modify default input parameters. Checking. * ENH: pkgdown. * ENH: Remove xgboost dependency. * BUG: Forgot to roxygenise.
1 parent 7d58c5a commit 0b7842d

279 files changed

Lines changed: 39334 additions & 8924 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ export(robustMatrixTransform)
136136
export(rsfDenoise)
137137
export(save.ANTsR)
138138
export(segmentShapeFromImage)
139+
export(segmentationRefinement.predict)
139140
export(segmentationRefinement.train)
140141
export(simlr)
141142
export(simlr2)

R/functionalLungSegmentation.R

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
#' @param image input proton-weighted MRI.
99
#' @param mask mask image designating the region to segment.
1010
#' 0/1 = background/foreground.
11-
#' @param numberOfIterations number of Atropos <--> N4 iterations.
11+
#' @param numberOfIterations number of Atropos <--> N4 iterations (outer loop).
12+
#' @param numberOfAtroposIterations number of Atropos iterations (inner loop).
13+
#' If \code{numberOfAtroposIterations = 0}, this is equivalent to K-means with
14+
#' no MRF priors.
1215
#' @param mrfParameters parameters for MRF in Atropos.
1316
#' @param verbose print progress to the screen.
1417
#' @return segmentation image, probability images, and processed input
@@ -27,7 +30,7 @@
2730
#' }
2831
#' @export
2932
functionalLungSegmentation <- function( image, mask, numberOfIterations = 1,
30-
mrfParameters = "[0.3,2x2x2]", verbose = TRUE )
33+
numberOfAtroposIterations = 0, mrfParameters = "[0.3,2x2x2]", verbose = TRUE )
3134
{
3235

3336
if( image@dimension != 3 )
@@ -40,6 +43,11 @@ functionalLungSegmentation <- function( image, mask, numberOfIterations = 1,
4043
stop( "Mask is missing." )
4144
}
4245

46+
if( numberOfIterations < 1 )
47+
{
48+
stop( "numberOfIterations must be >= 1.")
49+
}
50+
4351
generatePureTissueN4WeightMask <- function( probabilityImages )
4452
{
4553
numberOfProbabilityImages <- length( probabilityImages )
@@ -98,8 +106,9 @@ functionalLungSegmentation <- function( image, mask, numberOfIterations = 1,
98106
atroposInitialization <- atroposOutput$probabilityimages
99107
posteriorFormulation = "Socrates[1]"
100108
}
109+
iterations <- paste0( "[", numberOfAtroposIterations, ",0]" )
101110
atroposOutput <- atropos( preprocessedImage, x = dilatedMask, i = atroposInitialization,
102-
m = mrfParameters, c = "[5,0]", priorweight = 0.0, verbose = verbose, p = posteriorFormulation )
111+
m = mrfParameters, c = iterations, priorweight = 0.0, verbose = verbose, p = posteriorFormulation )
103112

104113
weightMask <- generatePureTissueN4WeightMask( atroposOutput$probabilityimages[2:4] )
105114
}

0 commit comments

Comments
 (0)