[FieldTrip] Fwd: FT doesn't close .fif files
v.litvak at ion.ucl.ac.uk
Wed Feb 9 21:48:35 CET 2011
I think I know Robert's views quite well and he wouldn't like your
solution because ft_preprocessing will have to deal with a
format-specific low-level issue that should be handled by fileio. This
will violate the software architecture which for FT is a big deal (and
rightly so). If, however, it is sufficient to store in the header a
single number which can then be used to find the data onset and from
there to find where to start reading (so perhaps not an fid but just
the data offset in bytes to do fseek), that'd be a perfectly good
solution and fast as well. But I don't know enough about fif format
to say if it's possible.
On Wednesday, February 9, 2011, Scott Burns <sburns at nmr.mgh.harvard.edu> wrote:
> --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 BurnsKuperberg LabMartinos Center for Biomedical Imagingsburns 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:
> 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.
More information about the fieldtrip