dorianps / LINDA

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

Problem with Prediction in linda_predict #3

Closed npnl closed 7 years ago

npnl commented 7 years ago

Hello,

Thanks for your all work on the LINDA toolbox.

I've been trying to run lesion segmentation with the toolbox, however, I keep running into an error at "Running 1st prediction"

It looks like there's an error with the function mrvnrfs.predict_chunks(). It seems that there may be a problem with matrix/array indexing:

`

1st prediction cat(paste(format(Sys.time(), "%H:%M") , "Running 1st prediction... \n")) 09:49 Running 1st prediction...

predlabel.sub = brainmaskleftbrain*1;

predlabel.sub[features[[4]] == 0] = 0

mmseg1<-suppressMessages(

  • mrvnrfs.predict_chunks( rfm$rflist, list(features),
  • predlabel.sub, rad=rad,
  • .... [TRUNCATED] Error in seqby[i]:nxt : NA/NaN argument In addition: Warning messages: 1: In .HTMLsearch(query) : Unrecognized search field: title 2: In .HTMLsearch(query) : Unrecognized search field: keyword 3: In .HTMLsearch(query) : Unrecognized search field: alias 4: In .HTMLsearch(query) : Unrecognized search field: title 5: In .HTMLsearch(query) : Unrecognized search field: keyword 6: In .HTMLsearch(query) : Unrecognized search field: alias

`

Thanks for your help, Kaori

dorianps commented 7 years ago

I suspect there might be a problem in the new updated functions in ANTsR when called from the (already old) LINDA script. Try to replace the file mrvnrfs_chunks.r with the attached one. This should force the use of old ANTsR functions. If that works, I will work on a permanent fix.

mrvnrfs_chunks.zip

npnl commented 7 years ago

Hi,

Thanks for your prompt response. I tried to replace the old mrvnrfs_chunks.r file with the new one you attached, but am still running into the same error:


> # 1st prediction
> cat(paste(format(Sys.time(), "%H:%M") , "Running 1st prediction... \n"))
14:56 Running 1st prediction... 

> predlabel.sub = brainmaskleftbrain*1;

> predlabel.sub[features[[4]] == 0] = 0

> mmseg1<-suppressMessages(
+   mrvnrfs.predict_chunks( rfm$rflist, list(features),
+                                predlabel.sub, rad=rad,
+         .... [TRUNCATED] 
Error in seqby[i]:nxt : NA/NaN argument

Thanks, Kaori

dorianps commented 7 years ago

There might be something wrong with the initial processing then. Options are:

  1. The field of view is too close to the brain, there are not enough black voxels surrounding it. If this is the case, you can zero-pad your image with something like:

    myimg = antsImageRead('/path/to/file.nii.gz')
    mynewimg = iMath(myimg, 'PadImage',10) # adds 10 voxels on every side
    antsImageWrite(mynewimg, '/path/to/newfile.nii.gz')
  2. Something went wrong during brain extraction. Check the file already produced. Does the file "N4corrected_Brain.nii.gz" show the brain with no skull? Does "BrainMask.nii.gz" overlay nicely on your original T1 to cover only the brain?

  3. Send me your T1 volume in some way (i.e., https://wetransfer.com/ ) and I can try to troubleshoot it on my machine.

Dorian

dorianps commented 7 years ago

Closing issue, reopen if necessary.

npnl commented 7 years ago

Hi Dorian,

my apologies for the belated response - just got back from out of town!

I tried the first option, but I got the same error again. The brain extraction also seems to run correctly; as does the mask creation.

I can send over the T1 (can you provide an email address?), but this is a problem that I am running into with multiple subject scans. (Also, I should mention that I have installed the code on two different computers as well with the same results)

Again, thank you very much for your help on this.

dorianps commented 7 years ago

Sorry for the delayed response. Please use dorian dot pustina at uphs dot upenn dot edu to send your image. Someone else (or maybe it's the same case) just submitted an email with the same error. Looks like this is a common issue caused by some ANTsR update. I will work to resolve this problem quickly once I get a failing example on my computer.

Thank you.

dorianps commented 7 years ago

The crash came from a recent update in ANTsR from last month. The problem is now resolved in the latest LINDA release v0.2.6. For some reason I can't upload the zip with the updated R files here, you have to download the whole release.

Here is the lesion segmentation I obtained from your patient. Prediction3_native.nii.gz

npnl commented 7 years ago

Thanks! This is working for me now.