Error reading default anatomy

Hi Brainstormers,

Has anyone ever encountered the following error when importing the default anatomy?:

Warning: Cannot open surface file '@default_subject/tess_outerskull.mat'. Adding '.bak' to the filename.

Files are copied to the subject anatomy folder, but the extension .bak has been added (for example, 'tess_outerskull.mat.bak') and are not properly read into matlab.

I've run this script previously and never had any issues. I've tried using the GUI to import subjects, and am also not able to import the default subject anatomy.

Matlab version is 2022a, Brainstorm3 (with latest update done yesterday).

Thanks for any help!
Rebecca

Has anyone ever encountered the following error when importing the default anatomy?:

What do you mean with "importing the default anatomy"?
What does it correspond to in your script?

Warning: Cannot open surface file '@default_subject/tess_outerskull.mat'. Adding '.bak' to the filename.

This indicates that the files can't be read.
Rename one of these files back to .mat, then load it from the Matlab command window with the Matlab function "load".
If it loads correctly, then it is the contents of the file that is corrupted, the files have been edited in some way. If you get an error that Matlab can't read the .mat files, then its the container itself that is broken, something bad happened to the files during a computer crash, a copy between file systems, etc...

In both cases, updating Brainstorm should restore the original files.

Hi Francois,
I get the error when I run the following:
[sSubject, iSubject] = db_add_subject(SubjectNames{iSubj}, [], 1, 0); % 1 indicates use the default anatomy.
However, the files fail to load even when I use the GUI and create a new protocol set to use the default anatomy.
I have confirmed that I am able to load the .mat files into the workspace using load(). I have tried updating Brainstorm, but I am still encountering the same error.

Thank you,
Rebecca

More precisely, things should be done in the order below:

  1. Close Matlab
  2. Delete the brainstorm3 folder
  3. Download a new version from the website (to make sure there is no residual corrupted files from the previous install)
  4. Start Matlab, start Brainstorm
  5. Type "brainstorm reset" in the Matlab command window
  6. When it asks for your database folder, use the same brainstorm_db folder as before
  7. Create a new protocol (from the GUI) => It copies the default anatomy into the protocol folder
  8. Check that you can load the file "new_protocol/anat/@default_subject/tess_outerskull.mat" command
  9. Create a new subject, configured to use the default anatomy (from the GUI)
  10. Double-click on the outer skull surface to make sure you can open it.

If you can reproduce the error with this procedure, please let me know precisely when this happens. Copy-paste here any warning of error message that appears in your Matlab command window.

Hi Francois,

Unfortunately, I am still getting the same error... I was able to successfully delete and re-download brainstorm, and reset it as asked:

brainstorm reset
Brainstorm environment reset.

brainstorm

BST> Starting Brainstorm:
BST> =================================
BST> Version: 03-Oct-2022
BST> Compiling main interface files...
BST> Deleting old process reports...
BST> Loading configuration file...
BST> Loading default montages...
BST> Checking internet connectivity... ok
BST> Initializing user interface...
BST> Starting OpenGL engine... software
BST> Warning: Switching between hardware and software at runtime is not possible on Linux systems.
BST> To force Matlab to use the software OpenGL: matlab -softwareopengl
BST> To force Matlab to use the hardware OpenGL: matlab -nosoftwareopengl
BST> Reading process folder...
BST> License accepted.
BST> Loading current protocol...
BST> =================================

BST> Reloading database...

The following error occurred at step 7, when the default anatomy is copied into the protocol folder:

Warning: Cannot open anatomy file
'/home/rebecca-reh/efs/brainstorm_db/Protocol25/anat/@default_subject/subjectimage_T1.mat'.

In db_parse_subject/io_getAnatomyInfo (line 271)
In db_parse_subject (line 157)
In db_reload_subjects (line 62)
In db_set_template (line 175)
In gui_edit_protocol/updateProtocolModificiations (line 190)
Warning: Cannot open surface file
'@default_subject/tess_aseg.mat'. Adding '.bak' to the
filename.
In db_parse_subject/io_getSurfaceInfo (line 303)
In db_parse_subject (line 163)
In db_reload_subjects (line 62)
In db_set_template (line 175)
In gui_edit_protocol/updateProtocolModificiations (line 190)
Warning: Cannot open surface file
'@default_subject/tess_cortex_pial_high.mat'. Adding
'.bak' to the filename.
In db_parse_subject/io_getSurfaceInfo (line 303)
In db_parse_subject (line 163)
In db_reload_subjects (line 62)
In db_set_template (line 175)
In gui_edit_protocol/updateProtocolModificiations (line 190)
Warning: Cannot open surface file
'@default_subject/tess_cortex_pial_low.mat'. Adding
'.bak' to the filename.
In db_parse_subject/io_getSurfaceInfo (line 303)
In db_parse_subject (line 163)
In db_reload_subjects (line 62)
In db_set_template (line 175)
In gui_edit_protocol/updateProtocolModificiations (line 190)
Warning: Cannot open surface file
'@default_subject/tess_head.mat'. Adding '.bak' to the
filename.
In db_parse_subject/io_getSurfaceInfo (line 303)
In db_parse_subject (line 163)
In db_reload_subjects (line 62)
In db_set_template (line 175)
In gui_edit_protocol/updateProtocolModificiations (line 190)
Warning: Cannot open surface file
'@default_subject/tess_innerskull.mat'. Adding '.bak'
to the filename.
In db_parse_subject/io_getSurfaceInfo (line 303)
In db_parse_subject (line 163)
In db_reload_subjects (line 62)
In db_set_template (line 175)
In gui_edit_protocol/updateProtocolModificiations (line 190)
Warning: Cannot open surface file
'@default_subject/tess_outerskull.mat'. Adding '.bak'
to the filename.
In db_parse_subject/io_getSurfaceInfo (line 303)
In db_parse_subject (line 163)
In db_reload_subjects (line 62)
In db_set_template (line 175)
In gui_edit_protocol/updateProtocolModificiations (line 190)

I'm wondering if at this point I should try re-installing Matlab?

Thanks!
Rebecca

I suspect some problems during the unzipping or the copy of the files.
Some more debugging: please execute separately the two blocks of code (copy-paste in the command window), and copy-paste the output here.

1

MriFile = fullfile(bst_get('BrainstormHomeDir'), 'defaults', 'Anatomy', 'ICBM152', 'subjectimage_T1.mat')
anatomyMat = load(MriFile, 'Comment')
relativeFilename = fullfile('ICBM152', 'subjectimage_T1.mat');

if (length(fieldnames(anatomyMat)) == 0)
    [fpath, basename] = bst_fileparts(relativeFilename);
    Anatomy(1).Comment = basename;
else
    Anatomy(1).Comment = anatomyMat.Comment;
end
Anatomy(1).FileName = relativeFilename;
Anatomy

2

MriFile = '/home/rebecca-reh/efs/brainstorm_db/Protocol25/anat/@default_subject/subjectimage_T1.mat';
anatomyMat = load(MriFile, 'Comment')
relativeFilename = '@default_subject/subjectimage_T1.mat';

if (length(fieldnames(anatomyMat)) == 0)
    [fpath, basename] = bst_fileparts(relativeFilename);
    Anatomy(1).Comment = basename;
else
    Anatomy(1).Comment = anatomyMat.Comment;
end
Anatomy(1).FileName = relativeFilename;
Anatomy

Here is the output for the first command (I did have to change the path, as the 'a' in my anatomy folder is not capitalized:

anatomyMat =

struct with fields:

Comment: 'MRI: ICBM152'

Anatomy =

struct with fields:

 Comment: 'MRI: ICBM152'
FileName: 'ICBM152/subjectimage_T1.mat'

Here is what I get when I run the second block of code:

Error using load
Unable to read MAT-file
/home/rebecca-reh/efs/brainstorm_db/Protocol25/anat/@default_subject/subjectimage_T1.mat.
Not a binary MAT-file. Try load -ASCII to read as text.

I don't think the problem you are having is related directly with Brainstorm. There is something wrong occurring on your system during the copy of the files from the default anatomy folder in the Brainstorm installation folder (which indeed has a lower case 'a') to the protocol folder. Maybe some access rights or file system issues?
Understanding the precise cause of this issue is possibly beyond the scope of this forum.

Some suggestions:

  • Check the size of the .bak files: if there are empty (0 bytes), they could not be copied.
  • After creating the protocol: copy manually the files from the brainstorm3 installation folder to the protocol folder, delete all the useless .bak files, then reload the protocol from the Brainstorm interface. This might solve the error during the creation of the protocol, but if there is a generic problem on your OS for copying files from Matlab, you would probably face many other bugs when using Brainstorm.
  • Put a breakpoint at the beginning of function db_set_template.m, create a new protocol, and when the debugger stops, execute the code line by line in order to understand what goes wrong.