Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
singlesp committed Dec 16, 2024
1 parent 1f9d246 commit 30a0076
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,8 @@ vignettes/*.pdf

# R Environment Variables
.Renviron

# log files
log/
/log/
**/log/
35 changes: 35 additions & 0 deletions curation/dcm2bids/dcm2bids_submit.sh
Original file line number Diff line number Diff line change
@@ -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
38 changes: 38 additions & 0 deletions curation/dcm2bids/dcm2bids_submit2.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 30a0076

Please sign in to comment.