Skip to content

Commit

Permalink
Merge pull request #7 from Australian-Imaging-Service/develop
Browse files Browse the repository at this point in the history
Bug fixes for TBP workflow
  • Loading branch information
tclose authored Apr 16, 2024
2 parents df0faff + b8401f0 commit 9d3a5f7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion xnat_ingest/cli/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
33 changes: 21 additions & 12 deletions xnat_ingest/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9d3a5f7

Please sign in to comment.