Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #335 from a3sha2/master
Browse files Browse the repository at this point in the history
acompcor
  • Loading branch information
a3sha2 committed May 15, 2020
2 parents 709eaa7 + b63ffef commit 0908955
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 13 deletions.
8 changes: 8 additions & 0 deletions modules/confound2/confound2.mod
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,18 @@ if (( ${confound2_acompcor[cxt]} == 1 ))


acompcor_path=${outdir}/${prefix}_acompcor.1D

if [[ -f ${confjson[sub]} ]]; then
exec_xcp acompcor_select.py -j ${confjson[sub]} -c ${fmriprepconf[sub]} \
-o ${acompcor_path}

else
exec_xcp generate_confmat.R \
-i ${fmriprepconf[sub]} \
-j aCompCor \
-o ${acompcor_path}

fi

output acompcor ${prefix}_acompcor.1D

Expand Down
6 changes: 6 additions & 0 deletions modules/prestats/prestats.mod
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,12 @@ while (( ${#rem} > 0 ))
mask1=${imgprt2}${mskpart}; maskpart2=${mask1#*_*_*_*}
refpart="_boldref.nii.gz"; refvol=${imgprt2}${refpart}

conf2="_desc-confounds_regressors.json"
if [[ -f ${imgprt}${conf2} ]]; then
exec_sys cp ${imgprt}${conf2} $out/prestats/${prefix}_fmriconf.json
output confjson $out/prestats/${prefix}_fmriconf.json
fi

strucn="${img1[sub]%/*/*}";
strucfile=$(ls -f ${strucn}/anat/*h5 2>/dev/null)
strucfile1=$(echo $strucfile | cut --delimiter " " --fields 1)
Expand Down
56 changes: 56 additions & 0 deletions utils/acompcor_select.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:

import json
import pandas as pd
from argparse import (ArgumentParser, RawTextHelpFormatter)


def get_parser():

parser = ArgumentParser(
formatter_class=RawTextHelpFormatter,
description='acompcor selection')
parser.add_argument(
'-c', '--confmat', action='store', required=True,
help='[required]'
'\n confmat.')
parser.add_argument(
'-j', '--confjson', action='store', required=True,
help='[required]'
'\n conjson.')
parser.add_argument(
'-o', '--outfile', action='store', required=False,
help='output directory')
return parser

opts = get_parser().parse_args()


with open(opts.confjson) as f:
data = json.load(f)

WM=[]
CSF=[]
for key, value in data.items():
if 'a_comp_cor' in key:
if value['Mask']=='WM' and value['Retained']==True:
WM.append([key,value['VarianceExplained']])
if value['Mask']=='CSF' and value['Retained']==True:
CSF.append([key,value['VarianceExplained']])

CSFlist=[CSF[0][0],CSF[1][0],CSF[2][0],CSF[3][0],CSF[4][0]]
WMlist=[WM[0][0],WM[1][0],WM[2][0],WM[3][0],WM[4][0]]

data2=pd.read_csv(opts.confmat,sep='\t')
combinelist=CSFlist+WMlist
acompcor=data2[combinelist]
acompcor.to_csv(opts.outfile,index=False,sep=' ',header=False)






26 changes: 13 additions & 13 deletions utils/aslqc.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
# Azeez Adebimpe penn bbl sept 2019
import nibabel as nib
import numpy as np
import pandas as pd
import os as os
import sys as sys
import seaborn as sns
from nibabel.processing import smooth_image
from scipy.stats import gmean
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
# Azeez Adebimpe penn bbl sept 2019
import nibabel as nib
import numpy as np
import pandas as pd
import os as os
import sys as sys
import seaborn as sns
from nibabel.processing import smooth_image
from scipy.stats import gmean
from argparse import (ArgumentParser, RawTextHelpFormatter)

def get_parser():
Expand Down

0 comments on commit 0908955

Please sign in to comment.