[FieldTrip] FT doesn't close .fif files

Scott Burns sburns at nmr.mgh.harvard.edu
Wed Feb 9 19:44:19 CET 2011

--I tried sending this on the bug report thread but got a delivery failure notice --

Robert, Laurence and Alexandre -

Thanks for the feedback on this issue. Here are my thoughts on further investigation.

Since ft_preprocessing calls its own ft_read_header (ft_preprocessing:327), ft_read_event isn't actually going for data, and that ft_definetrial and ft_preprocessing are separate high-level functions, then I think we can assume that no actual data will be read during ft_read_event and the file can be closed towards the end of the ft_read_event function. That closes one leak.

Because ft_preprocessing is one of the high-level functions of FT and that the function is structured to operate on the data file once per event, it should clean up anything it opened.  It'd be simple enough to check if hdr.orig.raw.fid is still open after all the data reading has been done (after ft_preprocessing:530) and close it.  This way, you wouldn't have to fundamentally change how ft_read_data operates on neuromag files. I'm not sure how the architecture of FT deals with other file formats and whether this is sort of leak can occur in other situations, but this seems to be the easiest fix to this problem.

Scott Burns
Kuperberg Lab
Martinos Center for Biomedical Imaging
sburns at nmr.mgh.harvard.edu

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.

On Feb 9, 2011, at 1:16 PM, Alexandre Gramfort wrote:

> hi,
>> I don't think this works because fopen will place the file cursor at the beginning of the file, whereas fiff_setup_read_raw places the cursor at the beginning of the data (after all the header tags in the .fif file).
> ok. That was a quick and dirty hack to give an idea.
>> So we need to store the cursor position too. See my earlier e-mail.
> maybe you or scott can propose a fix in the same vein?
> I can give you write access to the mne-matlab code if you want.
> Alex

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20110209/278c871a/attachment-0002.html>

More information about the fieldtrip mailing list