OSError: [Errno 7] Argument list too long

533 views
Skip to first unread message

thomas.nickson

unread,
Feb 10, 2014, 10:28:56 AM2/10/14
to nipy...@googlegroups.com
I'm trying to write a dcm2nifti script, currently trying to convert some resting state data which is over 5000 dcm's.

When I try and do this I get the error OSError: [Errno 7] Argument list too long.

Is this a common problem? Is there anyway to work around it?

I attach the crash file.

crash-20140210-145321-tnickson-dicom2nifti.a4.npz

Satrajit Ghosh

unread,
Feb 10, 2014, 10:43:50 AM2/10/14
to nipy-user
hi thomas,

unfortunately this is an os issue. to make things work with dcm2nii, you could:

- restrict the dicoms to each run
- give only one file (unless you are using this in a workflow - see below)
- modify the interface to attach a input directory option in lieu of files.

use in workflow:
because of how dcm2nii works, it will convert every dicom file in a directory. to prevent converting everything over and over again, a recent change in the interface links to the relevant files and attaches them to the command line. this could be changed in the interface to not list all the files but just the first one.

if you are comfortable making edits to the interface, you could do add the following to the dcm2nii _format_arg function:

if opt == 'source_names':
    return spec.argstr % val[0]

cheers,

satra

--
 
---
You received this message because you are subscribed to the Google Groups "NiPy Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nipy-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

thomas.nickson

unread,
Feb 10, 2014, 10:54:23 AM2/10/14
to nipy...@googlegroups.com
Hey, thanks for your reply. I would like to clarify a couple of things.



to prevent converting everything over and over again

Was this a previous bug? I'm not using it in a work flow so I assume that it shouldn't matter if I make such changes



modify the interface to attach a input directory option in lieu of files.

This seems like the most sane option to me but was there some reason that this option wasn't included?


if you are comfortable making edits to the interface, you could do add the following to the dcm2nii _format_arg function:

if opt == 'source_names':
    return spec.argstr % val[0]

Is this to make the change so that I only send the first file? Does it have to be the first file (sequentially) or can it be any single file?

Many thanks,

Tom

thomas.nickson

unread,
Feb 11, 2014, 4:46:12 AM2/11/14
to nipy...@googlegroups.com
I just checked that the command line version of it would actually crash out with the error due to it being too long for the command line. It doesn't. It works fine. I'm still not sure how this bug is being generated unless all of the commands are being && together but I don't think that that is the case. Any further thoughts on this?

Thanks,

Tom

Satrajit Ghosh

unread,
Feb 11, 2014, 6:54:26 AM2/11/14
to nipy-user
hi tom,

did you copy and paste the contents of the command output on the screen when running?

cheers,

satra

thomas.nickson

unread,
Feb 11, 2014, 7:44:56 AM2/11/14
to nipy...@googlegroups.com
Yes I just took it from the command.txt and pasted it in to the terminal.

Thanks

Ben

unread,
Jun 11, 2014, 12:16:45 PM6/11/14
to nipy...@googlegroups.com
I just started having issues with this as well.

My previous approach was to have a node that hard linked all of my dicoms (which were sometimes spread out over several directories) into a single folder, then hand the first item from that list of links to dcm2nii. This worked quite nicely.

Now I've updated my workflows for the new dcm2nii interface, and I'm running into this error all over the place.

So, I have a proposal: I'd like to write my link-creating stuff into the dcm2nii interface, so it'll create a folder in its working directory containing hard links of all of the passed-in dicoms, then call dcm2nii with the first of those links, telling it to convert everything in the directory.

I'm pretty sure that would get the issue fixed. If this sounds good to you, I can code it up and submit in the next couple of days.

I'll add this to the github issues list as well - in case you're reading one more than the other.

Ben Acland

thomas.nickson

unread,
Jun 16, 2014, 7:29:16 AM6/16/14
to nipy...@googlegroups.com
Did you try the fix that Satra suggested. I just add that to my code and then it works fine. The only thing is I need to re-write it every time I upgrade. I think he said he's not interested in doing it that way because it's too difficult to keep the hashes up to date or something. Anyway, if someone submits some code that's just a switch that sets the fix Satra suggested that would be great.

Chris Filo Gorgolewski

unread,
Jun 16, 2014, 7:41:16 AM6/16/14
to nipy...@googlegroups.com
This fixed have been merged into master a while ago. Please try it out.

Best,
Chris


For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages