---
# System prepended metadata

title: Running Pipelines

---

# Running Pipelines

## fMRIPrep

1. Update JSON files in BIDS folder
    - **code**: /scratch/jwong/intended_for/03-intended_for_tay.py

2. Run fMRIPrep pipeline
    - **code**: /scratch/jwong/prep_code/fmriprep/baseline/run_tay_fmriprep_ses01.sh
    - **sublist**: /scratch/jwong/prep_code/fmriprep/baseline/fmriprep_sub_ses01.txt
    - **JSON filter (baseline) file**: /scratch/jwong/prep_code/fmriprep/baseline/fmriprep_filter_ses01.json
    - **output**: /archive/data/TAY/pipelines/in_progress/jwong/fmriprep/baseline/

- sublist has 113 subjects (1 duplicate: 'sub-CMH00000345', ran twice due to duplicated files in bids folder)

## Ciftify

1. Create a new subject text file
    - **file**: /scratch/jwong/prep_code/fmriprep/baseline/fmriprep_sub_ses01_ciftify.txt
    - rename sub-CMH99999999 to CMH99999999

2. Run Ciftify (subject-level)
    - **code**: /scratch/jwong/prep_code/ciftify/run_ciftify.sh
    - **container**: /projects/smansour/cift-containers/cift_latest-2022-07-21-ee4ca7d3eadd.simg (allow skip-bids-validation)
    - - **output**: /archive/data/TAY/pipelines/in_progress/jwong/fmriprep/baseline/**output**

2. Run Ciftify (group-level)
    - **code**: /scratch/jwong/prep_code/ciftify/run_group_ciftify.sh
    - **output**: /archive/data/TAY/pipelines/in_progress/jwong/fmriprep/baseline/**output**


## ASLPrep

1. Rsync
    - shopt -s globstar
    - rsync -acR /archive/data/TAY/pipelines/in_progress/jwong/fmriprep/baseline/output/fmriprep/**/anat/ /scratch/jwong/fmriprep_dl_v2/
    - run "rename" script to remove intermediate folder
    - (optional) move the anat data to "fmriprep_dl_v2" if rsync to other folder

2. Add aslcontext.tsv file
    - add tsv file to "perf" folder of each participant

3. Run ASLPrep pipeline
    - **code**: /scratch/jwong/prep_code/aslprep/baseline/run_tay_aslprep_ses01.sh
    - **sublist**: /scratch/jwong/prep_code/aslprep/baseline/aslprep_sub_ses01.txt
    - **JSON filter (baseline) file**: /scratch/jwong/prep_code/aslprep/baseline/aslprep_filter_ses01.json
    - **output**: /archive/data/TAY/pipelines/in_progress/jwong/aslprep/baseline/

4. Extract QC and CBF values to a csv file
    - **code**: /external/mgmt3/imaging/home/kimel/jwong/r-scripts/mri/aslprep_cbf_analysis_all.R
    - concantenate output of all runs

5. Run Analysis 
    - **code**: /external/mgmt3/imaging/home/kimel/jwong/r-scripts/mri/aslprep_cbf_analysis.Rmd
    - analysis conducted in summer 2022 for SURP poster


## QSIPrep

1. Run QSIPrep pipeline
    - **code**: /scratch/jwong/prep_code/qsiprep/baseline/run_tay_qsiprep_ses01.sh
    - **sublist**: /scratch/jwong/prep_code/qsiprep/baseline/qsiprep_sub_ses01.txt
    - **JSON filter (baseline) file**: /scratch/jwong/prep_code/qsiprep/baseline/qsiprep_filter_ses01.json
    - **output**: /archive/data/TAY/pipelines/in_progress/jwong/qsiprep/baseline/
    - --freesurfer-input -/archive/data/TAY/pipelines/in_progress/jwong/fmriprep/baseline/output/freesurfer 
        - take direct output from fMRIPrep without changes

2. Run motion metrics script to a csv file
    - **code**: /external/mgmt3/imaging/home/kimel/jwong/r-scripts/mri/03-gen_qsiprep_motion_metrics_all.R
    - concantenate output of all runs


## MRIQC

1. Run MRIQC pipeline
    - **code**: 
        - **participant-level**: /scratch/jwong/prep_code/mriqc/run_mriqc.sh
        - **group-level**: /scratch/jwong/prep_code/mriqc/run_mriqc_group.sh
    - **sublist**: /scratch/jwong/prep_code/mriqc/mriqc_sub_anat.txt
    - **output**: /archive/data/TAY/pipelines/in_progress/jwong/mriqc_v2

 - 275 subs outputted 
    - should be 286 (11 missing)
    - missing subs: ['sub-CMH00000013', 'sub-CMH00000036', 'sub-CMH00000202', 'sub-CMH00000223', 'sub-CMH00000224', 'sub-CMH00000277', 'sub-CMH00000315', 'sub-CMH00000341', 'sub-CMH00000359', 'sub-CMH00000415', 'sub-CMH00000435']
    - rerun: /scratch/jwong/prep_code/mriqc/mriqc_sub_anat_missed.txt
    - only fixed 5 subs ['sub-CMH00000202', 'sub-CMH00000224', 'sub-CMH00000315', 'sub-CMH00000415', 'sub-CMH00000435']
    - another rerun on missed subs, fixed 3 subs ['sub-CMH00000223', 'sub-CMH00000277', 'sub-CMH00000359']
    - still missing 3 subs: ['sub-CMH00000013', 'sub-CMH00000036', 'sub-CMH00000341'] 