Problem loading protocol after update

Dear BST team,

I recently updated my BST version to the newest release, and after that my protocol will not load. Instead, I get the following error messages. Any idea of what might have gone wrong? I have another protocol in my database folder, but that one works just fine.

Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.

Error in bst_get (line 536)
argout1(iTargetAnalysis) = repmat(ProtocolStudies.AnalysisStudy, size(iTargetAnalysis));

Error in bst_get (line 859)
[argout1, argout2] = bst_get('Study', iAnalStudyInter);

Error in node_create_db_studies (line 101)
[sAnalysisStudy, iAnalysisStudy] = bst_get('AnalysisInterStudy');

Error in panel_protocols>UpdateTree (line 429)
case 'StudiesSubj', [selNode, dbNode, numNodes] = node_create_db_studies(nodeRoot, 'subject', iSearch);

Error in panel_protocols (line 45)
eval(macro_method);

Error in db_load_protocol (line 104)
panel_protocols('UpdateTree');

Error in gui_brainstorm>SetCurrentProtocol (line 1046)
db_load_protocol(iProtocol);

Error in gui_brainstorm (line 33)
eval(macro_method);

Error in bst_startup (line 592)
gui_brainstorm('SetCurrentProtocol', GlobalData.DataBase.iProtocol);

Error in brainstorm (line 103)
bst_startup(BrainstormHomeDir, 1, BrainstormDbDir);

I'm not sure why an update could cause this type of database error...
Have you tried reloading the protocol? The entire database?

Can you execute the following lines in your Matlab command window and paste the output here? (with the faulty protocol selected).

ProtocolInfo = bst_get('ProtocolInfo')
ProtocolStudies = bst_get('ProtocolStudies')
[sAnalysisStudy, iAnalysisStudy] = bst_get('AnalysisInterStudy')
bst_get('Study',-2)
argout1 = repmat(ProtocolStudies.DefaultStudy, 0)
iTargetAnalysis = find(-2 == -2)
size(iTargetAnalysis)
ProtocolStudies.AnalysisStudy
repmat(ProtocolStudies.AnalysisStudy, size(iTargetAnalysis))
argout1(iTargetAnalysis) = repmat(ProtocolStudies.AnalysisStudy, size(iTargetAnalysis))
ver

Hi Francois,

Yes, I've tried reloading the protocol and setting again the database folder but the error persists. Here's the output of your code lines:

ProtocolInfo =

struct with fields:

          Comment: 'HCLC'
          STUDIES: 'E:\Matlab\brainstorm_db\HCLC\data'
         SUBJECTS: 'E:\Matlab\brainstorm_db\HCLC\anat'
           iStudy: 160
   UseDefaultAnat: 1
UseDefaultChannel: 1

ProtocolStudies =

struct with fields:

        Study: [1×18 struct]
 DefaultStudy: [0×0 struct]
AnalysisStudy: [0×0 struct]

Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.

Error in bst_get (line 536)
argout1(iTargetAnalysis) = repmat(ProtocolStudies.AnalysisStudy, size(iTargetAnalysis));

Error in bst_get (line 859)
[argout1, argout2] = bst_get('Study', iAnalStudyInter);

Actually, I just noticed that my other protocol in the brainstorm database isn't working either. Instead of showing an error message upon trying to access it, this one loads but throws an error when I try to visualize data:


** Error: Line 699: Index exceeds the number of array elements (0).
**
** Call stack:
** >gui_layout.m>PositionFigure at 699
** >gui_layout.m>TileWindows at 631
** >gui_layout.m>Update at 50
** >gui_layout.m at 33
** >bst_figures.m>CreateFigure at 232
** >bst_figures.m at 59
** >view_timeseries.m at 149
** >tree_callbacks.m at 263
** >bst_call.m at 28
** >panel_protocols.m>CreatePanel/protocolTreeClicked_Callback at 124
** >bst_call.m at 28
** >panel_protocols.m>@(h,ev)bst_call(@protocolTreeClicked_Callback,h,ev) at 74
**


Yes, I've tried reloading the protocol and setting again the database folder but the error persists

The problem starts here:

ProtocolStudies =
struct with fields:
        Study: [1×18 struct]
 DefaultStudy: [0×0 struct]
AnalysisStudy: [0×0 struct]

You should always have a DefaultStudy and AnalysisStudy in your protocol. They correspond respectively to the folders:

  • E:\Matlab\brainstorm_db\HCLC\data\@default_study
  • E:\Matlab\brainstorm_db\HCLC\data\@inter

Some more debugging is needed to understand what has gone wrong in your database:

  • Do these folders exist in your database?
  • Can you load manually the .mat files in these folders with Matlab? Example:
    m=load('E:\Matlab\brainstorm_db\HCLC\data\@default_study\brainstormstudy.mat')
  • When you reload your protocol (go to the anatomy view, right-click on the top node > Reload), do you seen any warning in your Matlab command window?
  • What is this E: drive? A network drive? A backup drive? Is it possible that you made a copy that skipped the folders starting with '@'?
  • Do you have a full back of this protocol folder? Is it an option for you to restore to the previous working version? If the answer is no, I'd recommend you start by setting up a proper backup system for all your work.
  • You could try copying these two missing folders from other intact protocols (just keep the brainstormstudy.mat file in them)
  • You may have to do the same for each subject folder in data, which is also supposed to include a @intra folder. E.g. E:\Matlab\brainstorm_db\HCLC\data\subjectname\@intra

Actually, I just noticed that my other protocol in the brainstorm database isn't working either. Instead of showing an error message upon trying to access it, this one loads but throws an error when I try to visualize data:

This problem is related with the setup of your display, not with the data in your database.
What do you get if you execute decorationSize = bst_get('DecorationSize') ?

If you don't get a vector of six values (eg. [0 31 2 1 20 28]), this requires a step-by-step debugging directly on your environment...
Put a breakpoint in gui_layout.m at line 64, then start Brainstorm. After the debugger stop, execute the code line-by-line (button "Step") and try to understand what is not working. Same thing for function PositionFigure, starting from the beginning of the function.
If you don't know how to use the Matlab debugger, watch some tutorial video.

Have you changed anything in your computer environment recently?
Are you working on a local computer or on a distant desktop?

Dear Francois,

Do these folders exist in your database?

Yes, they exist in the brainstorm_db folder

Can you load manually the .mat files in these folders with Matlab?

Yes, I can load these .mat files without problem

When you reload your protocol (go to the anatomy view, right-click on the top node > Reload), do you seen any warning in your Matlab command window?

Ah okay, this actually works. When I do this, the functional data loads itself to the GUI. Two problems, though: 1) I have to do it again every time I restart BST, 2) data is now loaded but I cannot access/visualize it.

What is this E: drive? A network drive? A backup drive? Is it possible that you made a copy that skipped the folders starting with '@'?

It's an external SSD disk where both the brainstorm3 and braisntorm_db are located. I hadn't made any copy of the database before the error started occuring. Now I do have a copy for back up in another drive. Everything else is as in the original db.

is it an option for you to restore to the previous working version?

I'll attempt that. I had reinstalled the current version of BST to see if that fixed the problem, but that didn't work either.

You may have to do the same for each subject folder in data, which is also supposed to include a @intra folder. E.g. E:\Matlab\brainstorm_db\HCLC\data\subjectname\@intra

I just checked. Those two folders are in every subject's folder. So, no problem here.

What do you get if you execute decorationSize = bst_get('DecorationSize') ?

Ah, okay... the vairable is empty.

this requires a step-by-step debugging directly on your environment...
Put a breakpoint in gui_layout.m at line 64, then start Brainstorm. After the debugger stop, execute the code line-by-line (button "Step") and try to understand what is not working.

Okay, so here's another problem: when I start BST I get this database location error, apparently before the gui_layout.m function gets to execute. The error is in line 536 of the bst_get function. I'm taking a closer look at how the function retrieves the directories and I found this:

BrainstormDbDir =

 []

BrainstormHomeDir =

'E:\Matlab\brainstorm3'

It seems as though the brainstorm.m function is failing to locate the brainstorm_db location in the directory.

Have you changed anything in your computer environment recently?
Are you working on a local computer or on a distant desktop?

No, nothing apart from the BST update and I'm working from a local computer.

Thanks a lot again!

Don't try using an older version of Brainstorm.
I meant: an older version of the database...

It seems as though the brainstorm.m function is failing to locate the brainstorm_db location in the directory.

I don't know what is going on, but there is something that is seriously messed up.
It doesn't seem like this is related with any change in the Brainstorm version. Maybe some of the database issues started because your drive was disconnected at some point?

Start by resetting Brainstorm and forcing rebuilding all the database structures:

  • close matlab
  • Delete your $HOME/.brainstorm folder
  • Delete all your protocol_folder/data/protocol.mat folders
  • Start Matlab and Braintsorm again, set the database folder, let it reload all your protocols

What do you get if you execute decorationSize = bst_get('DecorationSize') ?

Ah, okay... the vairable is empty.

This variable is empty even when Brainstorm is running??
If this is really the case, there is something abnormal in the way the Java engine is configured on your computer.

  • Please copy-paste here the output of the command ver executed in the Matlab command window
  • Try debugging gui_layout.m as I described earlier
  • Try re-installing Matlab (or using a different version of Matlab)

Thanks for the suggestions. I'll attempt all of that. Meanwhile:

Don't try using an older version of Brainstorm.
I meant: an older version of the database..

Ah, in that case I don't think I have access to an older version of the db.

It doesn't seem like this is related with any change in the Brainstorm version. Maybe some of the database issues started because your drive was disconnected at some point?

I agree that this doesn't seem to be a BST version issue. I have connected/disconnected the E:/ drive in the past, but it was never a problem. In any case, this problem happened when the drive was connected. It's really, wierd. It just happened one day out of the blue.

I just found out that BST is locating relevant directories in two different disks. Is this normal or might this be the reason of the problem?

image

  • Please copy-paste here the output of the command ver executed in the Matlab command window

MATLAB Version: 9.6.0.1072779 (R2019a)
MATLAB License Number: 968398
Operating System: Microsoft Windows 11 Home Single Language Version 10.0 (Build 22000)
Java Version: Java 1.8.0_181-b13 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode

MATLAB Version 9.6 (R2019a)
Simulink Version 9.3 (R2019a)
5G Toolbox Version 1.1 (R2019a)
AUTOSAR Blockset Version 2.0 (R2019a)
Aerospace Blockset Version 4.1 (R2019a)
Aerospace Toolbox Version 3.1 (R2019a)
Antenna Toolbox Version 4.0 (R2019a)
Audio Toolbox Version 2.0 (R2019a)
Automated Driving Toolbox Version 2.0 (R2019a)
Bioinformatics Toolbox Version 4.12 (R2019a)
Communications Toolbox Version 7.1 (R2019a)
Computer Vision Toolbox Version 9.0 (R2019a)
Control System Toolbox Version 10.6 (R2019a)
Curve Fitting Toolbox Version 3.5.9 (R2019a)
DO Qualification Kit Version 3.7 (R2019a)
DSP System Toolbox Version 9.8 (R2019a)
Data Acquisition Toolbox Version 4.0 (R2019a)
Database Toolbox Version 9.1 (R2019a)
Datafeed Toolbox Version 5.8.1 (R2019a)
Deep Learning Toolbox Version 12.1 (R2019a)
Econometrics Toolbox Version 5.2 (R2019a)
Embedded Coder Version 7.2 (R2019a)
Filter Design HDL Coder Version 3.1.5 (R2019a)
Financial Instruments Toolbox Version 2.9 (R2019a)
Financial Toolbox Version 5.13 (R2019a)
Fixed-Point Designer Version 6.3 (R2019a)
Fuzzy Logic Toolbox Version 2.5 (R2019a)
GPU Coder Version 1.3 (R2019a)
Global Optimization Toolbox Version 4.1 (R2019a)
HDL Coder Version 3.14 (R2019a)
HDL Verifier Version 5.6 (R2019a)
IEC Certification Kit Version 3.13 (R2019a)
Image Acquisition Toolbox Version 6.0 (R2019a)
Image Processing Toolbox Version 10.4 (R2019a)
Instrument Control Toolbox Version 4.0 (R2019a)
LTE HDL Toolbox Version 1.3 (R2019a)
LTE Toolbox Version 3.1 (R2019a)
MATLAB Coder Version 4.2 (R2019a)
MATLAB Compiler Version 7.0.1 (R2019a)
MATLAB Compiler SDK Version 6.6.1 (R2019a)
MATLAB Report Generator Version 5.6 (R2019a)
Mapping Toolbox Version 4.8 (R2019a)
Mixed-Signal Blockset Version 1.0 (R2019a)
Model Predictive Control Toolbox Version 6.3 (R2019a)
Model-Based Calibration Toolbox Version 5.6 (R2019a)
OPC Toolbox Version 4.0.7 (R2019a)
Optimization Toolbox Version 8.3 (R2019a)
Parallel Computing Toolbox Version 7.0 (R2019a)
Partial Differential Equation Toolbox Version 3.2 (R2019a)
Phased Array System Toolbox Version 4.1 (R2019a)
Polyspace Bug Finder Version 3.0 (R2019a)
Polyspace Bug Finder Server Version 3.0 (R2019a)
Polyspace Code Prover Version 10.0 (R2019a)
Polyspace Code Prover Server Version 10.0 (R2019a)
Powertrain Blockset Version 1.5 (R2019a)
Predictive Maintenance Toolbox Version 2.0 (R2019a)
RF Blockset Version 7.2 (R2019a)
RF Toolbox Version 3.6 (R2019a)
Reinforcement Learning Toolbox Version 1.0 (R2019a)
Risk Management Toolbox Version 1.5 (R2019a)
Robotics System Toolbox Version 2.2 (R2019a)
Robust Control Toolbox Version 6.6 (R2019a)
Sensor Fusion and Tracking Toolbox Version 1.1 (R2019a)
SerDes Toolbox Version 1.0 (R2019a)
Signal Processing Toolbox Version 8.2 (R2019a)
SimBiology Version 5.8.2 (R2019a)
SimEvents Version 5.6 (R2019a)
Simscape Version 4.6 (R2019a)
Simscape Driveline Version 2.16 (R2019a)
Simscape Electrical Version 7.1 (R2019a)
Simscape Fluids Version 2.6 (R2019a)
Simscape Multibody Version 6.1 (R2019a)
Simulink 3D Animation Version 8.2 (R2019a)
Simulink Check Version 4.3 (R2019a)
Simulink Code Inspector Version 3.4 (R2019a)
Simulink Coder Version 9.1 (R2019a)
Simulink Control Design Version 5.3 (R2019a)
Simulink Coverage Version 4.3 (R2019a)
Simulink Design Optimization Version 3.6 (R2019a)
Simulink Design Verifier Version 4.1 (R2019a)
Simulink Desktop Real-Time Version 5.8 (R2019a)
Simulink PLC Coder Version 3.0 (R2019a)
Simulink Real-Time Version 6.10 (R2019a)
Simulink Report Generator Version 5.6 (R2019a)
Simulink Requirements Version 1.3 (R2019a)
Simulink Test Version 3.0 (R2019a)
SoC Blockset Version 1.0 (R2019a)
Spreadsheet Link Version 3.4.1 (R2019a)
Stateflow Version 10.0 (R2019a)
Statistics and Machine Learning Toolbox Version 11.5 (R2019a)
Symbolic Math Toolbox Version 8.3 (R2019a)
System Composer Version 1.0 (R2019a)
System Identification Toolbox Version 9.10 (R2019a)
Text Analytics Toolbox Version 1.3 (R2019a)
Trading Toolbox Version 3.5.1 (R2019a)
Vehicle Dynamics Blockset Version 1.2 (R2019a)
Vehicle Network Toolbox Version 4.2 (R2019a)
Vision HDL Toolbox Version 1.8 (R2019a)
WLAN Toolbox Version 2.1 (R2019a)
Wavelet Toolbox Version 5.2 (R2019a)

Ah, in that case I don't think I have access to an older version of the db.

Time to set up a proper backup :slight_smile:

I just found out that BST is locating relevant directories in two different disks. Is this normal or might this be the reason of the problem?

No, this is not a problem, the user .brainstorm folder is always going to be on your C: drive.
This is the folder I suggest to delete (make a copy first) before restarting Brainstorm.

Operating System: Microsoft Windows 11 Home

This is maybe a part of the problem. If the version of Java included in Matlab 2019a is not fully compatible with Win11, there might be some issues related with window positioning.
Unfortunately I don't have a Win11 computer yet, and can't test this further myself.

To test is the compatibility Win11/Matlab 2019a is a problem, you could try installing the last version of Brainstorm I compiled with Matlab 2022a. You can find it at the bottom of the download page of the Brainstorm website. Install the Matlab Runtime 2022a and follow the Brainstorm installation instructions "without matlab".
https://neuroimage.usc.edu/brainstorm/Installation

Dear Francois,

I tried this but the problem persisted. Then I tried this over gain, but leaving the faulty protocol out from the db folder and now BST works again as usual. I don't know what could have gone wrong with the faulty protocol, though. At least I can access all my other protocols now, which was what I cared most about.

Thanks a lot for your time and help Francois, I really appreciate it.