Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Equivalent for mne_mark_bad_channels #101

Closed
larsoner opened this issue Sep 19, 2012 · 8 comments
Closed

Equivalent for mne_mark_bad_channels #101

larsoner opened this issue Sep 19, 2012 · 8 comments

Comments

@larsoner
Copy link
Member

Currently making system calls to accomplish this. Perhaps it could currently be done by reading a raw fif and writing it out again, but I imagine this will be slow as it will have to re-write all the channel data (I assume this is not what the C code does?).

@dengemann
Copy link
Member

Wouldn't it be sufficient just to add the appropriate channel name to the respective raw.info['bads'] ?

On 20.09.2012, at 02:46, Eric89GXL notifications@github.com wrote:

Currently making system calls to accomplish this. Perhaps it could currently be done by reading a raw fif and writing it out again, but I imagine this will be slow as it will have to re-write all the channel data (I assume this is not what the C code does?).


Reply to this email directly or view it on GitHub.

@larsoner
Copy link
Member Author

I assume that that, followed by a save() would work---when I looked at the how Raw.save() was coded, I thought it would cause it to re-write all the data to disk, though. It's possible I mis-read the code, though, so I'll give it a shot tomorrow.

@dengemann
Copy link
Member

You have to explicitly pass a name to save which is different from raw.info['filename'] if i understand you problem right.

-Denis

On 20.09.k2012, at 03:34, Eric89GXL notifications@github.com wrote:

I assume that that, followed by a save() would work---when I looked at the how Raw.save() was coded, I thought it would cause it to re-write all the data to disk, though. It's possible I mis-read the code, though, so I'll give it a shot tomorrow.


Reply to this email directly or view it on GitHub.

@larsoner
Copy link
Member Author

Yeah, I think that's what it was. mne_mark_bad_channels is nice because it operates on the file itself, I believe without needing to re-write / duplicate the data. In the meantime I'll probably just save to a different file and replace the old one until there's a more elegant solution.

@agramfort
Copy link
Member

indeed mne_mark_bad_channels avoids duplicating the file. I could look into this. The thing is that since I work with python functions It just works to do raw.info['bads'] = ['...']

but I agree that its nice to store in the file the bad channels...

@mshamalainen
Copy link
Member

mne_mark_bad_channels makes use of the fact that the tags in a fif file form a linked list. Therefore, you can add new tags, in this case the bad channel list, in the middle of the existing tag list without having to move the remainder of the file forward. The bad channel list is thus physically located at the end of the file but logically in the middle of it. Furthermore, when a bad channel list is modified, mne_mark_bad_channels marks the existing list as "free space" and writes a new bad channel tag according to the new bad channel specification. This was necessary because the tag data sizes can be different.

I suppose all of this could be done in Python, too. However, when I wrote the MNE Matlab code I felt it was not necessary to include support for the rarely used fif features employed in mne_mark_bad_channels.

  • Matti

On Sep 20, 2012, at 1:04 AM, Eric89GXL wrote:

Yeah, I think that's what it was. mne_mark_bad_channels is nice because it operates on the file itself, I believe without needing to re-write / duplicate the data. In the meantime I'll probably just save to a different file and replace the old one until there's a more elegant solution.


Reply to this email directly or view it on GitHub.


Matti Hamalainen, Ph.D.
Athinoula A. Martinos Center for Biomedical Imaging
Massachusetts General Hospital

msh@nmr.mgh.harvard.edu
mhamalainen@partners.org

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.

@larsoner
Copy link
Member Author

That makes sense. It occurred to me that since we're porting our analysis stream to Python now, we should be able to just use what you all suggested and set the raw.info['bads'] directly, since we can combine that step in preprocessing with filtering, SSP, etc. before writing out the processed files. Feel free to close this issue!

@larsoner
Copy link
Member Author

Is it alright if I add a function to fiff.raw called mark_bad_channels that reads in bad channels from a text file and marks them in raw.info? I think it would decrease the barrier of entry for folks who were already making use of saving bad channels in text files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants