Could I export the whole flow by generate a .m file at once?

Dear Francois,
I want to perform batch source-analysis processing on 30 subjects. Steps are as follows:

 1. Create a new subject
 2. Use a default EEG cap and 'refine using head points' for MRI registration
 3. Import EEG/MEG with events from a .set file
 4. Accept all the trials
 5. compute head model (BEM)
 6. compute noise covariance from recordings (the baseline)
 7. compute sources (sLoreta) 
 8. output the source file

Could I export the whole flow by generate a .m file at once?
Or do I have to take each step apart and then put them together? I am wondering if every step can be exported into a .m file.

And do you have any advice to simplify this whole process?

Thank you in advance!

The pipeline editor does not handle loops over subjects (yet).

You can find various recommendations in the Scripting tutorial:

The group analysis tutorial is a full-scale example:

Thanks a lot !And I believe I will gain some insights from your guidance.

By the way,I am wondering why there are 39 (40 in total) trials being rejected with :exclamation:.after I import the clean epoch EEG data.
This situation happened in all the subjects being tested so far.

It’s there anything wrong?

https://neuroimage.usc.edu/brainstorm/Tutorials/Epoching#Import_in_database