From 4ac551e5a1df7edcd236b822f4b2c8fe49372b3b Mon Sep 17 00:00:00 2001 From: pvelasco Date: Wed, 6 Jan 2021 13:35:59 -0500 Subject: [PATCH 1/5] ENH: Adds "AcquisitionTime" to the `seqinfo` --- heudiconv/dicoms.py | 1 + heudiconv/utils.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/heudiconv/dicoms.py b/heudiconv/dicoms.py index 3a851e65..7d345b45 100644 --- a/heudiconv/dicoms.py +++ b/heudiconv/dicoms.py @@ -89,6 +89,7 @@ def create_seqinfo(mw, series_files, series_id): patient_age=dcminfo.get('PatientAge'), patient_sex=dcminfo.get('PatientSex'), date=dcminfo.get('AcquisitionDate'), + time=dcminfo.get('AcquisitionTime'), series_uid=dcminfo.get('SeriesInstanceUID') ) return seqinfo diff --git a/heudiconv/utils.py b/heudiconv/utils.py index f30a23e7..072dbbb5 100644 --- a/heudiconv/utils.py +++ b/heudiconv/utils.py @@ -45,7 +45,8 @@ 'patient_age', # 22 'patient_sex', # 23 'date', # 24 - 'series_uid', # 25 + 'time', # 25 + 'series_uid', # 26 ] SeqInfo = namedtuple('SeqInfo', seqinfo_fields) From 5b3364682ea3262ea957aa5c2681e691af04aaa5 Mon Sep 17 00:00:00 2001 From: pvelasco Date: Thu, 7 Jan 2021 11:43:46 -0500 Subject: [PATCH 2/5] Switch back order of seqinfo_fields To preserve backwards compatibility --- heudiconv/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/heudiconv/utils.py b/heudiconv/utils.py index 072dbbb5..517b58bc 100644 --- a/heudiconv/utils.py +++ b/heudiconv/utils.py @@ -45,9 +45,9 @@ 'patient_age', # 22 'patient_sex', # 23 'date', # 24 - 'time', # 25 - 'series_uid', # 26 - ] + 'series_uid', # 25 + 'time', # 26 +] SeqInfo = namedtuple('SeqInfo', seqinfo_fields) From 74d55d5d550ceae737dbfa9a7903535c93b572f0 Mon Sep 17 00:00:00 2001 From: pvelasco Date: Fri, 8 Jan 2021 09:29:54 -0500 Subject: [PATCH 3/5] Switch back order of SeqInfo arguments in dicom.py To preserve backwards compatibility --- heudiconv/dicoms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heudiconv/dicoms.py b/heudiconv/dicoms.py index 7d345b45..a8c66c21 100644 --- a/heudiconv/dicoms.py +++ b/heudiconv/dicoms.py @@ -89,8 +89,8 @@ def create_seqinfo(mw, series_files, series_id): patient_age=dcminfo.get('PatientAge'), patient_sex=dcminfo.get('PatientSex'), date=dcminfo.get('AcquisitionDate'), + series_uid=dcminfo.get('SeriesInstanceUID'), time=dcminfo.get('AcquisitionTime'), - series_uid=dcminfo.get('SeriesInstanceUID') ) return seqinfo From 0fb0c2f6801d03b72e8be321412605a72e8112b8 Mon Sep 17 00:00:00 2001 From: pvelasco Date: Fri, 8 Jan 2021 09:45:31 -0500 Subject: [PATCH 4/5] Adds unittest to check "time" in the right position in dicominfo.tsv --- heudiconv/tests/test_main.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/heudiconv/tests/test_main.py b/heudiconv/tests/test_main.py index d13f02ef..fdf5351e 100644 --- a/heudiconv/tests/test_main.py +++ b/heudiconv/tests/test_main.py @@ -283,6 +283,11 @@ def test_cache(tmpdir): assert (cachedir / 'S01.auto.txt').exists() assert (cachedir / 'S01.edit.txt').exists() + # check dicominfo has "time" as last column: + with open(cachedir / 'dicominfo.tsv', 'r') as f: + cols = f.readline().split() + assert cols[26] == "time" + def test_no_etelemetry(): # smoke test at large - just verifying that no crash if no etelemetry From 2768e7a8d666d20b11d364b5229d51e6eaa48ec1 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Tue, 12 Jan 2021 13:34:43 -0500 Subject: [PATCH 5/5] BF(py3.5): explicitly case path to str for open --- heudiconv/tests/test_main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heudiconv/tests/test_main.py b/heudiconv/tests/test_main.py index fdf5351e..89fde8b0 100644 --- a/heudiconv/tests/test_main.py +++ b/heudiconv/tests/test_main.py @@ -284,7 +284,7 @@ def test_cache(tmpdir): assert (cachedir / 'S01.edit.txt').exists() # check dicominfo has "time" as last column: - with open(cachedir / 'dicominfo.tsv', 'r') as f: + with open(str(cachedir / 'dicominfo.tsv'), 'r') as f: cols = f.readline().split() assert cols[26] == "time"