Skip to content

Commit

Permalink
enabled manual override of loaded project IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed Nov 16, 2023
1 parent efe18a2 commit f247fa1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 10 additions & 0 deletions xnat_ingest/cli/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ def __str__(self):
"The keyword or tag of the DICOM field to extract the XNAT imaging session ID from "
),
)
@click.option(
"--project-id",
type=str,
default=None,
help=(
"Override the project ID read from the DICOM headers"
)
)
@click.option(
"--assoc-files-glob",
type=str,
Expand Down Expand Up @@ -211,6 +219,7 @@ def upload(
project_field: str,
subject_field: str,
session_field: str,
project_id: str | None,
delete: bool,
log_file: Path,
log_emails: LoggerEmail,
Expand Down Expand Up @@ -253,6 +262,7 @@ def upload(
project_field=project_field,
subject_field=subject_field,
session_field=session_field,
project_id=project_id,
)

xnat_repo = Xnat(
Expand Down
6 changes: 5 additions & 1 deletion xnat_ingest/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def load(
project_field: str = "StudyID",
subject_field: str = "PatientID",
session_field: str = "AccessionNumber",
project_id: str | None = None,
) -> ty.List["ImagingSession"]:
"""Loads all imaging sessions from a list of DICOM files
Expand All @@ -200,6 +201,9 @@ def load(
session_field : str
the name of the DICOM field that is to be interpreted as the corresponding
XNAT project
project_id : str
Override the project ID loaded from the DICOM header (useful when invoking
manually)
Returns
-------
Expand Down Expand Up @@ -255,7 +259,7 @@ def get_id(field):
dicoms={str(s["SeriesNumber"]): s for s in session_dicom_series},
associated_file_fspaths=associated_file_fspaths,
associated_files_pattern=associated_files_pattern,
project_id=get_id(project_field),
project_id=(project_id if project_id else get_id(project_field)),
subject_id=get_id(subject_field),
session_id=get_id(session_field),
)
Expand Down

0 comments on commit f247fa1

Please sign in to comment.