Skip to content

Commit

Permalink
COMP: Issue with min/max not registering as ANTsRCore::min/max
Browse files Browse the repository at this point in the history
  • Loading branch information
ntustison committed Mar 29, 2024
1 parent 29547a6 commit ddd3d76
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 17 deletions.
7 changes: 2 additions & 5 deletions R/cerebellumMorphology.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ cerebellumMorphology <- function( t1, cerebellumMask = NULL,
t1TemplateBrainMask <- antsImageRead( getANTsXNetData( "magetTemplateBrainMask" ) )
t1TemplateBrain <- t1Template * t1TemplateBrainMask
t1CerebellumTemplate <- antsImageRead( getANTsXNetData( "magetCerebellumTemplate" ) )
t1CerebellumTemplate <- ( ( t1CerebellumTemplate - min( t1CerebellumTemplate ) ) /
( max( t1CerebellumTemplate ) - min( t1CerebellumTemplate ) ) )
t1CerebellumTemplate <- iMath( t1CerebellumTemplate, "Normalize" )
cerebellumxTemplateXfrm <- getANTsXNetData( "magetCerebellumxTemplate0GenericAffine" )

# spatial priors are in the space of the cerebellar template. First three are
Expand Down Expand Up @@ -262,9 +261,7 @@ cerebellumMorphology <- function( t1, cerebellumMask = NULL,
t1PreprocessedInCerebellumSpace <- t1PreprocessedInCerebellumSpace * t1PreprocessedMaskInCerebellumSpace
}

t1PreprocessedInCerebellumSpace <-
( t1PreprocessedInCerebellumSpace - min( t1PreprocessedInCerebellumSpace ) ) /
( max( t1PreprocessedInCerebellumSpace ) - min( t1PreprocessedInCerebellumSpace ) )
t1PreprocessedInCerebellumSpace <- iMath( t1PreprocessedInCerebellumSpace, "Normalize" )

batchX <- array( data = 0, dim = c( 2, imageSize, channelSize ) )
batchX[1,,,,1] <- as.array( padOrCropImageToSize( t1PreprocessedInCerebellumSpace, imageSize ) )
Expand Down
4 changes: 2 additions & 2 deletions R/chexnet.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ checkXrayLungOrientation <- function( image,
antsxnetCacheDirectory = antsxnetCacheDirectory )
model$load_weights( weightsFileName )

imageMin <- min( resampledImage )
imageMax <- max( resampledImage )
imageMin <- ANTsRCore::min( resampledImage )
imageMax <- ANTsRCore::max( resampledImage )
normalizedImage <- antsImageClone( resampledImage )
normalizedImage <- ( normalizedImage - imageMin ) / ( imageMax - imageMin )

Expand Down
8 changes: 4 additions & 4 deletions R/deepFlash.R
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@ deepFlash <- function( t1, t2 = NULL, doPreprocessing = TRUE,
direction <- antsGetDirection( tmpCropped )

t1TemplateRoiLeft <- cropIndices( t1Template, lowerBoundLeft, upperBoundLeft )
t1TemplateRoiLeft <- ( t1TemplateRoiLeft - min( t1TemplateRoiLeft ) ) / ( max( t1TemplateRoiLeft ) - min( t1TemplateRoiLeft ) ) * 2.0 - 1.0
t1TemplateRoiLeft <- iMath( t1TemplateRoiLeft, "Normalize" ) * 2.0 - 1.0
t2TemplateRoiLeft <- NULL
if( ! is.null( t2Template ) )
{
t2TemplateRoiLeft <- cropIndices( t2Template, lowerBoundLeft, upperBoundLeft )
t1TemplateRoiLeft <- ( t2TemplateRoiLeft - min( t2TemplateRoiLeft ) ) / ( max( t2TemplateRoiLeft ) - min( t2TemplateRoiLeft ) ) * 2.0 - 1.0
t2TemplateRoiLeft <- iMath( t2TemplateRoiLeft, "Normalize" ) * 2.0 - 1.0
}

labelsRight <- labels[seq.int( 3, length( labels ), by = 2)]
Expand All @@ -209,12 +209,12 @@ deepFlash <- function( t1, t2 = NULL, doPreprocessing = TRUE,
originRight <- antsGetOrigin( tmpCropped )

t1TemplateRoiRight <- cropIndices( t1Template, lowerBoundRight, upperBoundRight )
t1TemplateRoiRight <- ( t1TemplateRoiRight - min( t1TemplateRoiRight ) ) / ( max( t1TemplateRoiRight ) - min( t1TemplateRoiRight ) ) * 2.0 - 1.0
t1TemplateRoiRight <- iMath( t1TemplateRoiRight, "Normalize" ) * 2.0 - 1.0
t2TemplateRoiRight <- NULL
if( ! is.null( t2Template ) )
{
t2TemplateRoiRight <- cropIndices( t2Template, lowerBoundRight, upperBoundRight )
t2TemplateRoiRight <- ( t2TemplateRoiRight - min( t2TemplateRoiRight ) ) / ( max( t2TemplateRoiRight ) - min( t2TemplateRoiRight ) ) * 2.0 - 1.0
t2TemplateRoiRight <- iMath( t2TemplateRoiRight, "Normalize" ) * 2.0 - 1.0
}

################################
Expand Down
2 changes: 1 addition & 1 deletion R/histogramWarpImageIntensities.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ histogramWarpImageIntensities <- function( image,
transformedArray[indices] <- intensities + xfrm
}
transformedImage <- as.antsImage( transformedArray, reference = image ) *
( max( image ) - min( image ) ) + min( image )
( ANTsRCore::max( image ) - ANTsRCore::min( image ) ) + ANTsRCore::min( image )

return( transformedImage )
}
4 changes: 2 additions & 2 deletions R/histology.R
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ allenEx5BrainExtraction <- function( image, view = c( "coronal", "sagittal" ),
} else {
slice <- imageChannels[[i]]
}
if( max( slice ) > min( slice ) )
if( ANTsRCore::max( slice ) > ANTsRCore::min( slice ) )
{
sliceResampled <- resampleImage( slice, resampledImageSize, useVoxels = TRUE, interpType = 0 )
sliceArray <- as.array( sliceResampled )
Expand Down Expand Up @@ -347,7 +347,7 @@ allenHistologyBrainMask <- function( image,
} else {
slice <- imageChannels[[i]]
}
if( max( slice ) > min( slice ) )
if( ANTsRCore::max( slice ) > ANTsRCore::min( slice ) )
{
sliceResampled <- resampleImage( slice, resampledImageSize, useVoxels = TRUE, interpType = 0 )
sliceArray <- as.array( sliceResampled )
Expand Down
2 changes: 1 addition & 1 deletion R/hypothalamusSegmentation.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ hypothalamusSegmentation <- function( t1,
#
################################

t1Warped <- ( t1Warped - min( t1Warped ) ) / ( max( t1Warped ) - min( t1Warped ) )
t1Warped <- iMath( t1Warped, "Normalize" )

################################
#
Expand Down
3 changes: 1 addition & 2 deletions R/mriModalityClassification.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ mriModalityClassification <- function( image,
center = centerOfMassTemplate,
translation = centerOfMassImage - centerOfMassTemplate )
image <- applyAntsrTransformToImage( xfrm, image, template )

image <- ( image - min( image ) ) / ( max( image ) - min( image ) )
image <- iMath( image, "Normalize" )

################################
#
Expand Down

0 comments on commit ddd3d76

Please sign in to comment.