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

Commit 0908955

Browse files
authored
Merge pull request #335 from a3sha2/master
acompcor
2 parents 709eaa7 + b63ffef commit 0908955

File tree

4 files changed

+83
-13
lines changed

4 files changed

+83
-13
lines changed

modules/confound2/confound2.mod

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,18 @@ if (( ${confound2_acompcor[cxt]} == 1 ))
350350

351351

352352
acompcor_path=${outdir}/${prefix}_acompcor.1D
353+
354+
if [[ -f ${confjson[sub]} ]]; then
355+
exec_xcp acompcor_select.py -j ${confjson[sub]} -c ${fmriprepconf[sub]} \
356+
-o ${acompcor_path}
357+
358+
else
353359
exec_xcp generate_confmat.R \
354360
-i ${fmriprepconf[sub]} \
355361
-j aCompCor \
356362
-o ${acompcor_path}
363+
364+
fi
357365

358366
output acompcor ${prefix}_acompcor.1D
359367

modules/prestats/prestats.mod

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,12 @@ while (( ${#rem} > 0 ))
230230
mask1=${imgprt2}${mskpart}; maskpart2=${mask1#*_*_*_*}
231231
refpart="_boldref.nii.gz"; refvol=${imgprt2}${refpart}
232232

233+
conf2="_desc-confounds_regressors.json"
234+
if [[ -f ${imgprt}${conf2} ]]; then
235+
exec_sys cp ${imgprt}${conf2} $out/prestats/${prefix}_fmriconf.json
236+
output confjson $out/prestats/${prefix}_fmriconf.json
237+
fi
238+
233239
strucn="${img1[sub]%/*/*}";
234240
strucfile=$(ls -f ${strucn}/anat/*h5 2>/dev/null)
235241
strucfile1=$(echo $strucfile | cut --delimiter " " --fields 1)

utils/acompcor_select.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
4+
# vi: set ft=python sts=4 ts=4 sw=4 et:
5+
6+
import json
7+
import pandas as pd
8+
from argparse import (ArgumentParser, RawTextHelpFormatter)
9+
10+
11+
def get_parser():
12+
13+
parser = ArgumentParser(
14+
formatter_class=RawTextHelpFormatter,
15+
description='acompcor selection')
16+
parser.add_argument(
17+
'-c', '--confmat', action='store', required=True,
18+
help='[required]'
19+
'\n confmat.')
20+
parser.add_argument(
21+
'-j', '--confjson', action='store', required=True,
22+
help='[required]'
23+
'\n conjson.')
24+
parser.add_argument(
25+
'-o', '--outfile', action='store', required=False,
26+
help='output directory')
27+
return parser
28+
29+
opts = get_parser().parse_args()
30+
31+
32+
with open(opts.confjson) as f:
33+
data = json.load(f)
34+
35+
WM=[]
36+
CSF=[]
37+
for key, value in data.items():
38+
if 'a_comp_cor' in key:
39+
if value['Mask']=='WM' and value['Retained']==True:
40+
WM.append([key,value['VarianceExplained']])
41+
if value['Mask']=='CSF' and value['Retained']==True:
42+
CSF.append([key,value['VarianceExplained']])
43+
44+
CSFlist=[CSF[0][0],CSF[1][0],CSF[2][0],CSF[3][0],CSF[4][0]]
45+
WMlist=[WM[0][0],WM[1][0],WM[2][0],WM[3][0],WM[4][0]]
46+
47+
data2=pd.read_csv(opts.confmat,sep='\t')
48+
combinelist=CSFlist+WMlist
49+
acompcor=data2[combinelist]
50+
acompcor.to_csv(opts.outfile,index=False,sep=' ',header=False)
51+
52+
53+
54+
55+
56+

utils/aslqc.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
3-
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
4-
# vi: set ft=python sts=4 ts=4 sw=4 et:
5-
# Azeez Adebimpe penn bbl sept 2019
6-
import nibabel as nib
7-
import numpy as np
8-
import pandas as pd
9-
import os as os
10-
import sys as sys
11-
import seaborn as sns
12-
from nibabel.processing import smooth_image
13-
from scipy.stats import gmean
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
4+
# vi: set ft=python sts=4 ts=4 sw=4 et:
5+
# Azeez Adebimpe penn bbl sept 2019
6+
import nibabel as nib
7+
import numpy as np
8+
import pandas as pd
9+
import os as os
10+
import sys as sys
11+
import seaborn as sns
12+
from nibabel.processing import smooth_image
13+
from scipy.stats import gmean
1414
from argparse import (ArgumentParser, RawTextHelpFormatter)
1515

1616
def get_parser():

0 commit comments

Comments
 (0)