From a32ecde9ba127a80aa11b16139e99990be3c9bba Mon Sep 17 00:00:00 2001 From: Tom Close Date: Tue, 16 Apr 2024 13:41:46 +1000 Subject: [PATCH 1/3] fixed logger error --- xnat_ingest/cli/transfer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xnat_ingest/cli/transfer.py b/xnat_ingest/cli/transfer.py index a516d57..038ae82 100644 --- a/xnat_ingest/cli/transfer.py +++ b/xnat_ingest/cli/transfer.py @@ -194,7 +194,7 @@ def transfer( ): if session_dir.name.startswith("UNKNOWN"): logger.error( - "Session % in subject %s in project %s is not recognised and " + "Session %s in subject %s in project %s is not recognised and " "will not be transferred, please rename manually and transfer again", session_dir.name, subject_dir.name, From 430ea05fd32c9858bed6b49a9a3a1572db90616e Mon Sep 17 00:00:00 2001 From: Tom Close Date: Tue, 16 Apr 2024 14:37:47 +1000 Subject: [PATCH 2/3] handle case where some scans in the series contains some DICOMS where required fields are missing --- xnat_ingest/session.py | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/xnat_ingest/session.py b/xnat_ingest/session.py index a02e168..5a7c1a7 100644 --- a/xnat_ingest/session.py +++ b/xnat_ingest/session.py @@ -281,19 +281,28 @@ def from_dicoms( for session_dicom_series in dicom_sessions.values(): def get_id(field): - ids = set(s.metadata[field.keyword] for s in session_dicom_series) - if len(ids) > 1: - raise DicomParseError( - f"Multiple values for '{field}' tag found across scans in session: " - f"{session_dicom_series}" - ) - id_ = next(iter(ids)) - if isinstance(id_, list): - raise DicomParseError( - f"Multiple values for '{field}' tag found within scans in session: " - f"{session_dicom_series}" + ids = set(s.metadata.get(field.keyword) for s in session_dicom_series) + ids.discard(None) + if ids: + if len(ids) > 1: + raise DicomParseError( + f"Multiple values for '{field}' tag found across scans in session: " + f"{session_dicom_series}" + ) + id_ = next(iter(ids)) + if isinstance(id_, list): + raise DicomParseError( + f"Multiple values for '{field}' tag found within scans in session: " + f"{session_dicom_series}" + ) + id_ = cls.id_escape_re.sub("", id_) + else: + logger.warning( + "Did not find %s field in DICOM series %s", + field.keyword, + session_dicom_series, ) - id_ = cls.id_escape_re.sub("", id_) + id_ = None if not id_: id_ = "UNKNOWN" + "".join( random.choices(string.ascii_letters + string.digits, k=8) From b8401f0f6794ea03ff6d0ee6b680b195689061f3 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Tue, 16 Apr 2024 14:38:03 +1000 Subject: [PATCH 3/3] added aws cli to docker image --- Dockerfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Dockerfile b/Dockerfile index fb17115..8e57098 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,8 +6,14 @@ RUN apt-get update && apt-get install -y \ wget \ git \ mrtrix3 \ + curl \ + zip \ && rm -rf /var/lib/apt/lists/* +RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \ + && unzip awscliv2.zip \ + && ./aws/install + # Add application code ADD . /app