Index in position 1 exceeds array bounds (must not exceed 64)
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am plotting 4 different thresholded t-maps using .nii files. My first three t-maps are executed correctly. But there seems to be a problem with my fourth. Meaning that using the same script (and functions) works 3 out of 4 times. I attached error below. Matlab R2018a.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/473357/image.png)
function Y_rgb = sd_slice_to_rgb(Y, layer, settings)
% Panel dimensions
pandims = settings.slice.pandims;
% Use slover to scale slice to color map indices
Y_map_i = pr_scaletocmap(Y, ...
layer.color.range(1), ...
layer.color.range(2), ...
layer.color.map, ...
[0 256 0]);
% Convert to RGB - Error in next line
Y_rgb = reshape(layer.color.map(Y_map_i(:),:), ...
pandims);
Y_rgb(Y_rgb > 1) = 1;
end
% sd_display (line 93)
Y_rgb = sd_slice_to_rgb(Y_c,layers(i_layer),settings);
2 Kommentare
Walter Roberson
am 29 Dez. 2020
Some element of Y_map_i is greater than 64 but layer.color.map only has 64 elements.
We do not know anything about pr_scaletocmap to know how that could come about.
Antworten (1)
Walter Roberson
am 29 Dez. 2020
[0 256 0]);
The 256 there instructs that any values that would map outside of the colormap length should be replaced with 256, no matter what the length of the colormap is. You have at least one value that maps to outside the colormap, such as if your layer.color.range values are not correct for Y
2 Kommentare
Walter Roberson
am 29 Dez. 2020
Put a breakpoint at
outvals = {img<1, img>cml, isnan(img)};
and execute the code. When it gets to the breakpoint, step one line so that outvals is assigned to. Now ask
nnz(outvals{2})
if the reported number is not zero then
img(outvals{i}) = lrn(i);
is going to have an meaningful effect.
When that happens, you need to examine
max(inpimg(:))
min(inpimg(:))
mx
mn
max(img(:))
cml
[BR, BC] = find(inpimg > mx, 1);
if ~isempty(BR)
fprintf('inpimg(%d,%d) = %g which is greater than the declared max, %g\n', BR, BC, inpimg(BR,BC), mx)
end
Siehe auch
Kategorien
Mehr zu Purple finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!