Code base for XNAT applications
Instructions are based on Ubuntu 20.04.5 LTS
Remember to change every field with <> below according to your own situation.
- Docker engine (installation for ubuntu or official installation documentation here)
- All dicoms are organized inside sub-## folders (e.g., sub-01, sub-02...) in the project folder.
- Virtual environment recommended.
https://github.com/srikash/TheBeesKnees/wiki/Converting-DICOMs-to-BIDS-NIfTIs
Note: qtcreator
may be required for opening the GUI on ubuntu.
https://heudiconv.readthedocs.io/en/latest/
- Latest official heudiconv: run
docker pull nipy/heudiconv:latest
in terminal. - Our modified version (XNAT ready): run
docker pull yuexinxi/heudiconv:latest
in terminal.
Method1 for a single subject:
- Get a converter file.
- Use one of the following command.
If you use the official version:
docker run --rm -it -v <base_dir>:/base nipy/heudiconv:latest --files /base/<dicoms_dir>/ -o /base/<bids_dir>/ -f /base/<heuristic_file> -s <subject_index> -c dcm2niix -b --overwrite --minmeta
If you use our version:
docker run --rm -it -v <base_dir>:/base yuexinxi/heudiconv:latest --files /base/<dicoms_dir>/ -o /base/<bids_dir>/ -f /base/<heuristic_file> -s <subject_index> -c dcm2niix -b --overwrite --minmeta
Note: If you need to run heudiconv on the same data again, remove the existing output folder first.
Note: To use a converter file already in the container heuristics folder, just use the name (e.g. -f heuristic_sequence
)
Method2 for a single subject using our heudiconv and converter file: (easier to use but less freedom)
- Get the heudiconv_test.sh from this repository.
- Put heudiconv_test.sh in a base directory (base_dir). This base directory should be the parent directory of your project's dicom directory.
- When you are in the base directory, use
chmod u+x heudiconv_test.sh
to make the script executable. Then you can run heudiconv_test.sh with two arguments: the name of the dicom directory and the subject index (e.g.,./heudiconv_test.sh Yuexin_project 01
). The output will be have "BIDS" as suffix (e.g., ./Yuexin_project_BIDS).
- heuristic_protocol.py: classification based on series description. (no longer updated)
- heuristic_sequence.py: classification based on sequence name. Users need to modify the output BOLD file name on their own by replacing "taskName" with the actual task.
- heuristic_sequence_bold.py: classification based on sequence name. Users will be prompted to input the task name if fMRI data are present and the task will be in the output BOLD file name.
https://mriqc.readthedocs.io/en/latest/
- Data have to be in BIDS. You can validate your data with the validator. Some valid key labels may not be accepted by the validator but will not affect the overall performance of MRIQC.
- To see whether mriqc works properly, use
docker run -it nipreps/mriqc:latest --version
to check the version. - For a single subject:
docker run -it --rm -v <bids_dir>:/data:ro -v <output_dir>:/out nipreps/mriqc:latest /data /out participant --participant_label <subject_folder_name>
https://fmriprep.org/en/stable/
- Data have to be in BIDS. You can validate your data with the validator. Normally, no error or warning should be present for fMRIPrep to run properly (otherwise use
--skip_bids_validation
). - Run
docker pull nipreps/fmriprep:latest
to get the latest docker image ordocker pull nipreps/fmriprep:<version>
- Obtain Freesurfer software and its license.txt.
docker run -it --rm -v <bids_dir>:/data:ro -v <output_dir>:/out -v <freesurfer_license_path>:/opt/freesurfer/license.txt nipreps/fmriprep:latest /data /out participant --fs-no-reconall --md-only-boilerplate --output-spaces T1w
Note:
--fs-no-reconall
= skip surface reconstruction
--md-only-boilerplate
= skip generation of citation with pandoc
--output-spaces T1w
= register images to anatomical space (default is normalization to MNI space)
- This script takes the following arguments: 1st echo magnitude image, 2nd echo magnitude image, 1st echo phase image, 2nd echo phase image and delta TE (optional) to generate the fieldmap and json file in BIDS specification.
- Dependencies: Synthstrip, FSL, jq
- Example:
bto_dualecho_fieldmap.sh --mag1=sub-01_ses-01_acq-GRE_run-1_echo-1_part-mag_T2starw.nii.gz --mag2=sub-01_ses-01_acq-GRE_run-1_echo-2_part-mag_T2starw.nii.gz --phs1=sub-01_ses-01_acq-GRE_run-1_echo-1_part-phase_T2starw.nii.gz --phs2=sub-01_ses-01_acq-GRE_run-1_echo-2_part-phase_T2starw.nii.gz --dte=2.46
- This script takes the following arguments: 1st echo magnitude image, 2nd echo magnitude image, phasediff image and delta TE (optional) to generate the fieldmap and json file in BIDS specification.
- Dependencies: Synthstrip, FSL, jq
- Example:
phasediff_fieldmap.sh --mag1=sub-01_ses-01_acq-GRE_run-1_echo-1_magnitude1.nii.gz --mag2=sub-01_ses-01_acq-GRE_run-1_echo-2_magnitude2.nii.gz --phs=sub-01_ses-01_acq-GRE_run-1_echo-1_phasediff.nii.gz --dte=2.46
- This script takes the following arguments: functional image, reference anatomical image, white matter sementation and fieldmap (optional) to perform registration of functional image to anatomical image based on boundary based registration. This is the same method as what fMRIPrep uses (by 23.0.2).
- Dependencies: nipype
- Example:
python run_fsl_flirt.py sub-01_ses-01_task-rest_run-01_bold.nii.gz sub-01_acq-MPRAGE_run-01_T1w.nii.gz sub-01_acq-MPRAGE_run-03_label-WM_probseg.nii.gz nofieldmap
- This script takes the following arguments: two functional images of opposite phase encoding direction (with their metadata json files. Make sure the "AcquisitionMatrixPE" and "EffectiveEchoSpacing" fields are available) and the unwarp direction to perform distortion correction of functional image with topup method. The results will either be in the current directory or in a new directory ./output/contrasts/ depending on the method chosen.
- Dependencies: nipype or FSL
- Example:
python run_fsl_topup.py sub-01_ses-01_task-rest_dir-AP_bold.nii.gz sub-01_ses-01_task-rest_dir-PA_bold.nii.gz y-