Australian-Imaging-Service / pipelines

Scripts to generate analysis pipelines that can be run in XNAT's container service
Other
1 stars 3 forks source link

[STORY] create the session label using patientID and study date with four underscore between them. #311

Open anzhao opened 5 days ago

anzhao commented 5 days ago

Metadata

Epic: Dan's XNAT Data Upload

Description

Dan would like label in XNAT to be “patientID__StudyDate” eg. “1234___01/12/2023” The patient ID (which get from REDCap) will be used for the parent folder name. The study date will need to be “looked up” in the data tag within the Dicom.

Acceptance Criteria

The label under the experiments (shown below) are in the specified format of patientID_StudyDate (shown below).

Image

Dependencies

anzhao commented 3 days ago

Use the following bash script to inject the Patient Comments to the folder contains a series of DICOM files. When providing the patient comment, specified the session label in the format of PatientID____StudyDate

!/bin/bash

//Specify the Directory containing DICOM files DICOM_DIR="/path/to/DicomFileFolder" //Patient comment to be inserted PATIENT_COMMENT="Project:AnClinTrial001 Subject:subj001 Session:PatientID____StudyDate" //Loop through each DICOM file in the specified directory for DICOM_FILE in "$DICOM_DIR"/*.dcm; do // Check if the Patient Comments tag exists or not if ! dcmdump "$DICOM_FILE" | grep "(0010,4000)" > /dev/null; then // If the tag does not exist, insert the Patient Comment tag dcmodify -i "(0010,4000)=$PATIENT_COMMENT" "$DICOM_FILE" echo "Inserted specified comments into: $DICOM_FILE" else // If the tag exists, then modify the Patient Comment tag dcmodify -ma "(0010,4000)=$PATIENT_COMMENT" "$DICOM_FILE" echo "Modified patient comment in: $DICOM_FILE" fi // Check if dcmodify was successful if [ $? -eq 0 ]; then echo "Success: $DICOM_FILE" else echo "Failed to process: $DICOM_FILE" fi done

echo "Update Patient Comment complete."

The following is the exec output of running against a testing data:

Inserted comment into: .//IM-42220-0092.dcm Success: .//IM-42220-0092.dcm Inserted comment into: .//IM-42220-0093.dcm Success: .//IM-42220-0093.dcm Inserted comment into: .//IM-42220-0094.dcm Success: .//IM-42220-0094.dcm Inserted comment into: .//IM-42220-0095.dcm Success: .//IM-42220-0095.dcm Inserted comment into: .//IM-42220-0096.dcm Success: .//IM-42220-0096.dcm Inserted comment into: .//IM-42220-0097.dcm Success: .//IM-42220-0097.dcm Inserted comment into: .//IM-42220-0098.dcm Success: .//IM-42220-0098.dcm Inserted comment into: .//IM-42220-0099.dcm Success: .//IM-42220-0099.dcm Inserted comment into: .//IM-42220-0100.dcm Success: .//IM-42220-0100.dcm Inserted comment into: .//IM-42220-0101.dcm Success: .//IM-42220-0101.dcm Inserted comment into: .//IM-42220-0102.dcm Success: .//IM-42220-0102.dcm Inserted comment into: .//IM-42220-0103.dcm Success: .//IM-42220-0103.dcm Inserted comment into: .//IM-42220-0104.dcm Success: .//IM-42220-0104.dcm Inserted comment into: .//IM-42220-0105.dcm Success: .//IM-42220-0105.dcm Inserted comment into: .//IM-42220-0106.dcm Success: .//IM-42220-0106.dcm Inserted comment into: .//IM-42220-0107.dcm Success: .//IM-42220-0107.dcm Inserted comment into: .//IM-42220-0108.dcm Success: .//IM-42220-0108.dcm Inserted comment into: .//IM-42220-0109.dcm Success: .//IM-42220-0109.dcm Inserted comment into: .//IM-42220-0110.dcm Success: .//IM-42220-0110.dcm Inserted comment into: .//IM-42220-0111.dcm Success: .//IM-42220-0111.dcm Inserted comment into: .//IM-42220-0112.dcm Success: .//IM-42220-0112.dcm Inserted comment into: .//IM-42220-0113.dcm Success: .//IM-42220-0113.dcm Inserted comment into: .//IM-42220-0114.dcm Success: .//IM-42220-0114.dcm Inserted comment into: .//IM-42220-0115.dcm Success: .//IM-42220-0115.dcm Inserted comment into: .//IM-42220-0116.dcm Success: .//IM-42220-0116.dcm Inserted comment into: .//IM-42220-0117.dcm Success: .//IM-42220-0117.dcm Inserted comment into: .//IM-42220-0118.dcm Success: .//IM-42220-0118.dcm Inserted comment into: .//IM-42220-0119.dcm Success: .//IM-42220-0119.dcm Inserted comment into: .//IM-42220-0120.dcm Success: .//IM-42220-0120.dcm Comment processing complete.

Image

anzhao commented 2 days ago

Beside using the DicomEdit script to do the de-identification, we can also use the DICOM Toolkit to Modify the DICOM tags we wish.

!/bin/bash

// Directory containing DICOM files DICOM_DIR="./20160418Ct_Hr_Chest-12417/Axial_MIPS_5mm_612"

// Loop through each DICOM file in the directory for DICOM_FILE in "$DICOM_DIR"/*.dcm; do echo "De-identifying $DICOM_FILE" // Modify the specified DICOM tag to remove patient-identifying information dcmodify -ma "(0010,0010)=Anonymized" \ # Patient's Name
-ma "(0010,0030)=" \ # Patient's Birth Date -ma "(0010,0040)=" \ # Patient's Sex -ma "(0008,0080)=" \ # Institution Name -ma "(0008,0090)=" \ # Referring Physician's Name
-ma "(0008,1050)=" \ # Performing Physician's Name -ma "(0010,1010)=" \ # Patient's Age -ma "(0010,1020)=" \ # Patient's Size -ma "(0010,1030)=" \ # Patient's Weight -ma "(0010,2160)=" \ # Ethnic Group -e "$DICOM_FILE" done

echo "De-identification complete."