Skip to content
This repository was archived by the owner on Dec 27, 2022. It is now read-only.

Commit a6a407c

Browse files
committed
fix: fix to path output, and added absolute paths
1 parent f2180cc commit a6a407c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

preafq/preafq.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def move_t1_to_freesurfer(t1_file):
4040
stderr=subprocess.STDOUT)
4141

4242

43-
def upload_to_s3(output_files, bucket, prefix, site, session, subject):
43+
def upload_to_s3(output_files, outdir, bucket, prefix, site, session, subject):
4444
"""Upload output files to S3, using key format specified by input params
4545
4646
Parameters
@@ -50,6 +50,9 @@ def upload_to_s3(output_files, bucket, prefix, site, session, subject):
5050
relative paths that are appropriate to fill in after the 'preAFQ'
5151
directory.
5252
53+
outdir : string
54+
a path to the root of the data
55+
5356
bucket : string
5457
Output S3 bucket
5558
@@ -80,7 +83,7 @@ def filename2s3key(filename):
8083
])
8184

8285
for file in output_files:
83-
with open(file, 'rb') as fp:
86+
with open(op.abspath(op.join(outdir, file)), 'rb') as fp:
8487
s3.put_object(
8588
Bucket=bucket,
8689
Body=fp,
@@ -91,7 +94,7 @@ def filename2s3key(filename):
9194

9295

9396
def pre_afq_individual(input_s3_keys, s3_prefix, out_bucket,
94-
in_bucket='fcp-indi', workdir='.'):
97+
in_bucket='fcp-indi', workdir=op.abspath('.')):
9598
input_files = fetch.download_register(
9699
subject_keys=input_s3_keys,
97100
bucket=in_bucket,
@@ -122,6 +125,7 @@ def pre_afq_individual(input_s3_keys, s3_prefix, out_bucket,
122125
out_files.append(rel_path.replace(out_dir + '/', '', 1))
123126

124127
s3_output = upload_to_s3(output_files=out_files,
128+
outdir=out_dir,
125129
bucket=out_bucket,
126130
prefix=s3_prefix,
127131
site=input_s3_keys.site,

preafq/run_1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,5 +207,5 @@ def reportNodeFunc(dwi_corrected_file, eddy_rms, eddy_report,
207207
wf.run()
208208

209209
copyfile(bval_file, op.join(
210-
out_dir, bids_sub_name, "preafq", "dwi", op.split(bval_file)[1]
210+
out_dir, "preafq", "dwi", op.split(bval_file)[1]
211211
))

0 commit comments

Comments
 (0)