@@ -111,6 +111,7 @@ def test_FieldmapEstimation(dsA_dir, inputfiles, method, nsources, raises):
111111 assert fe .method == method
112112 assert len (fe .sources ) == nsources
113113 assert fe .bids_id is not None and fe .bids_id .startswith ("auto_" )
114+ assert fe .bids_id == fe .sanitized_id # Auto-generated IDs are sanitized
114115
115116 # Attempt to change bids_id
116117 with pytest .raises (ValueError ):
@@ -243,6 +244,33 @@ def test_FieldmapEstimationIdentifier(monkeypatch, dsA_dir):
243244
244245 fm .clear_registry ()
245246
247+ fe = fm .FieldmapEstimation (
248+ [
249+ fm .FieldmapFile (
250+ dsA_dir / "sub-01" / "fmap/sub-01_fieldmap.nii.gz" ,
251+ metadata = {
252+ "Units" : "Hz" ,
253+ "B0FieldIdentifier" : "fmap-with^special#chars" ,
254+ "IntendedFor" : ["file1.nii.gz" , "file2.nii.gz" ],
255+ },
256+ ),
257+ fm .FieldmapFile (
258+ dsA_dir / "sub-01" / "fmap/sub-01_magnitude.nii.gz" ,
259+ metadata = {"Units" : "Hz" , "B0FieldIdentifier" : "fmap-with^special#chars" },
260+ ),
261+ ]
262+ )
263+ assert fe .bids_id == "fmap-with^special#chars"
264+ assert fe .sanitized_id == "fmap_with_special_chars"
265+ # The unsanitized ID is used for lookups
266+ assert fm .get_identifier ("file1.nii.gz" ) == ("fmap-with^special#chars" ,)
267+ assert fm .get_identifier ("file2.nii.gz" ) == ("fmap-with^special#chars" ,)
268+
269+ wf = fe .get_workflow ()
270+ assert wf .name == "wf_fmap_with_special_chars"
271+
272+ fm .clear_registry ()
273+
246274
247275def test_type_setter ():
248276 """Cover the _type_setter routine."""
0 commit comments