Export to fif?

Hi Francois,

Is there a way to export a fif file once I clean out the artifact using Brainstorm?

Thanks!
Kana

No, I’m sorry, there is no easy way to save the modifications made in Brainstorm back to a FIF file.
Francois

Hi Kana,

I’ve just added an option to export the SSP projectors computed in Brainstorm (for the artifact cleaning) in FIF format.
This way you can import them back in the original FIF files using MNE (mne_browse_raw).

To do this:

  1. Open your cleaned continuous file.
  2. In the events panel, select the menu SSP > Select active projectors
  3. Select the category of projectors you want to export (“blink”, or “cardiac”, …)
  4. Click on the “save selected projector” button
  5. In the dialog box to select the file to create: change the file format to “Neuromag/MNE (*.fif)”

Cheers,
Francois

Hi Francois,
Is exporting fif an active development area? I’m interested in using BST to make bad channels before running SSS via maxfilter (for Elekta). This means I would want to start with BST, leave BST via fif, and return to BST.

Thanks,
Stephen

Hi Stephen,

I added a few days ago the support for processing native continuous FIF files with Brainstorm. The available operations are relatively limited, and can only overwrite directly the recordings values. We cannot make any change to the other information in the file (time definition, position of the sensors, list of bad channels, number of channels…). What is fully supported so far:

Note that the SSP calculated with Brainstorm are not saved back to the FIF file. They are kept in the Brainstorm database only (in the “Link to raw file” entry). But if you call the process “Artifacts > Apply SSP and CTF compensation”, Brainstorm creates a new file were all the SSP projectors are applied.

What do you mean by “make bad channels”? If it means replacing the real recordings with noise, yes this is doable easily, by creating your own process.

  1. Copy the process file brainstorm3/toolbox/process/functions/process_ssp_apply.m to your user process folder and rename it ($HOME/.brainstorm/process/process_make_bad.m)
  2. Change the process comment, line 31, so that you can identify it in the process list
  3. Add some code in the Run function (line 55) to replace the values of channel #i by noise:
    sInput.A(i,:slight_smile: = rand(1, size(sInput.A,2));
  4. Drag and drop the “link to raw file” to the Process1 box, and select your process “Artifacts > Make bad channels”. Those functions are plugins that are detected automatically each time you click on the “Run” button in the Process1 tab.

This will read the file time block by time block (as specified by line 43: processDim=2), pass the data to the Run function through the sInput.A field, and save the modifications to sInput.A back to the file.

Please let me know if you need more information.
Francois

Thanks for the reply. Great to hear I’m you and I are moving in the same direction. I’ll update my BST and test out the functions you mentioned.

“make bad channels” was a typo, sorry. I meant “using BST to MARK bad channels”. Before performing SSS via MaxFilter I need to inspect the data to mark bad channels.

Ideally we could have software that visualizes raw data, a user marks bad channels, SSS is performed, and the clean data is used from then on. Unfortunately, I haven’t seen any implementations of SSS other than MaxFilter, which means most people use mne_browse_raw to mark bad channels, send the marked fif files to maxfilter, and then have the clean data for their choice of analysis software. I’d love to streamline this process.

As I said earlier, we cannot change the list of bad channels from Brainstorm, we can just overwrite some blocks of recordings. I understand your objectives but the FIF format is very difficult to work with, I don’t want to invest too much development time into implementing operations that can be done in other ways.
Maybe you can ask about easy ways to modify the list of bad channels in the FIF files to the Elekta-Neuromag or MNE development teams.
I don’t know much about MaxFilter or SSS. To my understanding, Neuromag does not provide any clear details on the methods implemented in this program, which makes impossible the development of a free implementation.

Hi Francois,

I’m using your SSP export function (thanks) but have a question about how SSPs are applied in BST. My goal is to apply SSPs to the raw data outside of BST (or to export the cleaned data out of BST, but I don’t see that option).

I’ve worked through some of the math (summary: http://neuroimage.usc.edu/brainstorm/Tutorials/TutRawSsp#Calculate_the_projector) and I looked through the code (process_ssp.m), but I can’t find how/where the projectors are actually applied.

Thanks,
Stephen

[QUOTE=Francois;3719]Hi Kana,

I’ve just added an option to export the SSP projectors computed in Brainstorm (for the artifact cleaning) in FIF format.
This way you can import them back in the original FIF files using MNE (mne_browse_raw).

To do this:

  1. Open your cleaned continuous file.
  2. In the events panel, select the menu SSP > Select active projectors
  3. Select the category of projectors you want to export (“blink”, or “cardiac”, …)
  4. Click on the “save selected projector” button
  5. In the dialog box to select the file to create: change the file format to “Neuromag/MNE (*.fif)”

Cheers,
Francois[/QUOTE]

Hi Stephen,

The easiest way is that you force brainstorm to save a new file on which the SSP projectors are applied. For that, use the process “Artifacts > Apply SSP and CTF compensations”.
Note that they would not a appear as available SSP projectors available in MNE, it’s just the values that are modified.

Cheers,
Francois