Skip to content

Commit

Permalink
Bug fixes to get_wh_image
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-Sun committed May 13, 2024
1 parent 525069f commit a1c9068
Showing 1 changed file with 45 additions and 12 deletions.
57 changes: 45 additions & 12 deletions CanlabCore/@image_vector/get_wh_image.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,60 @@
% above. these field are all 1D

otherfields = {'image_names', 'fullpath', 'files_exist', 'removed_images', 'X', 'Y', 'metadata_table' 'threshold' 'image_labels'};

for f = otherfields
field = char(f);

if ~isprop(out, field), continue; end

sz = size(out.(field));

if ~isempty(out.(field)) && sz(1) == datsz(2)
try
field = char(f);

out.(field) = out.(field)(wh, :); % these field are all 1D
if ~isprop(out, field), continue; end

end

if ~isempty(out.(field)) && sz(2) == datsz(2)
sz = size(out.(field));

out.(field) = out.(field)(:, wh); % these field are all 1D
if ~isempty(out.(field)) && sz(1) == datsz(2) %

out.(field) = out.(field)(wh, :); % these field are all 1D

end

if ~isempty(out.(field)) && sz(2) == datsz(2)

out.(field) = out.(field)(:, wh); % these field are all 1D

end
catch
warning(['Field ', field, ' could not be modified']);
end

end

if strcmp(class(dat), 'statistic_image')
statfields={'p', 'sig', 'ste'}

for f = statfields
try
field = char(f);

if ~isprop(out, field), continue; end

sz = size(out.(field));

if ~isempty(out.(field)) && sz(2) ~= datsz(2)

out.(field) = out.(field)(:, wh); % these field are all 1D

end
catch
warning(['Field ', field, ' could not be modified']);
end

end
end

out.removed_images = ones(size(dat.removed_images)); % Set all elements to 1
out.removed_images(wh) = 0; % Set specified indices to 0



end % function


Expand Down

0 comments on commit a1c9068

Please sign in to comment.