incf-nidash / nidmresults-fsl

A python library to export FSL's feat results to NIDM-Results
http://nidm.nidash.org/specs/nidm-results.html
MIT License
3 stars 11 forks source link

Permission denied crash on export #148

Open mih opened 5 years ago

mih commented 5 years ago

Log:

% nidmfsl sub-01/2ndlvl.gfeat -g controls 3 -o /tmp/
Exporting NIDM results from /home/mih/forrest/collection/visloc/sub-01/2ndlvl.gfeat
...
Traceback (most recent call last):
  File "/home/mih/env/datalad3-dev/bin/nidmfsl", line 6, in <module>
    exec(compile(open(__file__).read(), __file__, 'exec'))
  File "/home/mih/hacking/datalad/nidmresults-fsl/bin/nidmfsl", line 47, in <module>
    output_path = fslnidm.export()
  File "/home/mih/hacking/datalad/nidmresults/nidmresults/exporter.py", line 480, in export
    self.add_object(inference.search_space.file)
  File "/home/mih/hacking/datalad/nidmresults/nidmresults/exporter.py", line 135, in add_object
    nidm_object.export(self.version, export_dir, self.prepend_path)
  File "/home/mih/hacking/datalad/nidmresults/nidmresults/objects/generic.py", line 307, in export
    shutil.copy(file_copied, new_file)
  File "/home/mih/env/datalad3-dev/lib/python3.6/shutil.py", line 241, in copy
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/home/mih/env/datalad3-dev/lib/python3.6/shutil.py", line 121, in copyfile
    with open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: '/tmp/nidm-38mhzddr/SearchSpaceMask.nii.gz'
nidmfsl sub-01/2ndlvl.gfeat -g controls 3 -o /tmp/  7.37s user 1.64s system 130% cpu 6.882 total

/tmp is, as usual mod-777. The directory '/tmp/nidm-38mhzddr/' does not exist at the time of the crash.

mih commented 5 years ago

Here is a three-liner to reproduce the crash

# get datalad dataset
% datalad install https://github.com/psychoinformatics-de/studyforrest-data-visualrois.git
# fetch file content for a single 2nd-level analysis output directory
% datalad get sub-01/2ndlvl.gfeat
# crash
% nidmfsl sub-01/2ndlvl.gfeat -g controls 3 -o /tmp/
mih commented 5 years ago

So it seems that this is an issue with nidmfsl not wanting to, or not being design for running on a 2nd-level analysis (please pardon my ignorance). When I point it do a 2nd-level FEAT output dir, I get this situation:

-> shutil.copy(file_copied, new_file)
(Pdb) new_file
'/tmp/nidm-l4sd7zht/SearchSpaceMask.nii.gz'
(Pdb) file_copied
'/tmp/studyforrest-data-visualrois/sub-01/2ndlvl.gfeat/cope7.feat/mask.nii.gz'

for every contrast, it aims to write to the same file. For some reason (no idea yet why), these files are created with 600 permissions (r--r--r--), hence the "permission denied" error. It should be OK to overwrite this file -- I don't think FSL supports per-contrast masks.

cmaumet commented 5 years ago

@mih: Thanks for digging that up! in principle nidmfsl is designed to work with both first-level and second-level analyses (e.g. this one in our test data). Let me try and see if I can find why this is not behaving as expected on your dataset.

cmaumet commented 5 years ago

The export now works for me on your data using: https://github.com/incf-nidash/nidmresults/pull/54 and https://github.com/incf-nidash/nidmresults-fsl/pull/156.

I'll check that the tests pass before merging.