#!/usr/bin/python import sys import os from OpenFMRIData import OpenFMRIData from OpenFMRIAnalyzer import OpenFMRIAnalyzer subnames = sys.argv[1:] data_dir = os.environ.get('DATA_DIR') or '/home/user/data' study_name = os.environ.get('STUDY_NAME') or 'LP' op = OpenFMRIData(data_dir, study_name) subcodes = [] for subname in subnames: subject_dir = op.subject_dir(subname=subname) subcodes.append(subject_dir.subcode()) analyzer = OpenFMRIAnalyzer(op,subcodes) analyzer.analyze(mc_align_task=True, func_seg=True)
import pandas as pd data_dir = os.environ.get('DATA_DIR') or '/home/daniel/fsl-analysis/data' study_name = os.environ.get('STUDY_NAME') or 'AV' raw_dir = os.path.join(data_dir, 'raw') behav_dir = os.path.join(data_dir, 'behavioral') op = OpenFMRIData(data_dir, raw_dir, study_name) # subject_names = ['HiAn'] # Specific subject names subject_names = op.get_subject_names() # All subjects for name in subject_names: subject_dir = op.create_subject_dir(name, overwrite=True) # if we want to create new data for analysis # subject_dir = op.create_subject_dir(name) # if we want to load new data for analysis # subject_dir = op.load_subject_dir(subname=name) create_events(subject_dir, behav_dir) analyzer = OpenFMRIAnalyzer(op,[subject_dir]) brain_image = analyzer.extract_brain(subject_dir) analyzer.estimate_bias_field(subject_dir, brain_image, overwrite=True) analyzer.anatomical_registration(subject_dir) analyzer.anatomical_smoothing(subject_dir) analyzer.slice_time_correction(subject_dir) analyzer.motion_correction(subject_dir) analyzer.functional_registration(subject_dir) analyzer.functional_smoothing(subject_dir)
def main(): conf = AnalysisConfiguration() data_dir = os.environ.get('DATA_DIR') or '/home/user/data' op = OpenFMRIData(data_dir, conf.study_name) analyzer = OpenFMRIAnalyzer(op, conf) all_subject_dirs = op.all_subjects_dirs_with_raw() for subject in all_subject_dirs: analyzer.extract_brain(subject) for subject in all_subject_dirs: analyzer.anatomical_registration(subject) for subject in all_subject_dirs: #for task in conf.mvpa_tasks: #subject.remove_volumes_from_model(1, "", task, conf.num_of_volumes_to_delete) analyzer.motion_correction(subject) analyzer.functional_registration(subject) if conf.func_seg: analyzer.functional_segmentation(subject) else: analyzer.segmentation(subject) analyzer.generate_functional_gm_masks(subject) #analyzer.warp_standard_mask(subject) for subject in all_subject_dirs: # DO SL out_dir = _opj(subject.path(),'results',conf.dir_name()) if not os.path.exists(out_dir): os.makedirs(out_dir) run_searchlight(op, subject, conf, out_dir) # run_searchlight(op.study_dir(), subject.subcode(), mask_name, k, [['G1','G4']], out_dir,flavor) #Group Level output_dir = _opj(op.study_dir(), 'results', "{}".format(conf.dir_name())) if not os.path.exists(output_dir): os.makedirs(output_dir) files = glob(_opj(op.study_dir(), "**", 'results', conf.dir_name(), '*acc_mni.nii.gz')) print files generate_group_level_map( files, output_dir)