Issue with button taking in inputs from multiple list buttons to highlight regions of atlas image. Error: Brace indexing is not support for variables of this type

1 view (last 30 days)
So I am creating an app that highlights certain regions on the area with different colors when selected from a list button. So far I have been successful when there is only one list to choose from. Here is my code for that:
% Load Atlas
% Relies on https://www.fieldtriptoolbox.org/template/atlas/ and
% https://github.com/fieldtrip/fieldtrip/tree/master/template/atlas and
% https://www.gin.cnrs.fr/en/tools/aal/
aalAtlas = ft_read_atlas('ROI_MNI_V4.nii');
BrainImage = ones(91, 109,'int8');
BrainImage(:,:) = aalAtlas.tissue(:, :, 50) %the tissue is part of the 3D BrainImage of the Atlas that looks at tissue
% explanation for below: https://www.mathworks.com/matlabcentral/answers/24865-converting-cell-of-strings-in-arry-or-cell-of-numbers
%Convert it to a proper format to allow parts of images to highlighted/brighter
String_region = sprintf('%s ', app.CerebralAreasListBox.Value{:});
List_of_specifed_regions_array = sscanf(String_region, '%f');
%put it in a for loop to display each section
for slice = 1:91
BrainImage(:,:) = aalAtlas.tissue(:, :, slice);
ColorBrainImage = ind2rgb(BrainImage, copper);
% Make those 3 regions a 5 times brighter value brighter.
ColorBrainImage(regions) = uint8(50 * double(ColorBrainImage(regions))); %double allows to multipy with decimals and uint brings it back to whole number
BBrainImage = imresize(ColorBrainImage,9);
imshow(BBrainImage)
end
But then I run into issues when I want to have multiple lists to choose from that can select their own respective regions of the brain. This is my code when I try to include the other two lists, which I want to add extra eventaully, but it keeps failing. My goal is to have each list show their regions in a different color, but for now I at least want to have them work on selecting regions on their own. I keep on getting an error that says "Brace indexing is not supported for variables of this type." I don't understand why that is when is worked in the lines above it. Thank you for the help in advance!
% Button pushed function: BrainAtlasButton
function LoadAtlas(app, event)
% Load Atlas
% Relies on https://www.fieldtriptoolbox.org/template/atlas/ and
% https://github.com/fieldtrip/fieldtrip/tree/master/template/atlas and
% https://www.gin.cnrs.fr/en/tools/aal/
aalAtlas = ft_read_atlas('ROI_MNI_V4.nii');
BrainImage = ones(91, 109,'int8');
BrainImage(:,:) = aalAtlas.tissue(:, :, 50) %the tissue is part of the 3D BrainImage of the Atlas that looks at tissue
% explanation for below: https://www.mathworks.com/matlabcentral/answers/24865-converting-cell-of-strings-in-arry-or-cell-of-numbers
%Convert it to a proper format to allow parts of images to highlighted/brighter
String_region = sprintf('%s ', app.CerebralAreasListBox.Value{:});
List_of_specifed_regions_array = sscanf(String_region, '%f');
String_region_2 = sprintf('%s ', app.CerebralAreasListBox_2.Value{:});
List_of_specifed_regions_array_2 = sscanf(String_region_2, '%f'); %ERROR: Brace indexing is not supported for variables of this type.
String_region_3 = sprintf('%s ', app.CerebralAreasListBox_3.Value{:});
List_of_specifed_regions_array_3 = sscanf(String_region_3, '%f');
%put it in a for loop to display each section
for slice = 1:91
BrainImage(:,:) = aalAtlas.tissue(:, :, slice);
regions_1 = ismember(BrainImage, List_of_specifed_regions_array);
regions_2 = ismember(BrainImage, List_of_specifed_regions_array_2 );
regions_3 = ismember(BrainImage, List_of_specifed_regions_array_3 );
regions = (regions_1).*(regions_2).*(regions_3)
ColorBrainImage = ind2rgb(BrainImage, copper);
% Make those 3 regions a 5 times brighter value brighter.
ColorBrainImage(regions) = uint8(50 * double(ColorBrainImage(regions))); %double allows to multipy with decimals and uint brings it back to whole number
BBrainImage = imresize(ColorBrainImage,9);
imshow(BBrainImage)
end

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by