def test_l1(): l1(PREPROCESS_BASE, mask='mouse', match={'session': ['ofMaF'], 'acq':['EPIlowcov']}, out_base='/var/tmp/samri_testing/pytest/', workflow_name='l1', )
def aic(): preprocessing.bruker( '~/ni_data/test/', functional_match={'trial': ['CogB', 'CogB2m', 'JogB']}, structural_match={'acquisition': ['TurboRARE', 'TurboRARElowcov']}, workflow_name='composite', lowpass_sigma=2, highpass_sigma=225, very_nasty_bruker_delay_hack=True, negative_contrast_agent=True, functional_registration_method="composite", keep_work=True, template="~/ni_data/templates/DSURQEc_200micron_average.nii", registration_mask="~/ni_data/templates/DSURQEc_200micron_mask.nii.gz", actual_size=True, verbose=True, ) glm.l1( '~/ni_data/test/preprocessing/composite', workflow_name='composite', # include={"subjects":["5689","5690","5691"]}, habituation="confound", mask="~/ni_data/templates/DSURQEc_200micron_mask.nii.gz", keep_work=True, )
def run_level1_glm(): glm.l1( preprocessing_dir='~/bandpass_ni_data/rsfM/preprocessing/composite', workflow_name='as_composite', habituation='confound', mask="/home/chymera/ni_data/templates/DSURQEc_200micron_mask.nii.gz", keep_work=True)
def aic(): from samri.pipelines import preprocess, glm preprocessing.bruker( '~/ni_data/test/', functional_match={'task': ['CogB', 'CogB2m', 'JogB']}, structural_match={'acquisition': ['TurboRARE', 'TurboRARElowcov']}, workflow_name='composite', lowpass_sigma=2, highpass_sigma=225, very_nasty_bruker_delay_hack=True, negative_contrast_agent=True, functional_registration_method="composite", keep_work=True, template="/usr/share/mouse-brain-atlases/dsurqec_200micron.nii", registration_mask= "/usr/share/mouse-brain-atlases/dsurqec_200micron_mask.nii", actual_size=True, verbose=True, ) glm.l1( '~/ni_data/test/preprocessing/composite', workflow_name='composite', # include={"subjects":["5689","5690","5691"]}, habituation="confound", mask="/usr/share/mouse-brain-atlases/dsurqec_200micron_mask.nii", keep_work=True, )
def test_l1(): l1(PREPROCESS_BASE, mask='mouse', match={"acq":["EPIlowcov"]}, out_base='/var/tmp/samri_testing/pytest/', workflow_name='l1', )
def run_level1_glm(): from samri.pipelines import glm, preprocess glm.l1(preprocessing_dir='~/bandpass_ni_data/rsfM/preprocessing/composite', workflow_name='as_composite', habituation='confound', mask="/usr/share/mouse-brain-atlases/dsurqec_200micron_mask.nii", keep_work=True)
def higher(): glm.l1( '~/ni_data/test/preprocessing/composite', workflow_name='higher', # include={"subjects":["5689","5690","5691"]}, habituation="confound", mask="~/ni_data/templates/DSURQEc_200micron_mask.nii.gz", keep_work=True, )
def dr_only(): glm.l1( "~/ni_data/ofM.dr/preprocessing/_composite", mask="~/ni_data/templates/roi/f_dr_chr.nii.gz", workflow_name="dr", # include={"subjects":["5689","5690","5691"]}, habituation="confound", keep_work=True, )
def glm_only(): from samri.pipelines import glm glm.l1( '~/ni_data/ofM.vta/bids/', workflow_name='composite', include={"subject": ["SN2143", "SN2145", "SN3974", "SN3975"]}, habituation="confound", keep_work=True, mask="", )
def test_l1(tmp_path): l1( PREPROCESS_BASE, mask='mouse', match={ 'session': ['ofMaF'], 'acq': ['EPIlowcov'] }, out_base=tmp_path, workflow_name='l1', )
def test_l1_generic(self): with tempfile.TemporaryDirectory() as tmpdirname: workflow_name = 'generic' mask = '/usr/share/mouse-brain-atlases/dsurqec_200micron_mask.nii' preprocess_base = '{}/preprocessing/'.format(TEST_DATA_DIR) bf_path = TEST_DATA_DIR / 'chr_beta1.txt' glm.l1(os.path.join(preprocess_base, workflow_name), bf_path=bf_path, workflow_name=workflow_name, habituation="confound", mask=mask, keep_work=False, match={'suffix': ['bold']}, exclude={'task': ['rest']}, invert=False, out_base='{}/l1'.format(tmpdirname) ) print('finished test_l1_generic successfully.')
def dr_composite(): from samri.pipelines import glm, preprocess preprocessing.bruker("~/ni_data/ofM.dr/", exclude_measurements=['20151027_121613_4013_1_1'], workflow_name="composite", very_nasty_bruker_delay_hack=True, negative_contrast_agent=True, functional_blur_xy=4, functional_registration_method="composite") glm.l1("~/ni_data/ofM.dr/preprocessing/composite", workflow_name="composite", include={"subjects": [i for i in range(4001, 4010)] + [4011, 4012]}, habituation="confound", mask="~/ni_data/templates/ds_QBI_chr_bin.nii.gz", keep_work=True) glm.l1( "~/ni_data/ofM.dr/preprocessing/composite", workflow_name="composite_dr", include={"subjects": [i for i in range(4001, 4010)] + [4011, 4012]}, habituation="confound", mask="~/ni_data/templates/roi/f_dr_chr_bin.nii.gz", ) glm.l2_common_effect("~/ni_data/ofM.dr/l1/composite", workflow_name="subjectwise_composite", groupby="subject") glm.l2_common_effect("~/ni_data/ofM.dr/l1/composite", workflow_name="sessionwise_composite", groupby="session", exclude={ "subjects": [ "4001", "4002", "4003", "4004", "4005", "4006", "4009", "4011", "4013" ] }) glm.l2_common_effect( "~/ni_data/ofM.dr/l1/composite", workflow_name="sessionwise_composite_w4011", groupby="session", exclude={ "subjects": ["4001", "4002", "4003", "4004", "4005", "4006", "4009", "4013"] })
def dr_full(): from labbookdb.report.development import animal_multiselect from samri.pipelines import glm from samri.pipelines.preprocess import bruker from samri.report.snr import iter_significant_signal from samri.utilities import bids_autofind # Assuming data cobnverted to BIDS bids_base = '~/ni_data/ofM.dr/bids' # Preprocess animal_list = animal_multiselect( cage_treatments=['cFluDW', 'cFluDW_', 'cFluIP']) # Animal list selection needs fixing in LabbookDB database, so we add the following animals manually animal_list.extend([ '4001', '4002', '4003', '4004', '4005', '4006', '4007', '4008', '4009', '4011', '4012', '4013', '6557' ]) full_prep( bids_base, "~/ni_data/templates/dsurqec_200micron.nii", registration_mask="~/ni_data/templates/dsurqec_200micron_mask.nii", functional_match={ 'type': [ 'cbv', ], }, structural_match={ 'acquisition': ['TurboRARE', 'TurboRARElowcov'], }, subjects=animal_list, actual_size=True, functional_registration_method="composite", negative_contrast_agent=True, out_dir='~/ni_data/ofM.dr/preprocessing', ) #bruker(bids_base, "~/ni_data/templates/dsurqec_200micron.nii", # registration_mask="~/ni_data/templates/dsurqec_200micron_mask.nii", # functional_match={'type':['bold',],}, # structural_match={'acquisition':['TurboRARE','TurboRARElowcov'],}, # subjects=animal_list, # actual_size=True, # functional_registration_method="composite", # negative_contrast_agent=False, # out_dir='~/ni_data/ofM.dr/preprocessing', # ) # Model fitting glm.l1( '~/ni_data/ofM.dr/preprocessing/generic', out_dir='~/ni_data/ofM.dr/l1', workflow_name='generic', habituation="confound", mask="/usr/share/mouse-brain-atlases/dsurqec_200micron_mask.nii", # We need the workdir to extract the betas keep_work=True, ) # Determining Responders by Significance substitutions = bids_autofind( '~/ni_data/ofM.dr/l1/generic/', path_template= "{bids_dir}/sub-{{subject}}/ses-{{session}}/sub-{{subject}}_ses-{{session}}_task-{{task}}_acq-{{acquisition}}_cbv_pfstat.nii.gz", match_regex= '.+/sub-(?P<sub>.+)/ses-(?P<ses>.+)/.*?_task-(?P<task>.+).*?_acq-(?P<acquisition>.+)_cbv_pfstat\.nii.gz', ) iter_significant_signal( '~/ni_data/ofM.dr/l1/generic/sub-{subject}/ses-{session}/sub-{subject}_ses-{session}_task-{task}_acq-{{acquisition}}_cbv_pfstat.nii.gz', substitutions=substitutions, mask_path='/usr/share/mouse-brain-atlases/dsurqec_200micron_mask.nii', save_as='~/ni_data/ofM.dr/l1/generic/total_significance.csv') # Determining Responders by a priori pattern glm.l2_common_effect( '~/ni_data/ofM.dr/l1/', workflow_name="a_priori_responders", include={ 'subject': [ '4001', '4005', '4006', '4007', '4008', '4009', '4011', '4012', '4013' ], }, groupby="session", keep_work=True, mask="/usr/share/mouse-brain-atlases/dsurqec_200micron_mask.nii", )
def cbv_composite( data_path, workflow_name, preprocessing_dir="preprocessing", l1_dir="l1", ): preprocessing.bruker( data_path, #exclude_measurements=['20151027_121613_4013_1_1'], functional_scan_types=["EPI_CBV_chr_longSOA", "EPI_CBV_jb_long"], #subjects=["4007","4008","4011","4012","5687","5688","5695","5689","5690","5691","5703","5704","5706"], subjects=["4007", "4008", "4011", "5687", "5688", "5704"], #subjects=["4007","4008","4009","4011","4012","5689","5690","5691","5703","5704","5706"], workflow_name=workflow_name, lowpass_sigma=2, highpass_sigma=225, very_nasty_bruker_delay_hack=True, negative_contrast_agent=True, functional_blur_xy=.4, functional_registration_method="composite", keep_work=True, template="~/ni_data/templates/DSURQEc_200micron_average.nii", registration_mask="~/ni_data/templates/DSURQEc_200micron_mask.nii.gz", actual_size=True, ) glm.l1( path.join(data_path, preprocessing_dir, workflow_name), workflow_name=workflow_name, # include={"subjects":["5689","5690","5691"]}, habituation="confound", mask="/home/chymera/ni_data/templates/DSURQEc_200micron_mask.nii.gz", keep_work=True, ) glm.l2_common_effect( path.join(data_path, l1_dir, workflow_name), workflow_name="composite_sessions_best_responders", exclude={ "scans": ["EPI_BOLD_"], "subjects": [ "4001", "4002", "4003", "4004", "4006", "4008", "4009", "5674", "5703", "5704", "5706", "4005", "5687" ] }, groupby="session", keep_work=True, mask="/home/chymera/ni_data/templates/DSURQEc_200micron_mask.nii.gz", ) glm.l2_common_effect( path.join(data_path, l1_dir, workflow_name), workflow_name="composite_sessions_responders", exclude={ "scans": ["EPI_BOLD_"], "subjects": [ "4001", "4002", "4003", "4004", "4006", "4008", "4009", "5674", "5703", "5704", "5706" ] }, groupby="session", keep_work=True, mask="/home/chymera/ni_data/templates/DSURQEc_200micron_mask.nii.gz", )
preprocess_base = '{}/preprocessing/'.format(scratch_dir) masks = { 'generic': '/usr/share/mouse-brain-atlases/dsurqec_200micron_mask.nii', 'masked': '/usr/share/mouse-brain-atlases/dsurqec_200micron_mask.nii', } for key in masks: glm.l1(path.join(preprocess_base, key), bf_path='../data/chr_beta1.txt', workflow_name=key, habituation="confound", mask=masks[key], keep_work=False, n_jobs_percentage=.33, match={'suffix': ['cbv']}, exclude={'task': ['rest']}, invert=True, out_base='{}/l1'.format(scratch_dir) ) glm.l1(path.join(preprocess_base, key), bf_path='../data/chr_beta1.txt', workflow_name=key, habituation="confound", mask=masks[key], keep_work=False, n_jobs_percentage=.33, match={'suffix': ['bold']}, exclude={'task': ['rest']}, invert=False,