This is now a python script that resides in the scripts directory. Make sure you add the scripts directory to your PATH as explained in the installation instructions on http://userdocs.mrtrix.org/en/latest/.
Well, I still have some issues with this command :
$ 5ttgen fsl T1w_acpc_dc_restore_brain.nii.gz 5TT.mif -premasked
5ttgen:
5ttgen: Note that this script makes use of commands / algorithms that have relevant articles for citation; INCLUDING FROM EXTERNAL SOFTWARE PACKAGES. Please consult the help page (-help option) for more information.
5ttgen:
5ttgen: Generated temporary directory: /tmp/5ttgen-tmp-9EIT1V/
Command: mrconvert T1w_acpc_dc_restore_brain.nii.gz /tmp/5ttgen-tmp-9EIT1V/input.mif -stride +1,+2,+3 -quiet
5ttgen: Changing to temporary directory (/tmp/5ttgen-tmp-9EIT1V/)
Command: mrconvert input.mif T1.nii -quiet
Command: mrconvert input.mif T1_masked.nii -quiet
Command: fast T1_masked.nii.gz
Command: run_first_all -s L_Accu,R_Accu,L_Caud,R_Caud,L_Pall,R_Pall,L_Puta,R_Puta,L_Thal,R_Thal -i T1.nii -o first -b
665
5ttgen: [ERROR] Missing .vtk file for structure L_Accu; run_first_all must have failed
5ttgen: Changing back to original directory (/home/cdeledal/brainware/hcp/structural_connectome)
5ttgen: Deleting temporary directory /tmp/5ttgen-tmp-9EIT1V/
Yes sorry, I was a little sneaky with the command/script renaming there. The old 5ttgen binary was a very small convenience function that the old act_anat_prepare_* scripts would use; whereas the new 5ttgenscript is a more all-encompassing script (with a much more concise name than the old scripts!).
Sometimes the FIRST script crashes out at the non-linear registration step, particularly when the sub-cortical mask is introduced (to prevent the cortex from driving the registration). It just fails catastrophically without any particularly useful warning; hence my script detects the absence of the files it expects that script to generate, and produces an error. And you’ve correctly used the -premasked option given you’ve used the *_brain.nii.gz image.
I suppose you could try running the script on the non-brain-masked image, see what happens. You could also check your FSL version: There was a bug introduced where affine transform text files were written in a format that FSL itself could not read, which could conceivably lead to this error. I believe the bug was fixed in 5.0.9. You can also use the -nocleanup option to retain the temporary directory: that will allow you to dig around in the guts of the script, see the error logs produced by run_first_all.
If none of that gets you anywhere, and you have a few problematic data sets available to play with, I would be very curious to know whether changing the mrconvert call from -stride +1,+2,+3 to -stride -1,+2,+3 makes any difference…
Hi,
I had to make two changes to the fsl.py script (found in /mrtrix3/scripts/src/_5ttgen/) in order to get the -premasked option to work. Firstly, in your output you see that the file extension of T1_masked is different for the two commands. [quote=“deledalle, post:4, topic:133”]
Command: mrconvert input.mif T1_masked.nii -quiet
Command: fast T1_masked.nii.gz
[/quote]
Try with changing to mrconvert input.mif T1_masked.nii.gz (line 95)
Secondly, line 149, there is a reference to T1-preBET, which is not created with -premasked.
Try with referring to the T1_masked.nii.gz instead: runCommand('mesh2pve ' + vtk_temp_path + ' T1_masked' + fsl_suffix + ' ' + pve_image_path)
@Orjan Thanks for the report: I’ll merge the required fixes into the repository. Given the new flexibility in these scripts, it’s really useful to have them running on different systems / configurations to iron out issues like this (that code ran fine on my system, probably because of the value of $FSLOUTPUTTYPE being different).
However I’m surprised that those fixes would have anything to do with @deledalle’s problem. The run_first_all call that apparently failed doesn’t even use those files. Weird…
…Yea, I should say that I don’t actually know how to program and I’ve never looked at a python script before - but I’m glad the hack worked for you too Charles!
Cheers,
Örjan
What I really meant by that was - thank you Robert (and anyone with this problem should pull from the repository rather than implementing my suggestions)
/Ö
I experienced the same error and I think I found why it happens.
As you see in the log, a line with just
665
follows the run_first_all command, meaning that the job was submitted to your SGE cluster. The problem is that the next command expects to find the *.vtk files (generated by run_first_all) but the job is still running on the queue… So it complains that the *.vtk files are missing.
A very ugly way to fix the problem is to insert a pause in the 5ttgen process between the run_first_all command and the next one.
Edit: It seems that the -tempdir option does not work, which is problematic when using an SGE cluster. By default temp dir is created in /tmp/, a local directory not accessible from remote machines.
In my experience, the integer (corresponding to a process ID) was being written to stdout at the end of the run_first_all script (i.e. when the script completed). If this is potentially indicating that a process is being run in parallel (potentially only in some configurations), then 5ttgen fsl needs to be altered in order to wait until the relevant processing is done. If anybody has an understanding of what’s going on with FIRST under the hood here, I’d like to hear from you; otherwise I’ll have to go get my hands dirty.
@wamigy When you say that -tempdir ‘doesn’t work’, do you mean that the script runs, but the temporary directory location doesn’t change away from the default? One thing to look for is the position of the -tempdir option on the command line: I recently made changes so that in 5ttgen and dwi2response you no longer have to specify generic command-line options before the algorithm name, but it seems that the converse now applies; i.e. it’s now compulsory to specify all options after the algorithm name, anything between 5ttgen and fsl is ignored. Unfortunately the Python command-line parsing library doesn’t behave how I want it to, so I’m progressively bastardizing it further and further. But if this isn’t the issue, something else is broken that I need to fix, so more information would be helpful.
The integer comes out from fsl_sub, which is the function that launches the actual jobs in run_first_all calls. If a SGE cluser is available, fsl_sub parallelizes the jobs.
I checked the -tempdir option and you’re right, placing the option after the arguments works.
I am also receiving the missing .vtk files error, working through the same tutorial. I am new to MRtrix but have tried to implement the advice given so far in this thread. I used -tempdir in between 5ttgen and fsl. I’ve copied the end of the -verbose output below. I am using a remote desktop to access a cluster where I only have write privileges in my home drive. My input was:
May I ask you if you have setup SGE on your computer? You can check this by:
echo $SGE_ROOT
If it returns a path to you (e.g. /usr/sge), that means you have this variable in your working environment. If this is the case, a very simple trick that I used is:
unset SGE_ROOT
This should give you a successful 5ttgen run in your case, but it does mean that FSL and any other application will be working without SGE in this current environment. Therefore, you will need to set the path SGE_ROOT again afterwards if you want to keep working in the same environment.
I think that the problem would be solved essentially in the future.
Dear experts , I got the following error, I am running MRtrix locally in MacBook, with the latest FSL.
I tried changing mrconvert input.mif T1.nii -stride -1,+2,+3 by mrconvert input.mif T1.nii -stride +1,+2,+3, but the problem still showing up. Any suggestion ?
Carloss-MacBook-Pro:mrtrix_test carlosengutierrez$ 5ttgen fsl 8.nii 5tt.mif -nocleanup
5ttgen:
5ttgen: Note that this script makes use of commands / algorithms that have relevant articles for citation; INCLUDING FROM EXTERNAL SOFTWARE PACKAGES. Please consult the help page (-help option) for more information.
5ttgen:
5ttgen: Generated temporary directory: /tmp/5ttgen-tmp-7JZLRM/
Command: mrconvert /Users/carlosengutierrez/datathon/mrtrix_test/8.nii /tmp/5ttgen-tmp-7JZLRM/input.mif
5ttgen: Changing to temporary directory (/tmp/5ttgen-tmp-7JZLRM/)
Command: mrconvert input.mif T1.nii -stride -1,+2,+3
Command: maskfilter /usr/local/fsl/data/standard/MNI152_T1_1mm_brain_mask_dil.nii.gz dilate mni_mask.nii -npass 4
Command: standard_space_roi T1.nii T1_preBET.nii.gz -maskMASK mni_mask.nii -roiFOV
Command: bet T1_preBET.nii.gz T1_BET.nii.gz -f 0.15 -R
Command: fast T1_BET.nii.gz
Command: run_first_all -s L_Accu,R_Accu,L_Caud,R_Caud,L_Pall,R_Pall,L_Puta,R_Puta,L_Thal,R_Thal -i T1.nii -o first
5ttgen: [ERROR] Missing .vtk file for structure L_Accu; run_first_all must have failed
5ttgen: Changing back to original directory (/Users/carlosengutierrez/datathon/mrtrix_test)
5ttgen: Contents of temporary directory kept, location: /tmp/5ttgen-tmp-7JZLRM/
I am not sure if unset FSLPARALLEL would work, I haven’t tried it yet. But as far as I can tell, FSLPARALLEL is used such as in FSL’s FDT tools but not in FIRST, i.e. FSLPARALLEL is not a global variable of FSL but seems to be specific for certain functions. The run_first_all command (as called by the 5ttgen script) checks SGE_ROOT variable to decide if the command can be passed onto a cluster. Have a look at ${YOUR_FSL_DIR}/src/first/run_first_all and ${YOUR_FSL_DIR}/bin/fsl_sub if interested.