[Mne_analysis] [mne-python] strange behavior of raw.save()

Denis-Alexander Engemann d.engemann at fz-juelich.de
Sat Sep 8 18:23:14 EDT 2012
Search archives:

Ok, self._data == True or self._preodaded == True does not make a difference.

Is it at all possible to write make a ras.save using the identical fid?
Otherwise we should just add:

if fname == self.info['filename']:
            raise RuntimeError('Invalid operation. Use an alternative
file name')


2012/9/9 Denis-Alexander Engemann <d.engemann at fz-juelich.de>
> Ok. self._preload
>
> 2012/9/9 Denis-Alexander Engemann <d.engemann at fz-juelich.de>:
>> Ok, I tried the following:
>>
>> I added
>>
>> if fname == self.info['filename'] and not hasattr(self,'_data'):
>>             raise ValueError('Invalid operation. Either read data with preload '
>>                                     'option or use alternative file name')
>>
>> to Raw.save
>>
>> Hower, in case the data is preloaded the file still breaks...
>>
>>
>>
>>
>> 2012/9/8 Denis-Alexander Engemann <d.engemann at fz-juelich.de>:
>>> Thanks Martin,
>>>
>>> that must be it.
>>> I actually I was testing a new command line tool of mine for mass riff
>>> export / augmentation  / conversion
>>> And in one of the use cases I simply wanted to change the info
>>> structure without loading the data.
>>> So this means I can either preload the data or work around it by e.g.
>>> iterative renaming.
>>>
>>> To prevent users from tnings like that one could add something like
>>>
>>> raw.save(fname)
>>>
>>> (...)
>>>
>>> if fname == self.raw.info['filename'] and not self.preload:
>>>     raise ValueError("Invalid operation "
>>>                             "Either load data or use alternative file name")
>>>
>>>
>>> Wdyt?
>>>
>>> Cheers,
>>> Denis
>>>
>>>
>>>
>>> 2012/9/8 Martin Luessi <mluessi at nmr.mgh.harvard.edu>:
>>>> Hi Denis,
>>>>
>>>> Are you by any chance saving the raw file to the same file from where you
>>>> read it? I.e., something like
>>>>
>>>> raw = Raw('test_raw.fif')
>>>> ..
>>>> raw.save('test_raw.fif')
>>>>
>>>> Unless you use preload=True, this won't work since raw.save() will read from
>>>> the file and at the same time overwrite it. We should add a check such that
>>>> it throws and exception with a explanatory error message if one tries to do
>>>> this.
>>>>
>>>> Martin
>>>>
>>>>
>>>> On 09/08/12 16:04, Denis-Alexander Engemann wrote:
>>>>>
>>>>> Hi all,
>>>>>
>>>>> on saving a raw file using the instance method save() I get the
>>>>> following error message.
>>>>>
>>>>> http://pastebin.com/g66H4svV
>>>>>
>>>>> After that the file is not readable anymore ( the same error message
>>>>> will appear as Raw.__init__() is called. )
>>>>>
>>>>> If I use an alternative file name this does not happen.
>>>>>
>>>>> a) what is the reason for that / what does it actually tell, and
>>>>>
>>>>> b) shouldn't that rather throw an exception than messing up the original
>>>>> file?
>>>>>
>>>>>
>>>>> Cheers,
>>>>> Denis
>>>>>
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------------------------
>>>>>
>>>>> ------------------------------------------------------------------------------------------------
>>>>> Forschungszentrum Juelich GmbH
>>>>> 52425 Juelich
>>>>> Sitz der Gesellschaft: Juelich
>>>>> Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
>>>>> Vorsitzender des Aufsichtsrats: MinDir Dr. Karl Eugen Huthmacher
>>>>> Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
>>>>> Karsten Beneke (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
>>>>> Prof. Dr. Sebastian M. Schmidt
>>>>>
>>>>> ------------------------------------------------------------------------------------------------
>>>>>
>>>>> ------------------------------------------------------------------------------------------------
>>>>>
>>>>> Kennen Sie schon unsere app? http://www.fz-juelich.de/app
>>>>>
>>>>> _______________________________________________
>>>>> Mne_analysis mailing list
>>>>> Mne_analysis at nmr.mgh.harvard.edu
>>>>> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> 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.
>>>>



More information about the Mne_analysis mailing list