Nipype: fsl Level1Design Traiterror

Hi there,

I’ve been trying to run a level one design using nipype and the fsl interfaces. As can be seen below, i get a
trait error (TraitError: The trait ‘ev_files’ of a Level1DesignOutputSpec instance is an existing file name, but the path REMOVED does not exist ). This of course makes it impossible to create the event files , fsf files, or the mat files. The other triait errors I have seen on here with this error seem to have to do with docker. I don’t have a writing error as far as I can tell and memory is not an issue with the computer.

I would greatly appreciate any tips on how to solve this or how others have gone about resolving trait errors like this where a file that should have been generated is not found.

Thank you!
Marlen

Here is the printout of the crash file with redacted information for ease of readability.

Node: LEVELONE.modelprep.level1design
Working directory: /var/folders/48/_q3xrnms1sqbtkhrvrj52x400000gp/T/tmpxajxgq9q/LEVELONE/modelprep/_ROI_id_R_DLPFC_BLOCK_TMS_subject_id_P101/level1design

Node inputs:

bases = {‘dgamma’: {‘derivs’: False}}
contrasts = [(‘OFF’, ‘T’, [‘OFF’, ‘B1’, ‘B2’, ‘B3’, ‘B4’, ‘B5’, ‘B6’, ‘B7’, ‘B8’, ‘B9’, ‘B10’], [1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]), (‘Block1’, ‘T’, [‘OFF’, ‘B1’, ‘B2’, ‘B3’, ‘B4’, ‘B5’, ‘B6’, ‘B7’, ‘B8’, ‘B9’, ‘B10’], [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]), (‘Block2’, ‘T’, [‘OFF’, ‘B1’, ‘B2’, ‘B3’, ‘B4’, ‘B5’, ‘B6’, ‘B7’, ‘B8’, ‘B9’, ‘B10’], [0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]), (‘Block3’, ‘T’, [‘OFF’, ‘B1’, ‘B2’, ‘B3’, ‘B4’, ‘B5’, ‘B6’, ‘B7’, ‘B8’, ‘B9’, ‘B10’], [0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]), (‘Block4’, ‘T’, [‘OFF’, ‘B1’, ‘B2’, ‘B3’, ‘B4’, ‘B5’, ‘B6’, ‘B7’, ‘B8’, ‘B9’, ‘B10’], [0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]), (‘Block5’, ‘T’, [‘OFF’, ‘B1’, ‘B2’, ‘B3’, ‘B4’, ‘B5’, ‘B6’, ‘B7’, ‘B8’, ‘B9’, ‘B10’], [0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0]), (‘Block6’, ‘T’, [‘OFF’, ‘B1’, ‘B2’, ‘B3’, ‘B4’, ‘B5’, ‘B6’, ‘B7’, ‘B8’, ‘B9’, ‘B10’], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0]), (‘Block7’, ‘T’, [‘OFF’, ‘B1’, ‘B2’, ‘B3’, ‘B4’, ‘B5’, ‘B6’, ‘B7’, ‘B8’, ‘B9’, ‘B10’], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0]), (‘Block8’, ‘T’, [‘OFF’, ‘B1’, ‘B2’, ‘B3’, ‘B4’, ‘B5’, ‘B6’, ‘B7’, ‘B8’, ‘B9’, ‘B10’], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0]), (‘Block9’, ‘T’, [‘OFF’, ‘B1’, ‘B2’, ‘B3’, ‘B4’, ‘B5’, ‘B6’, ‘B7’, ‘B8’, ‘B9’, ‘B10’], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0]), (‘Block10’, ‘T’, [‘OFF’, ‘B1’, ‘B2’, ‘B3’, ‘B4’, ‘B5’, ‘B6’, ‘B7’, ‘B8’, ‘B9’, ‘B10’], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0])]
ignore_exception = False
interscan_interval = 2.5
model_serial_correlations = True
orthogonalization =
session_info = [{‘cond’: [{‘duration’: [17.5], ‘name’: ‘B1’, ‘onset’: [32.399999999999999]}], ‘hpf’: 100.0, ‘regress’: [{‘name’: ‘Realign1’, ‘val’: [REMOVED]}, {‘name’: ‘Realign2’, ‘val’: [REMOVED]}, {‘name’: ‘Realign3’, ‘val’: [REMOVED]}, {‘name’: ‘Realign4’, ‘val’: [REMOVED]}, {‘name’: ‘Realign5’, ‘val’: [REMOVED]}, {‘name’: ‘Realign6’, ‘val’: [REMOVED]}, {‘name’: ‘Outlier1’, ‘val’: [REMOVED]}], ‘scans’: ‘/var/folders/48/_q3xrnms1sqbtkhrvrj52x400000gp/T/tmpzpv73ay0/LEVELONE/modelprep/_ROI_id_R_DLPFC_BLOCK_TMS_subject_id_P101/modelspec/Func_Ready_mcf_st_flirt_smooth.nii.gz’}]

Traceback:
Traceback (most recent call last):
File “/Users/marlengonzalez/anaconda3/lib/python3.6/site-packages/nipype/pipeline/plugins/linear.py”, line 44, in run
node.run(updatehash=updatehash)
File “/Users/marlengonzalez/anaconda3/lib/python3.6/site-packages/nipype/pipeline/engine/nodes.py”, line 487, in run
result = self._run_interface(execute=True)
File “/Users/marlengonzalez/anaconda3/lib/python3.6/site-packages/nipype/pipeline/engine/nodes.py”, line 571, in _run_interface
return self._run_command(execute)
File “/Users/marlengonzalez/anaconda3/lib/python3.6/site-packages/nipype/pipeline/engine/nodes.py”, line 668, in _run_command
_save_resultfile(result, outdir, self.name)
File “/Users/marlengonzalez/anaconda3/lib/python3.6/site-packages/nipype/pipeline/engine/utils.py”, line 244, in save_resultfile
result.outputs.set(**modify_paths(outputs, relative=True, basedir=cwd))
File “/Users/marlengonzalez/anaconda3/lib/python3.6/site-packages/traits/util/deprecated.py”, line 32, in wrapper
return fn(*args, **kw)
File “/Users/marlengonzalez/anaconda3/lib/python3.6/site-packages/traits/has_traits.py”, line 1551, in set
trait_change_notify=trait_change_notify, **traits)
File “/Users/marlengonzalez/anaconda3/lib/python3.6/site-packages/traits/has_traits.py”, line 1543, in trait_set
setattr( self, name, value )
File “/Users/marlengonzalez/anaconda3/lib/python3.6/site-packages/nipype/interfaces/base/traits_extension.py”, line 341, in validate
value = super(MultiPath, self).validate(object, name, newvalue)
File “/Users/marlengonzalez/anaconda3/lib/python3.6/site-packages/traits/trait_types.py”, line 2336, in validate
return TraitListObject( self, object, name, value )
File “/Users/marlengonzalez/anaconda3/lib/python3.6/site-packages/traits/trait_handlers.py”, line 2313, in init
raise excp
File “/Users/marlengonzalez/anaconda3/lib/python3.6/site-packages/traits/trait_handlers.py”, line 2305, in init
value = [ validate( object, name, val ) for val in value ]
File “/Users/marlengonzalez/anaconda3/lib/python3.6/site-packages/traits/trait_handlers.py”, line 2305, in
value = [ validate( object, name, val ) for val in value ]
File “/Users/marlengonzalez/anaconda3/lib/python3.6/site-packages/traits/trait_types.py”, line 2336, in validate
return TraitListObject( self, object, name, value )
File “/Users/marlengonzalez/anaconda3/lib/python3.6/site-packages/traits/trait_handlers.py”, line 2313, in init
raise excp
File “/Users/marlengonzalez/anaconda3/lib/python3.6/site-packages/traits/trait_handlers.py”, line 2305, in init
value = [ validate( object, name, val ) for val in value ]
File “/Users/marlengonzalez/anaconda3/lib/python3.6/site-packages/traits/trait_handlers.py”, line 2305, in
value = [ validate( object, name, val ) for val in value ]
File “/Users/marlengonzalez/anaconda3/lib/python3.6/site-packages/nipype/interfaces/base/traits_extension.py”, line 112, in validate
self.info_text, value))
traits.trait_errors.TraitError: The trait ‘ev_files’ of a Level1DesignOutputSpec instance is an existing file name, but the path ‘/private/var/folders/48/_q3xrnms1sqbtkhrvrj52x400000gp/T/tmpxajxgq9q/LEVELONE/modelprep/_ROI_id_R_DLPFC_BLOCK_TMS_subject_id_P101/level1design/ev_B1_0_1.txt’ does not exist.

I didn’t get if you run this specific example in a docker container. If yes, did you run other, simpler, workflows in the same container?

did you specify base_dir of your Workflow?

Hi @djarecka! Thanks for the reply. Although I’be seen this type of error around Neurostars relating to use of virtual machines, my own problem is actually with my own computer running everything. I checked to make sure that there are no base_dir issues and indeed everything matches up. I also tried to play around with how I call up the event files using the function below but that doesn’t seem to help.

Any further help would be appreciated!

Marlen

def subjectinfo(subject_id):
import pandas as pd
from nipype.interfaces.base import Bunch
from os.path import join as opj
#EV_FILE= opj(‘preproc’,‘TMS_Block_Timings.txt’)
trialinfo = pd.read_table(’~/Documents/Projects/spTMS-fMRI/fMRI_data/PREPROC_Try2/preproc/TMS_Block_Timings.txt’)
trialinfo.head()
conditions = []
onsets = []
durations = []
for group in trialinfo.groupby(‘Event’):
conditions.append(group[0])
onsets.append(group[1].Onset.tolist())
durations.append(group[1].Duration.tolist())
subject_info = [Bunch(conditions=conditions,
onsets=onsets,durations=durations,
#amplitudes=None,
#tmod=None,
#pmod=None,
#regressor_names=None,
#regressors=None
)]
return subject_info # this output will later be returned to infosource
# Function node to use getsubjectinfo
getsubjectinfo = Node(Function(input_names=[‘subject_id’],
output_names=[‘subject_info’],
function=subjectinfo),
name=‘getsubjectinfo’)

I don’t see Workflow in this code. Do you use nipype Workflow or only Node?

If you use Workflow can you please paste the code showing how you define and use it.

Hi @djarecka,

You were totally right. I have two workflows connected into a larger workflow. Once I specified the base_dir, in the larger workflow this error went away. Thanks!

LEVELONE = Workflow(name=‘LEVELONE’)
LEVELONE.base_dir= preproc_dir

great!
base_dir is important when using Workflow! We probably should think about better warnings.