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 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, 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)