def test_find_callable(): assert fa.find([ dict(label='pre 2016-01-01'), dict(label='post 2016-01-02'), ], label=lambda val: val.startswith('post ')) == dict( label='post 2016-01-02')
def anatomical_warp_inputs(acquisitions, **kwargs): anatomical = fa.find(acquisitions, label='anatomical_mdeft') return dict( native=anatomical.find_file('*.nii.gz'), standard=D99.find_file('D99_template.nii.gz'), warp_target=D99.find_file('D99_atlas_1.2a.nii.gz'), )
def dtiinit_inputs(acquisitions, **kwargs): diffusion = fa.find(acquisitions, label='DTI 2mm b1250 84dir(axial)') return dict( bvec=diffusion.find_file('*.bvec'), bval=diffusion.find_file('*.bval'), nifti=diffusion.find_file('*.nii.gz'), )
def reactivity_inputs(acquisition_label, acquisitions, session, **kwargs): functional = fa.find_required_input_source(acquisitions, label=acquisition_label) # using plain find() here b/c this T1w might be missing structural = fa.find(acquisitions, label='T1w 1mm') if not structural: assert session['_id'] in second_to_first_visit_id,\ 'the only sessions that should be missing T1w are second visits. {} was missing a T1w'\ .format(session['_id']) first_visit_session_id = second_to_first_visit_id[session['_id']] first_visit_acquisitions = client.request( 'sessions/{}/acquisitions'.format(first_visit_session_id)).json() structural = fa.find(first_visit_acquisitions, label='T1w 1mm') assert structural, 'Session {} is missing a structural.'.format(session['_id']) return dict( functional=functional.find_file('*.nii.gz'), structural=structural.find_file('*.nii.gz'), )
def dtiinit_inputs(acquisitions, **kwargs): diffusion = fa.find(acquisitions, label='Diffusion') return dict( bvec=diffusion.find_file('*1000.bvec'), bval=diffusion.find_file('*1000.bval'), dwi=diffusion.find_file('*1000.nii.gz'), ), dict( # Here you can add any configuration. So for instance to add robust tensor, do: # fitMethod='rt' )
def afq_inputs(analyses, **kwargs): dtiinit = fa.find(analyses, label=dtiinit_label) return dict(dtiInit_Archive=dtiinit.find_file('dtiInit_*.zip'), )
def test_find(): assert fa.find([ dict(label='pre'), dict(label='post'), ], label='post') == dict(label='post')
from scitran_client import ScitranClient import scitran_client.flywheel_analyzer as fa client = ScitranClient('https://flywheel.scitran.stanford.edu') with fa.installed_client(client): D99 = fa.find(client.request( 'sessions/588bd1ac449f9800159305c2/acquisitions').json(), label='atlas') def anatomical_warp_inputs(acquisitions, **kwargs): anatomical = fa.find(acquisitions, label='anatomical_mdeft') return dict( native=anatomical.find_file('*.nii.gz'), standard=D99.find_file('D99_template.nii.gz'), warp_target=D99.find_file('D99_atlas_1.2a.nii.gz'), ) if __name__ == '__main__': with fa.installed_client(client): fa.run([ fa.define_analysis('afni-brain-warp', anatomical_warp_inputs, label='anatomical warp'), ], project=fa.find_project(label='showdes'), max_workers=2)