dorianps / LINDA

Lesion Identification with Neighborhood Data Analysis
Apache License 2.0
21 stars 2 forks source link

Made a package #11

Closed muschellij2 closed 6 years ago

muschellij2 commented 6 years ago

This should fix #10. I think it has all the components necessary for a package, but haven't tested with an actual scan. I compute the ch2 to template on the fly, which takes time, but not that much overhead in the scheme of things. I use SyN for that, but I'm not sure if that what was used to get the registration to begin with.

If you add some tests and such, please consider submitting to neuroconductor: https://neuroconductor.org/submit-package

dorianps commented 6 years ago

This is massive and fantastic work. I tried to test it out overnight but gave me some errors and failed midway. Will need to see where it's coming from. If you want to try it yourself, I can send you a stroke example.

Dorian

> LINDA::linda_predict(filename)
00:09 Creating folder: /home/dorian/test-LINDA/linda
00:09 Loading file:
00:09 Loading template...
00:09 Skull stripping... (long process)
00:09 Running iteration 1
 bad det -1 v 1 u -1
 bad det -1 v 1 u -1 new 1
WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0x8aacb90): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0x39fbaa0): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

00:11 Running iteration 2
 bad det -1 v 1 u -1
 bad det -1 v 1 u -1 new 1
WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0xee430c0): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0x9b57fb0): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

00:14 Saving skull stripped files
00:14 Loading LINDA model
00:14 Computing asymmetry mask...
00:14 Saving asymmetry mask...
00:14 Running registration...
00:14 Feature calculation... 
WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0xee769a0): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0xea99d00): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

Error in as.vector(x, mode) : 
  cannot coerce type 'closure' to vector of type 'any'
In addition: Warning message:
In if (!is.na(mask[1])) { :
  the condition has length > 1 and only the first element will be used

Files produced:

image

muschellij2 commented 6 years ago

Can you do a traceback() and run sessioninfo::session_info() afterwards? I have added some caching to the mix so we can maybe diagnose faster.

John

On Sat, Nov 3, 2018 at 9:51 AM dorianps notifications@github.com wrote:

This is massive and fantastic work. I tried to test it out overnight but gave me some errors and failed midway. Will need to see where it's coming from. If you want to try it yourself, I can send you a stroke example.

Dorian

LINDA::linda_predict(filename) 00:09 Creating folder: /home/dorian/test-LINDA/linda 00:09 Loading file: 00:09 Loading template... 00:09 Skull stripping... (long process) 00:09 Running iteration 1 bad det -1 v 1 u -1 bad det -1 v 1 u -1 new 1 WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0x8aacb90): The input list sample has <= 1 element. Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0x39fbaa0): The input list sample has <= 1 element. Function evaluations will be equal to 0.

00:11 Running iteration 2 bad det -1 v 1 u -1 bad det -1 v 1 u -1 new 1 WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0xee430c0): The input list sample has <= 1 element. Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0x9b57fb0): The input list sample has <= 1 element. Function evaluations will be equal to 0.

00:14 Saving skull stripped files 00:14 Loading LINDA model 00:14 Computing asymmetry mask... 00:14 Saving asymmetry mask... 00:14 Running registration... 00:14 Feature calculation... WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0xee769a0): The input list sample has <= 1 element. Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0xea99d00): The input list sample has <= 1 element. Function evaluations will be equal to 0.

Error in as.vector(x, mode) : cannot coerce type 'closure' to vector of type 'any' In addition: Warning message: In if (!is.na(mask[1])) { : the condition has length > 1 and only the first element will be used

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dorianps/LINDA/pull/11#issuecomment-435589514, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBnruo3dbCHW-zuXPQFyb2zGiIZxJWNks5urZ93gaJpZM4YMczA .

dorianps commented 6 years ago
> sessionInfo()
R version 3.5.0 (2018-04-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS: /home/APPS/R/3.5.0/lib64/R/lib/libRblas.so
LAPACK: /home/APPS/R/3.5.0/lib64/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods  
[7] base     

other attached packages:
[1] LINDA_0.3.0

loaded via a namespace (and not attached):
 [1] compiler_3.5.0      RcppEigen_0.3.3.4.0 magrittr_1.5       
 [4] Matrix_1.2-14       tools_3.5.0         ITKR_0.4.17.5      
 [7] yaml_2.1.19         Rcpp_0.12.19        grid_3.5.0         
[10] ANTsR_0.4.6         ANTsRCore_0.6.0     lattice_0.20-35
> traceback()
13: as.vector(sigma)
12: .smoothImageHelper(inimg, sigma, sigmaInPhysicalCoordinates, 
        FWHM, max_kernel_width)
11: smoothImage(., sigma = sigma)
10: function_list[[i]](value)
9: freduce(value, `_function_list`)
8: `_fseq`(`_lhs`)
7: eval(quote(`_fseq`(`_lhs`)), env, env)
6: eval(quote(`_fseq`(`_lhs`)), env, env)
5: withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
4: img %>% smoothImage(sigma = sigma) %>% iMath(truncate, 0.001, 
       0.999) %>% iMath("Normalize")
3: getLesionFeatures(reg$warpedfixout, template_brain, tempmask, 
       sigma = sigma)
2: run_prediction(img = simg, brain_mask = submask, template_mask = tempmask, 
       voxel_resampling = voxel_resampling, template_brain = tempbrain, 
       typeofTransform = "SyN", lesion_mask = mask.lesion1, reflaxis = reflaxis, 
       verbose = verbose)
1: LINDA::linda_predict(filename)
muschellij2 commented 6 years ago

Should be fixed - reinstall.

John

On Sat, Nov 3, 2018 at 11:28 AM dorianps notifications@github.com wrote:

sessionInfo() R version 3.5.0 (2018-04-23) Platform: x86_64-pc-linux-gnu (64-bit) Running under: CentOS Linux 7 (Core)

Matrix products: default BLAS: /home/APPS/R/3.5.0/lib64/R/lib/libRblas.so LAPACK: /home/APPS/R/3.5.0/lib64/R/lib/libRlapack.so

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages: [1] stats graphics grDevices utils datasets methods [7] base

other attached packages: [1] LINDA_0.3.0

loaded via a namespace (and not attached): [1] compiler_3.5.0 RcppEigen_0.3.3.4.0 magrittr_1.5 [4] Matrix_1.2-14 tools_3.5.0 ITKR_0.4.17.5 [7] yaml_2.1.19 Rcpp_0.12.19 grid_3.5.0 [10] ANTsR_0.4.6 ANTsRCore_0.6.0 lattice_0.20-35

traceback() 13: as.vector(sigma) 12: .smoothImageHelper(inimg, sigma, sigmaInPhysicalCoordinates, FWHM, max_kernel_width) 11: smoothImage(., sigma = sigma) 10: function_list[i] 9: freduce(value, _function_list) 8: _fseq(_lhs) 7: eval(quote(_fseq(_lhs)), env, env) 6: eval(quote(_fseq(_lhs)), env, env) 5: withVisible(eval(quote(_fseq(_lhs)), env, env)) 4: img %>% smoothImage(sigma = sigma) %>% iMath(truncate, 0.001, 0.999) %>% iMath("Normalize") 3: getLesionFeatures(reg$warpedfixout, template_brain, tempmask, sigma = sigma) 2: run_prediction(img = simg, brain_mask = submask, template_mask = tempmask, voxel_resampling = voxel_resampling, template_brain = tempbrain, typeofTransform = "SyN", lesion_mask = mask.lesion1, reflaxis = reflaxis, verbose = verbose) 1: LINDA::linda_predict(filename)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dorianps/LINDA/pull/11#issuecomment-435596401, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBnrl3L-7qx9nzH9VBybonzwYdVNJ8Jks5urbYigaJpZM4YMczA .

dorianps commented 6 years ago
> LINDA::linda_predict(filename)
12:11 Creating folder: /home/dorian/test-LINDA/linda
12:11 Loading file:
12:11 Loading template...
12:11 Skull stripping... (long process)
12:11 Running iteration 1
 bad det -1 v 1 u -1
 bad det -1 v 1 u -1 new 1
WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0xc9eeba0): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0xe557190): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

12:14 Running iteration 2
 bad det -1 v 1 u -1
 bad det -1 v 1 u -1 new 1
WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0xc4bdb60): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0xb77c330): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

12:16 Saving skull stripped files
12:16 Loading LINDA model
12:16 Computing asymmetry mask...
12:16 Saving asymmetry mask...
12:16 Running registration...
12:17 Feature calculation... 
WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0xa4c3690): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0xdafc5f0): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

12:19 Running prediction...
Error in resampleImage(y[[i]], subdim, useVoxels = 1, interpType = as.numeric(asFactors)) : 
  trying to get slot "pixeltype" from an object (class "randomForest") that is not an S4 object 
In addition: Warning message:
In if (!is.na(mask[1])) { :
  the condition has length > 1 and only the first element will be used
> traceback()
7: resampleImage(y[[i]], subdim, useVoxels = 1, interpType = as.numeric(asFactors))
6: vwnrfs(y, x, labelmasks[[1]], rad, nsamples, ntrees, asFactors, 
       reduceFactor = mr)
5: ANTsR::mrvnrfs(rflist, list(features), predlabel.sub, rad = rad, 
       multiResSchedule = mr, voxchunk = 5000)
4: withCallingHandlers(expr, message = function(c) invokeRestart("muffleMessage"))
3: suppressMessages(ANTsR::mrvnrfs(rflist, list(features), predlabel.sub, 
       rad = rad, multiResSchedule = mr, voxchunk = 5000))
2: run_prediction(img = simg, brain_mask = submask, template_mask = tempmask, 
       voxel_resampling = voxel_resampling, template_brain = tempbrain, 
       typeofTransform = "SyN", lesion_mask = mask.lesion1, reflaxis = reflaxis, 
       sigma = sigma, verbose = verbose)
1: LINDA::linda_predict(filename)
dorianps commented 6 years ago

I tried the old LINDA and that shows a bunch of warnings, too, but it finishes through the end. The result is crap though. I am testing a case from which I have an old LINDA segmentation to see if I can replicate that one with the old LINDA at least. If that doesn't work, there might be a much deeper problem with changes in ANTsR that compromise even the old LINDA code.

Output from current release 0.2.7:

> source('linda_predict.R')
12:58 Starting LINDA v0.2.7 ...
Loading required package: ANTsRCore

Attaching package: ‘ANTsRCore’

The following object is masked from ‘package:stats’:

    var

The following objects are masked from ‘package:base’:

    all, any, apply, max, min, prod, range, sum

randomForest 4.6-14
Type rfNews() to see new features/changes/bug fixes.
12:59 Loading file: MR0042-2_2014_10_15_1429_0002_t1_mpr_AX_MPRAGE.nii.gz 
12:59 Creating folder: /home/dorian/test-LINDAold/linda 
12:59 Loading template... 
12:59 Skull stripping... (long process) 
 bad det -1 v 1 u -1
 bad det -1 v 1 u -1 new 1
WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0x20398c0): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0xa6a33b0): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

 bad det -1 v 1 u -1
 bad det -1 v 1 u -1 new 1
WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0x8747060): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0xe1d5a40): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

13:04 Saving skull stripped files 
13:04 Loading LINDA model 
13:04 Computing asymmetry mask... 
13:04 Saving asymmetry mask... 
13:04 Running 1st registration... 
13:05 Feature calculation... 
WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0xab6aa00): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0x2bb7e10): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

13:07 Running 1st prediction... 
13:07 Saving 1st prediction... 
13:07 Backprojecting 1st prediction... 
13:07 Running 2nd registration... 
13:08 Feature calculation... 
WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0x9185ad0): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0x907e330): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

13:10 Running 2nd prediction... 
13:10 Saving 2nd prediction... 
13:10 Backprojecting 2nd prediction... 
13:10 Running 3rd registration... (long process)
13:42 Saving 3rd registration results... 
13:42 Feature calculation... 
WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0xc21fee80): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0x9dffd10): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

13:44 Running 3rd prediction... 
13:45 Saving 3rd final prediction... 
13:45 Saving 3rd final prediction in template space... 
13:45 Saving 3rd final prediction in native space... 
13:45 Saving probabilistic prediction in template space... 
13:45 Saving probabilistic prediction in native space... 
13:45 Transferring data in MNI (ch2) space... 
13:45 Saving subject in MNI (ch2) space... 
13:45 Saving lesion in MNI (ch2) space... 
DONEWarning messages:
1: In if (!is.na(mask[1])) { :
  the condition has length > 1 and only the first element will be used
2: In if (!is.na(mask[1])) { :
  the condition has length > 1 and only the first element will be used
3: In if (!is.na(mask[1])) { :
  the condition has length > 1 and only the first element will be used
muschellij2 commented 6 years ago

I was using the mrfvs from ANTsR which may be a problem

On Sat, Nov 3, 2018 at 5:26 PM dorianps notifications@github.com wrote:

I tried the old LINDA and that shows a bunch of warnings, too, but it finishes through the end. The result is crap though. I am testing a case from which I have an old LINDA segmentation to see if I can replicate that one with the old LINDA at least. If that doesn't work, there might be a much deeper problem with changes in ANTsR that compromise even the old LINDA code.

Output from the old LINDA, release 0.2.7:

source('linda_predict.R') 12:58 Starting LINDA v0.2.7 ... Loading required package: ANTsRCore

Attaching package: ‘ANTsRCore’

The following object is masked from ‘package:stats’:

var

The following objects are masked from ‘package:base’:

all, any, apply, max, min, prod, range, sum

randomForest 4.6-14 Type rfNews() to see new features/changes/bug fixes. 12:59 Loading file: MR0042-2_2014_10_15_1429_0002_t1_mpr_AX_MPRAGE.nii.gz 12:59 Creating folder: /home/dorian/test-LINDAold/linda 12:59 Loading template... 12:59 Skull stripping... (long process) bad det -1 v 1 u -1 bad det -1 v 1 u -1 new 1 WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0x20398c0): The input list sample has <= 1 element. Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0xa6a33b0): The input list sample has <= 1 element. Function evaluations will be equal to 0.

bad det -1 v 1 u -1 bad det -1 v 1 u -1 new 1 WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0x8747060): The input list sample has <= 1 element. Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0xe1d5a40): The input list sample has <= 1 element. Function evaluations will be equal to 0.

13:04 Saving skull stripped files 13:04 Loading LINDA model 13:04 Computing asymmetry mask... 13:04 Saving asymmetry mask... 13:04 Running 1st registration... 13:05 Feature calculation... WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0xab6aa00): The input list sample has <= 1 element. Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0x2bb7e10): The input list sample has <= 1 element. Function evaluations will be equal to 0.

13:07 Running 1st prediction... 13:07 Saving 1st prediction... 13:07 Backprojecting 1st prediction... 13:07 Running 2nd registration... 13:08 Feature calculation... WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0x9185ad0): The input list sample has <= 1 element. Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0x907e330): The input list sample has <= 1 element. Function evaluations will be equal to 0.

13:10 Running 2nd prediction... 13:10 Saving 2nd prediction... 13:10 Backprojecting 2nd prediction... 13:10 Running 3rd registration... (long process) 13:42 Saving 3rd registration results... 13:42 Feature calculation... WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0xc21fee80): The input list sample has <= 1 element. Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0x9dffd10): The input list sample has <= 1 element. Function evaluations will be equal to 0.

13:44 Running 3rd prediction... 13:45 Saving 3rd final prediction... 13:45 Saving 3rd final prediction in template space... 13:45 Saving 3rd final prediction in native space... 13:45 Saving probabilistic prediction in template space... 13:45 Saving probabilistic prediction in native space... 13:45 Transferring data in MNI (ch2) space... 13:45 Saving subject in MNI (ch2) space... 13:45 Saving lesion in MNI (ch2) space... DONEWarning messages: 1: In if (!is.na(mask[1])) { : the condition has length > 1 and only the first element will be used 2: In if (!is.na(mask[1])) { : the condition has length > 1 and only the first element will be used 3: In if (!is.na(mask[1])) { : the condition has length > 1 and only the first element will be used

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dorianps/LINDA/pull/11#issuecomment-435622123, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBnrjydglyUxCF_11qnIb8BURD_BXUgks5urgoWgaJpZM4YMczA .

-- John

dorianps commented 6 years ago

That doesn't explain why the old code produced such a bad result. Will need to make sure the old code works on a verified case before resolving the rest.

Any idea why there are so many warnings in ANTsR now? I am not aware of significant changes that can break older scripts. Could it be related to ITKv5?

On Sat, Nov 3, 2018, 5:33 PM John Muschelli <notifications@github.com wrote:

I was using the mrfvs from ANTsR which may be a problem

On Sat, Nov 3, 2018 at 5:26 PM dorianps notifications@github.com wrote:

I tried the old LINDA and that shows a bunch of warnings, too, but it finishes through the end. The result is crap though. I am testing a case from which I have an old LINDA segmentation to see if I can replicate that one with the old LINDA at least. If that doesn't work, there might be a much deeper problem with changes in ANTsR that compromise even the old LINDA code.

Output from the old LINDA, release 0.2.7:

source('linda_predict.R') 12:58 Starting LINDA v0.2.7 ... Loading required package: ANTsRCore

Attaching package: ‘ANTsRCore’

The following object is masked from ‘package:stats’:

var

The following objects are masked from ‘package:base’:

all, any, apply, max, min, prod, range, sum

randomForest 4.6-14 Type rfNews() to see new features/changes/bug fixes. 12:59 Loading file: MR0042-2_2014_10_15_1429_0002_t1_mpr_AX_MPRAGE.nii.gz 12:59 Creating folder: /home/dorian/test-LINDAold/linda 12:59 Loading template... 12:59 Skull stripping... (long process) bad det -1 v 1 u -1 bad det -1 v 1 u -1 new 1 WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0x20398c0): The input list sample has <= 1 element. Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0xa6a33b0): The input list sample has <= 1 element. Function evaluations will be equal to 0.

bad det -1 v 1 u -1 bad det -1 v 1 u -1 new 1 WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0x8747060): The input list sample has <= 1 element. Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0xe1d5a40): The input list sample has <= 1 element. Function evaluations will be equal to 0.

13:04 Saving skull stripped files 13:04 Loading LINDA model 13:04 Computing asymmetry mask... 13:04 Saving asymmetry mask... 13:04 Running 1st registration... 13:05 Feature calculation... WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0xab6aa00): The input list sample has <= 1 element. Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0x2bb7e10): The input list sample has <= 1 element. Function evaluations will be equal to 0.

13:07 Running 1st prediction... 13:07 Saving 1st prediction... 13:07 Backprojecting 1st prediction... 13:07 Running 2nd registration... 13:08 Feature calculation... WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0x9185ad0): The input list sample has <= 1 element. Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0x907e330): The input list sample has <= 1 element. Function evaluations will be equal to 0.

13:10 Running 2nd prediction... 13:10 Saving 2nd prediction... 13:10 Backprojecting 2nd prediction... 13:10 Running 3rd registration... (long process) 13:42 Saving 3rd registration results... 13:42 Feature calculation... WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0xc21fee80): The input list sample has <= 1 element. Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122 GaussianListSampleFunction (0x9dffd10): The input list sample has <= 1 element. Function evaluations will be equal to 0.

13:44 Running 3rd prediction... 13:45 Saving 3rd final prediction... 13:45 Saving 3rd final prediction in template space... 13:45 Saving 3rd final prediction in native space... 13:45 Saving probabilistic prediction in template space... 13:45 Saving probabilistic prediction in native space... 13:45 Transferring data in MNI (ch2) space... 13:45 Saving subject in MNI (ch2) space... 13:45 Saving lesion in MNI (ch2) space... DONEWarning messages: 1: In if (!is.na(mask[1])) { : the condition has length > 1 and only the first element will be used 2: In if (!is.na(mask[1])) { : the condition has length > 1 and only the first element will be used 3: In if (!is.na(mask[1])) { : the condition has length > 1 and only the first element will be used

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dorianps/LINDA/pull/11#issuecomment-435622123, or mute the thread < https://github.com/notifications/unsubscribe-auth/ABBnrjydglyUxCF_11qnIb8BURD_BXUgks5urgoWgaJpZM4YMczA

.

-- John

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dorianps/LINDA/pull/11#issuecomment-435622499, or mute the thread https://github.com/notifications/unsubscribe-auth/AIqafdiRC3zcCNvnIndeKlSRIb5v7MtKks5urguNgaJpZM4YMczA .

dorianps commented 6 years ago

I can confirm that even the current LINDA v0.2.7 produces bad results. There might be an issue with changes in ANTsR.

17:22 Starting LINDA v0.2.7 ...
Loading required package: ANTsRCore

Attaching package: ?ANTsRCore?

The following object is masked from ?package:stats?:

    var

The following objects are masked from ?package:base?:

    all, any, apply, max, min, prod, range, sum

randomForest 4.6-14
Type rfNews() to see new features/changes/bug fixes.
17:22 Loading file: TMT_MPRAGE.nii 
17:22 Creating folder: /home/dorian/test-LINDA_TMTold/linda 
17:22 Loading template... 
17:22 Skull stripping... (long process) 
WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0xed68150): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0x4648b40): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0x9196030): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0xe8c54a0): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

17:29 Saving skull stripped files 
17:29 Loading LINDA model 
17:29 Computing asymmetry mask... 
17:29 Saving asymmetry mask... 
17:29 Running 1st registration... 
17:30 Feature calculation... 
WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0x8906960): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0xd0f0490): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

17:32 Running 1st prediction... 
17:32 Saving 1st prediction... 
17:32 Backprojecting 1st prediction... 
17:32 Running 2nd registration... 
17:33 Feature calculation... 
WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0x9e1a410): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

WARNING: In /home/dorian/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx, line 122
GaussianListSampleFunction (0x183a9410): The input list sample has <= 1 element.  Function evaluations will be equal to 0.

17:35 Running 2nd prediction... 
17:36 Saving 2nd prediction... 
17:36 Backprojecting 2nd prediction... 
17:36 Running 3rd registration... (long process)
18:00 Saving 3rd registration results... 
18:01 Feature calculation... 
18:06 Running 3rd prediction... 
18:06 Saving 3rd final prediction... 
18:06 Saving 3rd final prediction in template space... 
18:06 Saving 3rd final prediction in native space... 
18:06 Saving probabilistic prediction in template space... 
18:06 Saving probabilistic prediction in native space... 
18:06 Transferring data in MNI (ch2) space... 
18:06 Saving subject in MNI (ch2) space... 
18:06 Saving lesion in MNI (ch2) space... 
DONEWarning messages:
1: In if (!is.na(mask[1])) { :
  the condition has length > 1 and only the first element will be used
2: In if (!is.na(mask[1])) { :
  the condition has length > 1 and only the first element will be used
3: In if (!is.na(mask[1])) { :
  the condition has length > 1 and only the first element will be used

Output: image

Older output when LINDA worked: image

muschellij2 commented 6 years ago

I'm getting some odd things with new ANTsR. I would recommend setting verbose to 2. Getting odd error with Atropos:

itk::ExceptionObject (0x7fdc2e0758c8)
Location: "unknown" 
File: /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpnLxSMu/R.INSTALL93804bfeb58b/ANTsRCore/src/ants/ImageSegmentation/antsGaussianListSampleFunction.hxx
Line: 116
Description: itk::ERROR: GaussianListSampleFunction(0x7fdc2e095640): Covariance is singular (determinant = 2.52622e-07 < 1.0e-6)
muschellij2 commented 6 years ago

My case was failing because it was already skull stripped. Can you send me a case to test with?

dorianps commented 6 years ago

Will send it later, no access for a couple of hrs.

Tried the old Linda on a 1yr old ANTsR and worked as expected. Tried your pull on the old ANTsR and needs a couple more edits to make it run properly (no option verbose in the old kmeans).

There is definitely something off with the new ANTsR that makes the old Linda fail.

On Sun, Nov 4, 2018, 1:40 PM John Muschelli <notifications@github.com wrote:

My case was failing because it was already skull stripped. Can you send me a case to test with?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dorianps/LINDA/pull/11#issuecomment-435694689, or mute the thread https://github.com/notifications/unsubscribe-auth/AIqafVIHuIZey1ESggQrg68dQ225-_apks5urzSmgaJpZM4YMczA .

dorianps commented 6 years ago

Tried again to run your repository in an old ANTsR after:

Ran a bit longer now but there is some sort of bug in the returned prediction, might have to do with the mrvnrfs call.

...
17:19 Feature calculation... 
17:23 Running prediction...
Error in resampleImage(y[[i]], subdim, useVoxels = 1, interpType = as.numeric(asFactors)) : 
  trying to get slot "components" from an object (class "randomForest") that is not an S4 object 
dorianps commented 6 years ago
17:23 Running prediction...
Error in resampleImage(y[[i]], subdim, useVoxels = 1, interpType = as.numeric(asFactors)) : 
  trying to get slot "components" from an object (class "randomForest") that is not an S4 object 
> traceback()
7: resampleImage(y[[i]], subdim, useVoxels = 1, interpType = as.numeric(asFactors))
6: vwnrfs(y, x, labelmasks[[1]], rad, nsamples, ntrees, asFactors, 
       reduceFactor = mr)
5: ANTsR::mrvnrfs(rflist, list(features), predlabel.sub, rad = rad, 
       multiResSchedule = mr, voxchunk = 5000)
4: withCallingHandlers(expr, message = function(c) invokeRestart("muffleMessage"))
3: suppressMessages(ANTsR::mrvnrfs(rflist, list(features), predlabel.sub, 
       rad = rad, multiResSchedule = mr, voxchunk = 5000))
2: run_prediction(img = simg, brain_mask = submask, template_mask = tempmask, 
       voxel_resampling = voxel_resampling, template_brain = tempbrain, 
       typeofTransform = "SyN", lesion_mask = mask.lesion1, reflaxis = reflaxis, 
       sigma = sigma, verbose = verbose)
1: linda_predict(filename)
muschellij2 commented 6 years ago

Have you tried to change any code to fix this? the mrvnrfs is coming from ANTsR workflow, not yours.

The abpN4 and abpBrainExtraction of @stnava ANTsR seems to be broken. It seem also there is a bug https://github.com/dorianps/LINDA/blob/master/linda_predict.R#L98 whereimg should be n4 not subimg, right? I understand that you're updating the mask, but shouldn't the N4 version be the one to extract the brain?

dorianps commented 6 years ago

I think my rationale there was that the first N4 is run with a full image mask (including air and bones), the second is run with the correct brain mask. I thought the first N4 might not be optimal to feed to abpBrainExtraction, but I agree, it might still be better to feed n4 instead of subimg.

Haven't tried anything else yet, there might be something different in ANTsR's mrvnrfs compared to what I use, I vaguely remember that I tried to use the official one and something wasn't right, or maybe it was missing chunks, not sure.

First. I need to find out why the regular LINDA is not working properly, it's very odd that the new ANTsR is causing this. Then we can check how to extend fixes to your version. Unless you manage to find a working option with the data I sent you. This is why I did not want to touch LINDA, each time I do that something does not work. I even started to write a new version at some point with modules to add new prediction models, using the established ANTsR mrvnrf, etc, but something did not work and I was too busy to troubleshoot things.

muschellij2 commented 6 years ago

I think it is due to abpBrainExtraction to start.

John

On Sun, Nov 4, 2018 at 8:47 PM dorianps notifications@github.com wrote:

I think my rationale there was that the first N4 is run with a full image mask (including air and bones), the second is run with the correct brain mask. I thought the first N4 might not be optimal to feed to abpBrainExtraction, but I agree, it might still be better to feed n4 instead of subimg.

Haven't tried anything else yet, there might be something different ANTsR's mrvnrfs compared to what I use, I vaguely remember that I tried to use the official one and something wasn't right, or maybe it was missing chunks, not sure.

First. I need to find out why the regular LINDA is not working properly, it's very odd that the new ANTsR is causing this. Then we can check how to extend fixes to your version. Unless you manage to find a working option with the data I sent you. This is why I did not want to touch LINDA, each time I do that something does not work. I even started to write a new version at some point with modules to add new prediction models, using the established ANTsR mrvnrf, etc, but something did not work and I was too busy to troubleshoot things.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dorianps/LINDA/pull/11#issuecomment-435731504, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBnrkaK495ps4vWx28XxLYc5qOM6c45ks5ur5jBgaJpZM4YMczA .

muschellij2 commented 6 years ago

I added the options for verbose with kmeansSegmentation.

dorianps commented 6 years ago

Yes, but kmeans had no verbose a year ago. I was trying this pull on an old ANTsR to check if it worked.

On Sun, Nov 4, 2018, 9:03 PM John Muschelli <notifications@github.com wrote:

I added the options for verbose with kmeansSegmentation.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dorianps/LINDA/pull/11#issuecomment-435733461, or mute the thread https://github.com/notifications/unsubscribe-auth/AIqafcLcXMwCwtwhztM_-aXE45-2xYrqks5ur5xogaJpZM4YMczA .

muschellij2 commented 6 years ago

I know - I added the fix so that older ANTsR will work with it. John

On Sun, Nov 4, 2018 at 9:07 PM dorianps notifications@github.com wrote:

Yes, but kmeans had no verbose a year ago. I was trying this pull on an old ANTsR to check if it worked.

On Sun, Nov 4, 2018, 9:03 PM John Muschelli <notifications@github.com wrote:

I added the options for verbose with kmeansSegmentation.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dorianps/LINDA/pull/11#issuecomment-435733461, or mute the thread < https://github.com/notifications/unsubscribe-auth/AIqafcLcXMwCwtwhztM_-aXE45-2xYrqks5ur5xogaJpZM4YMczA

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dorianps/LINDA/pull/11#issuecomment-435734015, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBnriAAOkRQW0C8-Bfcq7Pey-amg-yjks5ur51jgaJpZM4YMczA .

dorianps commented 6 years ago

Ok, the old ANTsR works with your pull up to the mrvnrf call, then shows the above error. Do you want to integrate the original LINDA's mrvnrf functions? That should resolve the hiccup and enable us to compare predictions of 0.2.7 with this package.

Btw, you need to remove the ANTsRCore version requirement to allow the installation on older environments.

muschellij2 commented 6 years ago

Can you make those changes after the PR is accepted? John

On Sun, Nov 4, 2018 at 10:56 PM dorianps notifications@github.com wrote:

Ok, the old ANTsR works with your pull up to the mrvnrf call, then shows the above error. Do you want to integrate the original LINDA's mrvnrf functions? That should resolve the hiccup and enable us to compare predictions of 0.2.7 with this package.

Btw, you need to remove the ANTsRCore version requirement https://github.com/muschellij2/LINDA/blob/master/DESCRIPTION#L22 to allow the installation on older environments.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dorianps/LINDA/pull/11#issuecomment-435748304, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBnrhu-xfmRuNpCN7jA1CZdjhuOIFSYks5ur7bXgaJpZM4YMczA .

stnava commented 6 years ago

regarding mrvnrfs, i think dorian wrote his own "chunking" method. but i dont think mrvnrfs has changed over time. i refer to the vignette results to see this.

https://antsx.github.io/ANTsR/articles/rfLesionSeg.html

dorianps commented 6 years ago

Ok, preparing to merge. A couple of questions:

I may keep the old Readme for a bit, which advises people to download the release, until we figure out how to make the R package fully functional.

muschellij2 commented 6 years ago

1) Previous versions of ANTsR had bugs and people could have any value of ANTsR and have errors. 2) License is fine. 3) Again - you cannot include the warps. If you set the seeds, these registrations should be identical. Otherwise, you need to have checks that if the people have the registrations and run de-novo otherwise.

The package is "fully functional" - but you need to add tests and checks which this package very much needs. In some respects it's more tested than the sourced code as that can have silent errors.

John

On Mon, Nov 5, 2018 at 10:17 AM dorianps notifications@github.com wrote:

Ok, preparing to merge. A couple of questions:

  • Is there any reason to constrain to ANTsRCore >= 0.6 ?
  • I usually adopt the Apache 2 license for compatibility with ANTsR. Is that ok?
  • You are now using de-novo registration between pennTemplate->ch2. Is the idea here to include the original transformations in the releases and use de-novo registrations if people clone "by mistake"?

I may keep the old Readme for a bit, which advises people to download the release, until we figure out how to make the R package fully functional.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dorianps/LINDA/pull/11#issuecomment-435911979, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBnriyUTX0FHYu-l31V_v6sgM95om3tks5usFaIgaJpZM4YMczA .

dorianps commented 6 years ago

Merging, please put pull requests for future commits.

dorianps commented 6 years ago

What's with the version requirements? They seem to be higher than the current versions in the master branches:

Imports:
    ANTsR (>= 0.4.7),
    ANTsRCore (>= 0.6.0.1),
muschellij2 commented 6 years ago

I have 0.4.6 - which should be OK (0.4.7 needs review and pull request incorporated), but 0.6.0.1 works now in ANTsRCore. 0.6.0 has bugs so shouldn't be used! John

On Mon, Nov 5, 2018 at 11:59 AM dorianps notifications@github.com wrote:

What's with the version requirements? They seem to be higher than the current versions in the master branches:

Imports: ANTsR (>= 0.4.7), ANTsRCore (>= 0.6.0.1),

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dorianps/LINDA/pull/11#issuecomment-435951060, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBnrqAzDvesRZNEfMFMpVlADMGd0QMoks5usG5VgaJpZM4YMczA .

muschellij2 commented 6 years ago

so LINDA works well now, but the "native" data is not really native. The dimensions do not match up. I think using resampleImageToTarget should be used compared to resampleImage as per https://github.com/ANTsX/ANTsRCore/issues/7. Here is the output: output but I agree - not as "good" as before.

muschellij2 commented 6 years ago

I'm going to rerun with the resampleImageToTarget used.