Snakemake workflow: smk-melas

public public 1yr ago 0 bookmarks

Snakemake workflow for processing functional cerebellar data as described in "Neurodegenerative and functional signatures of the cerebellar cortex in m.3243A > G patients" (https://doi.org/10.1093/braincomms/fcac024)

Inputs:

  • participants.tsv with target subject IDs

  • For each target subject:

    • Freesurfer processed data

    • Functional data

Singularity containers required:

  • fMRIprep (for FreeSurfer, ADNI and FSL tools)

  • Connectome workbench

Authors

  • Roy AM Haast @royhaast

Usage

If you use this workflow in a paper, don't forget to give credits to the authors by citing the URL of this (original) repository and, if available, its DOI (see above).

Step 1: Obtain a copy of this workflow

  1. Create a new github repository using this workflow as a template .

  2. Clone the newly created repository to your local system, into the place where you want to perform the data analysis.

Step 2: Configure workflow

Configure the workflow according to your needs via editing the files in the config/ folder. Adjust config.yml to configure the workflow execution, and participants.tsv to specify your subjects.

Step 3: Install Snakemake

Install Snakemake using conda :

conda create -c bioconda -c conda-forge -n snakemake snakemake

For installation details, see the instructions in the Snakemake documentation .

Step 4: Execute workflow

Activate the conda environment:

conda activate snakemake

Test your configuration by performing a dry-run via

snakemake --use-singularity -n

Execute the workflow locally via

snakemake --use-singularity --cores $N

using $N cores or run it in a cluster environment via

snakemake --use-singularity --cluster qsub --jobs 100

or

snakemake --use-singularity --drmaa --jobs 100

If you are using Compute Canada, you can use the cc-slurm profile, which submits jobs and takes care of requesting the correct resources per job (including GPUs). Once it is set-up with cookiecutter, run:

snakemake --profile cc-slurm

Or, with neuroglia-helpers can get a 8-core, 32gb node and run locally there. First, get a node (default 8-core, 32gb, 3 hour limit):

regularInteractive 

Then, run:

snakemake --use-singularity --cores 8 --resources mem=32000

See the Snakemake documentation for further details.

Step 5: Investigate results

After successful execution, you can create a self-contained interactive HTML report with all results via:

snakemake --report report.html

This report can, e.g., be forwarded to your collaborators. An example (using some trivial test data) can be seen here .

Step 6: Commit changes

Whenever you change something, don't forget to commit the changes back to your github copy of the repository:

git commit -a
git push

Step 7: Obtain updates from upstream

Whenever you want to synchronize your workflow copy with new developments from upstream, do the following.

  1. Once, register the upstream repository in your local copy: git remote add -f upstream git@github.com:snakemake-workflows/{{cookiecutter.repo_name}}.git or git remote add -f upstream https://github.com/snakemake-workflows/{{cookiecutter.repo_name}}.git if you do not have setup ssh keys.

  2. Update the upstream version: git fetch upstream .

  3. Create a diff with the current version: git diff HEAD upstream/master workflow > upstream-changes.diff .

  4. Investigate the changes: vim upstream-changes.diff .

  5. Apply the modified diff via: git apply upstream-changes.diff .

  6. Carefully check whether you need to update the config files: git diff HEAD upstream/master config . If so, do it manually, and only where necessary, since you would otherwise likely overwrite your settings and samples.

Step 8: Contribute back

In case you have also changed or added steps, please consider contributing them back to the original repository:

  1. Fork the original repo to a personal or lab account.

  2. Clone the fork to your local system, to a different place than where you ran your analysis.

  3. Copy the modified files from your analysis to the clone of your fork, e.g., cp -r workflow path/to/fork . Make sure to not accidentally copy config file contents or sample sheets. Instead, manually update the example config files if necessary.

  4. Commit and push your changes to your fork.

  5. Create a pull request against the original repository.

Testing

TODO: create some test datasets

Code Snippets

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import numpy as np
import pandas as pd
import nibabel as nib
from nibabel.nifti1 import Nifti1Image
from nilearn.input_data import NiftiLabelsMasker

epi = nib.load(snakemake.input.vol)
csf = nib.load(snakemake.input.csf)
wm = nib.load(snakemake.input.wm)

img = Nifti1Image(csf.get_fdata(),epi.affine,csf.header)
masker = NiftiLabelsMasker(labels_img=img, standardize=False)
time_series1 = masker.fit_transform(epi)

img = Nifti1Image(wm.get_fdata(),epi.affine,wm.header)
masker = NiftiLabelsMasker(labels_img=img, standardize=False)
time_series2 = masker.fit_transform(epi)

# Concatenate timeseries
df1 = pd.DataFrame({'CSF': time_series1[:,0],'WhiteMatter': time_series2[:,0]})

# Load movement parameters (and their derivatives)
names = ['X','Y','Z','RotX','RotY','RotZ']
df2 = pd.read_csv(snakemake.input.movreg, names=names, header=None, delim_whitespace=True)

# Put everything together (excluding derivatives) and write to .tsv file for 'ciftify_clean_img' 
df_concat = pd.concat([df2, df1], axis=1)
df_concat.to_csv(snakemake.output[0],sep='\t')
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
epi=$1
mni=$2

# Relevant transformations
gdc_warp=$3
mc_dir=$4
topup_dir=$5
bbr_mat=$6
fnirt_warp=$7

# Output paths
warped_mni=$8
out_dir=`dirname $warped_mni`

# Generate second warp: gradient distortion corrected to MNI
fslmaths $topup_dir/epi_fout.nii.gz -mul 0.0343097 $topup_dir/epi_fout_scaled.nii.gz
secondwarp=$out_dir/gdc_to_mni.nii.gz
convertwarp -s $topup_dir/epi_fout_scaled.nii.gz -d y- --premat=$bbr_mat --warp1=$fnirt_warp --ref=$mni --out=$secondwarp --relout --rel -v

# Generate seperate warp up to topup correction
intermediatewarp=$out_dir/gdc_to_topup.nii.gz
convertwarp -s $topup_dir/epi_fout_scaled.nii.gz -d y- --ref=${epi}_0000.nii.gz --out=$intermediatewarp --relout --rel -v

for file in $mc_dir/* ; do
    vol=`echo $file | rev | cut -d'_' -f1  | rev`
    epi_vol=${epi}_${vol}

    # Generate first warp: slicetiming corrected to gradient distortion corrected
    firstwarp=$out_dir/firstwarps/st_${vol}_to_gdc.nii.gz

    if [ ! -d $out_dir/firstwarps ] ; then mkdir -p $out_dir/firstwarps ; fi
    convertwarp --warp1=$gdc_warp --midmat=$file --ref=$epi_vol --out=$firstwarp --abs --relout -v

    # Combine with second warp: slicetiming corrected to MNI
    combinedwarp=$out_dir/combinedwarps/st_${vol}_to_MNI.nii.gz

    if [ ! -d $out_dir/combinedwarps ] ; then mkdir -p $out_dir/combinedwarps ; fi
    convertwarp --warp1=$firstwarp --warp2=$secondwarp --out=$combinedwarp --ref=$mni --rel --relout -v

    # Combine with intermediate warp: slicetiming corrected to topup correction
    topupwarp=$out_dir/topupwarps/st_${vol}_to_topup.nii.gz

    if [ ! -d $out_dir/topupwarps ] ; then mkdir -p $out_dir/topupwarps ; fi
    convertwarp --warp1=$firstwarp --warp2=$intermediatewarp --out=$topupwarp --ref=$epi_vol --rel --relout -v

    # Apply warps to MNI
    if [ ! -d $out_dir/warped_mni ] ; then mkdir -p $out_dir/warped_mni ; fi
    applywarp -i $epi_vol -r $mni -o $out_dir/warped_mni/epi_rest_${vol}_mni.nii.gz -w $combinedwarp --rel --interp=spline -v

    # Apply warps to topup correction
    if [ ! -d $out_dir/warped_topup ] ; then mkdir -p $out_dir/warped_topup ; fi    
    applywarp -i $epi_vol -r $epi_vol -o $out_dir/warped_topup/epi_rest_${vol}_topup.nii.gz -w $topupwarp --rel --interp=spline -v
done

# Merge warped output into 4D volume
fslmerge -tr $warped_mni `ls $out_dir/warped_mni/epi_rest_*_mni.nii.gz` 2.0
fslmerge -tr $out_dir/epi_rest_topup.nii.gz `ls $out_dir/warped_topup/epi_rest_*topup.nii.gz` 2.0
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
import numpy as np
import pandas as pd
import nibabel as nib
from nibabel.nifti1 import Nifti1Image

t1 = nib.load(snakemake.input.t1)
t1_vals = t1.get_fdata()

lh_cerebellum = nib.load(snakemake.input.lh_cerebellum).get_fdata()
rh_cerebellum = nib.load(snakemake.input.rh_cerebellum).get_fdata()

combined = np.zeros((t1.shape))
combined[(lh_cerebellum>0) & (t1_vals<2000)] = 8
combined[(rh_cerebellum>0) & (t1_vals<2000)] = 47

img = Nifti1Image(combined,t1.affine,t1.header)
nib.save(img,snakemake.output[0])
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
script=$1
script_dir=`readlink -f $script`
script_dir=$(dirname "${script_dir}")
script=`basename $script .m`

in=$2
in=`realpath $in`

out=$3
out_dir=`realpath $out`

module load matlab

pushd $script_dir
    matlab -nosplash -nodisplay -nodesktop -r "${script}('${in}','${out_dir}'); quit"
popd
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
script=$1
script_dir=`readlink -f $script`
script_dir=$(dirname "${script_dir}")
script=`basename $script .m`

in_file=`realpath $2`
out_file=`realpath $3`
method=$4

module load matlab

pushd $script_dir
    matlab -nosplash -nodisplay -nodesktop -r "${script}('${in_file}','${out_file}','${method}'); quit"
popd
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
script=$1
script_dir=`readlink -f $script`
script_dir=$(dirname "${script_dir}")
script=`basename $script .m`

gm=$2
gm=`realpath $gm`

wm=$3
wm=`realpath $wm`

mask=$4
mask=`realpath $mask`

out=$5
out_dir=`realpath $out`

module load matlab

pushd $script_dir
    echo matlab -nosplash -nodisplay -nodesktop -r "${script}('${gm}','${wm}','${mask}','${out_dir}'); quit"
    matlab -nosplash -nodisplay -nodesktop -r "${script}('${gm}','${wm}','${mask}','${out_dir}'); quit"
popd
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
script=$1
script_dir=`readlink -f $script`
script_dir=$(dirname "${script_dir}")
script=`basename $script .m`

affine=`realpath $2`
flowfield=`realpath $3`
ref=`realpath $4`

in_file=`realpath $5`
in_filename=`basename $in_file .nii`

out_file=`realpath $6`
out_dir=`realpath $7`
mkdir -p $out_dir

#cp $in_file $out_dir/${in_filename}.nii

module load matlab

pushd $script_dir
    matlab -nosplash -nodisplay -nodesktop -r "${script}('${affine}','${flowfield}','${ref}','${in_file}'); quit"
popd

affine_dir=$(dirname "${affine}")
mv $affine_dir/iw*$in_filename*.nii $out_file
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
script=$1
script_dir=`readlink -f $script`
script_dir=$(dirname "${script_dir}")
script=`basename $script .m`

affine=`realpath $2`
flowfield=`realpath $3`
wm=`realpath $4`
gm=`realpath $5`
r1=`realpath $6`
mask=`realpath $7`
out_dir=`realpath $8`

r1map=$out_dir/r1_map_$9.nii

if (file $r1 | grep -q compressed ) ; then
    gunzip -k -c $t1 > $t1map
fi

module load matlab

pushd $script_dir
    matlab -nosplash -nodisplay -nodesktop -r "${script}('${affine}','${flowfield}','${wm}','${mask}','${out_dir}'); quit"
    matlab -nosplash -nodisplay -nodesktop -r "${script}('${affine}','${flowfield}','${gm}','${mask}','${out_dir}'); quit"
    matlab -nosplash -nodisplay -nodesktop -r "${script}('${affine}','${flowfield}','${r1}','${mask}','${out_dir}'); quit"
    matlab -nosplash -nodisplay -nodesktop -r "${script}_atlas('${affine}','${flowfield}','${gm}'); quit"
popd
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
script=$1
script_dir=`readlink -f $script`
script_dir=$(dirname "${script_dir}")
script=`basename $script .m`

in_file=`realpath $2`
fwhm=$3
out_dir=`realpath $4`

module load matlab

pushd $script_dir
    matlab -nosplash -nodisplay -nodesktop -r "${script}('${in_file}','${fwhm}','${out_dir}'); quit"
popd
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
script=$1
script_dir=`readlink -f $script`
script_dir=$(dirname "${script_dir}")
script=`basename $script .m`

input=`realpath $2`
output=`realpath $3`

module load matlab

pushd $script_dir
    matlab -nosplash -nodisplay -nodesktop -r "${script}('${input}','${output}'); quit"
popd
21
22
23
24
shell:
    "{params.fs_setup} mri_convert {input.parc} {output.parc_anat} && "
    "applywarp -i {output.parc_anat} -r {params.mni} -w {input.warp} -o {output.parc_mni} -d int --interp=nn  && "
    "flirt -in {output.parc_anat} -ref {input.epi} -applyxfm -init {input.inverse_mat} -datatype int -interp nearestneighbour -out {output.parc_epi}"
33
34
script:
    "../../scripts/prepare_cerebellum.py"
53
54
55
shell:
    "applywarp -i {input.cerebellum} -r {params.mni} -w {input.warp} -o {output.cerebellum_mni} -d int --interp=nn  && "
    "flirt -in {input.cerebellum} -ref {input.epi} -applyxfm -init {input.inverse_mat} -datatype int -interp nearestneighbour -out {output.cerebellum_epi}"
74
75
shell:
    "{params.fs_setup} mri_binarize --i {input.parc} --match 2 41 --erode 2 --o {output.wm} && "
91
92
shell:
    "wb_command -volume-label-import {input.rois} {input.labels} {output} -discard-others"
102
103
shell:
    "wb_command -cifti-create-label {output} -volume {input.rois} {input.rois} -left-label {input.lh_mmp} -right-label {input.rh_mmp}"
SnakeMake From line 102 of rules/cifti.smk
117
118
shell:
    "wb_command -cifti-create-dense-timeseries {output} -volume {input.vol} {input.rois} -left-metric {input.lh} -right-metric {input.rh} -timestep 2.0"
SnakeMake From line 117 of rules/cifti.smk
132
133
shell:
    "wb_command -cifti-create-dense-timeseries {output} -volume {input.vol} {input.rois} -left-metric {input.lh} -right-metric {input.rh} -timestep 2.0"
SnakeMake From line 132 of rules/cifti.smk
147
148
script:
    "../../scripts/extract_confounds.py"
SnakeMake From line 147 of rules/cifti.smk
166
167
168
shell:
    "ciftify_clean_img --verbose --output-file={output} --confounds-tsv={input.confounds} "
    "--smooth-fwhm=3 --left-surface {input.lh_surf} --right-surface {input.rh_surf} {params} {input.dtseries} &> {log}"
SnakeMake From line 166 of rules/cifti.smk
182
183
shell:
    'ciftify_clean_img --verbose --output-file={output} --confounds-tsv={input.confounds} {params} {input.dtseries} &> {log}'
SnakeMake From line 182 of rules/cifti.smk
195
196
shell:
    "wb_command -cifti-parcellate {input.dtseries} {input.dlabels} COLUMN {output}"
SnakeMake From line 195 of rules/cifti.smk
206
207
shell:
    "wb_command -cifti-correlation {input} {output}"
SnakeMake From line 206 of rules/cifti.smk
25
26
27
run:
    for in_file, out_file in zip(input, output):
        shell("mri_convert {in_file} {out_file} -nc")
SnakeMake From line 25 of rules/conn.smk
58
59
shell: 
    "wb_command -volume-to-surface-mapping {input.epi} {input.surf} {output} -trilinear"
SnakeMake From line 58 of rules/conn.smk
74
75
shell:
    "wb_command -cifti-create-dense-timeseries {output} -volume {input.vol} {input.rois} -left-metric {input.lh} -right-metric {input.rh} -timestep 2.0"
SnakeMake From line 74 of rules/conn.smk
91
92
shell:
    "wb_command -cifti-smoothing {input.dtseries} {params.surface_kernel} {params.volume_kernel} COLUMN {output} -left-surface {input.lh} -right-surface {input.rh} -fix-zeros-volume -fix-zeros-surface"
SnakeMake From line 91 of rules/conn.smk
104
105
shell:
    "bash scripts/wishart_filter.sh {params.script} {input} {output}" 
SnakeMake From line 104 of rules/conn.smk
21
22
23
shell:
    "{params.fs_setup} bbregister --s {wildcards.subject} --mov {input.epi} --reg {output.reg} --o {output.vol} {params.optional} && "
    "tkregister2 --noedit --reg {output.reg} --mov {input.epi} --targ {input.t1w} --fslregout {output.mat} &> {log}"      
38
39
40
shell:
    "convert_xfm -omat {output.inverse_mat} -inverse {input.mat} && "
    "flirt -interp spline -in {input.t1w} -ref {input.epi} -applyxfm -init {output.inverse_mat} -out {output.t1w_coreg}"
55
56
shell:
    "{params.fs_setup} mri_vol2vol --mov {input.epi} --targ {input.targ} --o {output} --reg {input.bbr} --no-resample"
74
75
shell:
    "flirt {params.optional} -in {input} -ref {params.MNI} -omat {output} -out {params.prefix} &> {log}"
 98
 99
100
shell:
    "fnirt --in={input.t1w} --ref={params.MNI} --aff={input.affine} --fout={output.fout} --jout={output.jout} "
    "--refout={output.refout} --iout={output.iout} --logout={output.logout} --intout={output.intout} --cout={output.cout} -v &> {log}"
113
114
shell:
    "invwarp -w {input.warp} -o {output} -r {input.t1w} --noconstraint"
136
137
138
shell:
    "bash scripts/onestepresampling.sh {params.epi} {params.mni} {input.gdc} {params.mat} "
    "{input.topup} {input.bbr} {input.fnirt} {output.warped_mni} &> {log}"
154
155
156
shell:
    "python /opt/ICA-AROMA/ICA_AROMA.py -o `dirname {output.den}` -i {input.vol} -mc {input.mc} "
    "-a {input.bbr} -w {input.fnirt} -m {input.mask} -tr 2 -den nonaggr -overwrite"
168
169
shell:
    "applywarp -i {input.vol} -r {input.mni} -o {output} -w {input.warp} --rel --interp=spline -v"
 9
10
11
12
13
run:
    for g, group in enumerate(['controls','patients']):
        cmd = "export FSLOUTPUTTYPE=NIFTI && fslmerge -t {} `ls output/suit/{}/*{}*.nii | tr '\n' ' '`".format(
            output[g], group, wildcards.modality)
        shell(cmd)
25
26
shell:
    "export FSLOUTPUTTYPE=NIFTI && fslmerge -t {output.concatenated} {input.controls} {input.patients}"           
SnakeMake From line 25 of rules/palm.smk
41
42
43
shell:
    "module load matlab && "
    "palm -i {input[0]} -i {input[2]} -d {params.design} -t {params.contrasts} -m {params.gm} {params.palm} -o `dirname {output}`/multivariate &> {log}"  
SnakeMake From line 41 of rules/palm.smk
58
59
60
shell:
    "module load matlab && "
    "palm -i {input[1]} -i {input[2]} -d {params.design} -t {params.contrasts} -m {params.wm} {params.palm} -o `dirname {output}`/multivariate &> {log}"
SnakeMake From line 58 of rules/palm.smk
68
69
70
71
72
73
74
75
76
77
78
79
80
81
run:
    import numpy as np
    import nibabel as nib

    palm = nib.load(input[0])
    data = palm.get_data()

    clustermap = np.zeros(data.shape)
    for label, pval in enumerate(np.unique(data)):
        if pval <= params.pvalue:
            clustermap[data==pval] = label

    img = nib.Nifti1Image(clustermap, header=palm.header, affine=palm.affine)
    nib.save(img, output[0])
101
102
103
run:
    for (in_file, out_file, method) in zip(input, output, params.method):
        shell("bash scripts/run_map2surf.sh {params.script} {in_file} {out_file} {method}")
SnakeMake From line 101 of rules/palm.smk
120
121
122
run:
    for in_file, out_file in zip(input.clustermap, output):
        shell("bash scripts/run_reslice_results.sh {params.script} {input.affine} {input.flowfield} {input.ref} {in_file} {out_file} {params.out_dir} {wildcards.subject}")
SnakeMake From line 120 of rules/palm.smk
135
136
shell:
    "flirt -interp spline -in {input.clustermap} -ref {input.epi} -applyxfm -init {input.inverse_mat} -out {output}"    
SnakeMake From line 135 of rules/palm.smk
150
151
shell:
    "applywarp -i {input.clustermap} -r {params.mni} -o {output} -w {input.warp} --rel --interp=nn -v"
SnakeMake From line 150 of rules/palm.smk
163
164
shell:
    "wb_command -cifti-create-dense-scalar {output} -volume {input.vol} {input.rois}"           
SnakeMake From line 163 of rules/palm.smk
15
16
17
18
shell:
    "TR=`fslval {input[0]} pixdim4` && "
    "3dTshift -prefix {output.corrected} -tpattern @{params.slicetiming} -TR $TR -tzero 0.0 {input} && "
    "fslsplit {output.corrected} `echo {output.splitted} | rev | cut -d'_' -f2-  | rev`_ -t &> {log}"
35
36
37
shell:
    "fslroi {input} {output.firstvol} 0 1 && "
    "procGradCorrect -i {output.firstvol} -g {params.coeff} -w {output.warp} -s {params.scratch} &> {log}"
53
54
55
56
57
58
59
shell:
    "applywarp -i {input.epi} -o {output.unwarped} -r {input.epi} -w {input.warp} --abs --interp=spline && "
    "fslroi {output.unwarped} {output.jacobian} 0 1 && "
    "reg_jacobian -ref {output.jacobian} -def {input.warp} -jac {output.jacobian} && "
    "fslmaths {output.jacobian} -mul -1 -abs {output.jacobian} && "
    "fslmaths {output.unwarped} -mul {output.jacobian} {output.corrected} && "
    "fslcpgeom {input.epi} {output.corrected}"
72
73
74
shell:
    "fslroi {input[0]} {output.first_vols} 0 5 && "
    "fslmerge -tr {output.concat_out} {output.first_vols} {input[1]} 2"
89
90
91
92
shell:
    "mkdir -p {output} && "
    "topup --imain={input} --datain={params.acquisition} --config={params.topup} "
    "--out={output}/epi --fout={output}/epi_fout --iout={output}/epi_iout -v &> {log}"
108
109
shell:
    "mcflirt -in {input} -out {output.vol} {params.optional} &> {log}"
128
129
130
131
shell:
    "fslroi {input.epi} {output.firstvol} 0 1 && "
    "applytopup --imain={output.firstvol} --inindex=1 --datain={params.acquisition} --topup={input.topup}/epi --out={output.firstvol_gdc} --method=jac -v &> {log} && "
    "applytopup --imain={input.epi} --inindex=1 --datain={params.acquisition} --topup={input.topup}/epi --out={output.gdc} --method=jac -v &> {log}"
137
138
shell:
    "bet {input.mask} {output} -f 0.3 -n -m -R"
8
9
shell:
    "{params.fs_setup} mri_convert {input} {output}"
22
23
shell:
    "bash scripts/run_isolate.sh {params.script} {input} {params.out_dir}" 
SnakeMake From line 22 of rules/suit.smk
42
43
44
45
46
47
48
49
shell:
    "{params.fs_setup} export FSLOUTPUTTYPE=NIFTI && "
    "fslmaths {input.lh_wm} -add {input.rh_wm} -bin {output.wm} && "
    "mri_convert {output.wm} {output.wm_cropped} -rl {input.cropped} -nc && "
    "fslmaths {input.gm} -bin {output.gm} && "
    "mri_convert {output.gm} {output.gm_cropped} -rl {input.cropped} -nc && "
    "fslmaths {output.wm} -add {output.gm} -bin {output.mask} && "
    "mri_convert {output.mask} {output.mask_cropped} -rl {input.cropped} -nc "
SnakeMake From line 42 of rules/suit.smk
64
65
shell:
    "bash scripts/run_normalise.sh {params.script} {input.gm} {input.wm} {input.mask} {params.out_dir}"
SnakeMake From line 64 of rules/suit.smk
74
75
shell:
    "export FSLOUTPUTTYPE=NIFTI && fslmaths {input.t1} -div 1000 -recip -thr 0 -uthr 2 -nan {output.r1}"
SnakeMake From line 74 of rules/suit.smk
97
98
99
shell:
    "bash scripts/run_reslice.sh {params.script} {input.affine} {input.flowfield} "
    "{input.wm} {input.gm} {input.r1} {input.mask} {params.out_dir} {wildcards.subject}"
SnakeMake From line 97 of rules/suit.smk
110
111
112
shell:
    "export FSLOUTPUTTYPE=NIFTI && "
    "fslmaths {input.atlas} -dilD -mul {input.gm} {output} -odt int"
SnakeMake From line 110 of rules/suit.smk
125
126
shell:
    "bash scripts/run_smooth.sh {params.script} {input} {params.fwhm} {params.out_dir}"
SnakeMake From line 125 of rules/suit.smk
137
138
139
140
141
142
143
144
run:
    dest_dir = os.path.dirname(output.controls)
    for filename in input.controls:
        shutil.copy(filename, dest_dir)

    dest_dir = os.path.dirname(output.patients)
    for filename in input.patients:
        shutil.copy(filename, dest_dir)
SnakeMake From line 137 of rules/suit.smk
160
161
shell:
    "bash scripts/run_reslice_results.sh {params.script} {input.affine} {input.flowfield} {input.ref} {input.suit} {output} {params.out_dir} {wildcards.subject}"
SnakeMake From line 160 of rules/suit.smk
10
11
shell:
    "{params.fs_setup} mris_convert {input} {output}"
20
21
shell:
    "wb_command -surface-cortex-layer {input.white} {input.pial} 0.5 {output}"      
32
33
shell: 
    "{params.fs_setup} mri_info {input} --tkr2scanner > {output}"
44
45
shell:
    "wb_command -convert-affine -from-flirt {input.bbr} {input.t1w} {input.epi} -to-world {output}"
55
56
shell: 
    "wb_command -surface-apply-affine {input.surf} {input.tkr2scanner} {output}"    
66
67
shell:     
    "wb_command -surface-apply-affine {input.surf} {input.scanner2epi} {output}"
78
79
shell:
    "wb_command -surface-apply-warpfield {input.surf} {input.inverse_warp} {output} -fnirt {input.warp}"
91
92
shell:    
    "wb_command -surface-resample {input.surf} {input.sphere_old} {input.sphere_new} BARYCENTRIC {output}"
103
104
shell:     
    "wb_command -surface-generate-inflated {input} {output.inflated} {output.very_inflated} {params}"   
119
120
shell: 
    "wb_command -volume-to-surface-mapping {input.epi} {input.surf} {output} -trilinear"
133
134
shell: 
    "wb_command -volume-to-surface-mapping {input.epi} {input.surf} {output} -trilinear"
149
150
shell:     
    "wb_command -metric-resample {input.metric} {input.sphere_old} {input.sphere_new} ADAP_BARY_AREA {output} -area-surfs {input.area_old} {input.area_new}"
163
164
shell:     
    "wb_command -metric-resample {input.metric} {input.sphere_old} {input.sphere_new} ADAP_BARY_AREA {output} -area-surfs {input.area_old} {input.area_new}"
ShowHide 77 more snippets with no or duplicated tags.

Login to post a comment if you would like to share your experience with this workflow.

Do you know this workflow well? If so, you can request seller status , and start supporting this workflow.

Free

Created: 1yr ago
Updated: 1yr ago
Maitainers: public
URL: https://github.com/royhaast/smk-melas
Name: smk-melas
Version: 1
Badge:
workflow icon

Insert copied code into your website to add a link to this workflow.

Other Versions:
Downloaded: 0
Copyright: Public Domain
License: None
  • Future updates

Related Workflows

cellranger-snakemake-gke
snakemake workflow to run cellranger on a given bucket using gke.
A Snakemake workflow for running cellranger on a given bucket using Google Kubernetes Engine. The usage of this workflow ...