function plot_val_arrays(vals,monkey) % project a set of values in cortical/array space % vals = 1x1024 % monkey = 'F' or 'N' % warning: some info are handcrafted, so it'll only work with 'F' and 'N' % 2024 P.Papale fecit img = imread(['\_code\code_utils_v2\_figs\',monkey,'_array.png']); bw = im2bw(img); stats = regionprops(not(bw),'Centroid'); vals(isnan(vals))=-Inf; if monkey == 'F' arrays_order = [16,15,14,13,12,11,10,9,1,2,3,4,5,7,6,8]; else arrays_order = [10,9,11,12,14,13,15,6,8,7,5,3,4,2,1]; vals(1+64*(6-1):64*6) = []; end stats = stats(arrays_order); [Xq,Yq] = meshgrid(-75:150/8:75,-75:150/8:75); z = ones(size(Xq)); XY = [Xq(:) Yq(:)]; theta=90; %TO ROTATE CLOCKWISE BY X DEGREES R=[cosd(theta) -sind(theta); sind(theta) cosd(theta)]; %CREATE THE MATRIX rotXY1=XY*R'; %MULTIPLY VECTORS BY THE ROT MATRIX Xqr = reshape(rotXY1(:,1), size(Xq,1), []); Yqr = reshape(rotXY1(:,2), size(Yq,1), []); XY = [Xqr(:) Yqr(:)]; theta=45; %TO ROTATE CLOCKWISE BY X DEGREES R=[cosd(theta) -sind(theta); sind(theta) cosd(theta)]; %CREATE THE MATRIX rotXY=XY*R'; %MULTIPLY VECTORS BY THE ROT MATRIX for i = 1:length(arrays_order) if monkey == 'F' && i >=14 && i <=16 Xqr = reshape(rotXY(:,1), size(Xqr,1), []); Yqr = reshape(rotXY(:,2), size(Yqr,1), []); end C = reshape(vals(1+64*(i-1):64*i),[8 8]); %SHIFTING Xqrs = Xqr+stats(i).Centroid(1); Yqrs = Yqr+stats(i).Centroid(2); fvc = surf2patch(Xqrs,Yqrs,z,C); p=patch(fvc); shading faceted hold on idx = i; if monkey == 'N' && i > 5 idx = i+1; end text(stats(i).Centroid(1),stats(i).Centroid(2),mat2str(idx),'color','r') end objs=findall(gcf,'-property','FaceColor'); set(objs,'EdgeColor','w') xlim([50 1890]) ylim([50 550]) axis equal axis off set(gca, 'YDir','reverse') hold off %%% Junk % % % % imshow(bw) % hold on % for i = 1:numel(stats) % temp = uniquetol(stats(i).Extrema,.05,'ByRows',1); % vertices(i,:,:) = [temp(3,:);temp([1,2,4],:)]; % scatter(temp(:,1),temp(:,2),'LineWidth',3) % scatter(stats(i).Centroid(1),stats(i).Centroid(2),'LineWidth',3) % hold on % end