Test running a MATLAB Script affecting Brainstorm GUI?

Hi. I ran the PLV connectivity analysis in Brainstorm GUI, saw that it worked and liked how it looked. So then I wanted to batch a couple of PLV connectivity analysis for my subjects and tried to write a MATLAB script for it, following the brainstorm tutorial. (I have little to no experience with MATLAB/scripting in general) I had the brainstorm open and ran the script in MATLAB; it gave me a bunch of errors and I decided while I figure the errors out, I'd continue running PLV analysis in Brainstorm individually like I did before. But then I discovered that the PLV analysis was not working (it would not progress further than 0% for 30+ minutes, when it only took ~15 minutes before) even in Brainstorm.

I have the "script" below. It was saved in my user directory as instructed in the tutorial. PLV analysis in Brainstorm works with a different protocol/dataset.

I appreciate your expertise and help.

EDIT:
Hi, I posted this topic. I fixed the GUI issue I talk about here, but I'd still like to ask about my script and check that this will loop the subjects and each of their start / end times specified. Can I edit it?

% Script generated by Brainstorm (03-Oct-2022)

% Input files; the link to dSPM unscaled MEG file, copied from File Content
PLV_files = {...
    'link|M87114552/@rawM87114552_rest_tsss_mc/results_dSPM-unscaled_MEG_GRAD_MEG_MAG_KERNEL_220429_0851.mat|M87114552/@rawM87114552_rest_tsss_mc/data_0raw_M87114552_rest_tsss_mc.mat','link|M87118992/@rawM87118992_rest_tsss_mc/results_dSPM-unscaled_MEG_GRAD_MEG_MAG_KERNEL_220502_1220.mat'};

SubjectNames_list = {...
    'M87114552', 'M87118992'};

% List of all start times and end times of the subjects' first Eyes Closed session
Start_time = {88.884,63.527}  
End_time = {178.886,153.529}



for subject = 1:length(PLV_files)
    
    sFiles = PLV_files(subject)
    SubjectNames = SubjectNames_list(subject)
    starttime = Start_time(subject)
    endtime = End_time(subject)
    
    % Start a new report
    bst_report('Start', sFiles);

    % Process: PLV: Phase locking value
    sFiles = bst_process('CallProcess', 'process_plv1n', sFiles, [], ...
        'timewindow', [starttime, endtime], ... % Different time window for each subject
        'scouts',     {'Desikan-Killiany', {'caudalmiddlefrontal L', 'caudalmiddlefrontal R', 'cuneus L', 'cuneus R', 'inferiortemporal L', 'inferiortemporal R', 'insula L', 'insula R', 'parstriangularis L', 'parstriangularis R', 'postcentral L', 'postcentral R', 'precentral L', 'precentral R', 'superiorfrontal L', 'superiorfrontal R', 'superiorparietal L', 'superiorparietal R', 'superiortemporal L', 'superiortemporal R', 'supramarginal L', 'supramarginal R'}}, ...
        'scoutfunc',  1, ...  % Mean
        'scouttime',  2, ...  % After
        'freqbands',  {'delta', '2, 4', 'mean'; 'theta', '5, 7', 'mean'; 'alpha', '8, 12', 'mean'; 'beta', '15, 29', 'mean'; 'gamma1', '30, 59', 'mean'; 'gamma2', '60, 90', 'mean'}, ...
        'plvmethod',  'plv', ...  % PLV: Phase locking value
        'keeptime',   0, ...
        'plvmeasure', 2, ...  % Magnitude
        'outputmode', 1);  % Save individual results (one file per input file)
    
end


% Save file
ReportFile = bst_report('Save', sFiles);
% Display report
bst_report('Open', ReportFile);
% bst_report('Export', ReportFile, ExportDir);
% bst_report('Email', ReportFile, username, to, subject, isFullReport);

Yes, you can edit your post by clicking on the tree dots (...) in the bottom of the post, and then the pencil (:pencil2:)

There is an problem with your code, the start (and end times) times are in a Matlab cell array (Start_time = {88.884,63.527} ) , you need to change it to Matlab matrix (change the curly brackets "{ }" by square brackets "[ ]").

Also note, that your variable SubjectNames is not used inside the for loop

To speed up your Matlab knowledge, you can check this introductory course on Matlab:

and these resources: