MRI segmentation bug report : Input must be a row vector of characters or string scalar and the segmentation is empty

Hello, I am currently doing EEG traceability research, because I only have the subject’s EEG data and no MRI data, so I used the MRI template. I used the T1 image in the MRI template for MRI segmentation.

I tried to used cat12 and fieldtrip to do MRI segmentation, but they all reported errors.
When I use cat12 for MRI segmentation, it will report an error Input must be a row vector of characters or string scalar. I tried the t1 image in the two MRI templates, and both reported this error.
bug1

When I use fieldtrip to do MRI segmentation, it will report the error the segmentation is empty.Of my two MRI templates, one can use fieldtrip for MRI segmentation normally, but one will report an error
bug3
My computer version is window10 (1094), the matlab version is r2019a, brainstorm and spm, cat, fieldtrip are the latest versions.
I also reproduced the whole process on a mac computer and it will report the same error.
Mac computer version (10.14.6 (18G5033)), Matlab version (2018b), each toolbox is the latest version.

I would like to ask if anyone has encountered this problem? Can someone help me? I have been troubled for a long time and I really want to solve this problem.

The following is my error code, the t1 image in the corresponding mri template, and the export file of my entire project.

https://drive.google.com/drive/folders/1l7Wfs3d0sZfaGzFB0sn2Da2Hr0Cs2IVP?usp=sharing

https://www.dropbox.com/sh/vhf0105q6v2igu1/AACm0rBd5kNTjX_IAoJGFkC5a?dl=0

I will look at your errors and data, but I will need a few days for that.
Please avoid posting multiple times the same messages - Thanks

The CAT12 segmentation/import functions are in the middle of major rework, I'm sorry for the bugs that are pushed to the main distribution...
Reporting them is very helpful for making the code more stable, thanks!

This commit should fix this the CAT12 import error (among many other things, like handling the non-linear MNI registration in the MRI viewer):
https://github.com/brainstorm-tools/brainstorm3/commit/29ef6a326ef6f9eb89082e8e46479ee0f210d625

This process is split in two: the segmentation done with CAT (which terminated correctly in your case) and the import of the output done by Brainstorm (which failed).
During the next few months of test phase, it can be a good idea to save the CAT segmentation folder (in the Brainstorm temporary folder: $HOME/.brainstorm/tmp/cat12). Make a copy of this entire folder (the output of CAT), outside of the brainstorm/tmp folder, which is emptied every time Brainstorm is started. If you need to wait for an import fix, or if you need to reimport your subject later, you'll be able to import it with the menu "Import anatomy folder".

The second bug, I will try to handle more gracefully, so that it returns a more readable error message.

In the Brainstorm protocol you sent, I could see that what you are trying to process are not real MRI volumes. One is a full-head volume with a contrast that really doesn't look like a T1 volume (which are required in input of the volume segmentation techniques available from Brainstorm), and one contains only the brain (no skull, no scalp), there is therefore nothing to run the segmentation on.
I fixed the bugs, but this not going to make your segmentation return anything meaningful. If you want to use this anatomy template, you should ask its provider to share a FreeSurfer/BrainSuite/CAT version of them, in order to use them in Brainstorm.

image image

Otherwise, you can use the Oreilly infant templates available in Brainstorm.
https://neuroimage.usc.edu/brainstorm/Tutorials/DefaultAnatomy#FreeSurfer_templates

@christianoreilly FYI

Ok, I understand what you mean, and I will further communicate with the person in charge of this NMR template.
I want to ask if I can still modify this topic. I wanted to send you the original MRI data, so I put the relevant links on it. I want to delete these two links now. I want to ask if I can delete them?
Very grateful for your help!

In addition, this template seems to have problems with fieldtrip for segmentation.
Is it the same problem as cat?

Yes, you can edit your previous posts and delete the links

In addition, this template seems to have problems with fieldtrip for segmentation. Is it the same problem as cat?

I could reproduce the error you reported for CAT: I fixed it.

I could not reproduce the error you reported for FieldTrip. I right-clicked on Subject04_bug2/chnpd_asym_07.0-08.0_t1w > FieldTrip MRI segmentation, it produced the expected files without errors, but the results do not make any sense.

Both CAT and FieldTrip start by the tissue segmentation from SPM, which requires in the first place to have all the tissues present in the processed volume. This is not the case in your volumes, therefor for them there is nothing to hope from those two methods.
I'm sorry, I'm not going to invest time in trying to fix the FieldTrip error, since it is not a valid use case.

Please report these bugs again if you observe them when trying to process real T1 scans.

Thank you very much for your help, I downloaded the github version of brainstorm in your reply, and then I can now use cat12 to do MRI segmentation.
But if you use fieldtrip to do MRI segmentation, you will still get an error.
The mri data is bug tmp1 IPCAS_age10_brain_template.nii.gz.

BST> FieldTrip install: /home/jade/app/eegpackage/fieldtrip-20201205
the input is volume data with dimensions [182 218 182]
Warning: adding /home/jade/app/eegpackage/fieldtrip-20201205/external/spm12 toolbox to your MATLAB path
using 'OldNorm' normalisation
Warning: adding /home/jade/app/eegpackage/fieldtrip-20201205/external/freesurfer toolbox to your MATLAB
path
Smoothing by 0 & 8mm..
Coarse Affine Registration..
Fine Affine Registration..
performing the segmentation on the specified volume, using the old-style segmentation

SPM12: spm_preproc (v4916) 19:11:07 - 19/12/2020

Completed : 19:11:25 - 19/12/2020
creating scalpmask ... using the anatomy field for segmentation
smoothing anatomy with a 5-voxel FWHM kernel
thresholding anatomy at a relative threshold of 0.100


** Error: Line 28: Undefined function 'imfill' for input arguments of type 'double'.
**
** Call stack:
** >volumefillholes.m at 28
** >ft_volumesegment.m at 619
** >process_ft_volumesegment.m>Compute at 241
** >process_ft_volumesegment.m>ComputeInteractive at 389
** >process_ft_volumesegment.m at 27
** >bst_call.m at 28
** >tree_callbacks.m>@(h,ev)bst_call(@process_ft_volumesegment,'ComputeInteractive',iSubject,iAnatomy) at 1059
**


In addition, if I use brainstorm to generate BEM, an error will be reported.


** Error: Line 185: scatteredInterpolant
** The input points must be a double array.
**
** Call stack:
** >griddata.m>useScatteredInterp at 185
** >griddata.m at 126
** >tess_parametrize_new.m at 48
** >tess_bem.m at 133
** >process_generate_bem.m>ComputeInteractive at 152
** >process_generate_bem.m at 24
** >bst_call.m at 28
** >tree_callbacks.m>@(h,ev)bst_call(@process_generate_bem,'ComputeInteractive',iSubject,iAnatomy) at 1050
**


Then if you use fieldtrip to generate BEM, an error will be reported. And this error will also report the same error when I use John E. Richards' mri template to generate bem. (I don’t know if I need to send you a John E. Richards mri template example?)

BST> FieldTrip install: /home/jade/app/eegpackage/fieldtrip-20201205
the input is volume data with dimensions [182 218 182]
using 'OldNorm' normalisation
Smoothing by 0 & 8mm..
Coarse Affine Registration..
Fine Affine Registration..
performing the segmentation on the specified volume, using the old-style segmentation

SPM12: spm_preproc (v4916) 19:19:39 - 19/12/2020

Completed : 19:19:55 - 19/12/2020
creating scalpmask ... using the anatomy field for segmentation
smoothing anatomy with a 5-voxel FWHM kernel
thresholding anatomy at a relative threshold of 0.100


** Error: Line 28: Undefined function 'imfill' for input arguments of type 'double'.
**
** Call stack:
** >volumefillholes.m at 28
** >ft_volumesegment.m at 619
** >process_ft_volumesegment.m>Compute at 241
** >process_ft_volumesegment.m>ComputeInteractive at 389
** >process_ft_volumesegment.m at 27
** >process_generate_bem.m>ComputeInteractive at 154
** >process_generate_bem.m at 24
** >bst_call.m at 28
** >tree_callbacks.m>@(h,ev)bst_call(@process_generate_bem,'ComputeInteractive',iSubject,iAnatomy) at 1050
**


Thank you very much for your help and look forward to your reply.

For updating Brainstorm, you can use the menu "Update > Update Brainstorm" from the interface.

But if you use fieldtrip to do MRI segmentation, you will still get an error.
The mri data is bug tmp1 IPCAS_age10_brain_template.nii.gz.

As I mentioned before, these are not T1 MRI volumes that you can process with these tools.
I'm sorry, I am not going to spend time on trying to make this work. If you want a segmentation of the tissues, you should ask the providers of the templates, or maybe the FieldTrip team.

Ok, I understand.
Thank you very much for your help, you really helped me a lot.