Skip to content

Commit

Permalink
Merge pull request #28 from adamkimbler/master
Browse files Browse the repository at this point in the history
[ENH] Moved Project Flag to config file
  • Loading branch information
tsalo authored Sep 20, 2018
2 parents 8adef53 + 7f9b4a5 commit d81db2e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
30 changes: 16 additions & 14 deletions cis_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ def get_parser():
'subfolder in dset_dir.')
parser.add_argument('--config', required=True, dest='config',
help='Path to the config json file.')
parser.add_argument('--project', required=True, dest='project',
help='The name of the project to analyze.')
parser.add_argument('--sub', required=True, dest='sub',
help='The label of the subject to analyze.')
parser.add_argument('--ses', required=False, dest='ses',
Expand All @@ -68,17 +66,6 @@ def main(argv=None):
if args.work_dir is None:
args.work_dir = CIS_DIR

if args.ses is None:
scan_work_dir = op.join(args.work_dir,
'{0}-{1}'.format(args.project, args.sub))
else:
scan_work_dir = op.join(args.work_dir,
'{0}-{1}-{2}'.format(args.project, args.sub,
args.ses))

if not scan_work_dir.startswith('/scratch'):
raise ValueError('Working directory must be in scratch.')

if not op.isfile(args.tar_file) or not args.tar_file.endswith('.tar'):
raise ValueError('Argument "tar_file" must be an existing file with '
'the suffix ".tar".')
Expand All @@ -95,6 +82,21 @@ def main(argv=None):
with open(args.config, 'r') as fo:
config_options = json.load(fo)

if 'project' not in config_options.keys():
raise Exception('Config File must be updated with project field'
'See Sample Config File for More information')

if args.ses is None:
scan_work_dir = op.join(args.work_dir,
'{0}-{1}'.format(config_options['project'], args.sub))
else:
scan_work_dir = op.join(args.work_dir,
'{0}-{1}-{2}'.format(config_options['project'], args.sub,
args.ses))

if not scan_work_dir.startswith('/scratch'):
raise ValueError('Working directory must be in scratch.')

bidsifier_file = op.join('/home/data/cis/singularity-images/',
config_options['bidsifier'])
mriqc_file = op.join('/home/data/cis/singularity-images/',
Expand Down Expand Up @@ -159,7 +161,7 @@ def main(argv=None):
cmd = ('{sing} -d {work} --heuristics {heur} --project {proj} --sub {sub} '
'--ses {ses}'.format(sing=scratch_bidsifier, work=scan_work_dir,
heur=op.join(scan_work_dir, 'heuristics.py'),
sub=args.sub, ses=args.ses, proj=args.project))
sub=args.sub, ses=args.ses, proj=config_options['project']))
run(cmd)

# Check if BIDSification ran successfully
Expand Down
1 change: 1 addition & 0 deletions config/Dick_AHEAD.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"project": "Dick_AHEAD",
"bidsifier": "cis_bidsify_v0.0.1-2018-08-24-04f91fa82d17.img",
"heuristics": "heuristics/Dick_AHEAD.py",
"mriqc": "poldracklab_mriqc_0.10.4-2018-03-23-8fb5f5e9184f.img",
Expand Down
1 change: 1 addition & 0 deletions config/Mattfeld_RTV.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"project": "Mattfeld_RTV",
"bidsifier": "cis_bidsify_v0.0.1-2018-08-24-04f91fa82d17.img",
"heuristics": "heuristics/Mattfeld_RTV.py",
"mriqc": "poldracklab_mriqc_0.10.4-2018-03-23-8fb5f5e9184f.img",
Expand Down
4 changes: 2 additions & 2 deletions example_lsf_job.sub
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ module load singularity
##########################################################

python cis_proc.py -d [/path/to/tarfile] -w [/scratch/path/to/working/directory/] \
-b [/path/to/bids/dataset/] --config [/path/to/config/file] --project [PROJECT] \
--sub [SUBJECTID] --ses [SESSION] --n_procs $NPROCS
-b [/path/to/bids/dataset/] --config [/path/to/config/file] --sub [SUBJECTID] \
--ses [SESSION] --n_procs $NPROCS

0 comments on commit d81db2e

Please sign in to comment.