Hi,
Welch and FFT run perfectly on this data, but when I try to compute the 1/f component within the 1β30 Hz frequency range, I encounter an error.
Could someone please help? Thank you!
Hi,
Welch and FFT run perfectly on this data, but when I try to compute the 1/f component within the 1β30 Hz frequency range, I encounter an error.
Could someone please help? Thank you!
Can you share a plot of the PSD that that you are using for FOOOF?
Is this PSD computed in "continuous" frequency bins, or frequency bands?
Share a screenshot of the parameters used for FOOOF
Are you able to run FOOOF with the provided data?
https://neuroimage.usc.edu/brainstorm/Tutorials/Fooof
Can you share a plot of the PSD that that you are using for FOOOF?
Is this PSD computed in "continuous" frequency bins, or frequency bands?
Continuous (Power)
Share a screenshot of the parameters used for FOOOF
Are you able to run FOOOF with the provided data?
https://neuroimage.usc.edu/brainstorm/Tutorials/Fooof
Yes
That looks ok.
Do you have the same problem with other PSD files?
Could you share the PSD file that causes the issue, to understand what is going on?
Upload the file somewhere and post the download links here.
here, please let me know if its helpful!
Hi @Kshitij, thank you for provided data.
The problem is with they way you computed the PSD.
It is not a PSD, as std was used to aggregate the power spectra across windows, a PSD is computed with the mean (Welch's method).
To compute the PSD use the process: Frequency > Power spectrum density (Welch)
Hi, I tried initially also the same way, and now also raw data then PSD(welch) and then 1/f (as u mentioned for the PSD) but the incompatible sizes error still comes!
Please share the PSD file, it would not make sense in our side to check for a file that was not intended as input (the provided std of power spectra)
hi here is the link for the raw data to get a better understanding of the process maybe ?
please let me know if it helps
The problem is that you are computing the PSD for the Event channel, which is DC (flat), leading to a flat PSD, which cause the FOOOF algorithm to fail as it expects a 1/f
-like PSD.
Solution: Use FOOOF only for data that has 1/f distribution.
After linking the raw data, inspect and fix if needed Channel file to indicate the correct type of the channels, thus processes running on EEG sensors will not process other types of sensors:
https://neuroimage.usc.edu/brainstorm/Tutorials/ChannelFile#Edit_the_channel_file
I was able to get it working earlier by manually changing the channel types. However, I'm now trying to automate this within a script using multiprocessing. I attempted the following approach to keep only the desired channels:
keep_channels = {'Fp1', 'F7', 'T3', 'T5', 'O1', 'F3', 'C3', 'P3', ...
'Fz', 'Cz', 'Fp2', 'F8', 'T4', 'T6', 'O2', ...
'F4', 'C4', 'P4', 'Fpz', 'Pz'};
% Convert the list into a comma-separated string
channel_string = strjoin(keep_channels, ',');
% Call the process to retain only specified channels
sFiles = bst_process('CallProcess', 'process_select_channels', sFiles, [], ...
'channelname', {channel_string}, ...
'method', 1); % Method 1: Keep selected channels
However, this throws an error.
How to correctly pass a list of channel names in a script when using process_select_channels
?
What is what you want to automate?
To set the channel type?
Please provide the error message
This process_select_channels
does not exist in Brainstorm source code.
What is what you want to automate?
To set the channel type?
yes! I am trying to set channel types in the script so that I dont have to change channel types manually, the current channel file takes every channel as EEG type but I just need the mentioned channels.
Thank you for the clarification
The channel types can be set with the process Import > Channel file > Set channels type
As all channels are detected as EEG
type, you may want to change the channel type for all the channels that you do not need, they can be set to MISC
type.
Finally, once you verify that the process works as expected, you can create a script directly from the GUI:
https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting#Starting_a_new_script
% Script generated by Brainstorm (19-Jun-2025)
% Input files
sFiles = [];
SubjectNames = {...
'NewSubject'};
RawFiles = {...
'C:\Users\garim\Downloads\P1\P1\FILE1\P1.edf'};
% Start a new report
bst_report('Start', sFiles);
% Process: Create link to raw file
sFiles = bst_process('CallProcess', 'process_import_data_raw', sFiles, [], ...
'subjectname', SubjectNames{1}, ...
'datafile', {RawFiles{1}, 'EEG-EDF'}, ...
'channelreplace', 1, ...
'channelalign', 1, ...
'evtmode', 'value');
% Process: Import MEG/EEG: Time
sFiles = bst_process('CallProcess', 'process_import_data_time', sFiles, [], ...
'subjectname', SubjectNames{1}, ...
'condition', '', ...
'timewindow', [0, 200], ...
'split', 30, ...
'ignoreshort', 0, ...
'usectfcomp', 1, ...
'usessp', 1, ...
'freq', [], ...
'baseline', [], ...
'blsensortypes', 'MEG, EEG');
% Process: Set channels type
sFiles = bst_process('CallProcess', 'process_channel_settype', sFiles, [], ...
'sensortypes', 'Fp1, F7', ...
'newtype', 'EEG');
% == STEP 3: Compute PSD features ==
% Note: The process 'process_psd_features' is from an older Brainstorm version.
% The modern name is 'process_psd'. I am using the modern syntax here for compatibility.
sFiles = bst_process('CallProcess', 'process_psd', sFiles, [], ...
'timewindow', [], ... % Use the entire file for each segment
'win_length', 4, ...
'win_overlap', 50, ...
'units', 'physical', ... % 'physical' for amplitude, 'power' for amplitude^2
'sensortypes', 'EEG', ...
'win_std', 0, ...
'edit', struct(...
'Comment', 'Power, Welch', ...
'TimeBands', [], ...
'Freqs', [], ...
'ClusterFuncTime', 'none', ...
'Measure', 'mean', ...
'Output', 'all', ...
'SaveKernel', 0));
% == STEP 4: specparam: Fitting oscillations and 1/f (FOOOF) ==
sFiles = bst_process('CallProcess', 'process_fooof', sFiles, [], ...
'implementation', 'matlab', ...
'freqrange', [1, 35], ...
'powerline', '50', ...
'method', 'leastsquare', ...
'peakwidth', [0.5, 12], ...
'maxpeaks', 3, ...
'minpeakheight', 3, ...
'proxthresh', 2, ...
'apermode', 'fixed', ...
'guessweight', 'none', ...
'sorttype', 'param', ... % Peak parameters
'sortparam', 'frequency', ... % Frequency
'sortbands', {});
% == STEP 5: Save and display report ==
ReportFile = bst_report('Save', sFiles);
bst_report('Open', ReportFile);
% bst_report('Export', ReportFile, ExportDir);
% bst_report('Email', ReportFile, username, to, subject, isFullReport);
% Delete temporary files
% gui_brainstorm('EmptyTempFolder');
@Kshitij, could you please include some details, and what you've already tried?
Screenshots on their own make it hard for other users to follow and offer useful advice.
All the other channels remain EEG. This is the situation that was described in my previous message, please read carefully.
Also, please note that error message that you get is exactly the same that you reported in the first post of this thread, the origin is the same: FOOOF is used over a flat spectrum, thus it fails to model it as 1/f
Hi, my apologies for the confusion. I was trying to run the script on just two channels by marking only them as EEG. What I'm still unclear about is this part:
'sensortypes', 'Fp1, F7', ...
Should I include all the required channel names here? I have 47 channels in total, some of which I don't need, but by default all are marked as EEG.
So I tried testing the script with just Fp1 and F7, assuming it would only process those.
My question is: is there a way to specify only the desired channel names so that the rest are dropped or excluded automatically? I feel selecting 17 out of 47 channels this way would be easier. Please let me know if thereβs a better approach.
FOOOF runs on all the PDSs contained in the PSD file.
So a way to compute FOOOF, in two channels is to compute the PSD just for those channels, this is done by setting the option Sensor types or names to the channels you want.
The resulting PSD will contain only the PSD for those two channels, then the FOOOF model will be computed just for those two channels.