@@ -57,7 +57,7 @@ def sortsession(sessionfolder: Path, dicomfiles: list, dicomfield: str, rename:
5757 # Extract the SeriesDescription and SeriesNumber from the dicomfield
5858 seriesnr = bids .get_dicomfield ('SeriesNumber' , dicomfile )
5959 if not seriesnr :
60- warnings . warn (f"No SeriesNumber found, skipping: { dicomfile } " ) # This is not a normal DICOM file, better not do anything with it
60+ LOGGER . warning (f"No SeriesNumber found, skipping: { dicomfile } " ) # This is not a normal DICOM file, better not do anything with it
6161 continue
6262 seriesdescr = bids .get_dicomfield (dicomfield , dicomfile )
6363 if not seriesdescr :
@@ -66,7 +66,7 @@ def sortsession(sessionfolder: Path, dicomfiles: list, dicomfield: str, rename:
6666 seriesdescr = bids .get_dicomfield ('ProtocolName' , dicomfile )
6767 if not seriesdescr :
6868 seriesdescr = 'unknown_protocol'
69- warnings . warn (f"No { dicomfield } , SeriesDecription or ProtocolName found for: { dicomfile } " )
69+ LOGGER . warning (f"No { dicomfield } , SeriesDecription or ProtocolName found for: { dicomfile } " )
7070 if rename :
7171 acquisitionnr = bids .get_dicomfield ('AcquisitionNumber' , dicomfile )
7272 instancenr = bids .get_dicomfield ('InstanceNumber' , dicomfile )
@@ -78,7 +78,7 @@ def sortsession(sessionfolder: Path, dicomfiles: list, dicomfield: str, rename:
7878
7979 # Move and/or rename the dicomfile in(to) the (series sub)folder
8080 if rename and not (patientname and seriesnr and seriesdescr and acquisitionnr and instancenr ):
81- warnings . warn (f"Missing one or more essential DICOM-fields, cannot safely rename { dicomfile } \n "
81+ LOGGER . warning (f"Missing one or more essential DICOM-fields, cannot safely rename { dicomfile } \n "
8282 f"patientname = { patientname } \n "
8383 f"seriesnumber = { seriesnr } \n "
8484 f"{ dicomfield } = { seriesdescr } \n "
@@ -106,7 +106,7 @@ def sortsession(sessionfolder: Path, dicomfiles: list, dicomfield: str, rename:
106106 else :
107107 newfilename = pathname / filename
108108 if newfilename .is_file ():
109- warnings . warn (f"File already exists, cannot safely rename { dicomfile } -> { newfilename } " )
109+ LOGGER . warning (f"File already exists, cannot safely rename { dicomfile } -> { newfilename } " )
110110 elif not dryrun :
111111 dicomfile .replace (newfilename )
112112
0 commit comments