Error running FLAMEO on Nipype

nipype

#1

Dear all,

I’m trying to do subject-level modeling on FSL using Nipype. I wrote a workflow that mostly works, but I keep running into this error when I use FLAMEO:

RuntimeError: Command:
flameo --copefile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-04/l1/fixedfx/copemerge/mapflow/_copemerge0/cope1_merged.nii.gz --covsplitfile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-04/l1/fixedfx/l2model/design.grp --designfile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-04/l1/fixedfx/l2model/design.mat --dofvarcopefile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-04/l1/fixedfx/gendofvolume/dof_file.nii.gz --ld=stats --maskfile=/scratch/groups/hyo/SwiSt/BIDS_data/derivatives/fmriprep/sub-04/func/sub-04_task-tomloc_run-01_space-MNI152NLin2009cAsym_desc-brain_mask.nii.gz --runmode=fe --tcontrastsfile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-04/l1/fixedfx/l2model/design.con --varcopefile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-04/l1/fixedfx/varcopemerge/mapflow/_varcopemerge0/varcope1_merged.nii.gz
Standard output:
Log directory is: stats
Setting up:
ntptsing=2.000000 

evs_group=1.000000 

Standard error:
Aborted
Return code: 134

The funny thing is, the command in the error message above works just fine if I run it through the terminal—so I’m guessing that this is a Nipype issue, rather than an FSL issue. Does anyone have any idea how to debug this? Some additional context:

Thanks in advance!
Natalia


Fixed-effects workflow for fmriprep outputs?
#2

Was this directly in your terminal, or via singularity shell?


#3

Ah, good catch! I was running it directly in my terminal. Here’s the error message I got when I ran through my Singularity image:

[nvelez@sh-06-36 /home/groups/hyo/singularity]$ singularity run -B $PI_HOME,$PI_SCRATCH sll_fmri_20190204.img 
Some packages in this Docker container are non-free
If you are considering commercial use of this container, please consult the relevant license:
https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/Licence
nvelez@sh-06-36:/home/groups/hyo/singularity$ flameo --copefile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-04/l1/fixedfx/copemerge/mapflow/_copemerge0/cope1_merged.nii.gz --covsplitfile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-04/l1/fixedfx/l2model/design.grp --designfile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-04/l1/fixedfx/l2model/design.mat --dofvarcopefile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-04/l1/fixedfx/gendofvolume/dof_file.nii.gz --ld=stats --maskfile=/scratch/groups/hyo/SwiSt/BIDS_data/derivatives/fmriprep/sub-04/func/sub-04_task-tomloc_run-01_space-MNI152NLin2009cAsym_desc-brain_mask.nii.gz --runmode=fe --tcontrastsfile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-04/l1/fixedfx/l2model/design.con --varcopefile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-04/l1/fixedfx/varcopemerge/mapflow/_varcopemerge0/varcope1_merged.nii.gz
Log directory is: stats
Setting up:
Image Exception : #22 :: ERROR: Could not open image /scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-04/l1/fixedfx/copemerge/mapflow/_copemerge0/cope1_merged
terminate called after throwing an instance of 'RBD_COMMON::BaseException'
Aborted


#4

Are you able to ls /scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-04/l1/fixedfx/copemerge/mapflow/_copemerge0/cope1_merged.nii.gz from within your singularity shell?

And I see that your singularity image has FSL 5.0.11 installed. What version do you have installed locally?


#5

(1) I cleared my working directory and ran the workflow cleanly, and I realized that the fixedfx directory doesn’t exist anymore because I changed the workflow a bit. (I build my own fixedfx workflow from scratch, rather than loading the pre-made workflow.) The FLAMEO command is now:

flameo --copefile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-06/l1/copemerge/mapflow/_copemerge0/cope1_merged.nii.gz --covsplitfile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-06/l1/l2model/design.grp --designfile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-06/l1/l2model/design.mat --ld=stats --maskfile=/scratch/groups/hyo/SwiSt/BIDS_data/derivatives/fmriprep/sub-06/func/sub-06_task-tomloc_run-01_space-MNI152NLin2009cAsym_desc-brain_mask.nii.gz --runmode=fe --tcontrastsfile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-06/l1/l2model/design.con --varcopefile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-06/l1/varcopemerge/mapflow/_varcopemerge0/varcope1_merged.nii.gz

I checked each of the files in this new command—I can ls all of them. I tried running this new command inside the Singularity image and got a different error:

flameo --copefile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-06/l1/copemerge/mapflow/_copemerge0/cope1_merged.nii.gz --covsplitfile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-06/l1/l2model/design.grp --designfile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-06/l1/l2model/design.mat --ld=stats --maskfile=/scratch/groups/hyo/SwiSt/BIDS_data/derivatives/fmriprep/sub-06/func/sub-06_task-tomloc_run-01_space-MNI152NLin2009cAsym_desc-brain_mask.nii.gz --runmode=fe --tcontrastsfile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-06/l1/l2model/design.con --varcopefile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-06/l1/varcopemerge/mapflow/_varcopemerge0/varcope1_merged.nii.gz
Log directory is: stats
Setting up:
ntptsing=2.000000 

evs_group=1.000000 

Aborted

The command does generate a new stats directory, but the directory only includes a logfile with a single line (the FSL command).

(2) 5.0.10! Here’s the output when I run the same command on the Terminal:

Log directory is: stats+
Setting up:
ntptsing=2.000000 

evs_group=1.000000 

No f contrasts

WARNING: The passed in varcope file, /scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-06/l1/varcopemerge/mapflow/_varcopemerge0/varcope1_merged.nii.gz, contains voxels inside the mask with zero (or negative) values. These voxels will be excluded from the analysis.
nevs=1
ntpts=2
ngs=1
nvoxels=74434
Running:
nmaskvoxels=74434
 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
Saving results

Log directory was: stats+

The stats+ directory contains the following files:

[nvelez@sh-06-36 /home/groups/hyo/singularity]$ ls stats+
cope1.nii.gz                     res4d.nii.gz     zflame1lowertstat1.nii.gz
logfile                          tdof_t1.nii.gz   zflame1uppertstat1.nii.gz
mask.nii.gz                      tstat1.nii.gz    zstat1.nii.gz
mean_random_effects_var1.nii.gz  varcope1.nii.gz
pe1.nii.gz                       weights1.nii.gz

#6

So this may be a bug in FSL 5.0.11. Would you be able to rebuild your Singularity image with FSL 5.0.10 and try again? If that resolves it, then it’s less likely to be nipype or your singularity environment, so I would go ahead and submit a bug report to FSL. (That said, they’ve released FSL 6.0, so I don’t know whether they’ll still be fixing issues in 5.0.x.)


#7

Hmmm, I’m getting the same error on a Singularity image with FSL 5.0.10 installed:

nvelez@sh-06-36:/home/groups/hyo/singularity$ flameo --copefile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-06/l1/copemerge/mapflow/_copemerge0/cope1_merged.nii.gz --covsplitfile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-06/l1/l2model/design.grp --designfile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-06/l1/l2model/design.mat --ld=stats --maskfile=/scratch/groups/hyo/SwiSt/BIDS_data/derivatives/fmriprep/sub-06/func/sub-06_task-tomloc_run-01_space-MNI152NLin2009cAsym_desc-brain_mask.nii.gz --runmode=fe --tcontrastsfile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-06/l1/l2model/design.con --varcopefile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-06/l1/varcopemerge/mapflow/_varcopemerge0/varcope1_merged.nii.gz
Log directory is: stats
Setting up:
ntptsing=2.000000 

evs_group=1.000000 

Aborted

#8

This may be a filesystem permissions issue. Can you try setting the argument to --ld to some directory you know you can write to from inside Singularity? e.g. --ld=/scratch/groups/hyo/SwiSt/stats


#9

So, I went to a couple of different directories from within the Singularity image, tested whether I can write to them, and tried to run the command there—unfortunately, I still got the same error.

nvelez@sh-06-36:/home/groups/hyo/SwiSt/3_model$ flameo --copefile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-06/l1/copemerge/mapflow/_copemerge0/cope1_merged.nii.gz --covsplitfile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-06/l1/l2model/design.grp --designfile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-06/l1/l2model/design.mat --ld=/scratch/groups/hyo/swist_cache/stats --maskfile=/scratch/groups/hyo/SwiSt/BIDS_data/derivatives/fmriprep/sub-06/func/sub-06_task-tomloc_run-01_space-MNI152NLin2009cAsym_desc-brain_mask.nii.gz --runmode=fe --tcontrastsfile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-06/l1/l2model/design.con --varcopefile=/scratch/groups/hyo/swist_cache/l1_model/task-tomloc_model-localizer_sub-06/l1/varcopemerge/mapflow/_varcopemerge0/varcope1_merged.nii.gz
Log directory is: /scratch/groups/hyo/swist_cache/stats
Setting up:
ntptsing=2.000000 

evs_group=1.000000 

Aborted