-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsKPCR_main.py
85 lines (66 loc) · 2.91 KB
/
sKPCR_main.py
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
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Script name: sKCPR_main.py
#
# Description: Functions to run sKPCR analysis using CPU
#
# Author: Weikang Gong
#
#Gong, Weikang, et al. "A powerful and efficient multivariate approach for voxel-level connectome-wide association studies." NeuroImage (2018).
#
# Weikang Gong
# DPhil Student, WIN, FMRIB
# Nuffield Department of Clinical Neurosciences
# University of Oxford
# Oxford OX3 9DU, UK
# Email: [email protected] or [email protected]
#
# Copyright 2018 University of Oxford
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import argparse
import sys
import os
def cli_parser():
# Create a parser. It'll print the description on the screen.
parser = argparse.ArgumentParser(description=__doc__)
# Add a positional argument
parser.add_argument('-toolbox_dir', help='The absolute directory of the sKPCR toolbox')
parser.add_argument('-image_dir', help='The absolute directory of the rsfMRI images')
parser.add_argument('-output_dir', help='The absolute directory for the sKPCR outputs')
parser.add_argument('-mask_file', help='The absolute directory of the mask file')
parser.add_argument('-target_file', help='The absolute directory of the variable of interest file (nsub * 1 numpy matrix saved in .npy or .txt format)')
parser.add_argument('-cov_file', help='The absolute directory of the covariates file (nsub * p numpy matrix saved in .npy or .txt format)')
parser.add_argument('-K_components', help='The number of components for analysis.')
parser.add_argument('-nperm', help='The number of permutations')
parser.add_argument('-ncore', help='Number of CPU to use for this analysis ')
return parser
parser = cli_parser()
args = parser.parse_args()
toolbox_dir=os.path.join(args.toolbox_dir,'')
output_dir=os.path.join(args.output_dir,'')
print('Result Directory = '+output_dir)
image_dir=os.path.join(args.image_dir,'')
mask_file=args.mask_file
target_file=args.target_file
cov_file=args.cov_file
K_components=int(args.K_components)
print('Number of components = '+str(K_components))
nperm=int(args.nperm)
print('Number of permutations = '+str(nperm))
ncore=int(args.ncore)
print('Number of cores = '+str(ncore))
sys.path.append(os.path.join(os.path.abspath(toolbox_dir)))
from sKPCR_cpu import sKPCR_run_full_analysis
sKPCR_run_full_analysis(output_dir,image_dir,mask_file,
toolbox_dir,target_file,cov_file,
K_components,nperm,ncore)