Station 9 · Lesson 5
Organizing files & storage
sub-002_task-FaceRecognition_eeg.set (D4) · Nothing yet: the data as downloaded.Download the data (opens in a new tab)Script to reach this state
[ALLEEG, EEG, CURRENTSET, ALLCOM] = eeglab;
% Run from inside faces_project, where ds002718 sits in rawdata
bidsRoot = fullfile(pwd, 'rawdata');
EEG = pop_loadset('sub-002_task-FaceRecognition_eeg.set', fullfile(bidsRoot, 'sub-002', 'eeg'));
% Show the dataset in the main EEGLAB window
[ALLEEG, EEG, CURRENTSET] = pop_newset(ALLEEG, EEG, 0, 'setname', 'sub-002 raw', 'gui', 'off');
eeglab redraw;Your browser's back button takes you to the exact place you were, so open anything you like.
The idea in brief
With one participantThe person whose data were recorded in the study., one folder for everything is enough. With twenty participants and five processing stages, you have a hundred files or more. Two months later you will not remember which file you cleaned, with which settings, or which version you used for the figure.
Before and after
Your next questions, each answered in its own section:
Why do I need this step?
The reasons in detail, and the terms you need
And storage grows faster than you expect. Every continuous copy you save of a participant takes about the same size as the raw file. In D4 the raw file of each participant is about 234 MB, and there are 18 participants, so about 4.2 GB for the raw data alone. If you save five stages per participant, you reach about 21 GB before any epochA short time segment cut out around an event. or figure.
This lesson gives you three rules before you start any project: a fixed folder structure, fixed file names, and a storage estimate with a decision in advance about what you save.
Why do I need this step?
And storage grows faster than you expect. Every continuous copy you save of a participant takes about the same size as the raw file. In D4 the raw file of each participant is about 234 MB, and there are 18 participants, so about 4.2 GB for the raw data alone. If you save five stages per participant, you reach about 21 GB before any epoch or figure.
This lesson gives you three rules before you start any project: a fixed folder structure, fixed file names, and a storage estimate with a decision in advance about what you save.
How do I do it in EEGLAB?
8 steps in the menus
First: the structure
- Create a project folder with only five folders in it:
rawdata: the raw data as you downloaded them. Never write anything here.derivatives/eeglab: everything processing produces, with one folder per participant.code: the scripts. They are what reproduces everything else.figures: the final figures.logs: the error files written by the batch scriptA MATLAB file of commands that runs processing steps in order. from the previous lesson.
This is the same logic as BIDSA standard for naming and organizing neuroimaging data files.: raw data in one place, derivatives in another, with the same participant names.
Second: the names
- Name every file from the same parts in the same order: participant, then task, then stage description, then type. Example:
sub-002_task-FaceRecognition_desc-clean_eeg.set. Thedesc-part says which stage this is, and the rest is copied from the raw file. - Make the datasetOne EEG data file loaded in EEGLAB together with its information. name inside EEGLAB say the same thing. When saving with File then Save current dataset as, type the full name, and change the Dataset name from Edit then Dataset info when needed.
Third: storage
- Open the
rawdatafolder in your file explorer and look at the size of one participant’s.setfile. Multiply it by the number of participants, then by the number of continuous stages you plan to save. - Decide what to save before you run. A practical rule:
- Save what is slow or depends on your judgment: ICAA method that separates the recording into independent sources, some brain and some artifact. weights, the list of bad channels, and the numbers of the components you removed.
- Recompute what is fast and automatic: filters, referenceThe point against which each channel's voltage is measured., epoching, baselineThe pre-stimulus period used as the zero level for comparison..
- Always save the final version that goes into statistics.
Fourth: convert your data to BIDS
- If your raw data are not in BIDS format, the EEGA recording of the brain's electrical activity from electrodes on the scalp.-BIDS pluginA package that adds new functions or menus to EEGLAB. bundled with EEGLAB converts them. Open File then BIDS tools then BIDS export wizard (from raw EEG to BIDS) and follow the steps: files, then task, then participants, then events.
- If you already have a STUDYAn EEGLAB structure that groups many participants' datasets for joint analysis., use File then BIDS tools then Export STUDY to BIDS folder.
- Check the result with File then BIDS tools then Validate BIDS dataset. It opens the official validator page in your browser.
D4 itself is an example of a ready BIDS dataset: open its folder and look at dataset_description.json, README, task-FaceRecognition_events.json, and the sub-002 folders and after.
To share one dataset with someone who uses another program, File then Export then Data to EDF/BDF/GDF file writes it in a standard format that most EEG programs read (it needs the Biosig plugin from the install lesson). Use it for sharing only; inside your project, keep the .set files and the BIDS folder.
How do I do it in EEGLAB?
First: the structure
- Create a project folder with only five folders in it:
rawdata: the raw data as you downloaded them. Never write anything here.derivatives/eeglab: everything processing produces, with one folder per participant.code: the scripts. They are what reproduces everything else.figures: the final figures.logs: the error files written by the batch script from the previous lesson.
This is the same logic as BIDS: raw data in one place, derivatives in another, with the same participant names.
Second: the names
- Name every file from the same parts in the same order: participant, then task, then stage description, then type. Example:
sub-002_task-FaceRecognition_desc-clean_eeg.set. Thedesc-part says which stage this is, and the rest is copied from the raw file. - Make the dataset name inside EEGLAB say the same thing. When saving with File then Save current dataset as, type the full name, and change the Dataset name from Edit then Dataset info when needed.
Third: storage
- Open the
rawdatafolder in your file explorer and look at the size of one participant’s.setfile. Multiply it by the number of participants, then by the number of continuous stages you plan to save. - Decide what to save before you run. A practical rule:
- Save what is slow or depends on your judgment: ICA weights, the list of bad channels, and the numbers of the components you removed.
- Recompute what is fast and automatic: filters, reference, epoching, baseline.
- Always save the final version that goes into statistics.
Fourth: convert your data to BIDS
- If your raw data are not in BIDS format, the EEG-BIDS plugin bundled with EEGLAB converts them. Open File then BIDS tools then BIDS export wizard (from raw EEG to BIDS) and follow the steps: files, then task, then participants, then events.
- If you already have a STUDY, use File then BIDS tools then Export STUDY to BIDS folder.
- Check the result with File then BIDS tools then Validate BIDS dataset. It opens the official validator page in your browser.
D4 itself is an example of a ready BIDS dataset: open its folder and look at dataset_description.json, README, task-FaceRecognition_events.json, and the sub-002 folders and after.
To share one dataset with someone who uses another program, File then Export then Data to EDF/BDF/GDF file writes it in a standard format that most EEG programs read (it needs the Biosig plugin from the install lesson). Use it for sharing only; inside your project, keep the .set files and the BIDS folder.
How do I write it as code?
The same steps in 36 lines of MATLAB
[ALLEEG, EEG, CURRENTSET, ALLCOM] = eeglab;
eeglabRoot = fileparts(which('eeglab'));
% Project layout: raw data stay untouched, results go to derivatives
projectRoot = pwd; % run from inside faces_project
bidsRoot = fullfile(projectRoot, 'rawdata'); % ds002718 lives here
derivRoot = fullfile(projectRoot, 'derivatives', 'eeglab');
folders = {bidsRoot, derivRoot, fullfile(projectRoot, 'code'), ...
fullfile(projectRoot, 'figures'), fullfile(projectRoot, 'logs')};
for k = 1:numel(folders)
if ~exist(folders{k}, 'dir'), mkdir(folders{k}); end
end
% Storage estimate from the raw files on disk
rawFiles = dir(fullfile(bidsRoot, 'sub-*', 'eeg', '*_eeg.set'));
rawGB = sum([rawFiles.bytes]) / 1e9;
nSubjects = numel(rawFiles);
fprintf('%d subject(s) on disk, %.2f GB of raw data\n', nSubjects, rawGB);
% Each continuous stage you save costs about one raw copy per subject
nSavedStages = 2; % clean continuous + epochs
fprintf('Derivatives for these subjects: up to about %.1f GB\n', rawGB * nSavedStages);
fprintf('Full dataset (18 subjects): about %.1f GB raw\n', 18 * rawGB / max(nSubjects, 1));
% BIDS-style derivative name for one subject and one stage
subj = 'sub-002';
stage = 'clean';
outDir = fullfile(derivRoot, subj, 'eeg');
if ~exist(outDir, 'dir'), mkdir(outDir); end
outName = sprintf('%s_task-FaceRecognition_desc-%s_eeg.set', subj, stage);
fprintf('Save stage "%s" as %s\n', stage, fullfile(outDir, outName));
% Small files are cheap: keep ICA weights apart from the data
% icaInfo = struct('icaweights', EEG.icaweights, 'icasphere', EEG.icasphere, ...
% 'icachansind', EEG.icachansind);
% save(fullfile(outDir, sprintf('%s_task-FaceRecognition_desc-ica.mat', subj)), '-struct', 'icaInfo');
% Convert a non-BIDS dataset (here D1) to BIDS with EEG-BIDS
data = struct('file', {fullfile(eeglabRoot, 'sample_data', 'eeglab_data.set')});
% Practice export only: delete d1_bids when you are done
bids_export(data, 'targetdir', fullfile(projectRoot, 'd1_bids'), ...
'tInfo', struct('TaskName', 'attention', 'PowerLineFrequency', 60));How do I write it as code?
[ALLEEG, EEG, CURRENTSET, ALLCOM] = eeglab;
eeglabRoot = fileparts(which('eeglab'));
% Project layout: raw data stay untouched, results go to derivatives
projectRoot = pwd; % run from inside faces_project
bidsRoot = fullfile(projectRoot, 'rawdata'); % ds002718 lives here
derivRoot = fullfile(projectRoot, 'derivatives', 'eeglab');
folders = {bidsRoot, derivRoot, fullfile(projectRoot, 'code'), ...
fullfile(projectRoot, 'figures'), fullfile(projectRoot, 'logs')};
for k = 1:numel(folders)
if ~exist(folders{k}, 'dir'), mkdir(folders{k}); end
end
% Storage estimate from the raw files on disk
rawFiles = dir(fullfile(bidsRoot, 'sub-*', 'eeg', '*_eeg.set'));
rawGB = sum([rawFiles.bytes]) / 1e9;
nSubjects = numel(rawFiles);
fprintf('%d subject(s) on disk, %.2f GB of raw data\n', nSubjects, rawGB);
% Each continuous stage you save costs about one raw copy per subject
nSavedStages = 2; % clean continuous + epochs
fprintf('Derivatives for these subjects: up to about %.1f GB\n', rawGB * nSavedStages);
fprintf('Full dataset (18 subjects): about %.1f GB raw\n', 18 * rawGB / max(nSubjects, 1));
% BIDS-style derivative name for one subject and one stage
subj = 'sub-002';
stage = 'clean';
outDir = fullfile(derivRoot, subj, 'eeg');
if ~exist(outDir, 'dir'), mkdir(outDir); end
outName = sprintf('%s_task-FaceRecognition_desc-%s_eeg.set', subj, stage);
fprintf('Save stage "%s" as %s\n', stage, fullfile(outDir, outName));
% Small files are cheap: keep ICA weights apart from the data
% icaInfo = struct('icaweights', EEG.icaweights, 'icasphere', EEG.icasphere, ...
% 'icachansind', EEG.icachansind);
% save(fullfile(outDir, sprintf('%s_task-FaceRecognition_desc-ica.mat', subj)), '-struct', 'icaInfo');
% Convert a non-BIDS dataset (here D1) to BIDS with EEG-BIDS
data = struct('file', {fullfile(eeglabRoot, 'sample_data', 'eeglab_data.set')});
% Practice export only: delete d1_bids when you are done
bids_export(data, 'targetdir', fullfile(projectRoot, 'd1_bids'), ...
'tInfo', struct('TaskName', 'attention', 'PowerLineFrequency', 60));Which value should I choose?
Suitable values for your analysis goal
| Decision | Choice in this lesson | Why |
|---|---|---|
| Location of raw data | rawdata, read only | If you damage a raw file by mistake, it cannot be fixed. Everything after it is rebuilt from the script. |
| Location of results | derivatives/eeglab/sub-XXX/eeg | The same logic as the BIDS specification for derivatives, so any researcher understands it and BIDS tools can read it. |
| Number of saved stages | Two: the clean continuous version, then the epochs | Enough to redo any later analysis without running ICA again. |
| Saved separately | ICA weights, bad channels, removed components | Very small, and they are the result of hours of computation or of decisions made by eye. |
| One or two files per dataset | Two files, .set and .fdt (the EEGLAB 2026.1 default) | Data load faster in a STUDY. Always copy or move the two files together. A single .set file is an option in File then Preferences. |
| Number format | single (EEGLAB default) | double doubles the size with no benefit for EEG data. |
Which value should I choose?
| Decision | Choice in this lesson | Why |
|---|---|---|
| Location of raw data | rawdata, read only | If you damage a raw file by mistake, it cannot be fixed. Everything after it is rebuilt from the script. |
| Location of results | derivatives/eeglab/sub-XXX/eeg | The same logic as the BIDS specification for derivatives, so any researcher understands it and BIDS tools can read it. |
| Number of saved stages | Two: the clean continuous version, then the epochs | Enough to redo any later analysis without running ICA again. |
| Saved separately | ICA weights, bad channels, removed components | Very small, and they are the result of hours of computation or of decisions made by eye. |
| One or two files per dataset | Two files, .set and .fdt (the EEGLAB 2026.1 default) | Data load faster in a STUDY. Always copy or move the two files together. A single .set file is an option in File then Preferences. |
| Number format | single (EEGLAB default) | double doubles the size with no benefit for EEG data. |
How do I check it worked?
4 quick checks
- The project folder holds the five folders, and no file in
rawdatahas changed since you downloaded it. - The script prints the number of participants, the size of their raw data, and the total estimate.
- Every file in
derivativeshas a name that starts withsub-and containsdesc-with its stage name. - The
d1_bidsfolder holdsdataset_description.jsonand asub-001folder.
How do I check it worked?
- The project folder holds the five folders, and no file in
rawdatahas changed since you downloaded it. - The script prints the number of participants, the size of their raw data, and the total estimate.
- Every file in
derivativeshas a name that starts withsub-and containsdesc-with its stage name. - The
d1_bidsfolder holdsdataset_description.jsonand asub-001folder.
What mistakes do people make?
4 mistakes and how to avoid them
- Saving over the raw file. File then Resave current dataset(s) writes over the open file. Always use File then Save current dataset as with the stage name.
- Saving every stage “just in case”. Five stages for 18 participants means more than 20 GB from D4 alone, and most of it is recomputed in minutes.
- Names like
final2_new_REAL.set. After a month nobody knows the difference. The stage name indesc-is enough, and the settings belong in the script incode. - Separating the script from the results. A result without the script that produced it cannot be reproduced. Save the script with every run, or use a version control system such as git for the
codefolder.
What mistakes do people make?
- Saving over the raw file. File then Resave current dataset(s) writes over the open file. Always use File then Save current dataset as with the stage name.
- Saving every stage “just in case”. Five stages for 18 participants means more than 20 GB from D4 alone, and most of it is recomputed in minutes.
- Names like
final2_new_REAL.set. After a month nobody knows the difference. The stage name indesc-is enough, and the settings belong in the script incode. - Separating the script from the results. A result without the script that produced it cannot be reproduced. Save the script with every run, or use a version control system such as git for the
codefolder.
Your browser doesn't allow saving progress. All lessons are open, but completion marks won't be saved.
Done. Your progress is saved in this browser.UndoWhere can I read more?
4 sources, official docs first
- EEGLAB TutorialDocumentation4. Import data > d. BIDS
- EEG-BIDS (GitHub)bids_export.m, bids_export_example.m
- BIDS specificationDerivatives
- From raw EEG to BIDS in 2 minutesVideoFull video · 22:58
Written for EEGLAB 2026.1 · 2026-10-28
Going further
- EEGLAB Tutorial: https://eeglab.org/tutorials/04_Import/BIDS.html (4. Import data > d. BIDS)
- EEG-BIDS (GitHub): https://github.com/sccn/EEG-BIDS (bids_export.m, bids_export_example.m)
- BIDS specification: https://bids-specification.readthedocs.io/ (Derivatives)
- From raw EEG to BIDS in 2 minutes: https://www.youtube.com/watch?v=LIiRj8-BVk4 (Full video)
Need help?
Ask, share feedback, or report an error
- Report a scientific error · Needs a GitHub account. Don't have one? Use "Share your thoughts".