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

Design Canfield Total Body Photography Upload Solution #2

Open
RyanPSullivan7 opened this issue Feb 25, 2022 · 1 comment
Open

Design Canfield Total Body Photography Upload Solution #2

RyanPSullivan7 opened this issue Feb 25, 2022 · 1 comment
Assignees

Comments

@RyanPSullivan7
Copy link
Member

RyanPSullivan7 commented Feb 25, 2022

Create configuration script for the Canfield TB-Photography instrument. This has a dependency on on the vendor.

@RyanPSullivan7 RyanPSullivan7 changed the title Configure Canfield Total Body Photography Upload Design Canfield Total Body Photography Upload Solution Mar 4, 2023
@RyanPSullivan7 RyanPSullivan7 self-assigned this Apr 14, 2023
@anzhao
Copy link

anzhao commented Nov 18, 2024

**Use the following shell script to upload the ACEMID data to XNAT: the command to run is: ./acemid_upload.sh subjectID/sessionID/your_zip_file.zip. For instance: if you have the follwing folder structure: acemid_123/acemid_session_123/hospital_123.zip, you can run it as ./acemid_upload.sh acemid_123/acemid_session_123/hospital_123.zip **

#!/bin/bash

# XNAT server URL
XNAT_URL="your_xnat_url"

# XNAT credentials
USERNAME="your_username"
PASSWORD="your_password"

# ACEMID Project ID
PROJECT_ID="ACEMID_NSW_HospitalOne"

# verify the full path
FILENAME=$1
echo "Filename: $FILENAME"

# Extract SUBJECT_ID and SESSION_ID from the filename
SUBJECT_ID=$(echo $FILENAME | cut -d'/' -f1)
SESSION_ID=$(echo $FILENAME | cut -d'/' -f2)

# Subject label and session label can be the same as their IDs 
SUBJECT_LABEL=$SUBJECT_ID
SESSION_LABEL=$SESSION_ID
echo "Subject ID: $SUBJECT_ID"
echo "Session ID: $SESSION_ID"

# Create a subject
curl -u $USERNAME:$PASSWORD -X PUT "$XNAT_URL/data/archive/projects/$PROJECT_ID/subjects/$SUBJECT_ID?label=$SUBJECT_LABEL" -H "Content-Type: application/json" -H "Content-Length: 0"

# Create a session (experiment) with session type
SESSION_TYPE="ais:xcpSessionData"  # Replace with the session type you want
RESPONSE=$(curl -u $USERNAME:$PASSWORD -X PUT "$XNAT_URL/data/archive/projects/$PROJECT_ID/subjects/$SUBJECT_ID/experiments/$SESSION_ID?xsiType=$SESSION_TYPE&label=$SESSION_LABEL" -H "Content-Type: application/json" -H "Content-Length: 0" -w "%{http_code}" -o /dev/null)

# Check if the session creation was successful
if [ "$RESPONSE" -eq 200 ] || [ "$RESPONSE" -eq 201 ]; then
  echo "XCPSession created successfully."
else
  echo "Failed to create XCPSession. HTTP response code: $RESPONSE"
  exit 1
fi

# Create a scan
SCAN_ID="1"  # Replace with the scan ID you want
SCAN_TYPE="ais:xcpScanData"  # Replace with the correct scan type you want
RESPONSE=$(curl -u $USERNAME:$PASSWORD -X PUT "$XNAT_URL/data/archive/projects/$PROJECT_ID/subjects/$SUBJECT_ID/experiments/$SESSION_ID/scans/$SCAN_ID?xsiType=$SCAN_TYPE" -H "Content-Type: application/json" -H "Content-Length: 0" -w "%{http_code}" -o /dev/null)

# Check if the scan creation was successful
if [ "$RESPONSE" -eq 200 ] || [ "$RESPONSE" -eq 201 ]; then
  echo "XCPScan created successfully."
else
  echo "Failed to create XCPScan. HTTP response code: $RESPONSE"
  exit 1
fi

# Upload the file
curl -u $USERNAME:$PASSWORD -X PUT "$XNAT_URL/data/projects/$PROJECT_ID/subjects/$SUBJECT_ID/experiments/$SESSION_ID/scans/$SCAN_ID/resources/TEST/files?extract=true" -F "file=@$FILENAME"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

No branches or pull requests

2 participants