stnava / superiq

make super-resolution fly: quantitatively and at scale
Apache License 2.0
1 stars 0 forks source link

More atlas libraries #4

Open stnava opened 3 years ago

stnava commented 3 years ago
stnava commented 3 years ago

script for brain extraction of 95 region data

library( ANTsR )
library( ANTsRNet )
fns=Sys.glob("*[0-9].nii.gz")
fnss=Sys.glob("*[0-9]*seg.nii.gz")
for ( x in 1:length(fns) ) {
  ofn = paste0( tools::file_path_sans_ext(fns[x],T), "_brain.nii.gz" )
  print(paste(fns[x],fnss[x]))
  img = antsImageRead( fns[x] )
  seg = antsImageRead( fnss[x] )
  bxt = thresholdImage( seg, 1, Inf ) %>% morphology( "close", 10 ) %>% iMath("FillHoles")
  antsImageWrite( img * bxt, ofn )
}
stnava commented 3 years ago