@@ -225,19 +225,26 @@ function print_mapping(obj, filename)
225225 input = obj .mapping(i );
226226 input = prepare_for_printing(input );
227227
228+ input_filename = input .filename ;
229+
228230 %%
229231 output = obj .mapping(i ).name_spec;
230232 output = prepare_for_printing(output );
231233
232- output.filename = [' *' output .filename ];
234+ output_filename = output .filename ;
235+
236+ output_filename = [' *' output_filename ];
237+ output_filename = strrep(output_filename , ' add-star' , ' *' );
233238
234239 if fid ~= 1
235- input.filename = strrep(input .filename , ' *' , ' \*' );
236- output.filename = strrep(output .filename , ' *' , ' \*' );
240+ input_filename = strrep(input_filename , ' *' , ' \*' );
241+ input_filename = strrep(input_filename , ' _' , ' \_' );
242+ output_filename = strrep(output_filename , ' *' , ' \*' );
243+ output_filename = strrep(output_filename , ' _' , ' \_' );
237244 end
238245
239246 fprintf(fid , ' %s%s%s%s%s\n ' , ...
240- left , input . filename , separator , output . filename , right );
247+ left , input_filename , separator , output_filename , right );
241248
242249 else
243250
@@ -367,17 +374,21 @@ function print_mapping(obj, filename)
367374
368375function bf = prepare_for_printing(spec )
369376
377+ if isfield(spec , ' entities' ) && strcmp(spec .entities , ' *' )
378+ spec.entities = struct(' add' , ' joker' );
379+ end
380+ bf = bids .File(spec , ' tolerant' , true );
381+
370382 if isfield(spec , ' suffix' ) && isempty(spec .suffix ) || ...
371383 ~isfield(spec , ' suffix' )
372- spec .suffix = ' *' ;
384+ bf .suffix = ' *' ;
373385 end
374386
375387 if isfield(spec , ' ext' ) && ~isempty(spec .ext )
376- spec .extension = ' .*' ;
388+ bf .extension = ' .*' ;
377389 end
378390 if ~isfield(spec , ' extension' ) || isempty(spec .extension )
379- spec.ext = ' .*' ;
391+ bf.extension = ' .*' ;
380392 end
381393
382- bf = bids .File(spec );
383394end
0 commit comments