Skip to content

Commit

Permalink
fix: json QA file can go to xnat
Browse files Browse the repository at this point in the history
  • Loading branch information
akeshavan committed Apr 5, 2012
1 parent 52fd04b commit c442045
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 16 deletions.
14 changes: 11 additions & 3 deletions fmri/qa/QA_fmri.py
Expand Up @@ -39,7 +39,9 @@ def preproc_datagrabber(name='preproc_datagrabber'):
'tsnr_detrended',
'tsnr_stddev',
'reg_file',
'motion_plots']),
'motion_plots',
'mean_image',
'mask']),
name = name)
datasource.inputs.base_directory = os.path.join(c.sink_dir,'analyses','func')
datasource.inputs.template ='*'
Expand All @@ -50,14 +52,18 @@ def preproc_datagrabber(name='preproc_datagrabber'):
tsnr_detrended='%s/preproc/tsnr/*_detrended.nii.gz',
tsnr_stddev='%s/preproc/tsnr/*tsnr_stddev.nii.gz',
reg_file='%s/preproc/bbreg/*.dat',
motion_plots='%s/preproc/motion/*.png')
motion_plots='%s/preproc/motion/*.png',
mean_image='%s/preproc/meanfunc/*.nii.gz',
mask='%s/preproc/mask/*_brainmask.nii')
datasource.inputs.template_args = dict(motion_parameters=[['subject_id']],
outlier_files=[['subject_id']],
art_norm=[['subject_id']],
tsnr=[['subject_id']],
tsnr_stddev=[['subject_id']],
reg_file=[['subject_id']],
motion_plots=[['subject_id']])
motion_plots=[['subject_id']],
mean_image=[['subject_id']],
mask=[['subject_id']])
return datasource


Expand Down Expand Up @@ -257,6 +263,8 @@ def QA_workflow(name='QA'):
name='report_sink')
write_rep.inputs.Introduction = "Quality Assurance Report for fMRI preprocessing."
write_rep.inputs.base_directory = os.path.join(c.sink_dir,'analyses','func')
write_rep.inputs.report_name = "Preprocessing_Report"
write_rep.inputs.json_sink = c.json_sink
workflow.connect(infosource,'subject_id',write_rep,'container')

# Define Inputs
Expand Down
27 changes: 14 additions & 13 deletions fmri/resting/sad_resting_config.py
Expand Up @@ -40,17 +40,17 @@
crash_dir : Location to store crash files
"""

working_dir = '/mindhive/scratch/satra/sad/resting'
working_dir = '/mindhive/scratch/keshavan/sad/resting'

base_dir = '/mindhive/gablab/sad/SAD_STUDY_Resting/data'

sink_dir = '/mindhive/gablab/sad/bips/resting'
sink_dir = '/mindhive/scratch/keshavan/sad/resting'

field_dir = '/mindhive/gablab/sad/Data_reorganized'

crash_dir = working_dir

surf_dir = '/mindhive/xnat/surfaces/sad/'
surf_dir = '/mindhive/xnat/surfaces/sad/' #names should match subject names

"""
Workflow Inputs:
Expand Down Expand Up @@ -94,8 +94,8 @@
'SAD_P46', 'SAD_P47', 'SAD_P48', 'SAD_P49', 'SAD_P50', 'SAD_P51',
'SAD_P52', 'SAD_P53', 'SAD_P54', 'SAD_P55', 'SAD_P56', 'SAD_P57',
'SAD_P58']
subjects = patients + controls
subjects = ['SAD_024']

subjects = ['SAD_024','SAD_P03']

run_on_grid = False

Expand Down Expand Up @@ -162,7 +162,7 @@
"""

norm_thresh = 2
norm_thresh = 0.5

z_thresh = 3

Expand Down Expand Up @@ -208,15 +208,16 @@
^^^^^^^^^^^^^^^
highpass_sigma : Float
Highpass cut off in mm
Highpass cut off in volumes
lowpass _sigma : Float
Lowpass cut off in mm
Lowpass cut off in volumes
"""
# Fix: convert Hz to volumes, so you can specify Hz in config

highpass_sigma = 100/(2*TR)
highpass_freq = .01

lowpass_sigma = 12.5/(2*TR)
lowpass_freq = .08

"""
Functions
Expand Down Expand Up @@ -249,7 +250,7 @@ def create_dataflow(name="datasource"):
name = name)
datasource.inputs.base_directory = base_dir
datasource.inputs.template ='*'
datasource.inputs.field_template = dict(func='%s/resting*.nii')
datasource.inputs.field_template = dict(func='%s/BOLD/resting.nii')
datasource.inputs.template_args = dict(func=[['subject_id']])
return datasource

Expand All @@ -262,8 +263,8 @@ def create_fieldmap_dataflow(name="datasource_fieldmap"):
name = name)
datasource.inputs.base_directory = field_dir
datasource.inputs.template ='*'
datasource.inputs.field_template = dict(mag='%s/fieldmap_resting/*run00*.nii.gz',
phase='%s/fieldmap_resting/*run01*.nii.gz')
datasource.inputs.field_template = dict(mag='%s/fieldmap/fieldmap_resting/magnitude.nii.gz',
phase='%s/fieldmap/fieldmap_resting/phase.nii.gz')
datasource.inputs.template_args = dict(mag=[['subject_id']],
phase=[['subject_id']])
return datasource
9 changes: 9 additions & 0 deletions utils/reportsink/io.py
Expand Up @@ -33,6 +33,8 @@ class ReportSinkInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec):
remove_dest_dir = traits.Bool(False, usedefault=True,
desc='remove dest directory when copying dirs')
report_name = traits.Str('Report',usedefault=True, desc='Name of report')
json_sink = Directory(desc="place to store json in addition to base_directory")

def __setattr__(self, key, value):
if key not in self.copyable_trait_names():
if not isdefined(value):
Expand Down Expand Up @@ -161,5 +163,12 @@ def _list_outputs(self):
rep.write()
# save json
save_json(os.path.join(outdir, self.inputs.report_name+'.json'), self.inputs._outputs)
if isdefined(self.inputs.json_sink):
if not isdefined(self.inputs.container):
save_json(os.path.join(self.inputs.json_sink, self.inputs.report_name+'.json'), self.inputs._outputs)
else:
if not os.path.exists(os.path.join(self.inputs.json_sink,self.inputs.container)):
os.mkdir(os.path.join(self.inputs.json_sink,self.inputs.container))
save_json(os.path.join(self.inputs.json_sink,self.inputs.container, self.inputs.report_name+'.json'), self.inputs._outputs)
print "json file " , os.path.join(outdir, self.inputs.report_name+'.json')
return None

0 comments on commit c442045

Please sign in to comment.