Nipype ExtractROI output

Hi everyone!

I am trying to run ExtractROI on my 4D time series so that I can trim down the time series to the same length on all my subjects. I am using Nipype to wrap ExtractROI. I have essentially used the exact same code that I am using right now, and it has worked, but I keep getting a very strange error for some reason. My code:

for i in list(range(len(mul_files))):
if os.path.isfile(mul_files[i]):
    print('Running FSL ExtractROI for ' + mul_files[i])

    trim = fsl.ExtractROI()
    trim.inputs.t_size = 381
    trim.inputs.t_min = 2
    trim.inputs.in_file = mul_files[i]
    trim.inputs.roi_file = mul_files[i][0:-7] + '_trim.nii.gz'
    trim.run()
    
    trimmed_files.append(mul_files[i][0:-7] + '_trim.nii.gz')
    
else:
    print('The file ' + mul_files[i] + ' does not exist.')  

… where “mul_files” is the list of all the files that need to be trimmed. However, I keep getting this error whenever I try running it:

Running FSL ExtractROI for /Users/ryanntansey/Documents/VSDevel_files/todo_correlation/sub-1089001/ses-6/func/regression/sub-1089001_ses-6_CenDetBPFRegFEFRem_warp_bet_mul.nii.gz
200414-15:40:56,512 nipype.interface INFO:
     stderr 2020-04-14T15:40:56.512227:vector
Traceback (most recent call last):

File "<ipython-input-2-74350b92a1ee>", line 13, in <module>
  trim.run()

File "//anaconda3/lib/python3.7/site-packages/nipype/interfaces/base/core.py", line 399, in run
  outputs = self.aggregate_outputs(runtime)

File "//anaconda3/lib/python3.7/site-packages/nipype/interfaces/base/core.py", line 507, in aggregate_outputs
  raise FileNotFoundError(msg)

FileNotFoundError: No such file or directory '/Users/ryanntansey/Documents/VSDevel_files/todo_correlation/sub-1089001/ses-6/func/regression/sub-1089001_ses-6_CenDetBPFRegFEFRem_warp_bet_mul_trim.nii.gz' for output 'roi_file' of a ExtractROI interface

This doesn’t make much sense to me, since “roi_file” is where I am setting the name of the output. Why is it mad that it can’t find the roi_file in my directory, if that’s what I’m telling it to create?

Thanks!

Ryann