Skip to content

Instantly share code, notes, and snippets.

@RyanZurrin
Created March 20, 2025 18:06
Show Gist options
  • Save RyanZurrin/e0e8a9b384945da00997436b0180940e to your computer and use it in GitHub Desktop.
Save RyanZurrin/e0e8a9b384945da00997436b0180940e to your computer and use it in GitHub Desktop.

Feed-Answer Unpacking and Processing Notes

1. Feed-Answer Unpacking

Identify the subjects you wish to unpack from DICOM to nifti format and create a case list text file of the subjects you wish to unpack. The case list text file should be formatted as follows:

sub-<subject_label>
sub-<subject_label>
sub-<subject_label>

The feed-answer dicom2nifti script is located in the scripts directory:

cd /data/pnlx/Collaborators/EDCRP/feed-answer/scripts

The feed-answer dicom2nifti script is called dicom2nifti.sh. The script requires the following arguments:

./dicom2nifti.sh <case_list> <dicom_dir>

where <case_list> is the path to the case list text file and <dicom_dir> is the path to the directory containing the DICOM files.

This unpacks the DICOM files for the subjects in the case list to the nifti format. The nifti files are saved in the nifti directory in the feed-answer directory.

2. BIDS Conversion

After unpacking the DICOM files to nifti format, the next step is to convert the nifti files to BIDS format. The feed-answer BIDS conversion script is located in the scripts directory:

cd /data/pnlx/Collaborators/EDCRP/feed-answer/scripts

The feed-answer BIDS conversion script is called nifti2bids.sh. The script requires the following arguments:

./nifti2bids.sh <src_dir> <bids_dir> <caselist>

where <src_dir> is the path to the directory containing the nifti files, <bids_dir> is the path to the directory where the BIDS formatted files will be saved, and <caselist> is the path to the case list text file.

Optional flages can be used as follows:

./nifti2bids.sh <src_dir> <bids_dir> <caselist> --dryrun --verbose

The --dryrun flag will print the operations that would be performed without actually executing them and the --verbose flag will print the operations as they are being performed.

This converts the nifti files for the subjects in the case list to BIDS format. The BIDS formatted files are saved in the bids directory specified in the <bids_dir> argument.

3. Axis alignment and mask creation

The feed-answer axis alignment and mask creation script is located in the scripts directory:

cd /data/pnlx/Collaborators/EDCRP/feed-answer/scripts

The feed-answer axis alignment and mask creation script is called dynamic_luigi.sh. The script requires you modify the following variables located at the top of the script:

# Job indices range
start_index=1
end_index=1

# Number of parallel jobs, do not exceed the number of GPUs
parallel_jobs=1

# Session and task
session=01
task=StructMask

# BIDS Data Directory
bids_data_dir=/data/pnlx/Collaborators/EDCRP/feed-answer/BIDS/rawdata

# Caselist
caselist=/data/pnlx/Collaborators/EDCRP/feed-answer/BIDS/caselists/caselist_latest_subs_partial.txt

# Set configuration file path
export LUIGI_CONFIG_PATH=/data/pnlx/Collaborators/EDCRP/feed-answer/BIDS/T1w_mask_params.cfg


# Template for DWI, T1w, and T2w images
dwi_template=""
t1_template="sub-*/ses-*/anat/*_T1w.nii.gz"
t2_template=""

# Output directories for logs
output_dir=/data/pnlx/Collaborators/EDCRP/feed-answer/BIDS/logs

Currently its set up to run the StructMask task which will also run axis alignment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment