Skip to content

Commit 1c7b584

Browse files
authored
[FIX] better handle metadata when changing suffix (#884)
* better handle metadata when changing suffix * fix
1 parent f466cc5 commit 1c7b584

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/workflows/bidsChangeSuffix.m

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ function bidsChangeSuffix(varargin)
6363
metafiles = bids.query(BIDS, 'metafiles', filter);
6464
end
6565

66+
if isstruct(metadata) && isempty(fieldnames(metadata))
67+
warning('No metadata for filter: %s', createUnorderedList(filter));
68+
end
69+
70+
if isstruct(metadata)
71+
tmp = {metadata};
72+
metadata = tmp;
73+
end
74+
6675
for iFile = 1:size(data, 1)
6776

6877
specification.suffix = newSuffix;
@@ -74,7 +83,7 @@ function bidsChangeSuffix(varargin)
7483
'force', force);
7584

7685
% create JSON side car
77-
if ~opt.dryRun
86+
if ~opt.dryRun && ~isempty(fieldnames(metadata{iFile}))
7887
json_file = fullfile(fileparts(data{iFile}), bf.json_filename);
7988
bids.util.jsonencode(json_file, metadata{iFile});
8089
end

0 commit comments

Comments
 (0)