Heudiconv time format error

Summary of what happened:

Hello,
I’m having some issues running heudiconv and I can’t find where the problem is. The error shows that it is a time format issue, but there is no relevant code from the heudiconv.py, I tried adding the time in dicominfo.tsv to .000000, but it still reports an error.

Command used (and if a helper script was used, a link to the helper script or the command generated):

docker run --rm -it -v /home/yoyimiya/application/luowenpei:/base nipy/heudiconv:latest -d /base/Dicom/sub-{subject}/ses-{session}/SCANS/*/* -o /base/Nifti -f /base/Nifti/code/heuristic.py -s 01 -ss 001 -c dcm2niix -b --overwrite

Version:

The system I use is ubuntu and the version of heudiconv is 0.13.0.

Environment (Docker, Singularity, custom installation):

Docker

Data formatted according to a validatable standard? Please provide the output of the validator:

Relevant log outputs (up to 20 lines):

INFO: Running heudiconv version 0.13.0 latest 0.13.0
INFO: Need to process 1 study sessions
INFO: PROCESSING STARTS: {'subject': '01', 'outdir': '/base/Nifti/', 'session': '001'}
INFO: Processing 31781 dicoms
INFO: Analyzing 31781 dicoms
INFO: Generated sequence info for 4 studies with 31781 entries total
INFO: Doing conversion using dcm2niix
INFO: Converting /base/Nifti/sub-01/ses-001/anat/sub-01_ses-001_run-001_T1w (176 DICOMs) -> /base/Nifti/sub-01/ses-001/anat . Converter: dcm2niix . Output types: ('nii.gz',)
230512-04:03:18,681 nipype.workflow INFO:
	 [Node] Setting-up "convert" in "/tmp/dcm2niix5c07ip82/convert".
INFO: [Node] Setting-up "convert" in "/tmp/dcm2niix5c07ip82/convert".
230512-04:03:18,696 nipype.workflow INFO:
	 [Node] Executing "convert" <nipype.interfaces.dcm2nii.Dcm2niix>
INFO: [Node] Executing "convert" <nipype.interfaces.dcm2nii.Dcm2niix>
230512-04:03:18,784 nipype.interface INFO:
	 stdout 2023-05-12T04:03:18.784595:Chris Rorden's dcm2niiX version v1.0.20220720  GCC10.2.1 x86-64 (64-bit Linux)
INFO: stdout 2023-05-12T04:03:18.784595:Chris Rorden's dcm2niiX version v1.0.20220720  GCC10.2.1 x86-64 (64-bit Linux)
230512-04:03:18,784 nipype.interface INFO:
	 stdout 2023-05-12T04:03:18.784595:Found 176 DICOM file(s)
INFO: stdout 2023-05-12T04:03:18.784595:Found 176 DICOM file(s)
230512-04:03:18,784 nipype.interface INFO:
	 stdout 2023-05-12T04:03:18.784595:Convert 176 DICOM as /base/Nifti/sub-01/ses-001/anat/sub-01_ses-001_run-001_T1w_heudiconv315 (256x256x176x1)
INFO: stdout 2023-05-12T04:03:18.784595:Convert 176 DICOM as /base/Nifti/sub-01/ses-001/anat/sub-01_ses-001_run-001_T1w_heudiconv315 (256x256x176x1)
230512-04:03:18,989 nipype.interface INFO:
	 stdout 2023-05-12T04:03:18.989403:Compress: "/usr/bin/pigz" -b 960 -n -f -6 "/base/Nifti/sub-01/ses-001/anat/sub-01_ses-001_run-001_T1w_heudiconv315.nii"
INFO: stdout 2023-05-12T04:03:18.989403:Compress: "/usr/bin/pigz" -b 960 -n -f -6 "/base/Nifti/sub-01/ses-001/anat/sub-01_ses-001_run-001_T1w_heudiconv315.nii"
230512-04:03:18,989 nipype.interface INFO:
	 stdout 2023-05-12T04:03:18.989403:Conversion required 0.256187 seconds (0.098949 for core code).
INFO: stdout 2023-05-12T04:03:18.989403:Conversion required 0.256187 seconds (0.098949 for core code).
230512-04:03:19,4 nipype.workflow INFO:
	 [Node] Finished "convert", elapsed time 0.28011s.
INFO: [Node] Finished "convert", elapsed time 0.28011s.
Traceback (most recent call last):
  File "/opt/miniconda-py39_4.12.0/bin/heudiconv", line 8, in <module>
    sys.exit(main())
  File "/src/heudiconv/heudiconv/cli/run.py", line 30, in main
    workflow(**kwargs)
  File "/src/heudiconv/heudiconv/main.py", line 463, in workflow
    prep_conversion(
  File "/src/heudiconv/heudiconv/convert.py", line 255, in prep_conversion
    convert(
  File "/src/heudiconv/heudiconv/convert.py", line 633, in convert
    save_scans_key(item, bids_outfiles)
  File "/src/heudiconv/heudiconv/bids.py", line 492, in save_scans_key
    rows[f_name] = get_formatted_scans_key_row(item[-1][0])
  File "/src/heudiconv/heudiconv/bids.py", line 577, in get_formatted_scans_key_row
    acq_datetime = dicoms.get_datetime_from_dcm(dcm_data=dcm_data)
  File "/src/heudiconv/heudiconv/dicoms.py", line 484, in get_datetime_from_dcm
    return datetime.datetime.strptime(acq_date + acq_time, "%Y%m%d%H%M%S.%f")
  File "/opt/miniconda-py39_4.12.0/lib/python3.9/_strptime.py", line 568, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
  File "/opt/miniconda-py39_4.12.0/lib/python3.9/_strptime.py", line 349, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data '20230310190100' does not match format '%Y%m%d%H%M%S.%f'

Screenshots / relevant information:

Any help is appreciated,
yang

Hi @ylinzhi84,

It looks like it expects the time to be a floating point number with YMDHMS fields. Can you change it from 20230310190100 to 20230310190100. (that is, add a period at the end)?

Best,
Steven

1 Like

so it seems we need to make subsecond portion optional. Continued on heudiconv failure with false report of successful conversion · Issue #657 · nipy/heudiconv · GitHub .

edit:

1 Like

Thank you very much for your attentive and effective reply, I re-pulled the previous version of heudiconv and it worked successfully. If time permits, I’ll try to modify the part of code you’ve suggested and try running again.