nii = load_nii('aal.nii');
labels = nii.img;
unique_labels = unique(labels);
unique_labels(unique_labels==0) = [];
for i = 1:length(unique_labels)
label = unique_labels(i);
label_indices = find(labels == label);
% 生成脑区nii文件
label_nii = nii;
label_nii.img = zeros(size(labels));
label_nii.img(label_indices) = 1;
save_nii(label_nii, ['label_', num2str(label), '.nii']);
end
网友评论