From 30a0076531f33e1be96572dc318dc7b7da45d33e Mon Sep 17 00:00:00 2001 From: singlesp Date: Mon, 16 Dec 2024 15:13:21 -0500 Subject: [PATCH] first commit --- .gitignore | 5 ++++ curation/dcm2bids/dcm2bids_submit.sh | 35 ++++++++++++++++++++++++ curation/dcm2bids/dcm2bids_submit2.sh | 38 +++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 curation/dcm2bids/dcm2bids_submit.sh create mode 100644 curation/dcm2bids/dcm2bids_submit2.sh diff --git a/.gitignore b/.gitignore index 55044b9..8d3f918 100644 --- a/.gitignore +++ b/.gitignore @@ -203,3 +203,8 @@ vignettes/*.pdf # R Environment Variables .Renviron + +# log files +log/ +/log/ +**/log/ diff --git a/curation/dcm2bids/dcm2bids_submit.sh b/curation/dcm2bids/dcm2bids_submit.sh new file mode 100644 index 0000000..b62ef1c --- /dev/null +++ b/curation/dcm2bids/dcm2bids_submit.sh @@ -0,0 +1,35 @@ +#!/bin/bash +#SBATCH --job-name=dcm2bids_conversion # Job name +#SBATCH --array=0-230 +#SBATCH --time=24:00:00 # Maximum runtime +#SBATCH --cpus-per-task=4 # Number of CPUs per task +#SBATCH --mem=8G # Memory per job +#SBATCH --output=/cbica/projects/grmpy/data/bids/code/dcm2bids/logs/dcm2bids_%A_%a.out # Output log +#SBATCH --error=/cbica/projects/grmpy/data/bids/code/dcm2bids/logs/dcm2bids_%A_%a.err # Error log + +# Define paths +bids="/cbica/projects/grmpy/data/bids" + +# Step 1: Get all subject IDs +subjects=($(ls -d ${bids}/sourcedata/GRMPY_822831/SUBJECTS/* | xargs -n 1 basename)) + +# Step 2: Select the current subject based on the SLURM array task ID +subID=${subjects[${SLURM_ARRAY_TASK_ID}]} + +# Step 3: Find all DICOM directories for all sessions of the current subject +session_dirs=$(find ${bids}/sourcedata/GRMPY_822831/SUBJECTS/${subID}/SESSIONS/*/ACQUISITIONS -maxdepth 0 -type d) + +# Step 4: Process each session +session_num=1 # Initialize session counter +for session_dir in "${session_dirs[@]}"; do + + ~/miniforge3/envs/dcmconv/bin/dcm2bids -p ${subID} \ + -s ${session_num} \ + -c ${bids}/code/dcm2bids/config.json \ + -o ${bids} \ + -d ${session_dir} \ + --force_dcm2bids + + ((session_num++)) + +done diff --git a/curation/dcm2bids/dcm2bids_submit2.sh b/curation/dcm2bids/dcm2bids_submit2.sh new file mode 100644 index 0000000..779c1b7 --- /dev/null +++ b/curation/dcm2bids/dcm2bids_submit2.sh @@ -0,0 +1,38 @@ +#!/bin/bash +#SBATCH --job-name=dcm2bids_conversion # Job name +#SBATCH --array=0-1 +#SBATCH --time=24:00:00 # Maximum runtime +#SBATCH --cpus-per-task=4 # Number of CPUs per task +#SBATCH --mem=8G # Memory per job +#SBATCH --output=/cbica/projects/grmpy/data/bids/code/dcm2bids/logs/dcm2bids_%A_%a.out # Output log +#SBATCH --error=/cbica/projects/grmpy/data/bids/code/dcm2bids/logs/dcm2bids_%A_%a.err # Error log + +# Define paths +bids="/cbica/projects/grmpy/data/bids" + +# Step 1: Get all subject IDs +# subjects=($(ls -d ${bids}/sourcedata/GRMPY_822831/SUBJECTS/* | xargs -n 1 basename)) +subjects=("95257" "20120") # For debugging + +# Step 2: Select the current subject based on the SLURM array task ID +subID=${subjects[${SLURM_ARRAY_TASK_ID}]} + +# Step 3: Find all DICOM directories for all sessions of the current subject +mapfile -t session_dirs < <(find ${bids}/sourcedata/GRMPY_822831/SUBJECTS/${subID}/SESSIONS/*/ACQUISITIONS -maxdepth 0 -type d) + +# Step 4: Process each session +session_num=1 # Initialize session counter +for session_dir in "${session_dirs[@]}"; do + + echo "Processing session ${session_num} for subject ${subID} in directory ${session_dir}" # For debugging + + ~/miniforge3/envs/dcmconv/bin/dcm2bids -p ${subID} \ + -s ${session_num} \ + -c ${bids}/code/dcm2bids/config.json \ + -o ${bids} \ + -d ${session_dir} \ + --force_dcm2bids + + ((session_num++)) + +done