Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes for TBP workflow #7

Merged
merged 3 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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(

Check warning on line 288 in xnat_ingest/session.py

View check run for this annotation

Codecov / codecov/patch

xnat_ingest/session.py#L288

Added line #L288 was not covered by tests
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(

Check warning on line 294 in xnat_ingest/session.py

View check run for this annotation

Codecov / codecov/patch

xnat_ingest/session.py#L294

Added line #L294 was not covered by tests
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(

Check warning on line 300 in xnat_ingest/session.py

View check run for this annotation

Codecov / codecov/patch

xnat_ingest/session.py#L300

Added line #L300 was not covered by tests
"Did not find %s field in DICOM series %s",
field.keyword,
session_dicom_series,
)
id_ = cls.id_escape_re.sub("", id_)
id_ = None

Check warning on line 305 in xnat_ingest/session.py

View check run for this annotation

Codecov / codecov/patch

xnat_ingest/session.py#L305

Added line #L305 was not covered by tests
if not id_:
id_ = "UNKNOWN" + "".join(
random.choices(string.ascii_letters + string.digits, k=8)
Expand Down
Loading