Morphologist (pipeline) fails

Questions about BrainVisa usage and installation

Moderators: denghien, riviere

Post Reply
leka0024
Posts: 19
Joined: Wed Jul 06, 2016 9:52 pm

Morphologist (pipeline) fails

Post by leka0024 »

Hello,

I'm a new user to BrainVISA. (if this thread needs to go in a different area of the forum, please move it)

This is what I have:
- new Dell workstation, with plenty of power
- Ubuntu 16.04 LTS (64-bit)
- BrainVISA 4.5.0
- latest nVidia drivers
- Matlab R2016a -- runs fine on its own
- SPM12 -- pretty sure this is installed correctly, because I can run spm in matlab and it brings up a new window with options
- dcm2niix utility to convert DICOM image files into a .nii file (this utility works very nicely!)
- the .nii file I'm trying to use got the tags: _AX_T1_PRE_xxxxxx.nii , so I think this is the correct type of scan to be used in Morphologist and have it "do it's thing"


This is what I want:
- right now, I just want to see Morphologist work on a single subject
- in other words, I want the eight windows in Morphologist UI to get filled in based on analyzing the lone .nii file mentioned above
- I think the outputs of that process can then be ported over to Anatomist to view 3D brain structures (right?)


What seems to work, so far:
- All the softwares seem to load and run fine (I can execute ./BrainVISA, ./anatomist, and ./morphologist without any problems)
- I created a new blank directory at /home/user/database
- In BV, I went to preferences and added a database at the above location
- in BV, I then used the "Update database" tool and that added some files into the above location (.minf and so on)
- in BV, I then used the "import T1 MRI" tool and gave it the location of the .nii file as well as selected the new database -- this seemed to work fine (no warnings) and now there is a "subjects" folder in the database
- in BV, finally I used the "run morphologist, on a database" and selected the database -- this lead to morphologist opening with a window saying "importing subjects", no errors or warnings and I can see the axial scan image in the top left corner

What doesn't seem to work, so far:
- in M, I select the one subject in the right side (check box), then at the bottom I hit "run" -- after a couple seconds, it stops running, and in the right side the status says "failed at orientation"



This makes me suspect that some pre-processing of the .nii file is required, in order for Morphologist pipeline to succeed. But how is the correct way to do this?? I also thought this would just be taken care of by the pipeline itself?

So, I've tried to manually use two different tools in the Morphologist toolbox, accessed from BrainVISA, to accomplish this pre-processing. Sorry, I can't quite remember their exact names, but I remember one was something about transforming to Talairach. Both tools seemed to call the same SPM/Matlab routine, which succeeded in both cases.

But then, when I tried to "run morphologist, on a database" with the new pre-processing completed, it worked the same up until the point when I tried to hit "run" -- then it simply said "missing inputs" and refused to do anything more. It did say on the right side in status "some outputs found"


So at this point, I'm kinda stuck ... any advice?? Thanks!
leka0024
Posts: 19
Joined: Wed Jul 06, 2016 9:52 pm

Re: Morphologist (pipeline) fails

Post by leka0024 »

Bumping.
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: Morphologist (pipeline) fails

Post by riviere »

Hi,
Maybe something is not OK in the configuration, I suspect the Matlab/SPM paths config, of course. Is is correctly setup in brainvisa so as to run the non-UI version of Morphologist ? If yes, maybe something is not correctly converted to the UI version. The thing is that: 1) Morphologist-UI is using a new infrastructure for pipelining and configuration, and the config is more or less converted, so I can't exclude a bug there, and 2) we generally use the standalone version of SPM, and I'm not totally sure to have re-tested the Matlab version in the context of Morphologist-UI.
So in all cases it can be a bug.
The first thing is to try running the old brainvisa-based Morphologist to check that the config is OK in this first case. Then we can check the converted one.

Another thing you can do:
Morphologist-UI doesn't show precise messages in case of failure. But you can use soma_workflow_gui to check and monitor the state of workflows. It allows to see which job(s) have failed, and get their standard outputs. It may provide more info on the failure.

Denis
leka0024
Posts: 19
Joined: Wed Jul 06, 2016 9:52 pm

Re: Morphologist (pipeline) fails

Post by leka0024 »

Thanks for the reply, reviere!

I didn't realize there was a non-UI version! Sorry, I am a newbie. 8) OK, I ran the non-UI version. It made it 10% before crashing.


Output of "Morphologist 2015 1" window:
"
Trying 1st pass of normalization...
matlabBatchPath /tmp/bv_25902_46_batch.m
Running matlab command: ['/usr/bin/matlab', u'-nosplash', u'-nodisplay', '-r', 'bv_25902_46_batch']
Skip unselected node: Reorient Anatomy
AC: [162, 144, 13] , mm: [121.28955078125, 108.11079406738281, 79.50799560546875]
PC: [163, 178, 15] , mm: [122.43662395328283, 133.8078888654709, 87.7543774843216]
IP: [164, 206, 8] , mm: [123.32936246693134, 154.66105663776398, 46.615118741989136]

in T1 Bias Correction 2 System call crashed
SignalException

in Morphologist 2015 2 System call crashed
SignalException
"

In the Ubuntu terminal, there was this:
"
perform_normalization = True
Exception in run_spm.runSpm8Standalone: SPM8 standalone is not configured
spm_run.run, matlab version result: 0
"

Lastly, an error window popped up in Ubuntu:
" VipT1BiasCorrection crashed with SIGSEGV in do_lookup_x() "



If the problem now is that I do not have the standalone SPM version, do you know how I can uninstall the Matlab version and install the standalone version? I think the reason I went with the Matlab version is that the SPM website recommended this, and said the standalone version had to be compiled. Is this difficult to do? Do you have a recommended way to perform this?


Thanks again!
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: Morphologist (pipeline) fails

Post by riviere »

Well the UI version is new and still lacks a few messages about configuration problems. But it should be working at the end...
So I guess that it's just SPM which is not configured in brainvisa. In BrainVisa config (which you can acces from brainvisa or from morphologist-ui), in the SPM section, is spm8_path or spm12_path configured ?

Denis
leka0024
Posts: 19
Joined: Wed Jul 06, 2016 9:52 pm

Re: Morphologist (pipeline) fails

Post by leka0024 »

I did the "auto-detect" for SPM. It set the SPM12, SPM8 and SPM5 paths all to "/home/[user]/spm12" , which I think is the correct directory. When I added that directory to the Matlab path, and I could then open matlab and just type 'spm' and it would open up a whole new window with options. So I'm pretty sure the SPM via Matlab is working.

But like I said, if it needs the standalone version to work correctly ... I'm fine doing that. Just would appreciate any advice about how to properly:

- uninstall SPM12 for Matlab (so to avoid any interference/conflicts)
- install SPM12 standalone (or should I do SPM8 ???)
-- how do I compile this? Do you have recommendations?

Also would be nice: if there was a "gold standard" .nii file from a T1 MRI scan that you know for sure should work with the Morphologist pipeline, that I could try to confirm everything is working correctly. Maybe for the future!

Thanks!
leka0024
Posts: 19
Joined: Wed Jul 06, 2016 9:52 pm

Re: Morphologist (pipeline) fails

Post by leka0024 »

Hi riviere,

I double checked again this morning in BrainVISA->Preferences->SPM:
spm12_path = /home/[user]/spm12
spm8_path = /home/[user]/spm12
spm5_path = /home/[user]/spm12

If I delete all except spm12_path, then even the first task on non-UI Morphologist ('image nomalization') will fail! The terminal says: "Exception in sun_spm.runSpm8: SPM8/Matlab is not configured"

I find this very odd. Some tasks apparently can use the matlab version of SPM??


If I delete all except spm8_path, then the image normalization runs correctly, as before, and fails at T1 bias removal. The terminal says "Exception in run_spm.runSpm8Standalone: SPM8 standalone is not configured"

Why does this step require the standalone version of SPM??


Also, why are both wanting to use SPM8? The current version is SPM12, per the website: http://www.fil.ion.ucl.ac.uk/spm/software/

And I don't understand why BrainVISA can't just use the Matlab version of SPM?? The standalone version of SPM has to be compiled in Matlab, so it's not really like you can escape having Matlab (I think)?



Now I will try to get the standalone version, but it appears I have to contact SPM separately.
leka0024
Posts: 19
Joined: Wed Jul 06, 2016 9:52 pm

Re: Morphologist (pipeline) fails

Post by leka0024 »

One last thing, I also downloaded the Matlab version of spm8. It gives the same result of spm12: failed at the T1 bias correction step of Morphologist (while image normalization works).

In both cases, BrainVISA output to terminal says:
"
Exception in run_spm.runSpm8Standalone: SPM8 standalone is not configured
spm_run.run, matlab version result: 0
"


Note: I can only get the above to work, with either spm12 or spm8 Matlab verisons, if I put the appropriate location in the BrainVISA SPM config line for "spm8_path". Nothing works if I instead use "spm12_path". I think this is because in the python file 'spm_run.py', it only has sections for spm8. But could be wrong.
leka0024
Posts: 19
Joined: Wed Jul 06, 2016 9:52 pm

Re: Morphologist (pipeline) fails

Post by leka0024 »

Hello,

Update: I was able to get both SPM8 and SPM12 standalone versions to work on my system.

(aside: a required package 'libxp6' for Ubuntu is no longer available from version 15.10 onward. So, you can download the 15.04 .deb package here: http://www.ubuntuupdates.org/package/co ... ase/libxp6 and install it with 'dpkg'. It worked for me on 16.04 LTS.)

Now I can run the Morphologist (non-UI) without getting an exception printed to the terminal about SPM standalone not being configured.


I'm certain the SPM config in BrainVISA is correct, because the first step in Morphologist (non-UI) pipeline works correctly, and outputs the AC, PC and IP coordinates.

But then, it still fails with the exact same failure mode! "VipT1BiasCorrection crashed with SIGSEGV in do_lookup_x()"



What does this mean? And how do I fix this??

Please help.
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: Morphologist (pipeline) fails

Post by riviere »

Hi,
Well, I must admit that I have not tested the matlab-based SPM for a while, so there might be a bug in the config somewhere.
The standalone version should be OK in any case.
I don't really know if the process works with SPM12, it seems that SPM8 is more or less hard-coded there...

However the bias correction is not done using SPM nor matlab at all, it is the bias correction from Morphologist, so it is not linked with Matlab or SPM configuration. But il may fail if the normalization went wrong.
Speaking of this, when you say that normalization could be done, have you checked the transformation and AC/PC position ?

In your message of july 11, the AC/PC points position values were obviously wrong:

AC: [162, 144, 13] , mm: [121.28955078125, 108.11079406738281, 79.50799560546875]
PC: [163, 178, 15] , mm: [122.43662395328283, 133.8078888654709, 87.7543774843216]
IP: [164, 206, 8] , mm: [123.32936246693134, 154.66105663776398, 46.615118741989136]

these are not reasonable values: Z positions in voxels (13, 15) are too small, and positions in mm (79, 87) from these voxels values would mean voxel size is about 6 mm in Z, which cannot be correct.
So the normalization process did not work in this case. This can completely explain that the bias correction failed.

Maybe the input image was messed up at some point ?
Now that SPM8 standalone seems to be configured and working (I hope so), could you please retry importing a clean image and starring it again ? (possibly after completely erasing the brainvisa subject directory and updating the database).

I'll try to check other versions of SPM and matlab-based SPMs when I can (but I cannot do it today).

Denis
leka0024
Posts: 19
Joined: Wed Jul 06, 2016 9:52 pm

Re: Morphologist (pipeline) fails

Post by leka0024 »

Hello D.R.,

Thanks for the reply. By the way, I know you must be very busy! So it's really a great service when you have the time to help.

**It could entirely be the case that I'm using an inappropriate MRI scan. It's a T1 Axial scan, so there are only 24 "slices" in that direction, with the other dimensions being higher res. I can't remember off top of my head, but I think it might be something like 256x256x24, although the numbers might not be exactly in the right positions. But hopefully you get the idea.

Is there a minimum -- or even better, a recommended -- image dimension??

Thanks!


PS - there is another thread on this forum, just below this one, that I've also posted in, with much more detail. Sorry, I didn't see that thread before I posted here. It's called "Morphologist bias correction crash." Maybe it would be helpful to merge those threads or to put your response in that thread?

I don't think you need to spend your time to test Matlab version and/or SPM12 version, unless these are on your priority TO-DO list anyway. I have the SPM8 Standalone working now on Ubuntu 16.04 LTS. It just took downloading the .deb package (last available under Unbuntu 15.04) and manually installing it, then SPM standalone worked fine.
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: Morphologist (pipeline) fails

Post by riviere »

Oh your image is *really* 24 slices of about 6mm ?

There is no way you can get a decent segmentation with such an image, I am sorry... The segmentation pipeline is designed for images of about 1mm resolution in each direction (typical images are about 256x256x128 voxels). It can segment images with slices of 1.3mm, 1.5 maximum, but with your image, going from a voxel to the next in Z direction gets most of the time to a completely different anatomical structure without any continuity, so there isn't enough information to reconstruct a 3D structure...

Denis
Post Reply