Q: File size limits
A question on the mne-analysis listserve made me wonder what types of file-size checks we do when writing files. I think we're not supposed to write files larger than 2GB due to FIFF limitations. It would be good to have some sort of check on this, since I don't remember seeing one...?
Eric, I think we've had this issue before and I remember the same hard facts.
You would even find this in the mne manuak: "If the length of an output raw data file exceeds the 2-Gbyte fif file size limit, the output is split into multiple files."
indeed we have to check the size limit...
I just spoke to @mshamalainen, the C code splits the files and puts a link to the next file at the end of each file, such that when opening the first file the other ones are loaded automatically. It seems to me that it is too late to add this and properly test it before 0.7. How about we add a check in Raw.save and throw an exception if the file will be larger than 2GB? Then we can properly fix it after the release.
Just a clarification: C code puts in the links but does not load the chain of files automatically.
- Matti
On Nov 25, 2013, at 9:21 AM, Martin Luessi [email protected] wrote:
I just spoke to @mshamalainen, the C code splits the files and puts a link to the next file at the end of each file, such that when opening the first file the other ones are loaded automatically. It seems to me that it is too late to add this and properly test it before 0.7. How about we add a check in Raw.save and throw an exception if the file will be larger than 2GB? Then we can properly fix it after the release.
— Reply to this email directly or view it on GitHub.
Matti Hamalainen, Ph.D. Athinoula A. Martinos Center for Biomedical Imaging Massachusetts General Hospital
[email protected] [email protected]
The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Partners Compliance HelpLine at http://www.partners.org/complianceline . If the e-mail was sent to you in error but does not contain patient information, please contact the sender and properly dispose of the e-mail.
Have a look at MNE/mne_browse_raw/save.c in the C code to see how the writing is done.
On Nov 25, 2013, at 9:21 AM, Martin Luessi [email protected] wrote:
I just spoke to @mshamalainen, the C code splits the files and puts a link to the next file at the end of each file, such that when opening the first file the other ones are loaded automatically. It seems to me that it is too late to add this and properly test it before 0.7. How about we add a check in Raw.save and throw an exception if the file will be larger than 2GB? Then we can properly fix it after the release.
— Reply to this email directly or view it on GitHub.
The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Partners Compliance HelpLine at http://www.partners.org/complianceline . If the e-mail was sent to you in error but does not contain patient information, please contact the sender and properly dispose of the e-mail.
It seems to me that it is too late to add this and properly test it before 0.7. How about we add a check in Raw.save and throw an exception if the file will be larger than 2GB? Then we can properly fix it after the release.
I would say let's add the basic treatment ASAP and then we can then see when we add the proper fix. We have still have ~24h ;-)
While it's not technically correct, we might be able to get away with writing raw files that are >2GB. I think the limitation comes from storing where the raw data tag begins, which should always be well under 2GB. AFAIK we don't store anything after the raw data.
If that's true, then we could issue a warning if the file size is > 2GB, as opposed to throwing an error. My fear with an error is that it might break lots of people's code, when we don't absolutely have to. Especially since we by default save data as float32, it's possible that people with recordings in short (16-bit) format, or people who have been working with concatenated files, may end up not being able to use mne-python due to this change. I don't particularly like leaving an error in place like that, but it might be workable...
The alternative is to throw an error. If we go this route, we should fix the bug ASAP (within a couple of weeks). That way, if we do break a bunch of people's code by throwing the error in 0.7, we can implement a fix and backport it to make a 0.7.1 release. Now that I think about it, I probably lean toward that solution for safety's sake.
There is also the problem that files larger than 2 GB cannot have the tag directory at the end. The clean solution would be to have a new fif format version with 64-bit pointers implemented. This could be done so that the 64-bit pointer, rarely needed, is a separate tag. I can flesh out this idea here.
On Nov 25, 2013, at 11:13, Eric89GXL [email protected] wrote:
While it's not technically correct, we might be able to get away with writing raw files that are >2GB. I think the limitation comes from storing where the raw data tag begins, which should always be well under 2GB. AFAIK we don't store anything after the raw data.
If that's true, then we could issue a warning if the file size is > 2GB, as opposed to throwing an error. My fear with an error is that it might break lots of people's code, when we don't absolutely have to. Especially since we by default save data as float32, it's possible that people with recordings in short (16-bit) format, or people who have been working with concatenated files, may end up not being able to use mne-python due to this change. I don't particularly like leaving an error in place like that, but it might be workable...
The alternative is to throw an error. If we go this route, we should fix the bug ASAP (within a couple of weeks). That way, if we do break a bunch of people's code by throwing the error in 0.7, we can implement a fix and backport it to make a 0.7.1 release. Now that I think about it, I probably lean toward that solution for safety's sake.
— Reply to this email directly or view it on GitHub.
The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Partners Compliance HelpLine at http://www.partners.org/complianceline . If the e-mail was sent to you in error but does not contain patient information, please contact the sender and properly dispose of the e-mail.
I just spoke to @mshamalainen https://github.com/mshamalainen, the C code splits the files and puts a link to the next file at the end of each file, such that when opening the first file the other ones are loaded automatically. It seems to me that it is too late to add this and properly test it before 0.7. How about we add a check in Raw.save and throw an exception if the file will be larger than 2GB? Then we can properly fix it after the release.
+1 for the exception and the proper fix for the next release
Anyone volunteering here? --- maybe our transatlantic fraction could take a look into it while the continentals take some sleep.
I guess the easiest fix would be to use fid.tell() in write_raw_buffer to check if the position is over the 2GB limit. Thoughts?
@mluessi maybe I'm to tired to get a grip on this, but assuming that we have all data in memory at some point as a numpy array, could it help to check data like this '%i MB' % (X.size * X.itemsize / 1e6)
@dengemann I think fid.tell() would be easier and it would also take into account the space needed for measurement info etc.
@mluessi it was my bad conscience for delegating this ;-) please go for it.
Will give it a try..