maartenmennes/ICA-AROMA

FileExistsError: [Errno 17] File exists: 'melodic.ica'

Closed this issue · 4 comments

ICA_AROMA.py -den nonaggr -i /scratch/fmriprep_wf/single_subject_01_wf/func_preproc_task_mixedgamblestask_run_01_wf/ica_aroma_wf/smooth/vol0000_xform-00000_merged_smooth.nii.gz -meldir /scratch/fmriprep_wf/single_subject_01_wf/func_preproc_task_mixedgamblestask_run_01_wf/ica_aroma_wf/melodic -mc /scratch/fmriprep_wf/single_subject_01_wf/func_preproc_task_mixedgamblestask_run_01_wf/bold_hmc_wf/normalize_motion/motion_params.txt -o out
Standard output:

------------------------------- RUNNING ICA-AROMA ------------------------------- 
--------------- 'ICA-based Automatic Removal Of Motion Artifacts' --------------- 

Step 1) MELODIC
  - The existing/specified MELODIC directory will be used.
  - The MELODIC directory does not contain the required 'stats' folder. Mixture modeling on the Z-statistical maps will be run.
Standard error:
Traceback (most recent call last):
  File "/opt/ICA-AROMA/ICA_AROMA.py", line 193, in <module>
    aromafunc.runICA(fslDir, inFile, outDir, melDir, mask, dim, TR)
  File "/opt/ICA-AROMA/ICA_AROMA_functions.py", line 60, in runICA
    os.makedirs(melDir)
  File "/usr/local/miniconda/lib/python3.6/os.py", line 220, in makedirs
    mkdir(name, mode)
FileExistsError: [Errno 17] File exists: 'melodic.ica'
Return code: 1

How to replicate: run ICA-AROMA with a -meldir that doesn't contain a stats/ folder.

Solution: do not create the folder because it must exist.

Hi Oscar,
this error is not related to running AROMA with a -meldir that doesn't contain a stats/ folder. Instead, it is related to RErunning AROMA with a -meldir that doesn't contain a stats/ folder while specifying an ICA-AROMA output folder that already exists and was used for a previous run. I have now added an explicit -overwrite option that will delete the existing folder (and thus avoid this error).

Hi @maartenmennes, please reopen this issue.

Because of this line:

os.chdir(scriptDir)

Any relative path given as output directory will be created under the path of ICA-AROMA.

I would suggest packaging the software properly or modifying the sys.path to allow the relative imports. But this directory change is really risky.

(I forgot to mention that you get this FileExistsError whenever you run ICA-AROMA for a second time in any given system if you are attempting to use relative paths for output directory)

yes, I'm really not happy with how this was originally implemented. This will be next on my AROMA list to change...