Hi François,
Sorry in advance if this bug has been reported earlier. I checked but did not find anything related.
For info I work with brainstorm in Matlab installed on a windows 10 PC and segment my MRI data on a Ubuntu 16.04 LTS linux PC.
I cannot import my recent freesurfer anatomy folder: the message is
** Error: Could not import FreeSurfer folder:
** MRI file was not found: T1.mgz
** Surface file was not found: lh.pial
** Surface file was not found: rh.pial
When I check the mri folder (in windows), the T1.mgz is there. in the surf folder, lh.pial and rh.pial are also there but after checking the same folders in the linux PC, it appears that they are symbolic links to files lh.pial.T1 and rh.pial.T1 respectively
Renaming the lh.pial.T1 to lh.pial doesnt help. Do you have any clue?
Thanks a lot for your help !
Isa
** Error: Could not import FreeSurfer folder:
** MRI file was not found: T1.mgz
** Surface file was not found: lh.pial
** Surface file was not found: rh.pial
The file mri/T1.mgz is there, therefore if you get this error, you probably did not select the correct folder. Unless mri is a symbolic link to a different folder, or any other Linux file system feature that is not ported to windows correctly.
But indeed, the import fails because of the links to the pial files.
Can you please confirm that the correct error message is not the one above?
(try to import what's in the .zip file you sent me if you can't reproduce this otherwise)
I will add a test to either try to follow the link, or to look for alternative pial files.
Pour info, using a zip compression removes the symbolic files. I used a .tar instead
Please send me the .tar file as well, so I can handle both cases correctly in my fix.
Sorry for your quick answer François.
here is the link to the .tar folder https://filesender.renater.fr/?s=download&token=734a9ebe-ad04-4b52-bcb7-b40b041d262d
Yes I confirm that this is indeed the error message I get
** Error: Could not import FreeSurfer folder:
** MRI file was not found: T1.mgz
** Surface file was not found: lh.pial
** Surface file was not found: rh.pial
It doesn't make sense to me why the T1.mgz isn't seen although it is in the folder.?
It doesn't make sense to me why the T1.mgz isn't seen although it is in the folder.?
No, it doesn't make sense.
Yes I confirm that this is indeed the error message I get
Just to make sure I replicate this exactly:
On a Windows computer, you untar the file you just sent me with 7-zip
In Brainstorm, you create a new subject
Right-click on the anatomy folder of the subject > Import anatomy folder > Select file format "FreeSurfer folder" and select top-level folder "SavBen1" (and not any of its subfolders)
Please copy-paste the output of the command ver in Matlab.
FYI: I've just tested it on my computer: Matlab 2020b / Windows 10 correctly follows the symbolic links from the .tar files and Brainstorm imports the folder SavBen1 without complaining:
The .zip version crashes, because the sym links are replaced with text files containing the name of the target file.
MATLAB Version: 9.4.0.813654 (R2018a)
MATLAB License Number: 40615955
Operating System: Microsoft Windows 10 Professionnel pour les Stations de travail Version 10.0 (Build 19041)
Java Version: Java 1.8.0_144-b01 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
MATLAB Version 9.4 (R2018a)
Simulink Version 9.1 (R2018a)
Bioinformatics Toolbox Version 4.10 (R2018a)
Computer Vision System Toolbox Version 8.1 (R2018a)
Fuzzy Logic Toolbox Version 2.3.1 (R2018a)
Image Processing Toolbox Version 10.2 (R2018a)
Neural Network Toolbox Version 11.1 (R2018a)
Optimization Toolbox Version 8.1 (R2018a)
Parallel Computing Toolbox Version 6.12 (R2018a)
RICOH MEG Reader toolbox for MATLAB Version 1.0.3
Signal Processing Toolbox Version 8.0 (R2018a)
Statistical Parametric Mapping Version 6685 (SPM12)
Statistics and Machine Learning Toolbox Version 11.3 (R2018a)
System Identification Toolbox Version 9.8 (R2018a)
Wavelet Toolbox Version 5.0 (R2018a)
Yokogawa MEG Reader toolbox for MATLAB Version 1.5.2
I tested even with old versions of Matlab, the folder from the .tar works.
Your error comes from something specific to your system, and needs to be debugged locally.
Make sure you don't have any parasite shadowing MATLAB functions in the path: Edit the Matlab path, remove ALL the folders that are not related with the Matlab installation. Save the path, restart Matlab.
If you are working on a network or external drive, copy the freesurfer folder to an internal hard drive (in a folder C:\Users\username\Documents\RawData\SavBen1\)
Put a breakpoint in import_anatomy_fs.m at line 122, then run the import with the menu "Import anatomy folder". When the debugger stops, type FsDir and file_find(FsDir, 'T1.mgz', 2) in the Matlab command window and copy-paste the result here.
"Step in" to explore what is happening in find_file. If you've never used the Matlab debugger, it's a good time to learn how to use this super useful tool
I modified a bit the FreeSurfer import so that the lh.pial.T1 can be read when lh.pial is an invalid link. This would allow to read new zipped FreeSurfer output folders.